pidgin: de9498ef: Fix some bogocity related to the GG "Add...

datallah at pidgin.im datallah at pidgin.im
Tue Jan 13 21:55:50 EST 2009


-----------------------------------------------------------------
Revision: de9498ef83a6077f5f72e1e2f9edbffeb5b33008
Ancestor: e602a35f60e3d423d43bacc72fcb7239c8b43cf0
Author: datallah at pidgin.im
Date: 2009-01-14T02:49:20
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/de9498ef83a6077f5f72e1e2f9edbffeb5b33008

Modified files:
        libpurple/protocols/gg/gg.c

ChangeLog: 

Fix some bogocity related to the GG "Add To Chat" menu item. Fixes #8112.

-------------- next part --------------
============================================================
--- libpurple/protocols/gg/gg.c	cd0d2a18fef8959b39fd8a39a5e3172f5ace63db
+++ libpurple/protocols/gg/gg.c	2f3f5251f789d7fc415cde9ea627459357fbf4be
@@ -755,18 +755,29 @@ static void ggp_change_passwd(PurplePlug
 
 /* ----- 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 @@ static void ggp_bmenu_add_to_chat(Purple
 	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 @@ static void ggp_bmenu_add_to_chat(Purple
 	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 @@ static void ggp_bmenu_add_to_chat(Purple
 			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 @@ static GList *ggp_blist_node_menu(Purple
 {
 	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,


More information about the Commits mailing list