[Telepathy-commits] [telepathy-qt4/master] Adapt to latest developments in -client-proxies; Connection now publicly inherits ConnectionInterface

Olli Salli olli.salli at collabora.co.uk
Mon Sep 22 04:58:09 PDT 2008


---
 TelepathyQt4/cli-connection.cpp |   65 +++++++++++++++-----------------------
 TelepathyQt4/cli-connection.h   |   34 +++++---------------
 2 files changed, 35 insertions(+), 64 deletions(-)

diff --git a/TelepathyQt4/cli-connection.cpp b/TelepathyQt4/cli-connection.cpp
index 68f61aa..4a385bd 100644
--- a/TelepathyQt4/cli-connection.cpp
+++ b/TelepathyQt4/cli-connection.cpp
@@ -39,7 +39,6 @@ namespace Client
 struct Connection::Private
 {
     Connection& parent;
-    ConnectionInterface interface;
     ConnectionInterfaceAliasingInterface aliasing;
     ConnectionInterfacePresenceInterface presence;
     ConnectionInterfaceSimplePresenceInterface simplePresence;
@@ -54,29 +53,25 @@ struct Connection::Private
     StatusSpecMap presenceStatuses;
     SimpleStatusSpecMap simplePresenceStatuses;
 
-    Private(Connection &parent,
-            const QDBusConnection& connection,
-            const QString& serviceName,
-            const QString& objectPath)
+    Private(Connection &parent)
         : parent(parent),
-          interface(connection, serviceName, objectPath, &parent),
-          aliasing(interface),
-          presence(interface),
-          simplePresence(interface),
-          properties(interface)
+          aliasing(parent),
+          presence(parent),
+          simplePresence(parent),
+          properties(parent)
     {
         ready = false;
         status = -1;
         statusReason = ConnectionStatusReasonNoneSpecified;
 
-        parent.connect(&interface,
-                       SIGNAL(statusChanged(uint, uint)),
-                       SLOT(statusChanged(uint, uint)));
+        parent.connect(&parent,
+                       SIGNAL(StatusChanged(uint, uint)),
+                       SLOT(onStatusChanged(uint, uint)));
 
         debug() << "Calling GetStatus()";
 
         QDBusPendingCallWatcher* watcher =
-            new QDBusPendingCallWatcher(interface.getStatus(), &parent);
+            new QDBusPendingCallWatcher(parent.GetStatus(), &parent);
         parent.connect(watcher,
                        SIGNAL(finished(QDBusPendingCallWatcher*)),
                        SLOT(gotStatus(QDBusPendingCallWatcher*)));
@@ -86,7 +81,7 @@ struct Connection::Private
     {
         debug() << "Calling GetAliasFlags()";
         QDBusPendingCallWatcher* watcher =
-            new QDBusPendingCallWatcher(aliasing.getAliasFlags(), &parent);
+            new QDBusPendingCallWatcher(aliasing.GetAliasFlags(), &parent);
         parent.connect(watcher,
                        SIGNAL(finished(QDBusPendingCallWatcher*)),
                        SLOT(gotAliasFlags(QDBusPendingCallWatcher*)));
@@ -96,7 +91,7 @@ struct Connection::Private
     {
         debug() << "Calling GetStatuses() (legacy)";
         QDBusPendingCallWatcher* watcher =
-            new QDBusPendingCallWatcher(presence.getStatuses(), &parent);
+            new QDBusPendingCallWatcher(presence.GetStatuses(), &parent);
         parent.connect(watcher,
                        SIGNAL(finished(QDBusPendingCallWatcher*)),
                        SLOT(gotStatuses(QDBusPendingCallWatcher*)));
@@ -106,7 +101,7 @@ struct Connection::Private
     {
         debug() << "Getting available SimplePresence statuses";
         QDBusPendingCall call =
-            properties.get(TELEPATHY_INTERFACE_CONNECTION_INTERFACE_SIMPLE_PRESENCE,
+            properties.Get(TELEPATHY_INTERFACE_CONNECTION_INTERFACE_SIMPLE_PRESENCE,
                            "Statuses");
         QDBusPendingCallWatcher* watcher =
             new QDBusPendingCallWatcher(call, &parent);
@@ -120,7 +115,7 @@ struct Connection::Private
         if (introspectQueue.isEmpty()) {
             debug() << "Connection ready";
             ready = true;
-            emit parent.ready();
+            emit parent.nowReady();
         } else {
             (this->*introspectQueue.dequeue())();
         }
@@ -130,8 +125,8 @@ struct Connection::Private
 Connection::Connection(const QString& serviceName,
                        const QString& objectPath,
                        QObject* parent)
-    : QObject(parent),
-      mPriv(new Private(*this, QDBusConnection::sessionBus(), serviceName, objectPath))
+    : ConnectionInterface(serviceName, objectPath, parent),
+      mPriv(new Private(*this))
 {
 }
 
@@ -139,8 +134,8 @@ Connection::Connection(const QDBusConnection& connection,
                        const QString& serviceName,
                        const QString& objectPath,
                        QObject* parent)
-    : QObject(parent),
-      mPriv(new Private(*this, connection, serviceName, objectPath))
+    : ConnectionInterface(connection, serviceName, objectPath, parent),
+      mPriv(new Private(*this))
 {
 }
 
@@ -149,16 +144,6 @@ Connection::~Connection()
     delete mPriv;
 }
 
-ConnectionInterface& Connection::interface()
-{
-    return mPriv->interface;
-}
-
-const ConnectionInterface& Connection::interface() const
-{
-    return mPriv->interface;
-}
-
 bool Connection::ready() const
 {
     return mPriv->ready;
@@ -179,6 +164,8 @@ QStringList Connection::interfaces() const
     return mPriv->interfaces;
 }
 
+#if 0
+
 ConnectionAliasFlags Connection::aliasFlags() const
 {
     return mPriv->aliasFlags;
@@ -189,6 +176,7 @@ StatusSpecMap Connection::presenceStatuses() const
     return mPriv->presenceStatuses;
 }
 
+
 SimpleStatusSpecMap Connection::simplePresenceStatuses() const
 {
     if (!ready() && mPriv->simplePresenceStatuses.isEmpty()) {
@@ -198,8 +186,9 @@ SimpleStatusSpecMap Connection::simplePresenceStatuses() const
 
     return mPriv->simplePresenceStatuses;
 }
+#endif
 
-void Connection::statusChanged(uint status, uint reason)
+void Connection::onStatusChanged(uint status, uint reason)
 {
     if (mPriv->status == -1) {
         // We've got a StatusChanged before the initial GetStatus reply, ignore it
@@ -211,12 +200,10 @@ void Connection::statusChanged(uint status, uint reason)
     mPriv->status = status;
     mPriv->statusReason = reason;
 
-    emit statusChanged(status, reason);
-
     if (status == ConnectionStatusConnected) {
         debug() << "Calling GetInterfaces()";
         QDBusPendingCallWatcher* watcher =
-            new QDBusPendingCallWatcher(interface().getInterfaces(), this);
+            new QDBusPendingCallWatcher(GetInterfaces(), this);
         connect(watcher,
                 SIGNAL(finished(QDBusPendingCallWatcher*)),
                 SLOT(gotInterfaces(QDBusPendingCallWatcher*)));
@@ -225,13 +212,13 @@ void Connection::statusChanged(uint status, uint reason)
 
 void Connection::gotStatus(QDBusPendingCallWatcher* watcher)
 {
-    QDBusPendingReply<uint, uint> reply = *watcher;
+    QDBusPendingReply<uint> reply = *watcher;
 
     if (!reply.isError()) {
         debug() << "Got reply to initial GetStatus()";
-        // Avoid early return in statusChanged()
+        // Avoid early return in onStatusChanged()
         mPriv->status = reply.argumentAt<0>();
-        statusChanged(reply.argumentAt<0>(), reply.argumentAt<1>());
+        onStatusChanged(reply.argumentAt<0>(), ConnectionStatusReasonNoneSpecified);
     } else {
         warning().nospace() << "GetStatus() failed with " << reply.error().name() << ": " << reply.error().message();
     }
diff --git a/TelepathyQt4/cli-connection.h b/TelepathyQt4/cli-connection.h
index b526fb9..959e18e 100644
--- a/TelepathyQt4/cli-connection.h
+++ b/TelepathyQt4/cli-connection.h
@@ -59,13 +59,15 @@ namespace Client
  *
  * High-level proxy object for accessing remote %Telepathy %Connection objects.
  *
- * It adds the following features compared to using ConnectionInterface alone:
+ * It adds the following features compared to using ConnectionInterface
+ * directly:
  * <ul>
  *  <li>%Connection status tracking</li>
- *  <li>Calling GetInterfaces automatically</li>
+ *  <li>Calling #GetInterfaces automatically</li>
+ *  <li>Calling #GetAliasFlags automatically</li>
  * </ul>
  */
-class Connection : public QObject
+class Connection : public ConnectionInterface
 {
     Q_OBJECT
 public:
@@ -99,25 +101,6 @@ public:
     ~Connection();
 
     /**
-     * Returns a reference to the underlying ConnectionInterface instance for
-     * easy direct access to the D-Bus properties, methods and signals on the
-     * remote object.
-     *
-     * Note that this class provides a more convenient way to access some
-     * functionality than using the interface class directly.
-     *
-     * \return A reference to the underlying ConnectionInterface instance.
-     *
-     * \{
-     */
-    ConnectionInterface& interface();
-    const ConnectionInterface& interface() const;
-
-    /**
-     * \}
-     */
-
-    /**
      * Initially <code>false</code>, changes to <code>true</code> when the
      * connection has gone to the Connected status, introspection is finished
      * and it's ready for use.
@@ -177,6 +160,7 @@ public:
      */
     QStringList interfaces() const;
 
+#if 0
     /**
      * Bitwise OR of flags detailing the behaviour of aliases on the
      * connection.
@@ -231,16 +215,16 @@ public:
      * \return Dictionary mapping string identifiers to structs for each status.
      */
     SimpleStatusSpecMap simplePresenceStatuses() const;
-
+#endif
 Q_SIGNALS:
     /**
      * Emitted when the value of the property #ready changes to
      * <code>true</code>.
      */
-    void ready();
+    void nowReady();
 
 private Q_SLOTS:
-    void statusChanged(uint, uint);
+    void onStatusChanged(uint, uint);
     void gotStatus(QDBusPendingCallWatcher* watcher);
     void gotInterfaces(QDBusPendingCallWatcher* watcher);
     void gotAliasFlags(QDBusPendingCallWatcher* watcher);
-- 
1.5.6.5




More information about the Telepathy-commits mailing list