# HG changeset patch # User Evan Schoenberg # Date 1205088429 0 # Node ID b53bacc6eb6ea1c714373724a9d42f664db995b8 # Parent 8802eddbfedccc521d040165d52154695af7a537 If we receive a Full Name and no nickname, use the Full Name as the serverside alias for an XMPP contact. If we receive just a nickname or both a full name and a nickname, prefer the nickname. diff -r 8802eddbfedc -r b53bacc6eb6e libpurple/protocols/jabber/buddy.c --- a/libpurple/protocols/jabber/buddy.c Sun Mar 09 16:52:07 2008 +0000 +++ b/libpurple/protocols/jabber/buddy.c Sun Mar 09 18:47:09 2008 +0000 @@ -1209,6 +1209,7 @@ GString *info_text; char *bare_jid; char *text; + char *serverside_alias = NULL; xmlnode *vcard; PurpleBuddy *b; JabberBuddyInfo *jbi = data; @@ -1247,6 +1248,10 @@ text = xmlnode_get_data(child); if(text && !strcmp(child->name, "FN")) { + /* If we havne't found a name yet, use this one as the serverside name */ + if (!serverside_alias) + serverside_alias = g_strdup(text); + jabber_string_escape_and_append(info_text, _("Full Name"), text, FALSE); } else if(!strcmp(child->name, "N")) { @@ -1270,11 +1275,11 @@ } g_free(text2); } - } else if(text && !strcmp(child->name, "NICKNAME")) { - serv_got_alias(js->gc, from, text); - if(b) { - purple_blist_node_set_string((PurpleBlistNode*)b, "servernick", text); - } + } else if(text && !strcmp(child->name, "NICKNAME")) { + /* Prefer the Nickcname to the Full Name as the serverside alias */ + g_free(serverside_alias); + serverside_alias = g_strdup(text); + jabber_string_escape_and_append(info_text, _("Nickname"), text, FALSE); } else if(text && !strcmp(child->name, "BDAY")) { @@ -1434,6 +1439,16 @@ } } + if (serverside_alias) { + /* If we found a serverside alias, set it and tell the core */ + serv_got_alias(js->gc, from, serverside_alias); + if (b) { + purple_blist_node_set_string((PurpleBlistNode*)b, "servernick", serverside_alias); + } + + g_free(serverside_alias); + } + jbi->vcard_text = purple_strdup_withhtml(info_text->str); g_string_free(info_text, TRUE); g_free(bare_jid);