[Telepathy-commits] [telepathy-qt4/master] StatefulDBusProxy: find out the unique name

Simon McVittie simon.mcvittie at collabora.co.uk
Mon Jan 12 09:08:09 PST 2009


For a stateful interface it doesn't make sense to follow name-owner
changes, so we want to bind to the unique name.

Currently I match telepathy-glib's implementation and use a
pseudo-blocking call; since our call is only to the dbus-daemon this
doesn't introduce any message reordering, and it avoids having to
delay the start of the introspection process for subclasses until
the unique name has been discovered.
---
 TelepathyQt4/Client/dbus-proxy.cpp |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/TelepathyQt4/Client/dbus-proxy.cpp b/TelepathyQt4/Client/dbus-proxy.cpp
index 9d2c386..9a09854 100644
--- a/TelepathyQt4/Client/dbus-proxy.cpp
+++ b/TelepathyQt4/Client/dbus-proxy.cpp
@@ -88,6 +88,11 @@ QString DBusProxy::busName() const
     return mPriv->busName;
 }
 
+void DBusProxy::setBusName(const QString &busName)
+{
+    mPriv->busName = busName;
+}
+
 // ==== StatelessDBusProxy =============================================
 
 StatelessDBusProxy::StatelessDBusProxy(const QDBusConnection& dbusConnection,
@@ -131,6 +136,20 @@ StatefulDBusProxy::StatefulDBusProxy(const QDBusConnection &dbusConnection,
         const QString &busName, const QString &objectPath, QObject *parent)
     : DBusProxy(dbusConnection, busName, objectPath, parent)
 {
+    QString uniqueName = busName;
+
+    if (!busName.startsWith(QChar(':'))) {
+        // For a stateful interface, it makes no sense to follow name-owner
+        // changes, so we want to bind to the unique name.
+        QDBusReply<QString> reply = dbusConnection.interface()->serviceOwner(
+                busName);
+        if (reply.isValid()) {
+            uniqueName = reply.value();
+        } else {
+            invalidate(reply.error());
+        }
+    }
+
     // FIXME: Am I on crack?
     connect(dbusConnection.interface(), SIGNAL(serviceOwnerChanged(QString, QString, QString)),
             this, SLOT(onServiceOwnerChanged(QString, QString, QString)));
-- 
1.5.6.5




More information about the Telepathy-commits mailing list