telepathy-qt: dbus-tubes: Rather than relying on a tube state change, use invalidated() to detect errors correctly.

Dario Freddi drf at kemper.freedesktop.org
Tue Jul 3 15:08:40 PDT 2012


Module: telepathy-qt
Branch: master
Commit: f26ef38d1f6e8f7e151993aabc74c7131cfc64ff
URL:    http://cgit.freedesktop.org/telepathy/telepathy-qt/commit/?id=f26ef38d1f6e8f7e151993aabc74c7131cfc64ff

Author: Dario Freddi <dario.freddi at collabora.co.uk>
Date:   Thu Jun  9 16:46:59 2011 +0200

dbus-tubes: Rather than relying on a tube state change, use invalidated() to detect errors correctly.

---

 TelepathyQt/pending-dbus-tube.cpp |   15 +++++++++++----
 TelepathyQt/pending-dbus-tube.h   |    3 +++
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/TelepathyQt/pending-dbus-tube.cpp b/TelepathyQt/pending-dbus-tube.cpp
index 755ab8b..7ab56b6 100644
--- a/TelepathyQt/pending-dbus-tube.cpp
+++ b/TelepathyQt/pending-dbus-tube.cpp
@@ -87,6 +87,9 @@ PendingDBusTube::PendingDBusTube(
 {
     mPriv->tube = object;
 
+    connect(mPriv->tube.data(), SIGNAL(invalidated(Tp::DBusProxy*,QString,QString)),
+            this, SLOT(onChannelInvalidated(Tp::DBusProxy*,QString,QString)));
+
     if (string->isFinished()) {
         onConnectionFinished(string);
     } else {
@@ -158,11 +161,15 @@ void PendingDBusTube::onStateChanged(TubeChannelState state)
     if (state == TubeChannelStateOpen) {
         // The tube is ready: mark the operation as finished
         setFinished();
-    } else if (state != TubeChannelStateLocalPending) {
-        // Something happened
-        setFinishedWithError(QLatin1String("Connection refused"),
-                QLatin1String("The connection to this tube was refused"));
     }
 }
 
+void PendingDBusTube::onChannelInvalidated(DBusProxy* proxy,
+        const QString& errorName, const QString& errorMessage)
+{
+    Q_UNUSED(proxy);
+
+    setFinishedWithError(errorName, errorMessage);
+}
+
 }
diff --git a/TelepathyQt/pending-dbus-tube.h b/TelepathyQt/pending-dbus-tube.h
index 9a77197..b4301a4 100644
--- a/TelepathyQt/pending-dbus-tube.h
+++ b/TelepathyQt/pending-dbus-tube.h
@@ -45,6 +45,9 @@ public:
 private Q_SLOTS:
     TP_QT_NO_EXPORT void onConnectionFinished(Tp::PendingOperation *op);
     TP_QT_NO_EXPORT void onStateChanged(Tp::TubeChannelState state);
+    TP_QT_NO_EXPORT void onChannelInvalidated(Tp::DBusProxy *proxy,
+                                        const QString &errorName,
+                                        const QString &errorMessage);
 
 private:
     PendingDBusTube(PendingString *string, const OutgoingDBusTubeChannelPtr &object);



More information about the telepathy-commits mailing list