diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2009-12-07 23:40:18 +0800 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2009-12-08 01:34:54 +0800 |
commit | ce76a397628746402c494ee8aec6e14a7d8322c7 (patch) | |
tree | f71757e18c44a7b214a2f89bc5cf7003858f5618 /libempathy-gtk | |
parent | 3f3d218978d49b77f18464977f3b92c5d644bc1b (diff) | |
download | gsoc2013-empathy-ce76a397628746402c494ee8aec6e14a7d8322c7.tar gsoc2013-empathy-ce76a397628746402c494ee8aec6e14a7d8322c7.tar.gz gsoc2013-empathy-ce76a397628746402c494ee8aec6e14a7d8322c7.tar.bz2 gsoc2013-empathy-ce76a397628746402c494ee8aec6e14a7d8322c7.tar.lz gsoc2013-empathy-ce76a397628746402c494ee8aec6e14a7d8322c7.tar.xz gsoc2013-empathy-ce76a397628746402c494ee8aec6e14a7d8322c7.tar.zst gsoc2013-empathy-ce76a397628746402c494ee8aec6e14a7d8322c7.zip |
chat: wait that connection is ready before re-requesting the channel (#603976)
Diffstat (limited to 'libempathy-gtk')
-rw-r--r-- | libempathy-gtk/empathy-chat.c | 67 |
1 files changed, 44 insertions, 23 deletions
diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c index 611f2eb56..c66f92d05 100644 --- a/libempathy-gtk/empathy-chat.c +++ b/libempathy-gtk/empathy-chat.c @@ -206,6 +206,43 @@ chat_connect_channel_reconnected (EmpathyDispatchOperation *dispatch, } static void +reconnected_connection_ready_cb (TpConnection *connection, + const GError *error, + gpointer user_data) +{ + EmpathyChat *chat = EMPATHY_CHAT (user_data); + EmpathyChatPriv *priv = GET_PRIV (chat); + + if (error != NULL) { + DEBUG ("connection is not ready: %s", error->message); + goto out; + } + + DEBUG ("Account reconnected, request a new Text channel"); + + switch (priv->handle_type) { + case TP_HANDLE_TYPE_CONTACT: + empathy_dispatcher_chat_with_contact_id ( + connection, priv->id, + chat_connect_channel_reconnected, + chat); + break; + case TP_HANDLE_TYPE_ROOM: + empathy_dispatcher_join_muc (connection, + priv->id, + chat_connect_channel_reconnected, + chat); + break; + default: + g_assert_not_reached (); + break; + } + +out: + g_object_unref (chat); +} + +static void chat_new_connection_cb (TpAccount *account, guint old_status, guint new_status, @@ -222,30 +259,14 @@ chat_new_connection_cb (TpAccount *account, connection = tp_account_get_connection (account); - if (!priv->tp_chat && account == priv->account && - priv->handle_type != TP_HANDLE_TYPE_NONE && - !EMP_STR_EMPTY (priv->id)) { - - DEBUG ("Account reconnected, request a new Text channel"); + if (priv->tp_chat != NULL || account != priv->account || + priv->handle_type == TP_HANDLE_TYPE_NONE || + EMP_STR_EMPTY (priv->id)) + return; - switch (priv->handle_type) { - case TP_HANDLE_TYPE_CONTACT: - empathy_dispatcher_chat_with_contact_id ( - connection, priv->id, - chat_connect_channel_reconnected, - chat); - break; - case TP_HANDLE_TYPE_ROOM: - empathy_dispatcher_join_muc (connection, - priv->id, - chat_connect_channel_reconnected, - chat); - break; - default: - g_assert_not_reached (); - break; - } - } + g_object_ref (chat); + tp_connection_call_when_ready (connection, reconnected_connection_ready_cb, + chat); } static void |