changeset 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 e4851710d9a9
children cb6bf374c7ee
files src/blist.c src/dialogs.c src/ui.h
diffstat 3 files changed, 29 insertions(+), 10 deletions(-) [+]
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) {
--- a/src/dialogs.c	Mon Oct 13 00:11:23 2003 +0000
+++ b/src/dialogs.c	Mon Oct 13 00:11:48 2003 +0000
@@ -1814,6 +1814,23 @@
 }
 
 static void
+alias_contact_cb(GaimContact *contact, const char *new_alias)
+{
+	gaim_contact_set_alias(contact, new_alias);
+	gaim_blist_save();
+}
+
+void
+alias_dialog_contact(GaimContact *contact)
+{
+	gaim_request_input(NULL, _("Alias Contact"), _("Alias contact"),
+			_("Please enter an aliased name for this contact."),
+			contact->alias, FALSE, FALSE,
+			_("OK"), G_CALLBACK(alias_contact_cb),
+			_("Cancel"), NULL, contact);
+}
+
+static void
 alias_buddy_cb(GaimBuddy *buddy, GaimRequestFields *fields)
 {
 	const char *alias;
--- a/src/ui.h	Mon Oct 13 00:11:23 2003 +0000
+++ b/src/ui.h	Mon Oct 13 00:11:48 2003 +0000
@@ -120,6 +120,7 @@
 
 /* Functions in dialogs.c */
 extern void alias_dialog_bud(GaimBuddy *);
+extern void alias_dialog_contact(GaimContact *);
 extern void alias_dialog_blist_chat(GaimChat *);
 extern void show_warn_dialog(GaimConnection *, char *);
 extern void show_im_dialog();