diff options
author | Gunnar Sletta <gunnar.sletta@nokia.com> | 2011-08-25 10:11:49 +0200 |
---|---|---|
committer | Gunnar Sletta <gunnar.sletta@nokia.com> | 2011-08-25 12:48:52 +0200 |
commit | 04d0a9626ce61b2e05a40f9562c2bcf12e234639 (patch) | |
tree | f1643f829aedc9ac51fcc260f7df2639dfe08360 /src/dbus/qdbusconnection.cpp | |
parent | 17f3451daa286b88a52f18c802d7b158dfb653b2 (diff) | |
parent | bdc417b3828737334723eae23097c85f70c23a33 (diff) |
Merge branch 'master' into refactor
Conflicts:
src/gui/kernel/qapplication_qpa.cpp
src/gui/kernel/qcursor_qpa.cpp
src/gui/kernel/qwindowsysteminterface_qpa.cpp
src/gui/kernel/qwindowsysteminterface_qpa.h
src/gui/kernel/qwindowsysteminterface_qpa_p.h
src/gui/text/qtextcontrol.cpp
src/plugins/platforms/wayland/wayland.pro
src/widgets/accessible/qaccessible2.h
src/widgets/widgets/qwidgetlinecontrol_p.h
Change-Id: I5e6f4eb184159dccc67e8f13673edb884d179c74
Diffstat (limited to 'src/dbus/qdbusconnection.cpp')
-rw-r--r-- | src/dbus/qdbusconnection.cpp | 52 |
1 files changed, 51 insertions, 1 deletions
diff --git a/src/dbus/qdbusconnection.cpp b/src/dbus/qdbusconnection.cpp index 9656903846..a55ff14fcf 100644 --- a/src/dbus/qdbusconnection.cpp +++ b/src/dbus/qdbusconnection.cpp @@ -222,6 +222,18 @@ void QDBusConnectionManager::setConnection(const QString &name, QDBusConnectionP */ /*! + \internal + \since 4.8 + \enum QDBusConnection::VirtualObjectRegisterOption + Specifies the options for registering virtual objects with the connection. The possible values are: + + \value SingleNode register a virtual object to handle one path only + \value SubPath register a virtual object so that it handles all sub paths + + \sa registerVirtualObject(), QDBusVirtualObject +*/ + +/*! \enum QDBusConnection::UnregisterMode The mode for unregistering an object path: @@ -801,9 +813,21 @@ bool QDBusConnection::registerObject(const QString &path, QObject *object, Regis // this node exists // consider it free if there's no object here and the user is not trying to // replace the object sub-tree - if ((options & ExportChildObjects && !node->children.isEmpty()) || node->obj) + if (node->obj) return false; + if (options & QDBusConnectionPrivate::VirtualObject) { + // technically the check for children needs to go even deeper + if (options & SubPath) { + foreach (const QDBusConnectionPrivate::ObjectTreeNode &child, node->children) { + if (child.obj) + return false; + } + } + } else { + if ((options & ExportChildObjects && !node->children.isEmpty())) + return false; + } // we can add the object here node->obj = object; node->flags = options; @@ -813,6 +837,13 @@ bool QDBusConnection::registerObject(const QString &path, QObject *object, Regis return true; } + // if a virtual object occupies this path, return false + if (node->obj && (node->flags & QDBusConnectionPrivate::VirtualObject) && (node->flags & QDBusConnection::SubPath)) { + qDebug("Cannot register object at %s because QDBusVirtualObject handles all sub-paths.", + qPrintable(path)); + return false; + } + // find the position where we'd insert the node QDBusConnectionPrivate::ObjectTreeNode::DataList::Iterator it = qLowerBound(node->children.begin(), node->children.end(), pathComponents.at(i)); @@ -841,6 +872,21 @@ bool QDBusConnection::registerObject(const QString &path, QObject *object, Regis } /*! + \internal + \since 4.8 + Registers a QDBusTreeNode for a path. It can handle a path including all child paths, thus + handling multiple DBus nodes. + + To unregister a QDBusTreeNode use the unregisterObject() function with its path. +*/ +bool QDBusConnection::registerVirtualObject(const QString &path, QDBusVirtualObject *treeNode, + VirtualObjectRegisterOption options) +{ + int opts = options | QDBusConnectionPrivate::VirtualObject; + return registerObject(path, (QObject*) treeNode, (RegisterOptions) opts); +} + +/*! Unregisters an object that was registered with the registerObject() at the object path given by \a path and, if \a mode is QDBusConnection::UnregisterTree, all of its sub-objects too. @@ -905,6 +951,8 @@ QObject *QDBusConnection::objectRegisteredAt(const QString &path) const while (node) { if (pathComponents.count() == i) return node->obj; + if ((node->flags & QDBusConnectionPrivate::VirtualObject) && (node->flags & QDBusConnection::SubPath)) + return node->obj; QDBusConnectionPrivate::ObjectTreeNode::DataList::ConstIterator it = qLowerBound(node->children.constBegin(), node->children.constEnd(), pathComponents.at(i)); @@ -917,6 +965,8 @@ QObject *QDBusConnection::objectRegisteredAt(const QString &path) const return 0; } + + /*! Returns a QDBusConnectionInterface object that represents the D-Bus server interface on this connection. |