diff pidgin/gtkconv.c @ 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 4a8407152e9a
children 591267f6f1d5 02df6998b466 15f61e6b15cd a59f65876d45 13ab08434a50
line wrap: on
line diff
--- 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;
 }