changeset 27279:c29a3fac6032

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.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Sat, 27 Jun 2009 23:38:53 +0000
parents c0f1ae3e16e0
children 478e0b091731
files libpurple/protocols/yahoo/yahoo.c libpurple/protocols/yahoo/yahoo.h
diffstat 2 files changed, 31 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/yahoo/yahoo.c	Sat Jun 27 22:43:45 2009 +0000
+++ b/libpurple/protocols/yahoo/yahoo.c	Sat Jun 27 23:38:53 2009 +0000
@@ -628,6 +628,9 @@
 			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 @@
 	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 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(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,
--- a/libpurple/protocols/yahoo/yahoo.h	Sat Jun 27 22:43:45 2009 +0000
+++ b/libpurple/protocols/yahoo/yahoo.h	Sat Jun 27 23:38:53 2009 +0000
@@ -155,6 +155,8 @@
 	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