changeset 25294:8aa7d8bcbc7d

Alias foo. I think blist.h structs are now completely hidden.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Fri, 31 Oct 2008 21:06:26 +0000
parents d93c93dfa435
children 53c27ca1bb71
files ChangeLog.API libpurple/blist.c libpurple/blist.h libpurple/protocols/jabber/google.c libpurple/protocols/jabber/roster.c libpurple/protocols/msn/msn.c libpurple/protocols/novell/novell.c libpurple/protocols/oscar/oscar.c libpurple/protocols/sametime/sametime.c libpurple/protocols/yahoo/yahoo_profile.c libpurple/protocols/zephyr/zephyr.c
diffstat 11 files changed, 50 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog.API	Fri Oct 31 20:04:35 2008 +0000
+++ b/ChangeLog.API	Fri Oct 31 21:06:26 2008 +0000
@@ -7,6 +7,7 @@
 		* purple_buddy_set_protocol_data
 		* purple_connection_get_protocol_data
 		* purple_connection_set_protocol_data
+		* purple_buddy_get_local_buddy_alias
 
 		Deprecated:
 		* purple_buddy_get_local_alias
--- a/libpurple/blist.c	Fri Oct 31 20:04:35 2008 +0000
+++ b/libpurple/blist.c	Fri Oct 31 21:06:26 2008 +0000
@@ -2061,6 +2061,12 @@
 	return buddy->name;
 }
 
