[Telepathy-commits] [telepathy-qt4/master] AccountManager: Use PendingReadyAccountManager.

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


P.s: Tests broken (will be fixed in a later patch)
---
 TelepathyQt4/Client/account-manager.cpp |   48 +++++++++++++-----------------
 TelepathyQt4/Client/account-manager.h   |    4 +-
 2 files changed, 23 insertions(+), 29 deletions(-)

diff --git a/TelepathyQt4/Client/account-manager.cpp b/TelepathyQt4/Client/account-manager.cpp
index 2003185..d51b298 100644
--- a/TelepathyQt4/Client/account-manager.cpp
+++ b/TelepathyQt4/Client/account-manager.cpp
@@ -29,7 +29,7 @@
 
 #include <TelepathyQt4/Client/Account>
 #include <TelepathyQt4/Client/PendingAccount>
-#include <TelepathyQt4/Client/PendingSuccess>
+#include <TelepathyQt4/Client/PendingReadyAccountManager>
 #include <TelepathyQt4/Constants>
 
 #include <QQueue>
@@ -67,11 +67,9 @@ struct AccountManager::Private
 
     void setAccountPaths(QSet<QString> &set, const QVariant &variant);
 
-    class PendingReady;
-
     AccountManagerInterface *baseInterface;
     bool ready;
-    PendingReady *pendingReady;
+    PendingReadyAccountManager *pendingReady;
     QQueue<void (AccountManager::*)()> introspectQueue;
     QStringList interfaces;
     AccountManager::Features features;
@@ -79,20 +77,6 @@ struct AccountManager::Private
     QSet<QString> invalidAccountPaths;
 };
 
-class AccountManager::Private::PendingReady : public PendingOperation
-{
-    // AccountManager is a friend so it can call finished() etc.
-    friend class AccountManager;
-
-public:
-    PendingReady(AccountManager *parent);
-};
-
-AccountManager::Private::PendingReady::PendingReady(AccountManager *parent)
-    : PendingOperation(parent)
-{
-}
-
 AccountManager::Private::Private(AccountManager *parent)
     : baseInterface(new AccountManagerInterface(parent->dbusConnection(),
                             parent->busName(), parent->objectPath(), parent)),
@@ -368,27 +352,37 @@ bool AccountManager::isReady(Features features) const
  * initial setup.
  *
  * \param features Which features should be tested.
- * \return A PendingOperation which will emit PendingOperation::finished
+ * \return A PendingReadyAccountManager object which will emit finished
  *         when this object has finished or failed its initial setup.
  */
-PendingOperation *AccountManager::becomeReady(Features features)
+PendingReadyAccountManager *AccountManager::becomeReady(Features requestedFeatures)
 {
     if (!isValid()) {
-        return new PendingFailure(this, TELEPATHY_ERROR_NOT_AVAILABLE,
+        PendingReadyAccountManager *operation =
+            new PendingReadyAccountManager(requestedFeatures, this);
+        operation->setFinishedWithError(TELEPATHY_ERROR_NOT_AVAILABLE,
                 "AccountManager is invalid");
+        return operation;
     }
 
-    if (isReady(features)) {
-        return new PendingSuccess(this);
+    if (isReady(requestedFeatures)) {
+        PendingReadyAccountManager *operation =
+            new PendingReadyAccountManager(requestedFeatures, this);
+        operation->setFinished();
+        return operation;
     }
 
-    if (features != 0) {
-        return new PendingFailure(this, "org.freedesktop.Telepathy.Qt.DoesntWork",
-                "Unimplemented");
+    if (requestedFeatures != 0) {
+        PendingReadyAccountManager *operation =
+            new PendingReadyAccountManager(requestedFeatures, this);
+        operation->setFinishedWithError(TELEPATHY_ERROR_INVALID_ARGUMENT,
+                "Invalid features argument");
+        return operation;
     }
 
     if (!mPriv->pendingReady) {
-        mPriv->pendingReady = new Private::PendingReady(this);
+        mPriv->pendingReady =
+            new PendingReadyAccountManager(requestedFeatures, this);
     }
     return mPriv->pendingReady;
 }
diff --git a/TelepathyQt4/Client/account-manager.h b/TelepathyQt4/Client/account-manager.h
index 715e28d..000704f 100644
--- a/TelepathyQt4/Client/account-manager.h
+++ b/TelepathyQt4/Client/account-manager.h
@@ -44,7 +44,7 @@ namespace Client
 class Account;
 class AccountManager;
 class PendingAccount;
-class PendingOperation;
+class PendingReadyAccountManager;
 
 class AccountManager : public StatelessDBusProxy,
                        private OptionalInterfaceFactory<AccountManager>
@@ -89,7 +89,7 @@ public:
 
     bool isReady(Features features = 0) const;
 
-    PendingOperation *becomeReady(Features features = 0);
+    PendingReadyAccountManager *becomeReady(Features features = 0);
 
 Q_SIGNALS:
     void accountCreated(const QString &path);
-- 
1.5.6.5




More information about the telepathy-commits mailing list