[Telepathy-commits] [telepathy-qt4/master] Account: Use ReadinessHelper class.

Andre Moreira Magalhaes (andrunko) andre.magalhaes at collabora.co.uk
Mon Mar 2 19:51:31 PST 2009


---
 TelepathyQt4/Client/account.cpp    |  313 ++++++++++++++----------------------
 TelepathyQt4/Client/account.h      |   21 +--
 examples/accounts/account-item.cpp |    2 +-
 tests/dbus/account-basics.cpp      |   21 ++-
 4 files changed, 147 insertions(+), 210 deletions(-)

diff --git a/TelepathyQt4/Client/account.cpp b/TelepathyQt4/Client/account.cpp
index 0167d26..7fc8fb9 100644
--- a/TelepathyQt4/Client/account.cpp
+++ b/TelepathyQt4/Client/account.cpp
@@ -31,9 +31,10 @@
 #include <TelepathyQt4/Client/Connection>
 #include <TelepathyQt4/Client/ConnectionManager>
 #include <TelepathyQt4/Client/PendingFailure>
-#include <TelepathyQt4/Client/PendingReadyAccount>
+#include <TelepathyQt4/Client/PendingReady>
 #include <TelepathyQt4/Client/PendingReadyConnectionManager>
 #include <TelepathyQt4/Client/PendingVoidMethodCall>
+#include <TelepathyQt4/Client/ReadinessHelper>
 #include <TelepathyQt4/Constants>
 #include <TelepathyQt4/Debug>
 
@@ -59,18 +60,26 @@ namespace Client
 
 struct Account::Private
 {
-    Private(AccountManager *am, Account *parent);
+    Private(Account *parent, AccountManager *am);
     ~Private();
 
+    void init();
+
+    static void introspectMain(Private *self);
+    static void introspectAvatar(Private *self);
+    static void introspectProtocolInfo(Private *self);
+
+    // Public object
+    Account *parent;
     AccountManager *am;
+
+    // Instance of generated interface class
     AccountInterface *baseInterface;
-    bool ready;
-    QList<PendingReadyAccount *> pendingOperations;
-    QQueue<void (Account::*)()> introspectQueue;
+
+    ReadinessHelper *readinessHelper;
+
+    // Introspection
     QStringList interfaces;
-    Account::Features features;
-    Account::Features pendingFeatures;
-    Account::Features missingFeatures;
     QVariantMap parameters;
     bool valid;
     bool enabled;
@@ -93,14 +102,11 @@ struct Account::Private
     QSharedPointer<Connection> connection;
 };
 
-Account::Private::Private(AccountManager *am, Account *parent)
-    : am(am),
+Account::Private::Private(Account *parent, AccountManager *am)
+    : parent(parent),
+      am(am),
       baseInterface(new AccountInterface(parent->dbusConnection(),
-                        parent->busName(), parent->objectPath(), parent)),
-      ready(false),
-      features(0),
-      pendingFeatures(0),
-      missingFeatures(0),
+                    parent->busName(), parent->objectPath(), parent)),
       valid(false),
       enabled(false),
       connectsAutomatically(false),
@@ -137,12 +143,42 @@ Account::Private::Private(AccountManager *am, Account *parent)
                 parent->objectPath();
         }
     }