+const char *purple_buddy_get_local_buddy_alias(PurpleBuddy *buddy)
+{
+	g_return_val_if_fail(buddy, NULL);
+	return buddy->alias;
+}
+
 const char *purple_buddy_get_server_alias(PurpleBuddy *buddy)
 {
         g_return_val_if_fail(buddy != NULL, NULL);
--- a/libpurple/blist.h	Fri Oct 31 20:04:35 2008 +0000
+++ b/libpurple/blist.h	Fri Oct 31 21:06:26 2008 +0000
@@ -709,6 +709,14 @@
 const char *purple_buddy_get_alias(PurpleBuddy *buddy);
 
 /**
+ * Returns the local alias for the buddy, or @c NULL if none exists.
+ *
+ * @param buddy  The buddy
+ * @return       The local alias for the buddy
+ */
+const char *purple_buddy_get_local_buddy_alias(PurpleBuddy *buddy);
+
+/**
  * Returns the correct name to display for a blist chat.
  *
  * @param chat   The chat whose name will be returned.
--- a/libpurple/protocols/jabber/google.c	Fri Oct 31 20:04:35 2008 +0000
+++ b/libpurple/protocols/jabber/google.c	Fri Oct 31 21:06:26 2008 +0000
@@ -283,6 +283,7 @@
 	xmlnode *group;
 	PurpleBuddy *b;
 	JabberBuddy *jb;
+	const char *balias;
 
 	js = (JabberStream*)(gc->proto_data);
 
@@ -314,8 +315,9 @@
 		buddies = buddies->next;
 	}
 
+	balias = purple_buddy_get_local_buddy_alias(b);
 	xmlnode_set_attrib(item, "jid", who);
-	xmlnode_set_attrib(item, "name", b->alias ? b->alias : "");
+	xmlnode_set_attrib(item, "name", balias ? balias : "");
 	xmlnode_set_attrib(item, "gr:t", "B");
 	xmlnode_set_attrib(query, "xmlns:gr", "google:roster");
 	xmlnode_set_attrib(query, "gr:ext", "2");
@@ -348,6 +350,7 @@
 	xmlnode *item;
 	xmlnode *group;
 	PurpleBuddy *b;
+	const char *balias;
 
 	g_return_if_fail(gc != NULL);
 	g_return_if_fail(who != NULL);
@@ -380,8 +383,9 @@
 		buddies = buddies->next;
 	}
 
+	balias = purple_buddy_get_local_buddy_alias(b);
 	xmlnode_set_attrib(item, "jid", who);
-	xmlnode_set_attrib(item, "name", b->alias ? b->alias : "");
+	xmlnode_set_attrib(item, "name", balias ? balias : "");
 	xmlnode_set_attrib(query, "xmlns:gr", "google:roster");
 	xmlnode_set_attrib(query, "gr:ext", "2");
 
--- a/libpurple/protocols/jabber/roster.c	Fri Oct 31 20:04:35 2008 +0000
+++ b/libpurple/protocols/jabber/roster.c	Fri Oct 31 21:06:26 2008 +0000
@@ -81,14 +81,15 @@
 		buddies = g_slist_remove(buddies, b);
 
 		if((l = g_slist_find_custom(g2, purple_group_get_name(g), (GCompareFunc)strcmp))) {
-			const char *servernick;
+			const char *servernick, *balias;
 
 			/* Previously stored serverside / buddy-supplied alias */
 			if((servernick = purple_blist_node_get_string((PurpleBlistNode*)b, "servernick")))
 				serv_got_alias(js->gc, jid, servernick);
 
 			/* Alias from our roster retrieval */
-			if(alias && (!b->alias || strcmp(b->alias, alias)))
+			balias = purple_buddy_get_local_buddy_alias(b);
+			if(alias && (!balias || strcmp(balias, alias)))
 				purple_serv_got_private_alias(js->gc, jid, alias);
 			g_free(l->data);
 			g2 = g_slist_delete_link(g2, l);
@@ -275,6 +276,7 @@
 	GSList *groups = NULL, *l;
 	JabberIq *iq;
 	xmlnode *query, *item, *group;
+	const char *balias;
 
 	if (js->currently_parsing_roster_push)
 		return;
@@ -303,7 +305,8 @@
 
 	xmlnode_set_attrib(item, "jid", name);
 
-	xmlnode_set_attrib(item, "name", b->alias ? b->alias : "");
+	balias = purple_buddy_get_local_buddy_alias(b);
+	xmlnode_set_attrib(item, "name", balias ? balias : "");
 
 	for(l = groups; l; l = l->next) {
 		group = xmlnode_new_child(item, "group");
--- a/libpurple/protocols/msn/msn.c	Fri Oct 31 20:04:35 2008 +0000
+++ b/libpurple/protocols/msn/msn.c	Fri Oct 31 21:06:26 2008 +0000
@@ -1817,9 +1817,10 @@
 		char *tmp;
 		const char *alias;
 
-		if (b->alias && b->alias[0])
+		alias = purple_buddy_get_local_buddy_alias(b);
+		if (alias && alias[0])
 		{
-			char *aliastext = g_markup_escape_text(b->alias, -1);
+			char *aliastext = g_markup_escape_text(alias, -1);
 			purple_notify_user_info_add_pair(user_info, _("Alias"), aliastext);
 			g_free(aliastext);
 		}
--- a/libpurple/protocols/novell/novell.c	Fri Oct 31 20:04:35 2008 +0000
+++ b/libpurple/protocols/novell/novell.c	Fri Oct 31 21:06:26 2008 +0000
@@ -2687,9 +2687,11 @@
 				}
 
 				if (group) {
+					const char *balias;
 					buddy = purple_find_buddy_in_group(user->client_data,
 													 name, group);
-					if (buddy && strcmp(buddy->alias, alias))
+					balias = buddy ? purple_buddy_get_local_buddy_alias(buddy) : NULL;
+					if (balias && strcmp(balias, alias))
 						purple_blist_alias_buddy(buddy, alias);
 				}
 
--- a/libpurple/protocols/oscar/oscar.c	Fri Oct 31 20:04:35 2008 +0000
+++ b/libpurple/protocols/oscar/oscar.c	Fri Oct 31 21:06:26 2008 +0000
@@ -5049,13 +5049,15 @@
 								/* If the buddy is an ICQ user then load his nickname */
 								const char *servernick = purple_blist_node_get_string((PurpleBlistNode*)b, "servernick");
 								char *alias;
+								const char *balias;
 								if (servernick)
 									serv_got_alias(gc, bname, servernick);
 
 								/* Store local alias on server */
 								alias = aim_ssi_getalias(od->ssi.local, gname, bname);
-								if (!alias && b->alias && strlen(b->alias))
-									aim_ssi_aliasbuddy(od, gname, bname, b->alias);
+								balias = purple_buddy_get_local_buddy_alias(b);
+								if (!alias && balias && *balias)
+									aim_ssi_aliasbuddy(od, gname, bname, balias);
 								g_free(alias);
 							} else {
 								purple_debug_info("oscar",
--- a/libpurple/protocols/sametime/sametime.c	Fri Oct 31 20:04:35 2008 +0000
+++ b/libpurple/protocols/sametime/sametime.c	Fri Oct 31 21:06:26 2008 +0000
@@ -732,7 +732,7 @@
 
 	  stu = mwSametimeUser_new(stg, utype, &idb);
 	  mwSametimeUser_setShortName(stu, purple_buddy_get_server_alias(bdy));
-	  mwSametimeUser_setAlias(stu, bdy->alias);
+	  mwSametimeUser_setAlias(stu, purple_buddy_get_local_buddy_alias(bdy));
 	}
       }
     }
