pidgin: a03e0bee: Set the server alias for myspace buddies...

markdoliner at pidgin.im markdoliner at pidgin.im
Wed Dec 17 00:40:45 EST 2008


-----------------------------------------------------------------
Revision: a03e0bee477b05d1143ef3e5607d990c1120da34
Ancestor: 9d89ef3f6424de7f80ef94926c05ce144cd28b30
Author: markdoliner at pidgin.im
Date: 2008-12-17T05:39:11
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/a03e0bee477b05d1143ef3e5607d990c1120da34

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

ChangeLog: 

Set the server alias for myspace buddies who haven't set their username.
This just keeps us from showing their less-than-useful user id.

I really feel like myspace buddy names should be their ID#, and we should
set their server alias to either their user name or their display name.
The way we do it now we have to do a LOT of tricks and callbacks and stuff
to lookup the username before adding users to the buddy list.  It just
doesn't seem worth it.  The server alias exists for a reason.

-------------- next part --------------
============================================================
--- libpurple/protocols/myspace/myspace.c	0263adf1c2c110689c811ee14851ccc2b3223668
+++ libpurple/protocols/myspace/myspace.c	73a5ddcd6e144c7c19decf2317e81c8a3db33cce
@@ -964,7 +964,7 @@ msim_add_contact_from_server_cb(MsimSess
 	PurpleGroup *group;
 	PurpleBuddy *buddy;
 	MsimUser *user;
-	gchar *username, *group_name;
+	gchar *username, *group_name, *display_name;
 	guint uid, visibility;
 
 	contact_info = (MsimMessage *)data;
@@ -973,10 +973,12 @@ msim_add_contact_from_server_cb(MsimSess
 
 	if (!user_lookup_info) {
 		username = g_strdup(msim_uid2username_from_blist(session->account, uid));
+		display_name = NULL;
 		g_return_if_fail(username != NULL);
 	} else {
 		user_lookup_info_body = msim_msg_get_dictionary(user_lookup_info, "body");
 		username = msim_msg_get_string(user_lookup_info_body, "UserName");
+		display_name = msim_msg_get_string(user_lookup_info_body, "DisplayName");
 		msim_msg_free(user_lookup_info_body);
 		g_return_if_fail(username != NULL);
 	}
@@ -1006,6 +1008,7 @@ msim_add_contact_from_server_cb(MsimSess
 		purple_privacy_deny_add(session->account, username, TRUE);
 		msim_msg_free(contact_info);
 		g_free(username);
+		g_free(display_name);
 		return;
 	}
 
@@ -1020,6 +1023,22 @@ msim_add_contact_from_server_cb(MsimSess
 	/* TODO: use 'Position' in contact_info to take into account where buddy is */
 	purple_blist_add_buddy(buddy, NULL, group, NULL /* insertion point */);
 
+	if (strtol(username, NULL, 10) == uid) {
+		/*
+		 * This user has not set their username!  Set their server
+		 * alias to their display name so that we don't see a bunch
+		 * of numbers in the buddy list.
+		 */
+		if (display_name != NULL) {
+			purple_blist_node_set_string(&buddy->node, "DisplayName", display_name);
+			serv_got_alias(session->gc, username, display_name);
+		} else {
+			serv_got_alias(session->gc, username,
+					purple_blist_node_get_string(&buddy->node, "DisplayName"));
+		}
+	}
+	g_free(display_name);
+
 	/* 3. Update buddy information */
 	user = msim_get_user_from_buddy(buddy);
 


More information about the Commits mailing list