+
+    QMap<uint, ReadinessHelper::Introspectable> introspectables;
+
+    // As Account does not have predefined statuses let's simulate one (0)
+    ReadinessHelper::Introspectable introspectableCore(
+        QSet<uint>() << 0,                                                      // makesSenseForStatuses
+        QSet<uint>(),                                                           // dependsOnFeatures
+        QStringList(),                                                          // dependsOnInterfaces
+        (ReadinessHelper::IntrospectFunc) &Private::introspectMain,
+        this);
+    introspectables[FeatureCore] = introspectableCore;
+
+    ReadinessHelper::Introspectable introspectableAvatar(
+        QSet<uint>() << 0,                                                      // makesSenseForStatuses
+        QSet<uint>() << FeatureCore,                                            // dependsOnFeatures (core)
+        QStringList() << TELEPATHY_INTERFACE_ACCOUNT_INTERFACE_AVATAR,          // dependsOnInterfaces
+        (ReadinessHelper::IntrospectFunc) &Private::introspectAvatar,
+        this);
+    introspectables[FeatureAvatar] = introspectableAvatar;
+
+    ReadinessHelper::Introspectable introspectableProtocolInfo(
+        QSet<uint>() << 0,                                                      // makesSenseForStatuses
+        QSet<uint>() << FeatureCore,                                            // dependsOnFeatures (core)
+        QStringList(),                                                          // dependsOnInterfaces
+        (ReadinessHelper::IntrospectFunc) &Private::introspectProtocolInfo,
+        this);
+    introspectables[FeatureProtocolInfo] = introspectableProtocolInfo;
+
+    readinessHelper = new ReadinessHelper(parent, 0 /* status */,
+            introspectables, parent);
+
+    init();
 }
 
 Account::Private::~Private()
 {
-    delete baseInterface;
-    delete cm;
 }
 
 /**
@@ -169,19 +205,8 @@ Account::Account(AccountManager *am, const QString &objectPath,
     : StatelessDBusProxy(am->dbusConnection(),
             am->busName(), objectPath, parent),
       OptionalInterfaceFactory<Account>(this),
-      mPriv(new Private(am, this))
+      mPriv(new Private(this, am))
 {
-    if (isValid()) {
-        connect(mPriv->baseInterface,
-                SIGNAL(Removed()),
-                SLOT(onRemoved()));
-        connect(mPriv->baseInterface,
-                SIGNAL(AccountPropertyChanged(const QVariantMap &)),
-                SLOT(onPropertyChanged(const QVariantMap &)));
-
-        mPriv->introspectQueue.enqueue(&Account::callGetAll);
-        QTimer::singleShot(0, this, SLOT(continueIntrospection()));
-    }
 }
 
 /**
@@ -347,14 +372,12 @@ PendingOperation *Account::setNickname(const QString &value)
  */
 const Telepathy::Avatar &Account::avatar() const
 {
-    if (mPriv->missingFeatures & FeatureAvatar) {
+    if (!isReady(QSet<uint>() << FeatureAvatar)) {
         warning() << "Trying to retrieve avatar from account, but "
-                     "avatar is not supported";
-    }
-    else if (!(mPriv->features & FeatureAvatar)) {
-        warning() << "Trying to retrieve avatar from account without "
-                     "calling Account::becomeReady(FeatureAvatar)";
+                     "avatar is not supported or was not requested. "
+                     "Use becomeReady(FeatureAvatar)";
     }
+
     return mPriv->avatar;
 }
 
@@ -367,9 +390,9 @@ const Telepathy::Avatar &Account::avatar() const
  */
 PendingOperation *Account::setAvatar(const Telepathy::Avatar &avatar)
 {
-    if (!avatarInterface()) {
+    if (!mPriv->interfaces.contains(TELEPATHY_INTERFACE_ACCOUNT_INTERFACE_AVATAR)) {
         return new PendingFailure(this, TELEPATHY_ERROR_NOT_IMPLEMENTED,
-                "Unimplemented");
+                "Account does not support Avatar");
     }
 
     return new PendingVoidMethodCall(this,
@@ -414,10 +437,12 @@ PendingOperation *Account::updateParameters(const QVariantMap &set,
  */
 ProtocolInfo *Account::protocolInfo() const
 {
-    if (!mPriv->features & FeatureProtocolInfo) {
-        warning() << "Trying to retrieve protocol info from account without"
-                     "calling Account::becomeReady(FeatureProtocolInfo)";
+    if (!isReady(QSet<uint>() << FeatureProtocolInfo)) {
+        warning() << "Trying to retrieve protocol info from account, but "
+                     "protocol info is not supported or was not requested. "
+                     "Use becomeReady(FeatureProtocolInfo)";
     }
+
     return mPriv->protocolInfo;
 }
 
@@ -624,10 +649,9 @@ PendingOperation *Account::remove()
  * \return \c true if the object has finished its initial setup for basic
  *         functionality plus the given features
  */
-bool Account::isReady(Features features) const
+bool Account::isReady(const QSet<uint> &features) const
 {
-    return mPriv->ready
-        && ((mPriv->features & features) == features);
+    return mPriv->readinessHelper->isReady(features);
 }
 
 /**
@@ -635,84 +659,16 @@ bool Account::isReady(Features features) const
  * its initial setup, or will fail if a fatal error occurs during this
  * initial setup.
  *
+ * If an empty set is used FeatureCore will be considered as the requested
+ * feature.
+ *
  * \param requestedFeatures The features which should be enabled.
- * \return A PendingReadyAccount object which will emit finished
+ * \return A PendingReady object which will emit finished
  *         when this object has finished or failed its initial setup.
  */
-PendingReadyAccount *Account::becomeReady(Features requestedFeatures)
+PendingReady *Account::becomeReady(const QSet<uint> &requestedFeatures)
 {
-    if (!isValid()) {
-        PendingReadyAccount *operation =
-                new PendingReadyAccount(requestedFeatures, this);
-        operation->setFinishedWithError(TELEPATHY_ERROR_NOT_AVAILABLE,
-                "Account is invalid");
-        return operation;
-    }
-
-    if (isReady(requestedFeatures)) {
-        PendingReadyAccount *operation =
-                new PendingReadyAccount(requestedFeatures, this);
-        operation->setFinished();
-        return operation;
-    }
-
-    debug() << "calling becomeReady with requested features:"
-            << requestedFeatures;
-    foreach (PendingReadyAccount *operation, mPriv->pendingOperations) {
-        if (operation->requestedFeatures() == requestedFeatures) {
-            debug() << "returning cached pending operation";
-            return operation;
-        }
-    }
-
-    if (requestedFeatures & FeatureAvatar) {
-        // if the only feature requested is avatar and avatar is know to not be
-        // supported, just finish silently
-        if (requestedFeatures == FeatureAvatar &&
-            mPriv->missingFeatures & FeatureAvatar) {
-            PendingReadyAccount *operation =
-                    new PendingReadyAccount(requestedFeatures, this);
-            operation->setFinished();
-            return operation;
-        }
-
-        // if we know that avatar is not supported, no need to
-        // queue the call to get avatar
-        if (!(mPriv->missingFeatures & FeatureAvatar) &&
-            !(mPriv->features & FeatureAvatar) &&
-            !(mPriv->pendingFeatures & FeatureAvatar)) {
-            mPriv->introspectQueue.enqueue(&Account::callGetAvatar);
-        }
-    }
-
-    if (requestedFeatures & FeatureProtocolInfo) {
-        // the user asked for protocol info
-        // but we already know that protocol info is not supported, so
-        // fail directly
-        if (mPriv->missingFeatures & FeatureProtocolInfo) {
-            PendingReadyAccount *operation =
-                    new PendingReadyAccount(requestedFeatures, this);
-            operation->setFinishedWithError(TELEPATHY_ERROR_NOT_IMPLEMENTED,
-                    QString("ProtocolInfo not found for protocol %1 on CM %2")
-                        .arg(mPriv->protocol).arg(mPriv->cmName));
-            return operation;
-        }
-
-        if (!(mPriv->features & FeatureProtocolInfo) &&
-            !(mPriv->pendingFeatures & FeatureProtocolInfo)) {
-            mPriv->introspectQueue.enqueue(&Account::callGetProtocolInfo);
-        }
-    }
-
-    mPriv->pendingFeatures |= requestedFeatures;
-
-    QTimer::singleShot(0, this, SLOT(continueIntrospection()));
-
-    debug() << "Creating new pending operation";
-    PendingReadyAccount *operation =
-            new PendingReadyAccount(requestedFeatures, this);
-    mPriv->pendingOperations.append(operation);
-    return operation;
+    return mPriv->readinessHelper->becomeReady(requestedFeatures);
 }
 
 QStringList Account::interfaces() const
@@ -778,51 +734,60 @@ AccountInterface *Account::baseInterface() const
 }
 
 /**** Private ****/
-void Account::checkForAvatarInterface()
+void Account::Private::init()
 {
-    AccountInterfaceAvatarInterface *iface = avatarInterface();
-    if (!iface) {
-        debug() << "Avatar interface is not support for account" << objectPath();
-        // add it to missing features so we don't try to retrieve the avatar
-        mPriv->missingFeatures |= Account::FeatureAvatar;
+    if (!parent->isValid()) {
+        return;
     }
+
+    parent->connect(baseInterface,
+            SIGNAL(Removed()),
+            SLOT(onRemoved()));
+    parent->connect(baseInterface,
+            SIGNAL(AccountPropertyChanged(const QVariantMap &)),
+            SLOT(onPropertyChanged(const QVariantMap &)));
 }
 
-void Account::callGetAll()
+void Account::Private::introspectMain(Account::Private *self)
 {
+    DBus::PropertiesInterface *properties = self->parent->propertiesInterface();
+    Q_ASSERT(properties != 0);
+
     debug() << "Calling Properties::GetAll(Account)";
     QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(
-            propertiesInterface()->GetAll(
-                TELEPATHY_INTERFACE_ACCOUNT), this);
-    connect(watcher,
+            properties->GetAll(
+                TELEPATHY_INTERFACE_ACCOUNT), self->parent);
+    self->parent->connect(watcher,
             SIGNAL(finished(QDBusPendingCallWatcher *)),
-            SLOT(onGetAllAccountReturn(QDBusPendingCallWatcher *)));
+            SLOT(gotMainProperties(QDBusPendingCallWatcher *)));
 }
 
-void Account::callGetAvatar()
+void Account::Private::introspectAvatar(Account::Private *self)
 {
     debug() << "Calling GetAvatar(Account)";
     // we already checked if avatar interface exists, so bypass avatar interface
     // checking
     AccountInterfaceAvatarInterface *iface =
-        avatarInterface(BypassInterfaceCheck);
+        self->parent->avatarInterface(BypassInterfaceCheck);
 
     // If we are here it means the user cares about avatar, so
     // connect to avatar changed signal, so we update the avatar
     // when it changes.
-    connect(iface,
+    self->parent->connect(iface,
             SIGNAL(AvatarChanged()),
             SLOT(onAvatarChanged()));
 
-    retrieveAvatar();
+    self->parent->retrieveAvatar();
 }
 
-void Account::callGetProtocolInfo()
+void Account::Private::introspectProtocolInfo(Account::Private *self)
 {
-    mPriv->cm = new ConnectionManager(
-            dbusConnection(),
-            mPriv->cmName, this);
-    connect(mPriv->cm->becomeReady(),
+    Q_ASSERT(self->cm == 0);
+
+    self->cm = new ConnectionManager(
+            self->parent->dbusConnection(),
+            self->cmName, self->parent);
+    self->parent->connect(self->cm->becomeReady(),
             SIGNAL(finished(Telepathy::Client::PendingOperation *)),
             SLOT(onConnectionManagerReady(Telepathy::Client::PendingOperation *)));
 }
@@ -834,8 +799,6 @@ void Account::updateProperties(const QVariantMap &props)
     if (props.contains("Interfaces")) {
         mPriv->interfaces = qdbus_cast<QStringList>(props["Interfaces"]);
         debug() << " Interfaces:" << mPriv->interfaces;
-
-        checkForAvatarInterface();
     }
 
     if (props.contains("DisplayName") &&
@@ -982,54 +945,58 @@ void Account::retrieveAvatar()
                 "Avatar"), this);
     connect(watcher,
             SIGNAL(finished(QDBusPendingCallWatcher *)),
-            SLOT(onGetAvatarReturn(QDBusPendingCallWatcher *)));
+            SLOT(gotAvatar(QDBusPendingCallWatcher *)));
 }
 
-void Account::onGetAllAccountReturn(QDBusPendingCallWatcher *watcher)
+void Account::gotMainProperties(QDBusPendingCallWatcher *watcher)
 {
     QDBusPendingReply<QVariantMap> reply = *watcher;
 
     if (!reply.isError()) {
         debug() << "Got reply to Properties.GetAll(Account)";
         updateProperties(reply.value());
+
+        mPriv->readinessHelper->setInterfaces(mPriv->interfaces);
+
         debug() << "Account basic functionality is ready";
-        mPriv->ready = true;
+        mPriv->readinessHelper->setIntrospectCompleted(FeatureCore, true);
     } else {
+        mPriv->readinessHelper->setIntrospectCompleted(FeatureCore, false);
+
         warning().nospace() <<
             "GetAll(Account) failed: " <<
             reply.error().name() << ": " << reply.error().message();
     }
 
-    continueIntrospection();
-
     watcher->deleteLater();
 }
 
-void Account::onGetAvatarReturn(QDBusPendingCallWatcher *watcher)
+void Account::gotAvatar(QDBusPendingCallWatcher *watcher)
 {
     QDBusPendingReply<QVariant> reply = *watcher;
 
-    mPriv->pendingFeatures &= ~(Account::FeatureAvatar);
-
     if (!reply.isError()) {
-        mPriv->features |= Account::FeatureAvatar;
-
         debug() << "Got reply to GetAvatar(Account)";
         mPriv->avatar = qdbus_cast<Telepathy::Avatar>(reply);
 
+        // first time
+        if (!mPriv->readinessHelper->actualFeatures().contains(FeatureAvatar)) {
+            mPriv->readinessHelper->setIntrospectCompleted(FeatureAvatar, true);
+        }
+
         emit avatarChanged(mPriv->avatar);
     } else {
-        // add it to missing features so we don't try to retrieve the avatar
-        // again
-        mPriv->missingFeatures |= Account::FeatureAvatar;
+        // check if the feature is already there, and for some reason retrieveAvatar
+        // failed when called the second time
+        if (!mPriv->readinessHelper->missingFeatures().contains(FeatureAvatar)) {
+            mPriv->readinessHelper->setIntrospectCompleted(FeatureAvatar, false);
+        }
 
         warning().nospace() <<
             "GetAvatar(Account) failed: " <<
             reply.error().name() << ": " << reply.error().message();
     }
 
-    continueIntrospection();
-
     watcher->deleteLater();
 }
 
@@ -1053,26 +1020,12 @@ void Account::onConnectionManagerReady(PendingOperation *operation)
         error = (mPriv->protocolInfo == 0);
     }
 
-    mPriv->pendingFeatures &= ~(Account::FeatureProtocolInfo);
-
     if (!error) {
-        mPriv->features |= Account::FeatureProtocolInfo;
+        mPriv->readinessHelper->setIntrospectCompleted(FeatureProtocolInfo, true);
     }
     else {
-        mPriv->missingFeatures |= Account::FeatureProtocolInfo;
-
-        // signal all pending operations that cares about protocol info that
-        // it failed, as FeatureProtocolInfo is mandatory
-        foreach (PendingReadyAccount *operation, mPriv->pendingOperations) {
-            if (operation->requestedFeatures() & FeatureProtocolInfo) {
-                operation->setFinishedWithError(operation->errorName(),
-                        operation->errorMessage());
-                mPriv->pendingOperations.removeOne(operation);
-            }
-        }
+        mPriv->readinessHelper->setIntrospectCompleted(FeatureProtocolInfo, false);
     }
-
-    continueIntrospection();
 }
 
 void Account::onPropertyChanged(const QVariantMap &delta)
@@ -1082,7 +1035,6 @@ void Account::onPropertyChanged(const QVariantMap &delta)
 
 void Account::onRemoved()
 {
-    mPriv->ready = false;
     mPriv->valid = false;
     mPriv->enabled = false;
     // This is the closest error we have at the moment
@@ -1090,24 +1042,5 @@ void Account::onRemoved()
             QLatin1String("Account removed from AccountManager"));
 }
 
