changeset 25323:051fe71c3d8f

Fix some bogocity related to the GG "Add To Chat" menu item. Fixes #8112.
author Daniel Atallah <daniel.atallah@gmail.com>
date Wed, 14 Jan 2009 02:49:20 +0000
parents bacb1e93e7c4
children df25f88ff22a
files libpurple/protocols/gg/gg.c
diffstat 1 files changed, 29 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/gg/gg.c	Tue Jan 13 02:02:14 2009 +0000
+++ b/libpurple/protocols/gg/gg.c	Wed Jan 14 02:49:20 2009 +0000
@@ -755,18 +755,29 @@
 
 /* ----- CONFERENCES ---------------------------------------------------- */
 
-static void ggp_callback_add_to_chat_ok(PurpleConnection *gc, PurpleRequestFields *fields)
+static void ggp_callback_add_to_chat_ok(PurpleBuddy *buddy, PurpleRequestFields *fields)
 {
-	GGPInfo *info = gc->proto_data;
+	GGPInfo *info;
+	PurpleConnection *conn;
 	PurpleRequestField *field;
-	/* TODO: sel may be null. */
 	GList *sel;
 
+	conn = purple_account_get_connection(purple_buddy_get_account(buddy));
+
+	g_return_if_fail(conn != NULL);
+
+	info = conn->proto_data;
+
 	field = purple_request_fields_get_field(fields, "name");
 	sel = purple_request_field_list_get_selected(field);
 
-	ggp_confer_participants_add_uin(gc, sel->data, info->tmp_buddy);
-	info->tmp_buddy = 0;
+	if (sel == NULL) {
+		purple_debug_error("gg", "No chat selected\n");
+		return;
+	}
+
+	ggp_confer_participants_add_uin(conn, sel->data,
+					ggp_str_to_uin(purple_buddy_get_name(buddy)));
 }
 
 static void ggp_bmenu_add_to_chat(PurpleBlistNode *node, gpointer ignored)
@@ -786,9 +797,6 @@
 	gc = purple_account_get_connection(purple_buddy_get_account(buddy));
 	info = gc->proto_data;
 
-	/* TODO: It tmp_buddy != 0 then stop! */
-	info->tmp_buddy = ggp_str_to_uin(purple_buddy_get_name(buddy));
-
 	fields = purple_request_fields_new();
 	group = purple_request_field_group_new(NULL);
 	purple_request_fields_add_group(fields, group);
@@ -796,8 +804,7 @@
 	field = purple_request_field_list_new("name", "Chat name");
 	for (l = info->chats; l != NULL; l = l->next) {
 		GGPChat *chat = l->data;
-		purple_request_field_list_add(field, g_strdup(chat->name),
-					    g_strdup(chat->name));
+		purple_request_field_list_add(field, chat->name, chat->name);
 	}
 	purple_request_field_group_add_field(group, field);
 
@@ -810,8 +817,8 @@
 			fields,
 			_("Add"), G_CALLBACK(ggp_callback_add_to_chat_ok),
 			_("Cancel"), NULL,
-			purple_connection_get_account(gc), NULL, NULL,			  
-			gc);
+			purple_connection_get_account(gc), NULL, NULL,
+			buddy);
 	g_free(msg);
 }
 
@@ -1699,14 +1706,20 @@
 {
 	PurpleMenuAction *act;
 	GList *m = NULL;
+	PurpleAccount *account;
+	GGPInfo *info;
 
 	if (!PURPLE_BLIST_NODE_IS_BUDDY(node))
 		return NULL;
 
-	act = purple_menu_action_new(_("Add to chat"),
-	                           PURPLE_CALLBACK(ggp_bmenu_add_to_chat),
-	                           NULL, NULL);
-	m = g_list_append(m, act);
+	account = purple_buddy_get_account((PurpleBuddy *) node);
+	info = purple_account_get_connection(account)->proto_data;
+	if (info->chats) {
+		act = purple_menu_action_new(_("Add to chat"),
+			PURPLE_CALLBACK(ggp_bmenu_add_to_chat),
+			NULL, NULL);
+		m = g_list_append(m, act);
+	}
 
 	/* Using a blist node boolean here is also wrong.
 	 * Once the Block and Unblock actions are added to the core,