pidgin: c3ed9a8c: Remember the profile ids associated with...

sadrul at pidgin.im sadrul at pidgin.im
Sat Jun 27 19:50:34 EDT 2009


-----------------------------------------------------------------
Revision: c3ed9a8c89dd38d30b7ad93055507b679b2f0f76
Ancestor: ae327bc8a249f9d8fced9c1ce208a5781f10056a
Author: sadrul at pidgin.im
Date: 2009-06-27T23:38:53
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/c3ed9a8c89dd38d30b7ad93055507b679b2f0f76

Modified files:
        libpurple/protocols/yahoo/yahoo.c
        libpurple/protocols/yahoo/yahoo.h

ChangeLog: 

Remember the profile ids associated with an account.

Trying to activate a non-existent profile kills the connection. So only
allow activating the available profiles.

-------------- next part --------------
============================================================
--- libpurple/protocols/yahoo/yahoo.c	e889e328587a5e3c7aaeccf89f12c136b086a149
+++ libpurple/protocols/yahoo/yahoo.c	dd072ea72ddf9b7a722357bde645d271f489d64e
@@ -628,6 +628,9 @@ static void yahoo_process_list(PurpleCon
 			else
 				g_string_append(yd->tmp_serv_ilist, pair->value);
 			break;
+		case 89:
+			yd->profiles = g_strsplit(pair->value, ",", -1);
+			break;
 		case 59: /* cookies, yum */
 			yahoo_process_cookie(yd, pair->value);
 			break;
@@ -3539,6 +3542,7 @@ static void yahoo_close(PurpleConnection
 	g_free(yd->pending_chat_id);
 	g_free(yd->pending_chat_topic);
 	g_free(yd->pending_chat_goto);
+	g_strfreev(yd->profiles);
 
 	g_free(yd->current_list15_grp);
 
@@ -3924,15 +3928,16 @@ static GList *yahoo_blist_node_menu(Purp
 	}
 }
 
-static void yahoo_act_id(PurpleConnection *gc, const char *entry)
+static void yahoo_act_id(PurpleConnection *gc, PurpleRequestFields *fields)
 {
 	struct yahoo_data *yd = gc->proto_data;
+	const char *name = yd->profiles[purple_request_fields_get_choice(fields, "id")];
 
 	struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_IDACT, YAHOO_STATUS_AVAILABLE, 0);
-	yahoo_packet_hash_str(pkt, 3, entry);
+	yahoo_packet_hash_str(pkt, 3, name);
 	yahoo_packet_send_and_free(pkt, yd);
 
-	purple_connection_set_display_name(gc, entry);
+	purple_connection_set_display_name(gc, name);
 }
 
 static void
@@ -4014,9 +4019,28 @@ static void yahoo_show_act_id(PurplePlug
 
 static void yahoo_show_act_id(PurplePluginAction *action)
 {
+	PurpleRequestFields *fields;
+	PurpleRequestFieldGroup *group;
+	PurpleRequestField *field;
 	PurpleConnection *gc = (PurpleConnection *) action->context;
-	purple_request_input(gc, NULL, _("Activate which ID?"), NULL,
-					   purple_connection_get_display_name(gc), FALSE, FALSE, NULL,
+	struct yahoo_data *yd = purple_connection_get_protocol_data(gc);
+	const char *name = purple_connection_get_display_name(gc);
+	int iter;
+
+	fields = purple_request_fields_new();
+	group = purple_request_field_group_new(NULL);
+	purple_request_fields_add_group(fields, group);
+	field = purple_request_field_choice_new("id", "Activate which ID?", 0);
+	purple_request_field_group_add_field(group, field);
+
+	for (iter = 0; yd->profiles[iter]; iter++) {
+		purple_request_field_choice_add(field, yd->profiles[iter]);
+		if (purple_strequal(yd->profiles[iter], name))
+			purple_request_field_choice_set_default_value(field, iter);
+	}
+
+	purple_request_fields(gc, NULL, _("Select the ID you want to activate"), NULL,
+					   fields,
 					   _("OK"), G_CALLBACK(yahoo_act_id),
 					   _("Cancel"), NULL,
 					   purple_connection_get_account(gc), NULL, NULL,
============================================================
--- libpurple/protocols/yahoo/yahoo.h	d5e2e453eb44d572c05fa46dafbae6d4b7f82ac5
+++ libpurple/protocols/yahoo/yahoo.h	814a6906c7bde274bd5c5293089c96252aed62bc
@@ -155,6 +155,8 @@ struct yahoo_data {
 	guint txhandler;
 	GHashTable *friends;
 
+	char **profiles;  /* Multiple profiles can be associated with an account */
+
 	/**
 	 * This is used to keep track of the IMVironment chosen
 	 * by people you talk to.  We don't do very much with


More information about the Commits mailing list