changeset 22451:ec8eddc93a7f

merge of '2df22d7ed44f0ccc912fc22ea2e0389c0e445b6f' and 'c5ef0491bd5e808f50c7826bf06e52d8ec3f1d7c'
author Stu Tomlinson <stu@nosnilmot.com>
date Sun, 09 Mar 2008 19:17:35 +0000
parents b53bacc6eb6e (diff) 76b501dfe231 (current diff)
children c2b9399d95b2
files
diffstat 1 files changed, 20 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/jabber/buddy.c	Sun Mar 09 18:47:09 2008 +0000
+++ b/libpurple/protocols/jabber/buddy.c	Sun Mar 09 19:17:35 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);