# HG changeset patch # User Sadrul Habib Chowdhury # Date 1256167601 0 # Node ID 71dc3b5edbe7984d5f9fe1487e674a3fa46295c3 # Parent d1c18bd588e2c6339296d1a62f0e88d2228553f1 Rejoin an opened chat after an account reconnects. Previously, we used to rejoin an open chat only if the account was disconnected due to an error. But now, the chat rooms will be rejoined even if we disconnected manually. diff -r d1c18bd588e2 -r 71dc3b5edbe7 ChangeLog --- a/ChangeLog Tue Oct 20 21:20:22 2009 +0000 +++ b/ChangeLog Wed Oct 21 23:26:41 2009 +0000 @@ -9,6 +9,7 @@ to announce the list of loaded plugins (in both Finch and Pidgin). * Fix building the GnuTLS plugin with older versions of GnuTLS. * Fix DNS TXT query resolution. + * Always rejoin open chats after an account reconnects. MSN: * Don't forget display names for buddies. diff -r d1c18bd588e2 -r 71dc3b5edbe7 finch/gntconn.c --- a/finch/gntconn.c Tue Oct 20 21:20:22 2009 +0000 +++ b/finch/gntconn.c Wed Oct 21 23:26:41 2009 +0000 @@ -107,7 +107,6 @@ { FinchAutoRecon *info; PurpleAccount *account = purple_connection_get_account(gc); - GList *list; if (!purple_connection_error_is_fatal(reason)) { info = g_hash_table_lookup(hash, account); @@ -144,21 +143,6 @@ g_free(secondary); purple_account_set_enabled(account, FINCH_UI, FALSE); } - - /* If we have any open chats, we probably want to rejoin when we get back online. */ - list = purple_get_chats(); - while (list) { - PurpleConversation *conv = list->data; - list = list->next; - if (purple_conversation_get_account(conv) != account || - purple_conv_chat_has_left(PURPLE_CONV_CHAT(conv))) - continue; - purple_conversation_set_data(conv, "want-to-rejoin", GINT_TO_POINTER(TRUE)); - purple_conversation_write(conv, NULL, _("The account has disconnected and you are no " - "longer in this chat. You will be automatically rejoined in the chat when " - "the account reconnects."), - PURPLE_MESSAGE_SYSTEM, time(NULL)); - } } static void diff -r d1c18bd588e2 -r 71dc3b5edbe7 finch/gntconv.c --- a/finch/gntconv.c Tue Oct 20 21:20:22 2009 +0000 +++ b/finch/gntconv.c Wed Oct 21 23:26:41 2009 +0000 @@ -367,6 +367,26 @@ } } +static void +account_signing_off(PurpleConnection *gc) +{ + GList *list = purple_get_chats(); + + /* We are about to sign off. See which chats we are currently in, and mark + * them for rejoin on reconnect. */ + while (list) { + PurpleConversation *conv = list->data; + if (!purple_conv_chat_has_left(PURPLE_CONV_CHAT(conv))) { + purple_conversation_set_data(conv, "want-to-rejoin", GINT_TO_POINTER(TRUE)); + purple_conversation_write(conv, NULL, _("The account has disconnected and you are no " + "longer in this chat. You will be automatically rejoined in the chat when " + "the account reconnects."), + PURPLE_MESSAGE_SYSTEM, time(NULL)); + } + list = list->next; + } +} + static gpointer finch_conv_get_handle(void) { @@ -1433,6 +1453,8 @@ PURPLE_CALLBACK(account_signed_on_off), NULL); purple_signal_connect(purple_connections_get_handle(), "signed-off", finch_conv_get_handle(), PURPLE_CALLBACK(account_signed_on_off), NULL); + purple_signal_connect(purple_connections_get_handle(), "signing-off", finch_conv_get_handle(), + PURPLE_CALLBACK(account_signing_off), NULL); } void finch_conversation_uninit() diff -r d1c18bd588e2 -r 71dc3b5edbe7 pidgin/gtkconn.c --- a/pidgin/gtkconn.c Tue Oct 20 21:20:22 2009 +0000 +++ b/pidgin/gtkconn.c Wed Oct 21 23:26:41 2009 +0000 @@ -142,7 +142,6 @@ { PurpleAccount *account = NULL; PidginAutoRecon *info; - GList *list; account = purple_connection_get_account(gc); info = g_hash_table_lookup(auto_reconns, account); @@ -164,17 +163,6 @@ purple_account_set_enabled(account, PIDGIN_UI, FALSE); } - - /* If we have any open chats, we probably want to rejoin when we get back online. */ - list = purple_get_chats(); - while (list) { - PurpleConversation *conv = list->data; - list = list->next; - if (conv->account != account || - purple_conv_chat_has_left(PURPLE_CONV_CHAT(conv))) - continue; - purple_conversation_set_data(conv, "want-to-rejoin", GINT_TO_POINTER(TRUE)); - } } static void pidgin_connection_network_connected (void) diff -r d1c18bd588e2 -r 71dc3b5edbe7 pidgin/gtkconv.c --- a/pidgin/gtkconv.c Tue Oct 20 21:20:22 2009 +0000 +++ b/pidgin/gtkconv.c Wed Oct 21 23:26:41 2009 +0000 @@ -4277,7 +4277,7 @@ /* Users */ for (; l != NULL; l = l->next) { tab_complete_process_item(&most_matched, entered, entered_bytes, &partial, nick_partial, - &matches, TRUE, ((PurpleConvChatBuddy *)l->data)->name); + &matches, FALSE, ((PurpleConvChatBuddy *)l->data)->name); } @@ -7601,6 +7601,26 @@ } } +static void +account_signing_off(PurpleConnection *gc) +{ + GList *list = purple_get_chats(); + + /* We are about to sign off. See which chats we are currently in, and mark + * them for rejoin on reconnect. */ + while (list) { + PurpleConversation *conv = list->data; + if (!purple_conv_chat_has_left(PURPLE_CONV_CHAT(conv))) { + purple_conversation_set_data(conv, "want-to-rejoin", GINT_TO_POINTER(TRUE)); + purple_conversation_write(conv, NULL, _("The account has disconnected and you are no " + "longer in this chat. You will be automatically rejoined in the chat when " + "the account reconnects."), + PURPLE_MESSAGE_SYSTEM, time(NULL)); + } + list = list->next; + } +} + static gboolean update_buddy_status_timeout(PurpleBuddy *buddy) { @@ -8095,6 +8115,8 @@ purple_signal_connect(purple_connections_get_handle(), "signed-off", handle, G_CALLBACK(account_signed_off_cb), GINT_TO_POINTER(PURPLE_CONV_ACCOUNT_OFFLINE)); + purple_signal_connect(purple_connections_get_handle(), "signing-off", handle, + G_CALLBACK(account_signing_off), NULL); purple_signal_connect(purple_conversations_get_handle(), "received-im-msg", handle, G_CALLBACK(received_im_msg_cb), NULL);