[telepathy-qt4/master] PendingChannelRequest: Finish with error immediatelly after retrieved CR if cancel was called previously.

Andre Moreira Magalhaes (andrunko) andre.magalhaes at collabora.co.uk
Thu Jun 11 10:05:02 PDT 2009


---
 TelepathyQt4/pending-channel-request.cpp |   28 +++++++++++++++-------------
 1 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/TelepathyQt4/pending-channel-request.cpp b/TelepathyQt4/pending-channel-request.cpp
index d60ca63..ea321a9 100644
--- a/TelepathyQt4/pending-channel-request.cpp
+++ b/TelepathyQt4/pending-channel-request.cpp
@@ -171,22 +171,24 @@ void PendingChannelRequest::onWatcherFinished(QDBusPendingCallWatcher *watcher)
         mPriv->channelRequest = ChannelRequest::create(mPriv->dbusConnection,
                 objectPath.path(), QVariantMap());
 
-        connect(mPriv->channelRequest.data(),
-                SIGNAL(failed(const QString &, const QString &)),
-                SLOT(onChannelRequestFailed(const QString &, const QString &)));
-        connect(mPriv->channelRequest.data(),
-                SIGNAL(succeeded()),
-                SLOT(onChannelRequestSucceeded()));
-
-        connect(mPriv->channelRequest->proceed(),
-                SIGNAL(finished(Tp::PendingOperation*)),
-                SLOT(onProceedOperationFinished(Tp::PendingOperation*)));
-
         if (mPriv->cancelOperation) {
             mPriv->cancelOperation->proceed(mPriv->channelRequest);
+            setFinishedWithError(TELEPATHY_ERROR_CANCELLED,
+                    "ChannelRequest cancelled");
+        } else {
+            connect(mPriv->channelRequest.data(),
+                    SIGNAL(failed(const QString &, const QString &)),
+                    SLOT(onChannelRequestFailed(const QString &, const QString &)));
+            connect(mPriv->channelRequest.data(),
+                    SIGNAL(succeeded()),
+                    SLOT(onChannelRequestSucceeded()));
+
+            connect(mPriv->channelRequest->proceed(),
+                    SIGNAL(finished(Tp::PendingOperation*)),
+                    SLOT(onProceedOperationFinished(Tp::PendingOperation*)));
+
+            emit channelRequestCreated(mPriv->channelRequest);
         }
-
-        emit channelRequestCreated(mPriv->channelRequest);
     } else {
         debug().nospace() << "Ensure/CreateChannel failed:" <<
             reply.error().name() << ": " << reply.error().message();
-- 
1.5.6.5




More information about the telepathy-commits mailing list