diff options
author | Jonny Lamb <jonny.lamb@collabora.co.uk> | 2009-09-08 23:16:03 +0800 |
---|---|---|
committer | Jonny Lamb <jonny.lamb@collabora.co.uk> | 2009-09-08 23:16:03 +0800 |
commit | 923bb82f3aa66ac7b24168b5b69541268bf9d055 (patch) | |
tree | 6da36506263f210b8f4f253052c9560528b69700 /src/empathy.c | |
parent | e423acc109dbfce1c34a23769c385dd38410f1f5 (diff) | |
download | gsoc2013-empathy-923bb82f3aa66ac7b24168b5b69541268bf9d055.tar gsoc2013-empathy-923bb82f3aa66ac7b24168b5b69541268bf9d055.tar.gz gsoc2013-empathy-923bb82f3aa66ac7b24168b5b69541268bf9d055.tar.bz2 gsoc2013-empathy-923bb82f3aa66ac7b24168b5b69541268bf9d055.tar.lz gsoc2013-empathy-923bb82f3aa66ac7b24168b5b69541268bf9d055.tar.xz gsoc2013-empathy-923bb82f3aa66ac7b24168b5b69541268bf9d055.tar.zst gsoc2013-empathy-923bb82f3aa66ac7b24168b5b69541268bf9d055.zip |
empathy: no need to connect to status-changed; notify::connection will do
Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
Diffstat (limited to 'src/empathy.c')
-rw-r--r-- | src/empathy.c | 86 |
1 files changed, 29 insertions, 57 deletions
diff --git a/src/empathy.c b/src/empathy.c index f9efda621..09d90744d 100644 --- a/src/empathy.c +++ b/src/empathy.c @@ -632,52 +632,15 @@ account_connection_notify_cb (EmpathyAccount *account, GParamSpec *pspec, EmpathyChatroom *room) { - g_signal_handlers_disconnect_by_func (account, - account_connection_notify_cb, room); + TpConnection *conn; - empathy_dispatcher_join_muc (empathy_account_get_connection (account), - empathy_chatroom_get_room (room), NULL, NULL); -} + conn = empathy_account_get_connection (account); -static void -account_chatroom_account_status_changed_cb (EmpathyAccount *account, - TpConnectionStatus old_status, - TpConnectionStatus new_status, - TpConnectionStatusReason reason, - EmpathyChatroomManager *chatroom_manager) -{ - GList *chatrooms, *l; - - if (new_status != TP_CONNECTION_STATUS_CONNECTED) + if (conn == NULL) return; - chatrooms = empathy_chatroom_manager_get_chatrooms ( - chatroom_manager, account); - - for (l = chatrooms; l != NULL; l = l->next) - { - EmpathyChatroom *room = EMPATHY_CHATROOM (l->data); - TpConnection *conn; - - if (!empathy_chatroom_get_auto_connect (room)) - continue; - - conn = empathy_account_get_connection (account); - - /* Sometimes the account's connection hasn't been initialized yet. */ - if (conn == NULL) - { - g_signal_connect (G_OBJECT (account), "notify::connection", - G_CALLBACK (account_connection_notify_cb), room); - } - else - { - empathy_dispatcher_join_muc (conn, empathy_chatroom_get_room (room), - NULL, NULL); - } - } - - g_list_free (chatrooms); + empathy_dispatcher_join_muc (conn, + empathy_chatroom_get_room (room), NULL, NULL); } static void @@ -691,26 +654,35 @@ account_manager_chatroom_ready_cb (EmpathyAccountManager *account_manager, for (l = accounts; l != NULL; l = g_list_next (l)) { - EmpathyAccount *a = EMPATHY_ACCOUNT (l->data); - TpConnectionStatus status; + EmpathyAccount *account = EMPATHY_ACCOUNT (l->data); + TpConnection *conn; + GList *chatrooms, *p; + + conn = empathy_account_get_connection (account); - g_object_get (a, - "connection-status", &status, - NULL); + chatrooms = empathy_chatroom_manager_get_chatrooms ( + chatroom_manager, account); - if (status == TP_CONNECTION_STATUS_CONNECTED) + for (p = chatrooms; p != NULL; p = p->next) { - account_chatroom_account_status_changed_cb (a, - TP_CONNECTION_STATUS_DISCONNECTED, - TP_CONNECTION_STATUS_CONNECTED, 0, chatroom_manager); + EmpathyChatroom *room = EMPATHY_CHATROOM (p->data); + + if (!empathy_chatroom_get_auto_connect (room)) + continue; + + if (conn == NULL) + { + g_signal_connect (G_OBJECT (account), "notify::connection", + G_CALLBACK (account_connection_notify_cb), room); + } + else + { + empathy_dispatcher_join_muc (conn, + empathy_chatroom_get_room (room), NULL, NULL); + } } - else - { - g_signal_connect (G_OBJECT (a), "status-changed", - G_CALLBACK (account_chatroom_account_status_changed_cb), - chatroom_manager); - } + g_list_free (chatrooms); } g_list_foreach (accounts, (GFunc) g_object_unref, NULL); |