[Telepathy-commits] [telepathy-qt4/master] Channel: Use ReadyObject class.

Andre Moreira Magalhaes (andrunko) andre.magalhaes at collabora.co.uk
Wed Mar 18 08:49:52 PDT 2009


---
 TelepathyQt4/Client/channel.cpp |   65 ++-------------------------------------
 TelepathyQt4/Client/channel.h   |   13 ++------
 2 files changed, 6 insertions(+), 72 deletions(-)

diff --git a/TelepathyQt4/Client/channel.cpp b/TelepathyQt4/Client/channel.cpp
index 8f5bdf4..0e9466a 100644
--- a/TelepathyQt4/Client/channel.cpp
+++ b/TelepathyQt4/Client/channel.cpp
@@ -204,6 +204,7 @@ Channel::Private::Private(Channel *parent, Connection *connection)
       connection(connection),
       group(0),
       properties(0),
+      readinessHelper(parent->readinessHelper()),
       targetHandleType(0),
       targetHandle(0),
       requested(false),
@@ -254,8 +255,7 @@ Channel::Private::Private(Channel *parent, Connection *connection)
         this);
     introspectables[FeatureCore] = introspectableCore;
 
-    readinessHelper = new ReadinessHelper(parent, 0 /* status */,
-            introspectables, parent);
+    readinessHelper->addIntrospectables(introspectables);
     readinessHelper->becomeReady(Features() << FeatureCore);
 }
 
@@ -969,6 +969,7 @@ Channel::Channel(Connection *connection,
     : StatefulDBusProxy(connection->dbusConnection(), connection->busName(),
             objectPath, parent),
       OptionalInterfaceFactory<Channel>(this),
+      ReadyObject(this, FeatureCore),
       mPriv(new Private(this, connection))
 {
     // FIXME: remember the immutableProperties, and use them to reduce the
@@ -1100,61 +1101,6 @@ QSharedPointer<Contact> Channel::initiatorContact() const
 }
 
 /**
- * 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 Channel::isReady(const Features &features) const
-{
-    if (features.isEmpty()) {
-        return mPriv->readinessHelper->isReady(Features() << FeatureCore);
-    }
-    return mPriv->readinessHelper->isReady(features);
-}
-
-/**
- * Return a pending operation 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 initial setup for basic
- *         functionality plus the given features
- */
-PendingReady *Channel::becomeReady(const Features &requestedFeatures)
-{
-    if (requestedFeatures.isEmpty()) {
-        return mPriv->readinessHelper->becomeReady(Features() << FeatureCore);
-    }
-    return mPriv->readinessHelper->becomeReady(requestedFeatures);
-}
-
-Features Channel::requestedFeatures() const
-{
-    return mPriv->readinessHelper->requestedFeatures();
-}
-
-Features Channel::actualFeatures() const
-{
-    return mPriv->readinessHelper->actualFeatures();
-}
-
-Features Channel::missingFeatures() const
-{
-    return mPriv->readinessHelper->missingFeatures();
-}
-
-/**
  * Start an asynchronous request that the channel be closed.
  * The returned PendingOperation object will signal the success or failure
  * of this request; under normal circumstances, it can be expected to
@@ -1836,11 +1782,6 @@ void Channel::gotMainProperties(QDBusPendingCallWatcher *watcher)
     continueIntrospection();
 }
 
-ReadinessHelper *Channel::readinessHelper() const
-{
-    return mPriv->readinessHelper;
-}
-
 void Channel::gotChannelType(QDBusPendingCallWatcher *watcher)
 {
     QDBusPendingReply<QString> reply = *watcher;
diff --git a/TelepathyQt4/Client/channel.h b/TelepathyQt4/Client/channel.h
index ee3dc7a..22f7276 100644
--- a/TelepathyQt4/Client/channel.h
+++ b/TelepathyQt4/Client/channel.h
@@ -34,6 +34,7 @@
 #include <TelepathyQt4/Client/DBusProxy>
 #include <TelepathyQt4/Client/OptionalInterfaceFactory>
 #include <TelepathyQt4/Client/ReadinessHelper>
+#include <TelepathyQt4/Client/ReadyObject>
 
 #include <QSet>
 #include <QSharedPointer>
@@ -51,7 +52,8 @@ class PendingOperation;
 class PendingReady;
 
 class Channel : public StatefulDBusProxy,
-                private OptionalInterfaceFactory<Channel>
+                private OptionalInterfaceFactory<Channel>,
+                public ReadyObject
 {
     Q_OBJECT
     Q_DISABLE_COPY(Channel)
@@ -76,13 +78,6 @@ public:
     bool isRequested() const;
     QSharedPointer<Contact> initiatorContact() const;
 
-    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;
-
     PendingOperation *requestClose();
 
     uint groupFlags() const;
@@ -271,8 +266,6 @@ protected:
         return optionalInterface<ChannelInterfaceGroupInterface>(check);
     }
 
-    ReadinessHelper *readinessHelper() const;
-
 private Q_SLOTS:
     void gotMainProperties(QDBusPendingCallWatcher *watcher);
     void gotChannelType(QDBusPendingCallWatcher *watcher);
-- 
1.5.6.5




More information about the telepathy-commits mailing list