Mercurial > pidgin.yaz
changeset 24761:c2054d8d23fc
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.
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Wed, 17 Dec 2008 05:39:11 +0000 |
parents | e12788365764 |
children | 9216da5184a2 9100b9176a16 |
files | libpurple/protocols/myspace/myspace.c |
diffstat | 1 files changed, 20 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/myspace/myspace.c Wed Dec 17 04:37:21 2008 +0000 +++ b/libpurple/protocols/myspace/myspace.c Wed Dec 17 05:39:11 2008 +0000 @@ -964,7 +964,7 @@ 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 @@ 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 @@ 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 @@ /* 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);