aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2009-11-05 02:47:17 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2009-11-09 19:02:18 +0800
commitd2d8c7d06ac924b2b4113b46cda916bbf2fb7b98 (patch)
tree07a92b75963361a01807a3f29f029c34a88d6dd4 /libempathy
parent6aafcb1c58ef0f8a5407cce2820d8bc30effc5b7 (diff)
downloadgsoc2013-empathy-d2d8c7d06ac924b2b4113b46cda916bbf2fb7b98.tar
gsoc2013-empathy-d2d8c7d06ac924b2b4113b46cda916bbf2fb7b98.tar.gz
gsoc2013-empathy-d2d8c7d06ac924b2b4113b46cda916bbf2fb7b98.tar.bz2
gsoc2013-empathy-d2d8c7d06ac924b2b4113b46cda916bbf2fb7b98.tar.lz
gsoc2013-empathy-d2d8c7d06ac924b2b4113b46cda916bbf2fb7b98.tar.xz
gsoc2013-empathy-d2d8c7d06ac924b2b4113b46cda916bbf2fb7b98.tar.zst
gsoc2013-empathy-d2d8c7d06ac924b2b4113b46cda916bbf2fb7b98.zip
dispatcher_init_connection_if_needed: wait that the connection is ready before using it (#600713)
Diffstat (limited to 'libempathy')
-rw-r--r--libempathy/empathy-dispatcher.c43
1 files changed, 32 insertions, 11 deletions
diff --git a/libempathy/empathy-dispatcher.c b/libempathy/empathy-dispatcher.c
index 40045cdb1..abc95108d 100644
--- a/libempathy/empathy-dispatcher.c
+++ b/libempathy/empathy-dispatcher.c
@@ -837,23 +837,21 @@ dispatcher_connection_advertise_capabilities_cb (TpConnection *connection,
}
static void
-dispatcher_init_connection_if_needed (EmpathyDispatcher *self,
- TpConnection *connection)
+connection_ready_cb (TpConnection *connection,
+ const GError *error,
+ gpointer user_data)
{
- EmpathyDispatcherPriv *priv = GET_PRIV (self);
+ EmpathyDispatcher *self = EMPATHY_DISPATCHER (user_data);
GPtrArray *capabilities;
GType cap_type;
GValue cap = {0, };
const gchar *remove_ = NULL;
- if (g_hash_table_lookup (priv->connections, connection) != NULL)
- return;
-
- g_hash_table_insert (priv->connections, g_object_ref (connection),
- new_connection_data ());
-
- g_signal_connect (connection, "invalidated",
- G_CALLBACK (dispatcher_connection_invalidated_cb), self);
+ if (error != NULL)
+ {
+ DEBUG ("Error: %s", error->message);
+ goto out;
+ }
if (tp_proxy_has_interface_by_id (TP_PROXY (connection),
TP_IFACE_QUARK_CONNECTION_INTERFACE_REQUESTS))
@@ -887,6 +885,29 @@ dispatcher_init_connection_if_needed (EmpathyDispatcher *self,
g_value_unset (&cap);
g_ptr_array_free (capabilities, TRUE);
+out:
+ g_object_unref (self);
+}
+
+static void
+dispatcher_init_connection_if_needed (EmpathyDispatcher *self,
+ TpConnection *connection)
+{
+ EmpathyDispatcherPriv *priv = GET_PRIV (self);
+
+ if (g_hash_table_lookup (priv->connections, connection) != NULL)
+ return;
+
+ g_hash_table_insert (priv->connections, g_object_ref (connection),
+ new_connection_data ());
+
+ g_signal_connect (connection, "invalidated",
+ G_CALLBACK (dispatcher_connection_invalidated_cb), self);
+
+ /* Ensure to keep the self object alive while the call_when_ready is
+ * running */
+ g_object_ref (self);
+ tp_connection_call_when_ready (connection, connection_ready_cb, self);
}
static void