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

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


P.s: Tests broken (will be fixed in a later patch)
---
 TelepathyQt4/Client/channel.cpp |   48 +++++++++++++++++---------------------
 TelepathyQt4/Client/channel.h   |    3 +-
 2 files changed, 24 insertions(+), 27 deletions(-)

diff --git a/TelepathyQt4/Client/channel.cpp b/TelepathyQt4/Client/channel.cpp
index 46ae4f2..37f48a6 100644
--- a/TelepathyQt4/Client/channel.cpp
+++ b/TelepathyQt4/Client/channel.cpp
@@ -31,6 +31,7 @@
 #include <TelepathyQt4/Client/PendingContacts>
 #include <TelepathyQt4/Client/PendingFailure>
 #include <TelepathyQt4/Client/PendingOperation>
+#include <TelepathyQt4/Client/PendingReadyChannel>
 #include <TelepathyQt4/Client/PendingSuccess>
 #include <TelepathyQt4/Client/ReferencedHandles>
 #include <TelepathyQt4/Constants>
@@ -93,7 +94,6 @@ struct Channel::Private
     bool fakeGroupInterfaceIfNeeded();
     void setReady();
 
-    class PendingReady;
     struct GroupMembersChangedInfo;
 
     // Public object
@@ -109,8 +109,8 @@ struct Channel::Private
     ChannelInterfaceGroupInterface *group;
     DBus::PropertiesInterface *properties;
 
-    PendingReady *pendingReady;
     bool ready;
+    PendingReadyChannel *pendingReady;
 
     // Introspection
     QStringList interfaces;
@@ -200,20 +200,6 @@ struct Channel::Private::GroupMembersChangedInfo
     QString message;
 };
 
-class Channel::Private::PendingReady : public PendingOperation
-{
-    // Channel is a friend so it can call finished() etc.
-    friend class Channel;
-
-public:
-    PendingReady(Channel *parent);
-};
-
-Channel::Private::PendingReady::PendingReady(Channel *parent)
-    : PendingOperation(parent)
-{
-}
-
 Channel::Private::Private(Channel *parent, Connection *connection)
     : parent(parent),
       baseInterface(new ChannelInterface(parent->dbusConnection(),
@@ -221,8 +207,8 @@ Channel::Private::Private(Channel *parent, Connection *connection)
       connection(connection),
       group(0),
       properties(0),
-      pendingReady(0),
       ready(false),
+      pendingReady(0),
       features(0),
       targetHandleType(0),
       targetHandle(0),
@@ -1136,27 +1122,37 @@ bool Channel::isReady(Features features) const
  * initial setup.
  *
  * \param features Which features should be tested.
- * \return A PendingOperation which will emit PendingOperation::finished
+ * \return A PendingReadyChannel object which will emit finished
  *         when this object has finished or failed its initial setup.
  */
-PendingOperation *Channel::becomeReady(Features features)
+PendingReadyChannel *Channel::becomeReady(Features requestedFeatures)
 {
     if (!isValid()) {
-        return new PendingFailure(this, TELEPATHY_ERROR_NOT_AVAILABLE,
+        PendingReadyChannel *operation =
+            new PendingReadyChannel(requestedFeatures, this);
+        operation->setFinishedWithError(TELEPATHY_ERROR_NOT_AVAILABLE,
                 "Channel is invalid");
+        return operation;
     }
 
-    if (isReady(features)) {
-        return new PendingSuccess(this);
+    if (isReady(requestedFeatures)) {
+        PendingReadyChannel *operation =
+            new PendingReadyChannel(requestedFeatures, this);
+        operation->setFinished();
+        return operation;
     }
 
-    if (features != 0) {
-        return new PendingFailure(this, TELEPATHY_ERROR_NOT_IMPLEMENTED,
-                "Unimplemented");
+    if (requestedFeatures != 0) {
+        PendingReadyChannel *operation =
+            new PendingReadyChannel(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 PendingReadyChannel(requestedFeatures, this);
     }
     return mPriv->pendingReady;
 }
diff --git a/TelepathyQt4/Client/channel.h b/TelepathyQt4/Client/channel.h
index d1738de..4349706 100644
--- a/TelepathyQt4/Client/channel.h
+++ b/TelepathyQt4/Client/channel.h
@@ -47,6 +47,7 @@ namespace Client
 
 class Connection;
 class PendingOperation;
+class PendingReadyChannel;
 
 class Channel : public StatefulDBusProxy,
                 private OptionalInterfaceFactory<Channel>
@@ -78,7 +79,7 @@ public:
     QSharedPointer<Contact> initiatorContact() const;
 
     bool isReady(Features features = 0) const;
-    PendingOperation *becomeReady(Features features = 0);
+    PendingReadyChannel *becomeReady(Features features = 0);
 
     PendingOperation *requestClose();
 
-- 
1.5.6.5




More information about the telepathy-commits mailing list