diff src/conversation.c @ 6456:ccfdf9f2cdd1

[gaim-migrate @ 6965] Conversation placement by group now applies to chats in the buddy list as well. Also added functions for finding a chat by name, and getting its parent group. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Wed, 13 Aug 2003 21:08:29 +0000
parents 9c65a439d327
children 338147ea6896
line wrap: on
line diff
--- a/src/conversation.c	Wed Aug 13 20:13:06 2003 +0000
+++ b/src/conversation.c	Wed Aug 13 21:08:29 2003 +0000
@@ -2220,15 +2220,7 @@
 
 	type = gaim_conversation_get_type(conv);
 
-	if (type != GAIM_CONV_IM) {
-		win = gaim_get_last_window_with_type(type);
-
-		if (win == NULL)
-			conv_placement_new_window(conv);
-		else
-			gaim_window_add_conversation(win, conv);
-	}
-	else {
+	if (type == GAIM_CONV_IM) {
 		struct buddy *b;
 		struct group *grp = NULL;
 		GList *wins, *convs;
@@ -2271,6 +2263,58 @@
 		/* Make a new window. */
 		conv_placement_new_window(conv);
 	}
+	else if (type == GAIM_CONV_CHAT) {
+		struct chat *chat;
+		struct group *group = NULL;
+		GList *wins, *convs;
+
+		chat = gaim_blist_find_chat(gaim_conversation_get_account(conv),
+									gaim_conversation_get_name(conv));
+
+		if (chat != NULL)
+			group = gaim_blist_chat_get_group(chat);
+
+		/* Go through the list of chats and find one with this group. */
+		for (wins = gaim_get_windows(); wins != NULL; wins = wins->next) {
+			GaimWindow *win2;
+			GaimConversation *conv2;
+			struct chat *chat2;
+			struct group *group2 = NULL;
+
+			win2 = (GaimWindow *)wins->data;
+
+			for (convs = gaim_window_get_conversations(win2);
+				 convs != NULL;
+				 convs = convs->next) {
+
+				conv2 = (GaimConversation *)convs->data;
+
+				chat2 = gaim_blist_find_chat(
+					gaim_conversation_get_account(conv2),
+					gaim_conversation_get_name(conv2));
+
+				if (chat2 != NULL)
+					group2 = gaim_blist_chat_get_group(chat2);
+
+				if (group == group2) {
+					gaim_window_add_conversation(win2, conv);
+
+					return;
+				}
+			}
+		}
+
+		/* Make a new window. */
+		conv_placement_new_window(conv);
+	}
+	else {
+		win = gaim_get_last_window_with_type(type);
+
+		if (win == NULL)
+			conv_placement_new_window(conv);
+		else
+			gaim_window_add_conversation(win, conv);
+	}
 }
 
 /* This groups things by account.  Otherwise, the same semantics as above */