diff options
author | Frederik Gladhorn <frederik.gladhorn@nokia.com> | 2011-05-22 19:36:10 (GMT) |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@nokia.com> | 2011-07-04 11:44:14 (GMT) |
commit | b07919b3de8cff3e44b7271062372b14bcda5b83 (patch) | |
tree | fb6e9c5ebbade0756b85819b59eb3efcf0ee242d /src/dbus/qdbusintegrator.cpp | |
parent | cee1f6454a7b52a52795590e2f793c0cd4e15ce1 (diff) | |
download | Qt-b07919b3de8cff3e44b7271062372b14bcda5b83.zip Qt-b07919b3de8cff3e44b7271062372b14bcda5b83.tar.gz Qt-b07919b3de8cff3e44b7271062372b14bcda5b83.tar.bz2 |
Add DBus VirtualObject to handle multiple paths.
When a virtual object is registered with the SubPath option
it will handle all dbus calls to itself and all child paths.
It needs to reimplement handleMessage for that purpose.
Introspection needs to be implemented manually in the introspect function.
Reviewed-by: Thiago Macieira <thiago.macieira@nokia.com>
Diffstat (limited to 'src/dbus/qdbusintegrator.cpp')
-rw-r--r-- | src/dbus/qdbusintegrator.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index f3f3d0b..2cde07e 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -57,6 +57,7 @@ #include "qdbusabstractadaptor.h" #include "qdbusabstractadaptor_p.h" #include "qdbusutil_p.h" +#include "qdbusvirtualobject.h" #include "qdbusmessage_p.h" #include "qdbuscontext_p.h" #include "qdbuspendingcall_p.h" @@ -442,7 +443,11 @@ static bool findObject(const QDBusConnectionPrivate::ObjectTreeNode *root, // walk the object tree const QDBusConnectionPrivate::ObjectTreeNode *node = root; - while (start < length && node && !(node->flags & QDBusConnection::ExportChildObjects)) { + while (start < length && node) { + if (node->flags & QDBusConnection::ExportChildObjects) + break; + if ((node->flags & QDBusConnectionPrivate::VirtualObject) && (node->flags & QDBusConnection::SubPath)) + break; int end = fullpath.indexOf(QLatin1Char('/'), start); end = (end == -1 ? length : end); QStringRef pathComponent(&fullpath, start, end - start); @@ -1328,7 +1333,7 @@ bool QDBusConnectionPrivate::activateInternalFilters(const ObjectTreeNode &node, if (interface.isEmpty() || interface == QLatin1String(DBUS_INTERFACE_INTROSPECTABLE)) { if (msg.member() == QLatin1String("Introspect") && msg.signature().isEmpty()) { //qDebug() << "QDBusConnectionPrivate::activateInternalFilters introspect" << msg.d_ptr->msg; - QDBusMessage reply = msg.createReply(qDBusIntrospectObject(node)); + QDBusMessage reply = msg.createReply(qDBusIntrospectObject(node, msg.path())); send(reply); return true; } @@ -1375,6 +1380,15 @@ void QDBusConnectionPrivate::activateObject(ObjectTreeNode &node, const QDBusMes // object may be null + if (node.flags & QDBusConnectionPrivate::VirtualObject) { + if (node.treeNode->handleMessage(msg, q(this))) { + return; + } else { + if (activateInternalFilters(node, msg)) + return; + } + } + if (pathStartPos != msg.path().length()) { node.flags &= ~QDBusConnection::ExportAllSignals; node.obj = findChildObject(&node, msg.path(), pathStartPos); |