From 0eec8c86b604374c3210133822d41df229698b34 Mon Sep 17 00:00:00 2001 From: Kevron Rees Date: Thu, 22 Jan 2015 15:00:36 -0800 Subject: 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 Reviewed-by: Thiago Macieira --- src/dbus/qdbusconnection.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/dbus/qdbusconnection.cpp') 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 @@ -761,6 +761,26 @@ bool QDBusConnection::disconnect(const QString &service, const QString &path, co was registered with QDBusConnection::ExportChildObjects. */ 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"); @@ -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()); -- cgit v1.2.3