-void Account::continueIntrospection()
-{
-    if (mPriv->introspectQueue.isEmpty()) {
-        foreach (PendingReadyAccount *operation, mPriv->pendingOperations) {
-            if (mPriv->ready &&
-                ((operation->requestedFeatures() &
-                    (mPriv->features | mPriv->missingFeatures)) == operation->requestedFeatures())) {
-                operation->setFinished();
-            }
-            if (operation->isFinished()) {
-                mPriv->pendingOperations.removeOne(operation);
-            }
-        }
-    }
-    else {
-        (this->*(mPriv->introspectQueue.dequeue()))();
-    }
-}
-
 } // Telepathy::Client
 } // Telepathy
diff --git a/TelepathyQt4/Client/account.h b/TelepathyQt4/Client/account.h
index de08cbc..70ee41b 100644
--- a/TelepathyQt4/Client/account.h
+++ b/TelepathyQt4/Client/account.h
@@ -33,6 +33,7 @@
 #include <TelepathyQt4/Client/OptionalInterfaceFactory>
 #include <TelepathyQt4/Constants>
 
+#include <QSet>
 #include <QSharedPointer>
 #include <QString>
 #include <QStringList>
@@ -48,17 +49,18 @@ class AccountManager;
 class Connection;
 class PendingConnection;
 class PendingOperation;
