From: Thiago Macieira Date: Thu, 29 Mar 2012 14:11:51 +0000 (-0300) Subject: Introduce the new UnknownProperty and PropertyReadOnly errors X-Git-Tag: 071012110112~1235^2^2~30 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e12c34b244cbd15011c264b594cfee45b8e052f4;p=profile%2Fivi%2Fqtbase.git Introduce the new UnknownProperty and PropertyReadOnly errors Those error codes have been standardised for years but we haven't used them until now. Task-number: QTBUG-23274 Change-Id: Iebc9ded949f363281a4d43fd9d29a284f2e2df08 Reviewed-by: Jason McDonald Reviewed-by: Lorn Potter --- diff --git a/src/dbus/qdbuserror.cpp b/src/dbus/qdbuserror.cpp index 9b21ade..b81d8a6 100644 --- a/src/dbus/qdbuserror.cpp +++ b/src/dbus/qdbuserror.cpp @@ -94,6 +94,8 @@ org.freedesktop.DBus.Error.TimedOut org.freedesktop.DBus.Error.InvalidSignature org.freedesktop.DBus.Error.UnknownInterface org.freedesktop.DBus.Error.UnknownObject +org.freedesktop.DBus.Error.UnknownProperty +org.freedesktop.DBus.Error.PropertyReadOnly org.qtproject.QtDBus.Error.InternalError org.qtproject.QtDBus.Error.InvalidService org.qtproject.QtDBus.Error.InvalidObjectPath @@ -123,6 +125,8 @@ static const char errorMessages_string[] = "org.freedesktop.DBus.Error.InvalidSignature\0" "org.freedesktop.DBus.Error.UnknownInterface\0" "org.freedesktop.DBus.Error.UnknownObject\0" + "org.freedesktop.DBus.Error.UnknownProperty\0" + "org.freedesktop.DBus.Error.PropertyReadOnly\0" "org.qtproject.QtDBus.Error.InternalError\0" "org.qtproject.QtDBus.Error.InvalidService\0" "org.qtproject.QtDBus.Error.InvalidObjectPath\0" @@ -133,8 +137,8 @@ static const char errorMessages_string[] = static const int errorMessages_indices[] = { 0, 6, 40, 76, 118, 153, 191, 231, 273, 313, 349, 384, 421, 461, 501, 540, - 581, 617, 661, 705, 746, 787, 829, 874, - 918, -1 + 581, 617, 661, 705, 746, 789, 833, 874, + 916, 961, 1005, -1 }; static const int errorMessages_count = sizeof errorMessages_indices / @@ -230,6 +234,10 @@ static inline QDBusError::ErrorType get(const char *name) (\c org.freedesktop.DBus.Error.UnknownInterface) \value UnknownObject The object path points to an object that does not exist (\c org.freedesktop.DBus.Error.UnknownObject) + \value UnknownProperty The property does not exist in this interface + (\c org.freedesktop.DBus.Error.UnknownProperty) + \value PropertyReadOnly The property set failed because the property is read-only + (\c org.freedesktop.DBus.Error.PropertyReadOnly) \value InternalError An internal error occurred diff --git a/src/dbus/qdbuserror.h b/src/dbus/qdbuserror.h index a79e66c..a6b3c9a 100644 --- a/src/dbus/qdbuserror.h +++ b/src/dbus/qdbuserror.h @@ -81,6 +81,8 @@ public: InvalidSignature, UnknownInterface, UnknownObject, + UnknownProperty, + PropertyReadOnly, InternalError, InvalidService, InvalidObjectPath, diff --git a/src/dbus/qdbusinternalfilters.cpp b/src/dbus/qdbusinternalfilters.cpp index 28d43c8..e498531 100644 --- a/src/dbus/qdbusinternalfilters.cpp +++ b/src/dbus/qdbusinternalfilters.cpp @@ -197,7 +197,7 @@ static inline QDBusMessage interfaceNotFoundError(const QDBusMessage &msg, const static inline QDBusMessage propertyNotFoundError(const QDBusMessage &msg, const QString &interface_name, const QByteArray &property_name) { - return msg.createErrorReply(QDBusError::InvalidArgs, + return msg.createErrorReply(QDBusError::UnknownProperty, QString::fromLatin1("Property %1%2%3 was not found in object %4") .arg(interface_name, QString::fromLatin1(interface_name.isEmpty() ? "" : "."), @@ -277,6 +277,7 @@ enum PropertyWriteResult { PropertyWriteSuccess = 0, PropertyNotFound, PropertyTypeMismatch, + PropertyReadOnly, PropertyWriteFailed }; @@ -292,6 +293,12 @@ static QDBusMessage propertyWriteReply(const QDBusMessage &msg, const QString &i .arg(interface_name, QString::fromLatin1(interface_name.isEmpty() ? "" : "."), QString::fromLatin1(property_name))); + case PropertyReadOnly: + return msg.createErrorReply(QDBusError::PropertyReadOnly, + QString::fromLatin1("Property %1%2%3 is read-only") + .arg(interface_name, + QString::fromLatin1(interface_name.isEmpty() ? "" : "."), + QString::fromLatin1(property_name))); case PropertyWriteFailed: return msg.createErrorReply(QDBusError::InternalError, QString::fromLatin1("Internal error")); @@ -315,6 +322,10 @@ static int writeProperty(QObject *obj, const QByteArray &property_name, QVariant QMetaProperty mp = mo->property(pidx); + // check if this property is writable + if (!mp.isWritable()) + return PropertyReadOnly; + // check if this property is exported bool isScriptable = mp.isScriptable(); if (!(propFlags & QDBusConnection::ExportScriptableProperties) && isScriptable)