summaryrefslogtreecommitdiffstats
path: root/src/dbus/qdbusconnection.cpp
diff options
context:
space:
mode:
authorKevron Rees <kevron.m.rees@intel.com>2015-01-22 15:00:36 -0800
committerThiago Macieira <thiago.macieira@intel.com>2015-02-15 02:17:53 +0000
commit0eec8c86b604374c3210133822d41df229698b34 (patch)
treeef38b6a2def0b285aa35b57c52fbbe14263640a2 /src/dbus/qdbusconnection.cpp
parent06ecd74db138bcdf6f87df5917f6d5035da41823 (diff)
QDBusConnection::registorObject with interface
Currently QDBus relies on a key in QMetaClassInfo to understand the DBus interface name. This patch allows QDBus to also use a specified interface name in the registerObject call instead of relying on QMetaClassInfo that might not be there (if the QObject was created in QML or Javascript for example). Change-Id: Ie02b2c67e7deb07f43e35eb166c11833fcbf38f3 Task-number: QTBUG-44074 Reviewed-by: Kevron Rees <kevron.m.rees@intel.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/dbus/qdbusconnection.cpp')
-rw-r--r--src/dbus/qdbusconnection.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/dbus/qdbusconnection.cpp b/src/dbus/qdbusconnection.cpp
index c758f85d79..ff897faab6 100644
--- a/src/dbus/qdbusconnection.cpp
+++ b/src/dbus/qdbusconnection.cpp
@@ -762,6 +762,26 @@ bool QDBusConnection::disconnect(const QString &service, const QString &path, co
*/
bool QDBusConnection::registerObject(const QString &path, QObject *object, RegisterOptions options)
{
+ return registerObject(path, QString(), object, options);
+}
+
+/*!
+ \overload
+ \since 5.5
+
+ Registers the object \a object at path \a path with interface name \a interface
+ and returns \c true if the registration was successful. The \a options parameter
+ specifies how much of the object \a object will be exposed through
+ D-Bus.
+
+ This function does not replace existing objects: if there is already an object registered at
+ path \a path, this function will return false. Use unregisterObject() to unregister it first.
+
+ You cannot register an object as a child object of an object that
+ was registered with QDBusConnection::ExportChildObjects.
+*/
+bool QDBusConnection::registerObject(const QString &path, const QString &interface, QObject *object, RegisterOptions options)
+{
Q_ASSERT_X(QDBusUtil::isValidObjectPath(path), "QDBusConnection::registerObject",
"Invalid object path given");
if (!d || !d->connection || !object || !options || !QDBusUtil::isValidObjectPath(path))
@@ -793,6 +813,7 @@ bool QDBusConnection::registerObject(const QString &path, QObject *object, Regis
// we can add the object here
node->obj = object;
node->flags = options;
+ node->interfaceName = interface;
d->registerObject(node);
//qDebug("REGISTERED FOR %s", path.toLocal8Bit().constData());