diff pidgin/gtkconn.c @ 20691:f1fe9b873b0b

propagate from branch 'im.pidgin.pidgin.2.2.1' (head 7494c5484079eedcf158172f4208be3f986c068f) to branch 'im.pidgin.pidgin' (head ead56863984a2925621479326e71927d704eb22c)
author Richard Laager <rlaager@wiktel.com>
date Fri, 28 Sep 2007 18:23:54 +0000
parents b7460582a135
children f3cfcbbac3d8
line wrap: on
line diff
--- a/pidgin/gtkconn.c	Fri Sep 28 18:21:40 2007 +0000
+++ b/pidgin/gtkconn.c	Fri Sep 28 18:23:54 2007 +0000
@@ -53,7 +53,7 @@
  * The key is a pointer to the PurpleAccount and the
  * value is a pointer to a PidginAutoRecon.
  */
-static GHashTable *hash = NULL;
+static GHashTable *auto_reconns = NULL;
 
 static void
 pidgin_connection_connect_progress(PurpleConnection *gc,
@@ -80,7 +80,7 @@
 		pidgin_status_box_set_connecting(PIDGIN_STATUS_BOX(gtkblist->statusbox),
 					   (purple_connections_get_connecting() != NULL));
 
-	g_hash_table_remove(hash, account);
+	g_hash_table_remove(auto_reconns, account);
 
 	pidgin_blist_update_account_error_state(account, NULL);
 }
@@ -120,7 +120,7 @@
 
 	purple_debug_info("autorecon", "do_signon called\n");
 	g_return_val_if_fail(account != NULL, FALSE);
-	info = g_hash_table_lookup(hash, account);
+	info = g_hash_table_lookup(auto_reconns, account);
 
 	if (info)
 		info->timeout = 0;
@@ -141,15 +141,16 @@
 {
 	PurpleAccount *account = NULL;
 	PidginAutoRecon *info;
+	GList *list;
 
 	account = purple_connection_get_account(gc);
-	info = g_hash_table_lookup(hash, account);
+	info = g_hash_table_lookup(auto_reconns, account);
 
 	pidgin_blist_update_account_error_state(account, text);
 	if (!gc->wants_to_die) {
 		if (info == NULL) {
 			info = g_new0(PidginAutoRecon, 1);
-			g_hash_table_insert(hash, account, info);
+			g_hash_table_insert(auto_reconns, account, info);
 			info->delay = g_random_int_range(INITIAL_RECON_DELAY_MIN, INITIAL_RECON_DELAY_MAX);
 		} else {
 			info->delay = MIN(2 * info->delay, MAX_RECON_DELAY);
@@ -160,7 +161,7 @@
 	} else {
 		char *p, *s, *n=NULL ;
 		if (info != NULL)
-			g_hash_table_remove(hash, account);
+			g_hash_table_remove(auto_reconns, account);
 
 		if (purple_account_get_alias(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 ()
@@ -204,7 +216,7 @@
 
 	while (list) {
 		PurpleAccount *account = (PurpleAccount*)list->data;
-		g_hash_table_remove(hash, account);
+		g_hash_table_remove(auto_reconns, account);
 		if (purple_account_is_disconnected(account))
 			do_signon(account);
 		list = list->next;
@@ -265,7 +277,7 @@
 static void
 account_removed_cb(PurpleAccount *account, gpointer user_data)
 {
-	g_hash_table_remove(hash, account);
+	g_hash_table_remove(auto_reconns, account);
 
 	pidgin_blist_update_account_error_state(account, NULL);
 }
@@ -286,7 +298,7 @@
 void
 pidgin_connection_init(void)
 {
-	hash = g_hash_table_new_full(
+	auto_reconns = g_hash_table_new_full(
 							g_direct_hash, g_direct_equal,
 							NULL, free_auto_recon);
 
@@ -300,5 +312,5 @@
 {
 	purple_signals_disconnect_by_handle(pidgin_connection_get_handle());
 
-	g_hash_table_destroy(hash);
+	g_hash_table_destroy(auto_reconns);
 }