changeset 15181:4b500bd49d38

[gaim-migrate @ 17967] Fix auto-joining chatrooms. You don't need to keep the buddylist open for autojoins to work. committer: Tailor Script <tailor@pidgin.im>
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Tue, 12 Dec 2006 03:30:49 +0000
parents 6c43dbf293ad
children fbe2187bceec
files console/gntblist.c
diffstat 1 files changed, 18 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/console/gntblist.c	Tue Dec 12 01:06:42 2006 +0000
+++ b/console/gntblist.c	Tue Dec 12 03:30:49 2006 +0000
@@ -109,6 +109,7 @@
 static void savedstatus_changed(GaimSavedStatus *now, GaimSavedStatus *old);
 static void blist_show(GaimBuddyList *list);
 static void update_buddy_display(GaimBuddy *buddy, GGBlist *ggblist);
+static void account_signed_on_cb();
 
 /* Sort functions */
 static int blist_node_compare_text(GaimBlistNode *n1, GaimBlistNode *n2);
@@ -515,11 +516,6 @@
 	node->ui_data = gnt_tree_add_row_after(GNT_TREE(ggblist->tree), chat,
 				gnt_tree_create_row(GNT_TREE(ggblist->tree), get_display_name(node)),
 				group, NULL);
-
-	/* XXX: This causes problem because you can close a chat window, hide the buddylist.
-	 * When you show the buddylist, you automatically join the chat again. */
-	if (gaim_blist_node_get_bool((GaimBlistNode*)chat, "gnt-autojoin"))
-		serv_join_chat(gaim_account_get_connection(chat->account), chat->components);
 }
 
 static void
@@ -1587,6 +1583,8 @@
 	gaim_prefs_connect_callback(gg_blist_get_handle(),
 			PREF_ROOT "/sort_type", redraw_blist, NULL);
 
+	gaim_signal_connect(gaim_connections_get_handle(), "signed-on", gaim_blist_get_handle(),
+			G_CALLBACK(account_signed_on_cb), NULL);
 	return;
 }
 
@@ -1945,6 +1943,21 @@
 	}
 }
 
+static void
+account_signed_on_cb()
+{
+	GaimBlistNode *node;
+
+	for (node = gaim_blist_get_root(); node;
+			node = gaim_blist_node_next(node, FALSE)) {
+		if (GAIM_BLIST_NODE_IS_CHAT(node)) {
+			GaimChat *chat = (GaimChat*)node;
+			if (gaim_blist_node_get_bool(node, "gnt-autojoin"))
+				serv_join_chat(gaim_account_get_connection(chat->account), chat->components);
+		}
+	}
+}
+
 static void show_offline_cb(GntMenuItem *item, gpointer n)
 {
 	gaim_prefs_set_bool(PREF_ROOT "/showoffline",