diff options
author | Sjoerd Simons <sjoerd.simons@collabora.co.uk> | 2009-01-10 00:12:54 +0800 |
---|---|---|
committer | Xavier Claessens <xclaesse@src.gnome.org> | 2009-01-10 00:12:54 +0800 |
commit | b52e8ba0bf98b9d7f27b2ab2e496f0f11dc3a5be (patch) | |
tree | 0eb253af1991a899abde869862b0155da5c4643e | |
parent | 28eb54eade5e8a9a53feab5d45cf21355fae1fb9 (diff) | |
download | gsoc2013-empathy-b52e8ba0bf98b9d7f27b2ab2e496f0f11dc3a5be.tar gsoc2013-empathy-b52e8ba0bf98b9d7f27b2ab2e496f0f11dc3a5be.tar.gz gsoc2013-empathy-b52e8ba0bf98b9d7f27b2ab2e496f0f11dc3a5be.tar.bz2 gsoc2013-empathy-b52e8ba0bf98b9d7f27b2ab2e496f0f11dc3a5be.tar.lz gsoc2013-empathy-b52e8ba0bf98b9d7f27b2ab2e496f0f11dc3a5be.tar.xz gsoc2013-empathy-b52e8ba0bf98b9d7f27b2ab2e496f0f11dc3a5be.tar.zst gsoc2013-empathy-b52e8ba0bf98b9d7f27b2ab2e496f0f11dc3a5be.zip |
Wait untill the TpChat object is ready before going into pending state
Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
svn path=/trunk/; revision=2142
-rw-r--r-- | libempathy/empathy-dispatch-operation.c | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/libempathy/empathy-dispatch-operation.c b/libempathy/empathy-dispatch-operation.c index 7c3079452..d0496cb78 100644 --- a/libempathy/empathy-dispatch-operation.c +++ b/libempathy/empathy-dispatch-operation.c @@ -82,6 +82,7 @@ struct _EmpathyDispatchOperationPriv gboolean incoming; gboolean approved; gulong invalidated_handler; + gulong ready_handler; }; #define GET_PRIV(o) \ @@ -295,9 +296,18 @@ empathy_dispatch_operation_dispose (GObject *object) g_object_unref (priv->connection); + if (priv->channel_wrapper != NULL) + g_object_unref (priv->channel_wrapper); + + if (priv->ready_handler != 0) + g_signal_handler_disconnect (priv->channel_wrapper, + priv->invalidated_handler); + + g_signal_handler_disconnect (priv->channel, priv->invalidated_handler); g_object_unref (priv->channel); + if (priv->contact != NULL) g_object_unref (priv->contact); @@ -336,6 +346,23 @@ empathy_dispatch_operation_set_status (EmpathyDispatchOperation *self, } static void +empathy_dispatcher_operation_tp_chat_ready_cb (GObject *object, + GParamSpec *spec, gpointer user_data) +{ + EmpathyDispatchOperation *self = EMPATHY_DISPATCH_OPERATION (user_data); + EmpathyDispatchOperationPriv *priv = GET_PRIV (self); + + if (!empathy_tp_chat_is_ready (EMPATHY_TP_CHAT (priv->channel_wrapper))) + return; + + g_signal_handler_disconnect (priv->channel_wrapper, priv->ready_handler); + priv->ready_handler = 0; + + empathy_dispatch_operation_set_status (self, + EMPATHY_DISPATCHER_OPERATION_STATE_PENDING); +} + +static void empathy_dispatch_operation_channel_ready_cb (TpChannel *channel, const GError *error, gpointer user_data) { @@ -345,8 +372,9 @@ empathy_dispatch_operation_channel_ready_cb (TpChannel *channel, g_assert (channel == priv->channel); + /* If the channel wrapper is defined, we assume it's ready */ if (priv->channel_wrapper != NULL) - goto out; + goto ready; channel_type = tp_channel_get_channel_type_id (channel); @@ -354,11 +382,20 @@ empathy_dispatch_operation_channel_ready_cb (TpChannel *channel, { EmpathyTpChat *chat= empathy_tp_chat_new (channel); priv->channel_wrapper = G_OBJECT (chat); + + if (!empathy_tp_chat_is_ready (chat)) + { + priv->ready_handler = g_signal_connect (chat, "notify::ready", + G_CALLBACK (empathy_dispatcher_operation_tp_chat_ready_cb), self); + goto readying; + } + } else if (channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_STREAMED_MEDIA) { EmpathyTpCall *call = empathy_tp_call_new (channel); priv->channel_wrapper = G_OBJECT (call); + } else if (channel_type == EMP_IFACE_QUARK_CHANNEL_TYPE_FILE_TRANSFER) { @@ -366,9 +403,11 @@ empathy_dispatch_operation_channel_ready_cb (TpChannel *channel, priv->channel_wrapper = G_OBJECT (file); } -out: +ready: empathy_dispatch_operation_set_status (self, EMPATHY_DISPATCHER_OPERATION_STATE_PENDING); +readying: + return; } EmpathyDispatchOperation * |