[telepathy-qt4/master] Channel: Make sure connection is ready before start introspection.

Andre Moreira Magalhaes (andrunko) andre.magalhaes at collabora.co.uk
Thu May 28 14:47:02 PDT 2009


Make sure connection is ready before start introspection, as we need the
Connection object to be ready in order to access some of its methods (e.g.
Connection::selfHandle()),
---
 TelepathyQt4/channel.cpp |   29 +++++++++++++++++++++++------
 TelepathyQt4/channel.h   |    1 +
 2 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/TelepathyQt4/channel.cpp b/TelepathyQt4/channel.cpp
index 5ffa6dd..d45c0fb 100644
--- a/TelepathyQt4/channel.cpp
+++ b/TelepathyQt4/channel.cpp
@@ -69,6 +69,7 @@ struct Channel::Private
     ~Private();
 
     static void introspectMain(Private *self);
+    void introspectMainProperties();
     void introspectMainFallbackChannelType();
     void introspectMainFallbackHandle();
     void introspectMainFallbackInterfaces();
@@ -273,17 +274,27 @@ Channel::Private::~Private()
 
 void Channel::Private::introspectMain(Channel::Private *self)
 {
-    if (!self->properties) {
-        self->properties = self->parent->propertiesInterface();
-        Q_ASSERT(self->properties != 0);
+    // Make sure connection object is ready, as we need to use some methods that
+    // are only available after connection object gets ready.
+    debug() << "Calling Connection::becomeReady()";
+    self->parent->connect(self->connection->becomeReady(),
+            SIGNAL(finished(Tp::PendingOperation*)),
+            SLOT(onConnectionReady(Tp::PendingOperation*)));
+}
+
+void Channel::Private::introspectMainProperties()
+{
+    if (!properties) {
+        properties = parent->propertiesInterface();
+        Q_ASSERT(properties != 0);
     }
 
     debug() << "Calling Properties::GetAll(Channel)";
     QDBusPendingCallWatcher *watcher =
         new QDBusPendingCallWatcher(
-                self->properties->GetAll(TELEPATHY_INTERFACE_CHANNEL),
-                self->parent);
-    self->parent->connect(watcher,
+                properties->GetAll(TELEPATHY_INTERFACE_CHANNEL),
+                parent);
+    parent->connect(watcher,
             SIGNAL(finished(QDBusPendingCallWatcher*)),
             SLOT(gotMainProperties(QDBusPendingCallWatcher*)));
 }
@@ -2086,6 +2097,12 @@ void Channel::onClosed()
     invalidate(TELEPATHY_ERROR_CANCELLED, "Closed");
 }
 
+void Channel::onConnectionReady(PendingOperation *op)
+{
+    Q_UNUSED(op);
+    mPriv->introspectMainProperties();
+}
+
 void Channel::onConnectionInvalidated()
 {
     debug() << "Owning connection died leaving an orphan Channel, "
diff --git a/TelepathyQt4/channel.h b/TelepathyQt4/channel.h
index b791f91..c75285b 100644
--- a/TelepathyQt4/channel.h
+++ b/TelepathyQt4/channel.h
@@ -287,6 +287,7 @@ private Q_SLOTS:
     void gotInterfaces(QDBusPendingCallWatcher *watcher);
     void onClosed();
 
+    void onConnectionReady(Tp::PendingOperation *op);
     void onConnectionInvalidated();
     void onConnectionDestroyed();
 
-- 
1.5.6.5




More information about the telepathy-commits mailing list