summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2012-03-29 11:11:51 -0300
committerQt by Nokia <qt-info@nokia.com>2012-04-16 00:07:49 +0200
commite12c34b244cbd15011c264b594cfee45b8e052f4 (patch)
tree634f46b4b741f248d50919a8ee97dac72c181699 /src
parente02a144a3c8e7858d879ac2d0038bc7d00906ae6 (diff)
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 <jason.mcdonald@nokia.com> Reviewed-by: Lorn Potter <lorn.potter@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/dbus/qdbuserror.cpp12
-rw-r--r--src/dbus/qdbuserror.h2
-rw-r--r--src/dbus/qdbusinternalfilters.cpp13
3 files changed, 24 insertions, 3 deletions
diff --git a/src/dbus/qdbuserror.cpp b/src/dbus/qdbuserror.cpp
index 9b21adee45..b81d8a68f6 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 a79e66cc04..a6b3c9a70a 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 28d43c8c89..e498531c51 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)