summaryrefslogtreecommitdiffstats
path: root/src/dbus/qdbusinternalfilters.cpp
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/dbus/qdbusinternalfilters.cpp
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/dbus/qdbusinternalfilters.cpp')
-rw-r--r--src/dbus/qdbusinternalfilters.cpp13
1 files changed, 12 insertions, 1 deletions
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)