[Telepathy-commits] [telepathy-qt4/master] ConnectionManager: Use PendingReadyConnectionManager.

Andre Moreira Magalhaes (andrunko) andre.magalhaes at collabora.co.uk
Fri Feb 13 12:54:57 PST 2009


P.s: Tests broken (will be fixed in a later patch)
---
 TelepathyQt4/Client/account.cpp                   |    1 +
 TelepathyQt4/Client/connection-manager-internal.h |   14 +---------
 TelepathyQt4/Client/connection-manager.cpp        |   27 +++++++++++----------
 TelepathyQt4/Client/connection-manager.h          |    4 +-
 4 files changed, 19 insertions(+), 27 deletions(-)

diff --git a/TelepathyQt4/Client/account.cpp b/TelepathyQt4/Client/account.cpp
index ef7a3f9..8a1d1f6 100644
--- a/TelepathyQt4/Client/account.cpp
+++ b/TelepathyQt4/Client/account.cpp
@@ -32,6 +32,7 @@
 #include <TelepathyQt4/Client/ConnectionManager>
 #include <TelepathyQt4/Client/PendingFailure>
 #include <TelepathyQt4/Client/PendingReadyAccount>
+#include <TelepathyQt4/Client/PendingReadyConnectionManager>
 #include <TelepathyQt4/Client/PendingVoidMethodCall>
 #include <TelepathyQt4/Constants>
 #include <TelepathyQt4/Debug>
diff --git a/TelepathyQt4/Client/connection-manager-internal.h b/TelepathyQt4/Client/connection-manager-internal.h
index f640013..97e2d00 100644
--- a/TelepathyQt4/Client/connection-manager-internal.h
+++ b/TelepathyQt4/Client/connection-manager-internal.h
@@ -36,6 +36,7 @@ namespace Client
 
 class ConnectionManager;
 class ConnectionManagerInterface;
+class PendingReadyConnectionManager;
 
 struct ConnectionManager::Private
 {
@@ -47,7 +48,6 @@ struct ConnectionManager::Private
 
     ProtocolInfo *protocol(const QString &protocolName);
 
-    class PendingReady;
     class PendingNames;
 
     ConnectionManagerInterface *baseInterface;
@@ -58,20 +58,10 @@ struct ConnectionManager::Private
     QQueue<QString> protocolQueue;
     QStringList interfaces;
     ProtocolInfoList protocols;
-    PendingReady *pendingReady;
+    PendingReadyConnectionManager *pendingReady;
     ConnectionManager::Features features;
 };
 
-class ConnectionManager::Private::PendingReady : public PendingOperation
-{
-    // ConnectionManager is a friend so it can call finished() etc.
-    friend class ConnectionManager;
-
-public:
-    PendingReady(ConnectionManager *parent);
-};
-
-
 class ConnectionManager::Private::PendingNames : public PendingStringList
 {
     Q_OBJECT
diff --git a/TelepathyQt4/Client/connection-manager.cpp b/TelepathyQt4/Client/connection-manager.cpp
index bc1f26c..c51080e 100644
--- a/TelepathyQt4/Client/connection-manager.cpp
+++ b/TelepathyQt4/Client/connection-manager.cpp
@@ -31,7 +31,7 @@
 
 #include <TelepathyQt4/Client/DBus>
 #include <TelepathyQt4/Client/PendingConnection>
-#include <TelepathyQt4/Client/PendingSuccess>
+#include <TelepathyQt4/Client/PendingReadyConnectionManager>
 #include <TelepathyQt4/Constants>
 #include <TelepathyQt4/ManagerFile>
 #include <TelepathyQt4/Types>
@@ -224,11 +224,6 @@ void ProtocolInfo::addParameter(const ParamSpec &spec)
     mPriv->params.append(param);
 }
 
-ConnectionManager::Private::PendingReady::PendingReady(ConnectionManager *parent)
-    : PendingOperation(parent)
-{
-}
-
 ConnectionManager::Private::PendingNames::PendingNames(const QDBusConnection &bus)
     : PendingStringList(),
       mBus(bus)
@@ -478,24 +473,30 @@ bool ConnectionManager::isReady(Features features) const
  * its initial setup, or will fail if a fatal error occurs during this
  * initial setup.
  *
- * \return A PendingOperation which will emit PendingOperation::finished
+ * \return A PendingReadyConnectionManager object which will emit finished
  *         when this object has finished or failed its initial setup.
  */
-PendingOperation *ConnectionManager::becomeReady(Features features)
+PendingReadyConnectionManager *ConnectionManager::becomeReady(Features requestedFeatures)
 {
     if (!isValid()) {
-        return new PendingFailure(this, TELEPATHY_ERROR_NOT_AVAILABLE,
+        PendingReadyConnectionManager *operation =
+            new PendingReadyConnectionManager(requestedFeatures, this);
+        operation->setFinishedWithError(TELEPATHY_ERROR_NOT_AVAILABLE,
                 "ConnectionManager is invalid");
+        return operation;
     }
 
-    if (isReady(features)) {
-        return new PendingSuccess(this);
+    if (isReady(requestedFeatures)) {
+        PendingReadyConnectionManager *operation =
+            new PendingReadyConnectionManager(requestedFeatures, this);
+        operation->setFinished();
+        return operation;
     }
 
     if (!mPriv->pendingReady) {
-        mPriv->pendingReady = new Private::PendingReady(this);
+        mPriv->pendingReady =
+            new PendingReadyConnectionManager(requestedFeatures, this);
     }
-
     return mPriv->pendingReady;
 }
 
diff --git a/TelepathyQt4/Client/connection-manager.h b/TelepathyQt4/Client/connection-manager.h
index c4b3302..5080ab9 100644
--- a/TelepathyQt4/Client/connection-manager.h
+++ b/TelepathyQt4/Client/connection-manager.h
@@ -39,7 +39,7 @@ namespace Client
 {
 
 class PendingConnection;
-class PendingOperation;
+class PendingReadyConnectionManager;
 class PendingStringList;
 class ProtocolParameter;
 class ProtocolInfo;
@@ -146,7 +146,7 @@ public:
 
     bool isReady(Features features = 0) const;
 
-    PendingOperation *becomeReady(Features features = 0);
+    PendingReadyConnectionManager *becomeReady(Features features = 0);
 
     static PendingStringList *listNames(const QDBusConnection &bus = QDBusConnection::sessionBus());
 
-- 
1.5.6.5




More information about the telepathy-commits mailing list