summaryrefslogtreecommitdiffstats
path: root/src/dbus
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2009-06-29 14:31:09 (GMT)
committerThiago Macieira <thiago.macieira@nokia.com>2009-07-02 09:43:28 (GMT)
commitbda9c20a556aa6ab6ccba978f7fc1ffe02c50813 (patch)
treedbc8d5afb250ff720be025e15e2387b58ac21f42 /src/dbus
parent96152ee50dfca7adf47b81b14015355260564a22 (diff)
downloadQt-bda9c20a556aa6ab6ccba978f7fc1ffe02c50813.zip
Qt-bda9c20a556aa6ab6ccba978f7fc1ffe02c50813.tar.gz
Qt-bda9c20a556aa6ab6ccba978f7fc1ffe02c50813.tar.bz2
Add support for error messages in the D-Bus marshaller.
Reviewed-By: Harald Fernengel
Diffstat (limited to 'src/dbus')
-rw-r--r--src/dbus/qdbusargument_p.h3
-rw-r--r--src/dbus/qdbusmarshaller.cpp35
2 files changed, 24 insertions, 14 deletions
diff --git a/src/dbus/qdbusargument_p.h b/src/dbus/qdbusargument_p.h
index b49a517..78bc683 100644
--- a/src/dbus/qdbusargument_p.h
+++ b/src/dbus/qdbusargument_p.h
@@ -130,7 +130,7 @@ public:
QDBusMarshaller *endCommon();
void open(QDBusMarshaller &sub, int code, const char *signature);
void close();
- void error();
+ void error(const QString &message);
bool appendVariantInternal(const QVariant &arg);
bool appendRegisteredType(const QVariant &arg);
@@ -140,6 +140,7 @@ public:
DBusMessageIter iterator;
QDBusMarshaller *parent;
QByteArray *ba;
+ QString errorString;
char closeCode;
bool ok;
diff --git a/src/dbus/qdbusmarshaller.cpp b/src/dbus/qdbusmarshaller.cpp
index 7ada1ed..bb7fa6b 100644
--- a/src/dbus/qdbusmarshaller.cpp
+++ b/src/dbus/qdbusmarshaller.cpp
@@ -121,7 +121,7 @@ inline void QDBusMarshaller::append(const QDBusObjectPath &arg)
{
QByteArray data = arg.path().toUtf8();
if (!ba && data.isEmpty())
- error();
+ error(QLatin1String("Invalid object path passed in arguments"));
const char *cdata = data.constData();
qIterAppend(&iterator, ba, DBUS_TYPE_OBJECT_PATH, &cdata);
}
@@ -130,7 +130,7 @@ inline void QDBusMarshaller::append(const QDBusSignature &arg)
{
QByteArray data = arg.signature().toUtf8();
if (!ba && data.isEmpty())
- error();
+ error(QLatin1String("Invalid signature passed in arguments"));
const char *cdata = data.constData();
qIterAppend(&iterator, ba, DBUS_TYPE_SIGNATURE, &cdata);
}
@@ -161,7 +161,7 @@ inline bool QDBusMarshaller::append(const QDBusVariant &arg)
QVariant::Type id = QVariant::Type(value.userType());
if (id == QVariant::Invalid) {
qWarning("QDBusMarshaller: cannot add a null QDBusVariant");
- error();
+ error(QLatin1String("Variant containing QVariant::Invalid passed in arguments"));
return false;
}
@@ -180,7 +180,8 @@ inline bool QDBusMarshaller::append(const QDBusVariant &arg)
qWarning("QDBusMarshaller: type `%s' (%d) is not registered with D-BUS. "
"Use qDBusRegisterMetaType to register it",
QVariant::typeToName( id ), id);
- error();
+ error(QString::fromLatin1("Unregistered type %1 passed in arguments")
+ .arg(QLatin1String(QVariant::typeToName(id))));
return false;
}
@@ -220,7 +221,8 @@ inline QDBusMarshaller *QDBusMarshaller::beginArray(int id)
qWarning("QDBusMarshaller: type `%s' (%d) is not registered with D-BUS. "
"Use qDBusRegisterMetaType to register it",
QVariant::typeToName( QVariant::Type(id) ), id);
- error();
+ error(QString::fromLatin1("Unregistered type %1 passed in arguments")
+ .arg(QLatin1String(QVariant::typeToName(QVariant::Type(id)))));
return this;
}
@@ -234,22 +236,26 @@ inline QDBusMarshaller *QDBusMarshaller::beginMap(int kid, int vid)
qWarning("QDBusMarshaller: type `%s' (%d) is not registered with D-BUS. "
"Use qDBusRegisterMetaType to register it",
QVariant::typeToName( QVariant::Type(kid) ), kid);
- error();
+ error(QString::fromLatin1("Unregistered type %1 passed in arguments")
+ .arg(QLatin1String(QVariant::typeToName(QVariant::Type(kid)))));
return this;
}
if (ksignature[1] != 0 || !q_dbus_type_is_basic(*ksignature)) {
qWarning("QDBusMarshaller: type '%s' (%d) cannot be used as the key type in a D-BUS map.",
QVariant::typeToName( QVariant::Type(kid) ), kid);
- error();
+ error(QString::fromLatin1("Type %1 passed in arguments cannot be used as a key in a map")
+ .arg(QLatin1String(QVariant::typeToName(QVariant::Type(kid)))));
return this;
}
const char *vsignature = QDBusMetaType::typeToSignature( QVariant::Type(vid) );
if (!vsignature) {
+ const char *typeName = QVariant::typeToName(QVariant::Type(vid));
qWarning("QDBusMarshaller: type `%s' (%d) is not registered with D-BUS. "
"Use qDBusRegisterMetaType to register it",
- QVariant::typeToName( QVariant::Type(vid) ), vid);
- error();
+ typeName, vid);
+ error(QString::fromLatin1("Unregistered type %1 passed in arguments")
+ .arg(QLatin1String(typeName)));
return this;
}
@@ -328,11 +334,13 @@ void QDBusMarshaller::close()
}
}
-void QDBusMarshaller::error()
+void QDBusMarshaller::error(const QString &msg)
{
ok = false;
if (parent)
- parent->error();
+ parent->error(msg);
+ else
+ errorString = msg;
}
bool QDBusMarshaller::appendVariantInternal(const QVariant &arg)
@@ -340,7 +348,7 @@ bool QDBusMarshaller::appendVariantInternal(const QVariant &arg)
int id = arg.userType();
if (id == QVariant::Invalid) {
qWarning("QDBusMarshaller: cannot add an invalid QVariant");
- error();
+ error(QLatin1String("Variant containing QVariant::Invalid passed in arguments"));
return false;
}
@@ -371,7 +379,8 @@ bool QDBusMarshaller::appendVariantInternal(const QVariant &arg)
qWarning("QDBusMarshaller: type `%s' (%d) is not registered with D-BUS. "
"Use qDBusRegisterMetaType to register it",
QVariant::typeToName( QVariant::Type(id) ), id);
- error();
+ error(QString::fromLatin1("Unregistered type %1 passed in arguments")
+ .arg(QLatin1String(QVariant::typeToName(QVariant::Type(id)))));
return false;
}