[Telepathy-commits] [telepathy-qt4/master] Account: Use ReadyObject class.
Andre Moreira Magalhaes (andrunko)
andre.magalhaes at collabora.co.uk
Wed Mar 18 08:49:42 PDT 2009
---
TelepathyQt4/Client/account.cpp | 64 ++-------------------------------------
TelepathyQt4/Client/account.h | 13 ++------
2 files changed, 6 insertions(+), 71 deletions(-)
diff --git a/TelepathyQt4/Client/account.cpp b/TelepathyQt4/Client/account.cpp
index dde67de..8565edf 100644
--- a/TelepathyQt4/Client/account.cpp
+++ b/TelepathyQt4/Client/account.cpp
@@ -108,6 +108,7 @@ Account::Private::Private(Account *parent, AccountManager *am)
am(am),
baseInterface(new AccountInterface(parent->dbusConnection(),
parent->busName(), parent->objectPath(), parent)),
+ readinessHelper(parent->readinessHelper()),
valid(false),
enabled(false),
connectsAutomatically(false),
@@ -172,8 +173,7 @@ Account::Private::Private(Account *parent, AccountManager *am)
this);
introspectables[FeatureProtocolInfo] = introspectableProtocolInfo;
- readinessHelper = new ReadinessHelper(parent, 0 /* status */,
- introspectables, parent);
+ readinessHelper->addIntrospectables(introspectables);
readinessHelper->becomeReady(Features() << FeatureCore);
init();
@@ -211,6 +211,7 @@ Account::Account(AccountManager *am, const QString &objectPath,
: StatelessDBusProxy(am->dbusConnection(),
am->busName(), objectPath, parent),
OptionalInterfaceFactory<Account>(this),
+ ReadyObject(this, FeatureCore),
mPriv(new Private(this, am))
{
}
@@ -644,60 +645,6 @@ PendingOperation *Account::remove()
return new PendingVoidMethodCall(this, baseInterface()->Remove());
}
-/**
- * Return whether this object has finished its initial setup.
- *
- * This is mostly useful as a sanity check, in code that shouldn't be run
- * until the object is ready. To wait for the object to be ready, call
- * becomeReady() and connect to the finished signal on the result.
- *
- * \param features The features which should be tested
- * \return \c true if the object has finished its initial setup for basic
- * functionality plus the given features
- */
-bool Account::isReady(const Features &features) const
-{
- if (features.isEmpty()) {
- return mPriv->readinessHelper->isReady(Features() << FeatureCore);
- }
- return mPriv->readinessHelper->isReady(features);
-}
-
-/**
- * Return a pending ready account which will succeed when this object finishes
- * 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 PendingReady object which will emit finished
- * when this object has finished or failed its initial setup.
- */
-PendingReady *Account::becomeReady(const Features &requestedFeatures)
-{
- if (requestedFeatures.isEmpty()) {
- return mPriv->readinessHelper->becomeReady(Features() << FeatureCore);
- }
- return mPriv->readinessHelper->becomeReady(requestedFeatures);
-}
-
-Features Account::requestedFeatures() const
-{
- return mPriv->readinessHelper->requestedFeatures();
-}
-
-Features Account::actualFeatures() const
-{
- return mPriv->readinessHelper->actualFeatures();
-}
-
-Features Account::missingFeatures() const
-{
- return mPriv->readinessHelper->missingFeatures();
-}
-
QStringList Account::interfaces() const
{
return mPriv->interfaces;
@@ -760,11 +707,6 @@ AccountInterface *Account::baseInterface() const
return mPriv->baseInterface;
}
-ReadinessHelper *Account::readinessHelper() const
-{
- return mPriv->readinessHelper;
-}
-
/**** Private ****/
void Account::Private::init()
{
diff --git a/TelepathyQt4/Client/account.h b/TelepathyQt4/Client/account.h
index d38ec83..302cc44 100644
--- a/TelepathyQt4/Client/account.h
+++ b/TelepathyQt4/Client/account.h
@@ -32,6 +32,7 @@
#include <TelepathyQt4/Client/DBusProxy>
#include <TelepathyQt4/Client/OptionalInterfaceFactory>
#include <TelepathyQt4/Client/ReadinessHelper>
+#include <TelepathyQt4/Client/ReadyObject>
#include <TelepathyQt4/Constants>
#include <QSet>
@@ -54,7 +55,8 @@ class PendingReady;
class ProtocolInfo;
class Account : public StatelessDBusProxy,
- private OptionalInterfaceFactory<Account>
+ private OptionalInterfaceFactory<Account>,
+ public ReadyObject
{
Q_OBJECT
Q_DISABLE_COPY(Account)
@@ -127,13 +129,6 @@ public:
PendingOperation *remove();
- virtual bool isReady(const Features &features = Features()) const;
- virtual PendingReady *becomeReady(const Features &requestedFeatures = Features());
-
- virtual Features requestedFeatures() const;
- virtual Features actualFeatures() const;
- virtual Features missingFeatures() const;
-
QStringList interfaces() const;
template <class Interface>
@@ -181,8 +176,6 @@ Q_SIGNALS:
protected:
AccountInterface *baseInterface() const;
- ReadinessHelper *readinessHelper() const;
-
private Q_SLOTS:
void gotMainProperties(QDBusPendingCallWatcher *);
void gotAvatar(QDBusPendingCallWatcher *);
--
1.5.6.5
More information about the telepathy-commits
mailing list