Mercurial > pidgin.yaz
changeset 20552:b7460582a135
Fix #104 (Reconnect to network should reconnect chats also). This has been
working OK in finch. I think it's going to work in Pidgin too.
If you are in a chat when an account disconnects due to some error, then
you will rejoin the chats when the account signs back on.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Wed, 19 Sep 2007 10:57:37 +0000 |
parents | 51285cbe582d |
children | bed3c9affda6 a59f65876d45 |
files | finch/gntconv.c pidgin/gtkconn.c pidgin/gtkconv.c |
diffstat | 3 files changed, 37 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/finch/gntconv.c Wed Sep 19 10:07:03 2007 +0000 +++ b/finch/gntconv.c Wed Sep 19 10:57:37 2007 +0000 @@ -326,8 +326,8 @@ list = purple_get_chats(); while (list) { PurpleConversation *conv = list->data; - gboolean del = FALSE; PurpleChat *chat; + GHashTable *comps = NULL; list = list->next; if (conv->account != gc->account || @@ -336,15 +336,14 @@ chat = purple_blist_find_chat(conv->account, conv->name); if (chat == NULL) { - GHashTable *hash = NULL; if (PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info_defaults != NULL) - hash = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info_defaults(gc, conv->name); - chat = purple_chat_new(gc->account, conv->name, hash); - del = TRUE; + comps = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info_defaults(gc, conv->name); + } else { + comps = chat->components; } - serv_join_chat(gc, chat->components); - if (del) - purple_blist_remove_chat(chat); + serv_join_chat(gc, comps); + if (chat == NULL && comps != NULL) + g_hash_table_destroy(comps); } } }
--- a/pidgin/gtkconn.c Wed Sep 19 10:07:03 2007 +0000 +++ b/pidgin/gtkconn.c Wed Sep 19 10:57:37 2007 +0000 @@ -141,6 +141,7 @@ { PurpleAccount *account = NULL; PidginAutoRecon *info; + GList *list; account = purple_connection_get_account(gc); info = g_hash_table_lookup(auto_reconns, account); @@ -192,6 +193,17 @@ */ 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 ()
--- a/pidgin/gtkconv.c Wed Sep 19 10:07:03 2007 +0000 +++ b/pidgin/gtkconv.c Wed Sep 19 10:57:37 2007 +0000 @@ -7241,6 +7241,23 @@ /* if (purple_conversation_get_account(conv) == account) */ pidgin_conv_update_fields(conv, PIDGIN_CONV_TAB_ICON | PIDGIN_CONV_MENU | PIDGIN_CONV_COLORIZE_TITLE); + + if (PURPLE_CONNECTION_IS_CONNECTED(gc) && + conv->type == PURPLE_CONV_TYPE_CHAT && + conv->account == gc->account && + purple_conversation_get_data(conv, "want-to-rejoin")) { + GHashTable *comps = NULL; + PurpleChat *chat = purple_blist_find_chat(conv->account, conv->name); + if (chat == NULL) { + if (PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info_defaults != NULL) + comps = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info_defaults(gc, conv->name); + } else { + comps = chat->components; + } + serv_join_chat(gc, comps); + if (chat == NULL && comps != NULL) + g_hash_table_destroy(comps); + } } } @@ -7385,6 +7402,7 @@ if (gtkconv->attach.current) return TRUE; + g_object_set_data(G_OBJECT(gtkconv->entry), "attach-start-time", NULL); purple_signal_emit(pidgin_conversations_get_handle(), "conversation-displayed", gtkconv); g_source_remove(gtkconv->attach.timer); @@ -7425,7 +7443,6 @@ timer = GPOINTER_TO_INT(purple_conversation_get_data(conv, "close-timer")); if (timer) purple_timeout_remove(timer); - return TRUE; }