-class PendingReadyAccount;
+class PendingReady;
 class ProtocolInfo;
 
 class Account : public StatelessDBusProxy,
                 private OptionalInterfaceFactory<Account>
 {
     Q_OBJECT
+    Q_DISABLE_COPY(Account)
 
 public:
     enum Feature {
-        /** Get the avatar data */
+        FeatureCore = 0,
         FeatureAvatar = 1,
         FeatureProtocolInfo = 2,
         _Padding = 0xFFFFFFFF
@@ -128,9 +130,9 @@ public:
 
     PendingOperation *remove();
 
-    bool isReady(Features features = 0) const;
+    bool isReady(const QSet<uint> &features = QSet<uint>()) const;
 
-    PendingReadyAccount *becomeReady(Features features = 0);
+    PendingReady *becomeReady(const QSet<uint> &requestedFeatures = QSet<uint>());
 
     QStringList interfaces() const;
 
@@ -180,21 +182,14 @@ protected:
     AccountInterface *baseInterface() const;
 
 private Q_SLOTS:
-    void onGetAllAccountReturn(QDBusPendingCallWatcher *);
-    void onGetAvatarReturn(QDBusPendingCallWatcher *);
+    void gotMainProperties(QDBusPendingCallWatcher *);
+    void gotAvatar(QDBusPendingCallWatcher *);
     void onAvatarChanged();
     void onConnectionManagerReady(Telepathy::Client::PendingOperation *);
     void onPropertyChanged(const QVariantMap &delta);
     void onRemoved();
-    void continueIntrospection();
 
 private:
-    Q_DISABLE_COPY(Account);
-
-    void checkForAvatarInterface();
-    void callGetAll();
-    void callGetAvatar();
-    void callGetProtocolInfo();
     void updateProperties(const QVariantMap &props);
     void retrieveAvatar();
 
diff --git a/examples/accounts/account-item.cpp b/examples/accounts/account-item.cpp
index 2bb46c0..995de00 100644
--- a/examples/accounts/account-item.cpp
+++ b/examples/accounts/account-item.cpp
@@ -22,7 +22,7 @@
 #include "_gen/account-item.moc.hpp"
 
 #include <TelepathyQt4/Client/AccountManager>
-#include <TelepathyQt4/Client/PendingReadyAccount>
+#include <TelepathyQt4/Client/PendingReady>
 
 #include <QDebug>
 #include <QComboBox>
diff --git a/tests/dbus/account-basics.cpp b/tests/dbus/account-basics.cpp
index 6be88ec..bd10c26 100644
--- a/tests/dbus/account-basics.cpp
+++ b/tests/dbus/account-basics.cpp
@@ -8,7 +8,6 @@
 #include <TelepathyQt4/Client/ConnectionManager>
 #include <TelepathyQt4/Client/PendingAccount>
 #include <TelepathyQt4/Client/PendingOperation>
-#include <TelepathyQt4/Client/PendingReadyAccount>
 #include <TelepathyQt4/Client/PendingReady>
 
 #include <tests/lib/test.h>
@@ -99,10 +98,12 @@ void TestAccountBasics::testBasics()
 
     QCOMPARE(acc->displayName(), QString("foobar (account 0)"));
 
-    QVERIFY(connect(acc->becomeReady(Account::FeatureAvatar),
+    QSet<uint> features = QSet<uint>() << Account::FeatureAvatar;
+    QVERIFY(connect(acc->becomeReady(features),
                     SIGNAL(finished(Telepathy::Client::PendingOperation *)),
                     SLOT(expectSuccessfulCall(Telepathy::Client::PendingOperation *))));
     QCOMPARE(mLoop->exec(), 0);
+    QCOMPARE(acc->isReady(features), true);
 
     QCOMPARE(acc->avatar().MIMEType, QString("image/png"));
 
@@ -116,10 +117,12 @@ void TestAccountBasics::testBasics()
                     SLOT(expectSuccessfulCall(Telepathy::Client::PendingOperation *))));
     QCOMPARE(mLoop->exec(), 0);
 
-    QVERIFY(connect(acc->becomeReady(Account::FeatureAvatar),
+    features = QSet<uint>() << Account::FeatureAvatar;
+    QVERIFY(connect(acc->becomeReady(features),
                     SIGNAL(finished(Telepathy::Client::PendingOperation *)),
                     SLOT(expectSuccessfulCall(Telepathy::Client::PendingOperation *))));
     QCOMPARE(mLoop->exec(), 0);
+    QCOMPARE(acc->isReady(features), true);
 
     // wait for avatarChanged signal
     QCOMPARE(mLoop->exec(), 0);
@@ -140,10 +143,12 @@ void TestAccountBasics::testBasics()
 
     acc = mAM->accountForPath(
             "/org/freedesktop/Telepathy/Account/spurious/normal/Account0");
-    QVERIFY(connect(acc->becomeReady(Account::FeatureProtocolInfo),
+    features = QSet<uint>() << Account::FeatureProtocolInfo;
+    QVERIFY(connect(acc->becomeReady(features),
                     SIGNAL(finished(Telepathy::Client::PendingOperation *)),
                     SLOT(expectSuccessfulCall(Telepathy::Client::PendingOperation *))));
     QCOMPARE(mLoop->exec(), 0);
+    QCOMPARE(acc->isReady(features), true);
 
     ProtocolInfo *protocolInfo = acc->protocolInfo();
     QCOMPARE((bool) protocolInfo, !((ProtocolInfo *) 0));
@@ -151,17 +156,21 @@ void TestAccountBasics::testBasics()
     QCOMPARE(protocolInfo->hasParameter("password"), true);
     QCOMPARE(protocolInfo->hasParameter("register"), true);
 
-    QVERIFY(connect(acc->becomeReady(Account::FeatureAvatar),
+    features = QSet<uint>() << Account::FeatureAvatar;
+    QVERIFY(connect(acc->becomeReady(features),
                     SIGNAL(finished(Telepathy::Client::PendingOperation *)),
                     SLOT(expectSuccessfulCall(Telepathy::Client::PendingOperation *))));
     QCOMPARE(mLoop->exec(), 0);
+    QCOMPARE(acc->isReady(features), true);
 
     QCOMPARE(acc->avatar().MIMEType, QString("image/png"));
 
-    QVERIFY(connect(acc->becomeReady(Account::FeatureProtocolInfo | Account::FeatureAvatar),
+    features = QSet<uint>() << Account::FeatureAvatar << Account::FeatureProtocolInfo;
+    QVERIFY(connect(acc->becomeReady(features),
                     SIGNAL(finished(Telepathy::Client::PendingOperation *)),
                     SLOT(expectSuccessfulCall(Telepathy::Client::PendingOperation *))));
     QCOMPARE(mLoop->exec(), 0);
+    QCOMPARE(acc->isReady(features), true);
 
     QCOMPARE(acc->avatar().MIMEType, QString("image/png"));
     protocolInfo = acc->protocolInfo();
-- 
1.5.6.5




More information about the telepathy-commits mailing list