aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSjoerd Simons <sjoerd.simons@collabora.co.uk>2011-03-23 21:09:09 +0800
committerSjoerd Simons <sjoerd.simons@collabora.co.uk>2011-03-23 23:12:07 +0800
commite3849f0476977eac243b5baafd10b3075f1ceee1 (patch)
treef4ce9ddf53ff309fc3903f89a77e2849104f1036
parentbf7d9036e61d2006c93a434b15e0896c2282fbdb (diff)
downloadgsoc2013-empathy-e3849f0476977eac243b5baafd10b3075f1ceee1.tar
gsoc2013-empathy-e3849f0476977eac243b5baafd10b3075f1ceee1.tar.gz
gsoc2013-empathy-e3849f0476977eac243b5baafd10b3075f1ceee1.tar.bz2
gsoc2013-empathy-e3849f0476977eac243b5baafd10b3075f1ceee1.tar.lz
gsoc2013-empathy-e3849f0476977eac243b5baafd10b3075f1ceee1.tar.xz
gsoc2013-empathy-e3849f0476977eac243b5baafd10b3075f1ceee1.tar.zst
gsoc2013-empathy-e3849f0476977eac243b5baafd10b3075f1ceee1.zip
Wait for the channel to be ready before handling it
-rw-r--r--src/empathy-call-factory.c51
1 files changed, 43 insertions, 8 deletions
diff --git a/src/empathy-call-factory.c b/src/empathy-call-factory.c
index 48b711b89..5d14ad52d 100644
--- a/src/empathy-call-factory.c
+++ b/src/empathy-call-factory.c
@@ -285,6 +285,39 @@ call_channel_got_contact (TpConnection *connection,
g_object_unref (handler);
}
+static void
+call_channel_ready (EmpathyCallFactory *factory,
+ TpyCallChannel *call)
+{
+ TpChannel *channel = TP_CHANNEL (call);
+ const gchar *id;
+
+ id = tp_channel_get_identifier (channel);
+
+ /* The ready callback has a reference, so pass that on */
+ empathy_tp_contact_factory_get_from_id (
+ tp_channel_borrow_connection (channel),
+ id,
+ call_channel_got_contact,
+ channel,
+ g_object_unref,
+ (GObject *) factory);
+}
+
+static void
+call_channel_ready_cb (TpyCallChannel *call,
+ GParamSpec *spec,
+ EmpathyCallFactory *factory)
+{
+ gboolean ready;
+
+ g_object_get (call, "ready", &ready, NULL);
+ if (!ready)
+ return;
+
+ call_channel_ready (factory, call);
+}
+
static void
handle_channels_cb (TpSimpleHandler *handler,
@@ -303,7 +336,7 @@ handle_channels_cb (TpSimpleHandler *handler,
{
TpChannel *channel = l->data;
TpyCallChannel *call;
- const gchar *id;
+ gboolean ready;
if (tp_proxy_get_invalidated (channel) != NULL)
continue;
@@ -317,13 +350,15 @@ handle_channels_cb (TpSimpleHandler *handler,
call = TPY_CALL_CHANNEL (channel);
- id = tp_channel_get_identifier (channel);
- empathy_tp_contact_factory_get_from_id (connection,
- id,
- call_channel_got_contact,
- g_object_ref (channel),
- g_object_unref,
- (GObject *) self);
+ /* Take a ref to keep while hopping through the async callbacks */
+ g_object_ref (call);
+ g_object_get (call, "ready", &ready, NULL);
+
+ if (!ready)
+ tp_g_signal_connect_object (call, "notify::ready",
+ G_CALLBACK (call_channel_ready_cb), self, 0);
+ else
+ call_channel_ready (self, call);
}
tp_handle_channels_context_accept (context);