[Telepathy-commits] [telepathy-qt4/master] ConnectionManager: add a concept of "is it ready?"

Simon McVittie simon.mcvittie at collabora.co.uk
Mon Dec 8 07:32:37 PST 2008


---
 TelepathyQt4/cli-connection-manager.cpp |   37 +++++++++++++++++++-----------
 TelepathyQt4/cli-connection-manager.h   |   17 +++++++++-----
 2 files changed, 34 insertions(+), 20 deletions(-)

diff --git a/TelepathyQt4/cli-connection-manager.cpp b/TelepathyQt4/cli-connection-manager.cpp
index 165760b..f46c5c1 100644
--- a/TelepathyQt4/cli-connection-manager.cpp
+++ b/TelepathyQt4/cli-connection-manager.cpp
@@ -60,15 +60,10 @@ struct ConnectionManager::Private
                 TELEPATHY_CONNECTION_MANAGER_OBJECT_PATH_BASE).append(name);
     }
 
-    void continueIntrospection()
+    ~Private()
     {
-        if (!ready) {
-            if (introspectQueue.isEmpty()) {
-                // TODO: signal ready
-                debug() << "ConnectionManager is ready";
-            } else {
-                (this->*introspectQueue.dequeue())();
-            }
+        Q_FOREACH (ProtocolInfo* protocol, protocols) {
+            delete protocol;
         }
     }
 
@@ -115,7 +110,7 @@ struct ConnectionManager::Private
 
         introspectQueue.enqueue(&Private::callGetAll);
         introspectQueue.enqueue(&Private::callListProtocols);
-        QTimer::singleShot(0, &parent, SLOT(onStartIntrospection()));
+        QTimer::singleShot(0, &parent, SLOT(continueIntrospection()));
     }
 };
 
@@ -156,6 +151,12 @@ QStringList ConnectionManager::supportedProtocols() const
 }
 
 
+bool ConnectionManager::isReady() const
+{
+    return mPriv->ready;
+}
+
+
 ConnectionManagerInterface* ConnectionManager::baseInterface() const
 {
     return mPriv->baseInterface;
@@ -182,7 +183,7 @@ void ConnectionManager::onGetAllConnectionManagerReturn(
     if (props.contains("Interfaces")) {
         mPriv->interfaces = qdbus_cast<QStringList>(props["Interfaces"]);
     }
-    mPriv->continueIntrospection();
+    continueIntrospection();
 }
 
 
@@ -206,7 +207,7 @@ void ConnectionManager::onListProtocolsReturn(
         mPriv->protocolQueue.enqueue(protocol);
         mPriv->introspectQueue.enqueue(&Private::callGetParameters);
     }
-    mPriv->continueIntrospection();
+    continueIntrospection();
 }
 
 
@@ -229,12 +230,20 @@ void ConnectionManager::onGetParametersReturn(
         debug() << "Parameter" << spec.name << "has flags" << spec.flags
             << "and signature" << spec.signature;
     }
-    mPriv->continueIntrospection();
+    continueIntrospection();
 }
 
-void ConnectionManager::onStartIntrospection()
+void ConnectionManager::continueIntrospection()
 {
-    mPriv->continueIntrospection();
+    if (!mPriv->ready) {
+        if (mPriv->introspectQueue.isEmpty()) {
+            debug() << "ConnectionManager is ready";
+            mPriv->ready = true;
+            Q_EMIT ready(this);
+        } else {
+            (mPriv->*(mPriv->introspectQueue.dequeue()))();
+        }
+    }
 }
 
 } // Telepathy::Client
diff --git a/TelepathyQt4/cli-connection-manager.h b/TelepathyQt4/cli-connection-manager.h
index 64f7452..3b67462 100644
--- a/TelepathyQt4/cli-connection-manager.h
+++ b/TelepathyQt4/cli-connection-manager.h
@@ -69,11 +69,6 @@ class ConnectionManager : public StatelessDBusProxy,
 {
     Q_OBJECT
 
-private:
-    struct Private;
-    friend struct Private;
-    Private *mPriv;
-
 public:
     ConnectionManager(const QString& name, QObject* parent = 0);
     ConnectionManager(const QDBusConnection& bus,
@@ -99,6 +94,11 @@ public:
                 *baseInterface());
     }
 
+    bool isReady() const;
+
+Q_SIGNALS:
+    void ready(ConnectionManager*);
+
 protected:
     /**
      * Get the ConnectionManagerInterface for this ConnectionManager. This
@@ -115,7 +115,12 @@ private Q_SLOTS:
     void onGetParametersReturn(QDBusPendingCallWatcher*);
     void onListProtocolsReturn(QDBusPendingCallWatcher*);
     void onGetAllConnectionManagerReturn(QDBusPendingCallWatcher*);
-    void onStartIntrospection();
+    void continueIntrospection();
+
+private:
+    struct Private;
+    friend struct Private;
+    Private *mPriv;
 };
 
 
-- 
1.5.6.5




More information about the Telepathy-commits mailing list