Mercurial > pidgin
comparison libpurple/protocols/jabber/buddy.c @ 22450:b53bacc6eb6e
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.
author | Evan Schoenberg <evan.s@dreskin.net> |
---|---|
date | Sun, 09 Mar 2008 18:47:09 +0000 |
parents | 67f62f55fc5a |
children | 3225c99785b8 |
comparison
equal
deleted
inserted
replaced
22448:8802eddbfedc | 22450:b53bacc6eb6e |
---|---|
1207 { | 1207 { |
1208 const char *id, *from; | 1208 const char *id, *from; |
1209 GString *info_text; | 1209 GString *info_text; |
1210 char *bare_jid; | 1210 char *bare_jid; |
1211 char *text; | 1211 char *text; |
1212 char *serverside_alias = NULL; | |
1212 xmlnode *vcard; | 1213 xmlnode *vcard; |
1213 PurpleBuddy *b; | 1214 PurpleBuddy *b; |
1214 JabberBuddyInfo *jbi = data; | 1215 JabberBuddyInfo *jbi = data; |
1215 | 1216 |
1216 from = xmlnode_get_attrib(packet, "from"); | 1217 from = xmlnode_get_attrib(packet, "from"); |
1245 if(child->type != XMLNODE_TYPE_TAG) | 1246 if(child->type != XMLNODE_TYPE_TAG) |
1246 continue; | 1247 continue; |
1247 | 1248 |
1248 text = xmlnode_get_data(child); | 1249 text = xmlnode_get_data(child); |
1249 if(text && !strcmp(child->name, "FN")) { | 1250 if(text && !strcmp(child->name, "FN")) { |
1251 /* If we havne't found a name yet, use this one as the serverside name */ | |
1252 if (!serverside_alias) | |
1253 serverside_alias = g_strdup(text); | |
1254 | |
1250 jabber_string_escape_and_append(info_text, | 1255 jabber_string_escape_and_append(info_text, |
1251 _("Full Name"), text, FALSE); | 1256 _("Full Name"), text, FALSE); |
1252 } else if(!strcmp(child->name, "N")) { | 1257 } else if(!strcmp(child->name, "N")) { |
1253 for(child2 = child->child; child2; child2 = child2->next) | 1258 for(child2 = child->child; child2; child2 = child2->next) |
1254 { | 1259 { |
1268 jabber_string_escape_and_append(info_text, | 1273 jabber_string_escape_and_append(info_text, |
1269 _("Middle Name"), text2, FALSE); | 1274 _("Middle Name"), text2, FALSE); |
1270 } | 1275 } |
1271 g_free(text2); | 1276 g_free(text2); |
1272 } | 1277 } |
1273 } else if(text && !strcmp(child->name, "NICKNAME")) { | 1278 } else if(text && !strcmp(child->name, "NICKNAME")) { |
1274 serv_got_alias(js->gc, from, text); | 1279 /* Prefer the Nickcname to the Full Name as the serverside alias */ |
1275 if(b) { | 1280 g_free(serverside_alias); |
1276 purple_blist_node_set_string((PurpleBlistNode*)b, "servernick", text); | 1281 serverside_alias = g_strdup(text); |
1277 } | 1282 |
1278 jabber_string_escape_and_append(info_text, | 1283 jabber_string_escape_and_append(info_text, |
1279 _("Nickname"), text, FALSE); | 1284 _("Nickname"), text, FALSE); |
1280 } else if(text && !strcmp(child->name, "BDAY")) { | 1285 } else if(text && !strcmp(child->name, "BDAY")) { |
1281 jabber_string_escape_and_append(info_text, | 1286 jabber_string_escape_and_append(info_text, |
1282 _("Birthday"), text, FALSE); | 1287 _("Birthday"), text, FALSE); |
1432 } | 1437 } |
1433 g_free(text); | 1438 g_free(text); |
1434 } | 1439 } |
1435 } | 1440 } |
1436 | 1441 |
1442 if (serverside_alias) { | |
1443 /* If we found a serverside alias, set it and tell the core */ | |
1444 serv_got_alias(js->gc, from, serverside_alias); | |
1445 if (b) { | |
1446 purple_blist_node_set_string((PurpleBlistNode*)b, "servernick", serverside_alias); | |
1447 } | |
1448 | |
1449 g_free(serverside_alias); | |
1450 } | |
1451 | |
1437 jbi->vcard_text = purple_strdup_withhtml(info_text->str); | 1452 jbi->vcard_text = purple_strdup_withhtml(info_text->str); |
1438 g_string_free(info_text, TRUE); | 1453 g_string_free(info_text, TRUE); |
1439 g_free(bare_jid); | 1454 g_free(bare_jid); |
1440 | 1455 |
1441 jabber_buddy_info_show_if_ready(jbi); | 1456 jabber_buddy_info_show_if_ready(jbi); |