]> git.0d.be Git - empathy.git/commitdiff
Wait for the connection to be ready before requesting contacts from it.
authorJonny Lamb <jonny.lamb@collabora.co.uk>
Tue, 25 Aug 2009 10:40:16 +0000 (11:40 +0100)
committerSjoerd Simons <sjoerd.simons@collabora.co.uk>
Tue, 25 Aug 2009 11:03:49 +0000 (12:03 +0100)
Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
libempathy/empathy-dispatch-operation.c

index 79fe8c62d08723da54cf3633f9c180c66f341718..d7afcbea6f88b3e0dc1bf9f5b24ace626d2a25bd 100644 (file)
@@ -200,6 +200,26 @@ dispatcher_operation_got_contact_cb (EmpathyTpContactFactory *factory,
     empathy_dispatch_operation_channel_ready_cb, self);
 }
 
+static void
+dispatch_operation_connection_ready (TpConnection *connection,
+    const GError *error,
+    gpointer user_data)
+{
+  EmpathyDispatchOperation *self = EMPATHY_DISPATCH_OPERATION (user_data);
+  EmpathyDispatchOperationPriv *priv = GET_PRIV (self);
+  EmpathyTpContactFactory *factory;
+  TpHandle handle;
+
+  handle = tp_channel_get_handle (priv->channel, NULL);
+
+  factory = empathy_tp_contact_factory_dup_singleton (priv->connection);
+
+  empathy_tp_contact_factory_get_from_handle (factory, handle,
+      dispatcher_operation_got_contact_cb, NULL, NULL, G_OBJECT (self));
+
+  g_object_unref (factory);
+}
+
 static void
 empathy_dispatch_operation_constructed (GObject *object)
 {
@@ -219,12 +239,8 @@ empathy_dispatch_operation_constructed (GObject *object)
 
   if (handle_type == TP_HANDLE_TYPE_CONTACT && priv->contact == NULL)
     {
-      EmpathyTpContactFactory *factory;
-
-      factory = empathy_tp_contact_factory_dup_singleton (priv->connection);
-      empathy_tp_contact_factory_get_from_handle (factory, handle,
-       dispatcher_operation_got_contact_cb, NULL, NULL, object);
-      g_object_unref (factory);
+      tp_connection_call_when_ready (priv->connection,
+          dispatch_operation_connection_ready, object);
       return;
     }