diff src/blist.c @ 7245:747b9e00ef60

[gaim-migrate @ 7822] contact aliasing support (sorry, I had to touch ui.h) committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Mon, 13 Oct 2003 00:11:48 +0000
parents d14e026611c0
children cb6bf374c7ee
line wrap: on
line diff
--- a/src/blist.c	Mon Oct 13 00:11:23 2003 +0000
+++ b/src/blist.c	Mon Oct 13 00:11:48 2003 +0000
@@ -757,12 +757,20 @@
 
 void gaim_contact_set_alias(GaimContact* contact, const char *alias)
 {
+	GaimBlistUiOps *ops = gaimbuddylist->ui_ops;
+
 	g_return_if_fail(contact != NULL);
 
 	if(contact->alias)
 		g_free(contact->alias);
 
-	contact->alias = g_strdup(alias);
+	if(alias && *alias)
+		contact->alias = g_strdup(alias);
+	else
+		contact->alias = NULL;
+
+	if (ops)
+		ops->update(gaimbuddylist, (GaimBlistNode*)contact);
 }
 
 const char *gaim_contact_get_alias(GaimContact* contact)
@@ -1156,17 +1164,11 @@
 
 const char *  gaim_get_buddy_alias (GaimBuddy *buddy)
 {
-	GaimContact *contact;
 	const char *ret;
 
 	if(!buddy)
 		return _("Unknown");
 
-	contact = (GaimContact*)((GaimBlistNode*)buddy)->parent;
-
-	if(contact && contact->alias)
-		return contact->alias;
-
 	ret= gaim_get_buddy_alias_only(buddy);
 
 	return ret ? ret : buddy->name;
@@ -1936,14 +1938,13 @@
 {
 	GaimContact *contact = gaim_contact_new();
 	xmlnode *x;
+	const char *alias;
 
 	gaim_blist_add_contact(contact, group,
 			gaim_blist_get_last_child((GaimBlistNode*)group));
 
-	if((x = xmlnode_get_child(cnode, "alias"))) {
-		char *alias = xmlnode_get_data(x);
+	if((alias = xmlnode_get_attrib(cnode, "alias"))) {
 		gaim_contact_set_alias(contact, alias);
-		g_free(alias);
 	}
 
 	for(x = cnode->child; x; x = x->next) {