[telepathy-qt4/master] PendingChannelRequest: Call ChannelRequest::proceed if we are done and not cancelled.

Andre Moreira Magalhaes (andrunko) andre.magalhaes at collabora.co.uk
Thu Jun 11 08:32:46 PDT 2009


---
 TelepathyQt4/pending-channel-request.cpp |   22 +++++++++++++++++++++-
 TelepathyQt4/pending-channel-request.h   |    1 +
 2 files changed, 22 insertions(+), 1 deletions(-)

diff --git a/TelepathyQt4/pending-channel-request.cpp b/TelepathyQt4/pending-channel-request.cpp
index 983fd7d..6e26c7e 100644
--- a/TelepathyQt4/pending-channel-request.cpp
+++ b/TelepathyQt4/pending-channel-request.cpp
@@ -48,12 +48,14 @@ namespace Tp
 struct PendingChannelRequest::Private
 {
     Private(const QDBusConnection &dbusConnection)
-        : dbusConnection(dbusConnection)
+        : dbusConnection(dbusConnection),
+          channelRequestFinished(false)
     {
     }
 
     QDBusConnection dbusConnection;
     ChannelRequestPtr channelRequest;
+    bool channelRequestFinished;
 };
 
 /**
@@ -127,6 +129,12 @@ PendingChannelRequest::PendingChannelRequest(const QDBusConnection &dbusConnecti
  */
 PendingChannelRequest::~PendingChannelRequest()
 {
+    // let's call proceed now, as the channel request was not canceled neither
+    // succeeded yet.
+    if (!mPriv->channelRequestFinished && isFinished() && isValid()) {
+        mPriv->channelRequest->proceed();
+    }
+
     delete mPriv;
 }
 
@@ -177,6 +185,13 @@ void PendingChannelRequest::onWatcherFinished(QDBusPendingCallWatcher *watcher)
         connect(mPriv->channelRequest->becomeReady(),
                 SIGNAL(finished(Tp::PendingOperation*)),
                 SLOT(onChannelRequestReady(Tp::PendingOperation*)));
+
+        connect(mPriv->channelRequest.data(),
+                SIGNAL(failed(const QString &, const QString &)),
+                SLOT(onChannelRequestFinished()));
+        connect(mPriv->channelRequest.data(),
+                SIGNAL(succeeded()),
+                SLOT(onChannelRequestFinished()));
     } else {
         debug().nospace() << "Ensure/CreateChannel failed:" <<
             reply.error().name() << ": " << reply.error().message();
@@ -198,4 +213,9 @@ void PendingChannelRequest::onChannelRequestReady(PendingOperation *op)
     setFinished();
 }
 
+void PendingChannelRequest::onChannelRequestFinished()
+{
+    mPriv->channelRequestFinished = true;
+}
+
 } // Tp
diff --git a/TelepathyQt4/pending-channel-request.h b/TelepathyQt4/pending-channel-request.h
index 60aff18..097648f 100644
--- a/TelepathyQt4/pending-channel-request.h
+++ b/TelepathyQt4/pending-channel-request.h
@@ -55,6 +55,7 @@ public:
 private Q_SLOTS:
     void onWatcherFinished(QDBusPendingCallWatcher *watcher);
     void onChannelRequestReady(Tp::PendingOperation *op);
+    void onChannelRequestFinished();
 
 private:
     friend class Account;
-- 
1.5.6.5




More information about the telepathy-commits mailing list