changeset 17608:2f21e46758a3

This makes Conversation->More work for non-buddies and chats not on your buddy list. I finally found a use for purple_version_check, yay. Why did I call it purple_version_check and not the more confusing (to me) purple_check_version?
author Stu Tomlinson <stu@nosnilmot.com>
date Wed, 13 Jun 2007 00:32:51 +0000
parents 10aba1e6abc9
children 8e316800d00a
files pidgin/gtkconv.c
diffstat 1 files changed, 42 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin/gtkconv.c	Tue Jun 12 20:19:23 2007 +0000
+++ b/pidgin/gtkconv.c	Wed Jun 13 00:32:51 2007 +0000
@@ -49,6 +49,7 @@
 #include "prpl.h"
 #include "request.h"
 #include "util.h"
+#include "version.h"
 
 #include "gtkdnd-hints.h"
 #include "gtkblist.h"
@@ -2091,6 +2092,9 @@
 	return TRUE;
 }
 
+static void
+regenerate_options_items(PidginWindow *win);
+
 void
 pidgin_conv_switch_active_conversation(PurpleConversation *conv)
 {
@@ -2191,6 +2195,8 @@
 
 	gray_stuff_out(gtkconv);
 	update_typing_icon(gtkconv);
+	g_object_set_data(G_OBJECT(entry), "transient_buddy", NULL);
+	regenerate_options_items(gtkconv->win);
 
 	gtk_window_set_title(GTK_WINDOW(gtkconv->win->window),
 	                     gtk_label_get_text(GTK_LABEL(gtkconv->tab_label)));
@@ -2953,11 +2959,45 @@
 
 	menu = gtk_item_factory_get_widget(win->menu.item_factory, N_("/Conversation/More"));
 
-	if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT)
+	if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) {
 		chat = purple_blist_find_chat(conv->account, conv->name);
-	else
+
+		if ((chat == NULL) && (gtkconv->imhtml != NULL)) {
+			chat = g_object_get_data(G_OBJECT(gtkconv->imhtml), "transient_chat");
+		}
+
+		if ((chat == NULL) && (gtkconv->imhtml != NULL)) {
+			GHashTable *components;
+			components = g_hash_table_new_full(g_str_hash, g_str_equal,
+					g_free, g_free);
+			g_hash_table_replace(components, g_strdup("channel"),
+					g_strdup(conv->name));
+			chat = purple_chat_new(conv->account, NULL, components);
+			purple_blist_node_set_flags((PurpleBlistNode *)chat,
+					PURPLE_BLIST_NODE_FLAG_NO_SAVE);
+			g_object_set_data_full(G_OBJECT(gtkconv->imhtml), "transient_chat",
+					chat, (GDestroyNotify)purple_blist_remove_chat);
+		}
+	} else {
 		buddy = purple_find_buddy(conv->account, conv->name);
 
+		/* gotta remain bug-compatible :( libpurple < 2.0.2 didn't handle
+		 * removing "isolated" buddy nodes well */
+		if (purple_version_check(2, 0, 2) == NULL) {
+			if ((buddy == NULL) && (gtkconv->imhtml != NULL)) {
+				buddy = g_object_get_data(G_OBJECT(gtkconv->imhtml), "transient_buddy");
+			}
+
+			if ((buddy == NULL) && (gtkconv->imhtml != NULL)) {
+				buddy = purple_buddy_new(conv->account, conv->name, NULL);
+				purple_blist_node_set_flags((PurpleBlistNode *)buddy,
+						PURPLE_BLIST_NODE_FLAG_NO_SAVE);
+				g_object_set_data_full(G_OBJECT(gtkconv->imhtml), "transient_buddy",
+						buddy, (GDestroyNotify)purple_blist_remove_buddy);
+			}
+		}
+	}
+
 	if (chat)
 		node = (PurpleBlistNode *)chat;
 	else if (buddy)