--- a/libpurple/protocols/yahoo/yahoo_profile.c	Fri Oct 31 20:04:35 2008 +0000
+++ b/libpurple/protocols/yahoo/yahoo_profile.c	Fri Oct 31 21:06:26 2008 +0000
@@ -699,8 +699,9 @@
 			info_data->name);
 
 	if (b) {
-		if(b->alias && b->alias[0]) {
-			char *aliastext = g_markup_escape_text(b->alias, -1);
+		const char *balias = purple_buddy_get_local_buddy_alias(b);
+		if(balias && balias[0]) {
+			char *aliastext = g_markup_escape_text(balias, -1);
 			purple_notify_user_info_add_pair(user_info, _("Alias"), aliastext); 
 			g_free(aliastext);
 		}
--- a/libpurple/protocols/zephyr/zephyr.c	Fri Oct 31 20:04:35 2008 +0000
+++ b/libpurple/protocols/zephyr/zephyr.c	Fri Oct 31 21:06:26 2008 +0000
@@ -789,10 +789,12 @@
 				int one = 1;
 				PurpleNotifyUserInfo *user_info = purple_notify_user_info_new();
 				char *tmp;
+				const char *balias;
 
 				purple_notify_user_info_add_pair(user_info, _("User"), (b ? bname : user));
-				if (b && b->alias)
-					purple_notify_user_info_add_pair(user_info, _("Alias"), b->alias);
+				balias = purple_buddy_get_local_buddy_alias(b);
+				if (b && balias)
+					purple_notify_user_info_add_pair(user_info, _("Alias"), balias);
 
 				if (!nlocs) {
 					purple_notify_user_info_add_pair(user_info, NULL, _("Hidden or not logged-in"));
@@ -1170,12 +1172,14 @@
 				if ((b && pending_zloc(zephyr,bname)) || pending_zloc(zephyr,user) || pending_zloc(zephyr,local_zephyr_normalize(zephyr,user))){
 					PurpleNotifyUserInfo *user_info = purple_notify_user_info_new();
 					char *tmp;
+					const char *balias;
 
 					purple_notify_user_info_add_pair(user_info, _("User"), (b ? bname : user));
 
-					if (b && b->alias)
-						purple_notify_user_info_add_pair(user_info, _("Alias"), b->alias);
-											
+					balias = b ? purple_buddy_get_local_buddy_alias(b) : NULL;
+					if (balias)
+						purple_notify_user_info_add_pair(user_info, _("Alias"), balias);
+
 					if (!nlocs) {
 						purple_notify_user_info_add_pair(user_info, NULL, _("Hidden or not logged-in"));
 					} else {