pidgin: 052b844e: Allow changing contact details for folks...

sadrul at pidgin.im sadrul at pidgin.im
Tue Jul 14 23:15:34 EDT 2009


-----------------------------------------------------------------
Revision: 052b844e0de47c283f4eefb3e5c9d511dbb287aa
Ancestor: 44089d25afaf6adbd5be6f061262c40da27d6c0e
Author: sadrul at pidgin.im
Date: 2009-07-15T03:17:54
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/052b844e0de47c283f4eefb3e5c9d511dbb287aa

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

ChangeLog: 

Allow changing contact details for folks in the buddylist.

-------------- next part --------------
============================================================
--- libpurple/protocols/yahoo/libymsg.c	780b6c489397cc0594a9ea7e8de980ad8b948b5d
+++ libpurple/protocols/yahoo/libymsg.c	4bd9bd07b90b3e65cff05114e9362ebb927a252b
@@ -3871,6 +3871,16 @@ static void yahoo_doodle_blist_node(Purp
 	yahoo_doodle_initiate(gc, purple_buddy_get_name(b));
 }
 
+static void
+yahoo_userinfo_blist_node(PurpleBlistNode *node, gpointer data)
+{
+	PurpleBuddy *b = (PurpleBuddy *)node;
+	PurpleAccount *account = purple_buddy_get_account(b);
+	PurpleConnection *gc = purple_account_get_connection(account);
+
+	yahoo_set_userinfo_for_buddy(gc, b);
+}
+
 static GList *yahoo_buddy_menu(PurpleBuddy *buddy)
 {
 	GList *m = NULL;
@@ -3932,13 +3942,16 @@ static GList *yahoo_buddy_menu(PurpleBud
 		act = purple_menu_action_new(_("Presence Settings"), NULL, NULL,
 		                           build_presence_submenu(f, gc));
 		m = g_list_append(m, act);
-	}
 
-	if (f) {
 		act = purple_menu_action_new(_("Start Doodling"),
 		                           PURPLE_CALLBACK(yahoo_doodle_blist_node),
 		                           NULL, NULL);
 		m = g_list_append(m, act);
+
+		act = purple_menu_action_new(_("Set User Info..."),
+		                           PURPLE_CALLBACK(yahoo_userinfo_blist_node),
+		                           NULL, NULL);
+		m = g_list_append(m, act);
 	}
 
 	return m;
============================================================
--- libpurple/protocols/yahoo/yahoo_aliases.c	7417fdca20786811a40e1d33ae128ae39f1c85de
+++ libpurple/protocols/yahoo/yahoo_aliases.c	9cf8f5bedf0b36ee5158bc76a00e703587206b5a
@@ -467,8 +467,8 @@ yahoo_set_userinfo_cb(PurpleConnection *
 	xmlnode_set_attrib(node, "cc", "1");		/* XXX: ? */
 
 	xmlnode_set_attrib(ct, "e", "1");
-	xmlnode_set_attrib(ct, "yi", purple_connection_get_display_name(gc));
-	xmlnode_set_attrib(ct, "id", yd->ypd.id);
+	xmlnode_set_attrib(ct, "yi", purple_request_fields_get_string(fields, "yname"));
+	xmlnode_set_attrib(ct, "id", purple_request_fields_get_string(fields, "yid"));
 	xmlnode_set_attrib(ct, "pr", "0");
 
 	for (i = 0; yfields[i]; i++) {
@@ -529,25 +529,25 @@ yahoo_set_userinfo_cb(PurpleConnection *
 	g_free(request);
 }
 
-void yahoo_set_userinfo(PurpleConnection *gc)
+static PurpleRequestFields *
+request_fields_from_personal_details(YahooPersonalDetails *ypd, const char *id)
 {
 	PurpleRequestFields *fields;
 	PurpleRequestFieldGroup *group;
 	PurpleRequestField *field;
-	struct yahoo_data *yd = purple_connection_get_protocol_data(gc);
 	int i;
 	struct {
 		char *id;
 		char *text;
 		char *value;
 	} yfields[] = {
-		{"fn", N_("First Name"), yd->ypd.names.first},
-		{"ln", N_("Last Name"), yd->ypd.names.last},
-		{"nn", N_("Nickname"), yd->ypd.names.nick},
-		{"mn", N_("Middle Name"), yd->ypd.names.middle},
-		{"hp", N_("Home Phone Number"), yd->ypd.phone.home},
-		{"wp", N_("Work Phone Number"), yd->ypd.phone.work},
-		{"mo", N_("Mobile Phone Number"), yd->ypd.phone.mobile},
+		{"fn", N_("First Name"), ypd->names.first},
+		{"ln", N_("Last Name"), ypd->names.last},
+		{"nn", N_("Nickname"), ypd->names.nick},
+		{"mn", N_("Middle Name"), ypd->names.middle},
+		{"hp", N_("Home Phone Number"), ypd->phone.home},
+		{"wp", N_("Work Phone Number"), ypd->phone.work},
+		{"mo", N_("Mobile Phone Number"), ypd->phone.mobile},
 		{NULL, NULL, NULL}
 	};
 
@@ -555,18 +555,52 @@ void yahoo_set_userinfo(PurpleConnection
 	group = purple_request_field_group_new(NULL);
 	purple_request_fields_add_group(fields, group);
 
+	field = purple_request_field_string_new("yname", "", id, FALSE);
+	purple_request_field_set_visible(field, FALSE);
+	purple_request_field_group_add_field(group, field);
+
+	field = purple_request_field_string_new("yid", "", ypd->id, FALSE);
+	purple_request_field_set_visible(field, FALSE);
+	purple_request_field_group_add_field(group, field);
+
 	for (i = 0; yfields[i].id; i++) {
 		field = purple_request_field_string_new(yfields[i].id, _(yfields[i].text),
 				yfields[i].value, FALSE);
 		purple_request_field_group_add_field(group, field);
 	}
 
+	return fields;
+}
+
+void yahoo_set_userinfo_for_buddy(PurpleConnection *gc, PurpleBuddy *buddy)
+{
+	PurpleRequestFields *fields;
+	YahooFriend *f;
+	const char *name;
+
+	name = purple_buddy_get_name(buddy);
+	f = yahoo_friend_find(gc, name);
+	if (!f)
+		return;
+
+	fields = request_fields_from_personal_details(&f->ypd, name);
 	purple_request_fields(gc, NULL, _("Set User Info"), NULL, fields,
 			_("OK"), G_CALLBACK(yahoo_set_userinfo_cb),
 			_("Cancel"), NULL,
 			purple_connection_get_account(gc), NULL, NULL, gc);
 }
 
+void yahoo_set_userinfo(PurpleConnection *gc)
+{
+	struct yahoo_data *yd = purple_connection_get_protocol_data(gc);
+	PurpleRequestFields *fields = request_fields_from_personal_details(&yd->ypd,
+					purple_connection_get_display_name(gc));
+	purple_request_fields(gc, NULL, _("Set User Info"), NULL, fields,
+			_("OK"), G_CALLBACK(yahoo_set_userinfo_cb),
+			_("Cancel"), NULL,
+			purple_connection_get_account(gc), NULL, NULL, gc);
+}
+
 static gboolean
 parse_contact_details(struct yahoo_data *yd, const char *who, const char *xml)
 {
============================================================
--- libpurple/protocols/yahoo/yahoo_aliases.h	8f5192edb5ef00f7e2cc7d90ca47a8ad3fb75897
+++ libpurple/protocols/yahoo/yahoo_aliases.h	9543e76cfe2fdd35fb9362e9ddb764e16e70ffe3
@@ -36,5 +36,6 @@ void yahoo_set_userinfo(PurpleConnection
 void yahoo_update_alias(PurpleConnection *gc, const char *who, const char *alias);
 void yahoo_fetch_aliases(PurpleConnection *gc);
 void yahoo_set_userinfo(PurpleConnection *gc);
+void yahoo_set_userinfo_for_buddy(PurpleConnection *gc, PurpleBuddy *buddy);
 void yahoo_personal_details_reset(YahooPersonalDetails *ypd, gboolean all);
 void yahoo_process_contact_details(PurpleConnection *gc, struct yahoo_packet *pkt);


More information about the Commits mailing list