Mercurial > pidgin
comparison 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 |
comparison
equal
deleted
inserted
replaced
7244:e4851710d9a9 | 7245:747b9e00ef60 |
---|---|
755 return c; | 755 return c; |
756 } | 756 } |
757 | 757 |
758 void gaim_contact_set_alias(GaimContact* contact, const char *alias) | 758 void gaim_contact_set_alias(GaimContact* contact, const char *alias) |
759 { | 759 { |
760 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; | |
761 | |
760 g_return_if_fail(contact != NULL); | 762 g_return_if_fail(contact != NULL); |
761 | 763 |
762 if(contact->alias) | 764 if(contact->alias) |
763 g_free(contact->alias); | 765 g_free(contact->alias); |
764 | 766 |
765 contact->alias = g_strdup(alias); | 767 if(alias && *alias) |
768 contact->alias = g_strdup(alias); | |
769 else | |
770 contact->alias = NULL; | |
771 | |
772 if (ops) | |
773 ops->update(gaimbuddylist, (GaimBlistNode*)contact); | |
766 } | 774 } |
767 | 775 |
768 const char *gaim_contact_get_alias(GaimContact* contact) | 776 const char *gaim_contact_get_alias(GaimContact* contact) |
769 { | 777 { |
770 return contact ? contact->alias : NULL; | 778 return contact ? contact->alias : NULL; |
1154 return NULL; | 1162 return NULL; |
1155 } | 1163 } |
1156 | 1164 |
1157 const char * gaim_get_buddy_alias (GaimBuddy *buddy) | 1165 const char * gaim_get_buddy_alias (GaimBuddy *buddy) |
1158 { | 1166 { |
1159 GaimContact *contact; | |
1160 const char *ret; | 1167 const char *ret; |
1161 | 1168 |
1162 if(!buddy) | 1169 if(!buddy) |
1163 return _("Unknown"); | 1170 return _("Unknown"); |
1164 | |
1165 contact = (GaimContact*)((GaimBlistNode*)buddy)->parent; | |
1166 | |
1167 if(contact && contact->alias) | |
1168 return contact->alias; | |
1169 | 1171 |
1170 ret= gaim_get_buddy_alias_only(buddy); | 1172 ret= gaim_get_buddy_alias_only(buddy); |
1171 | 1173 |
1172 return ret ? ret : buddy->name; | 1174 return ret ? ret : buddy->name; |
1173 } | 1175 } |
1934 | 1936 |
1935 static void parse_contact(GaimGroup *group, xmlnode *cnode) | 1937 static void parse_contact(GaimGroup *group, xmlnode *cnode) |
1936 { | 1938 { |
1937 GaimContact *contact = gaim_contact_new(); | 1939 GaimContact *contact = gaim_contact_new(); |
1938 xmlnode *x; | 1940 xmlnode *x; |
1941 const char *alias; | |
1939 | 1942 |
1940 gaim_blist_add_contact(contact, group, | 1943 gaim_blist_add_contact(contact, group, |
1941 gaim_blist_get_last_child((GaimBlistNode*)group)); | 1944 gaim_blist_get_last_child((GaimBlistNode*)group)); |
1942 | 1945 |
1943 if((x = xmlnode_get_child(cnode, "alias"))) { | 1946 if((alias = xmlnode_get_attrib(cnode, "alias"))) { |
1944 char *alias = xmlnode_get_data(x); | |
1945 gaim_contact_set_alias(contact, alias); | 1947 gaim_contact_set_alias(contact, alias); |
1946 g_free(alias); | |
1947 } | 1948 } |
1948 | 1949 |
1949 for(x = cnode->child; x; x = x->next) { | 1950 for(x = cnode->child; x; x = x->next) { |
1950 if(x->type != NODE_TYPE_TAG) | 1951 if(x->type != NODE_TYPE_TAG) |
1951 continue; | 1952 continue; |