changeset 29053:c06e1f777e42

merge of '32e63a51dbb65b8b63d134bde098d40167574148' and '4be5956e86cfd7ac16331092beb6255db19e0640'
author John Bailey <rekkanoryo@rekkanoryo.org>
date Sun, 29 Nov 2009 16:16:49 +0000
parents f2a69bee9ef6 (current diff) 6c333c1d20b9 (diff)
children 54db9b78be71
files libpurple/protocols/oscar/oscar.c
diffstat 1 files changed, 68 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/oscar/oscar.c	Sun Nov 29 16:14:36 2009 +0000
+++ b/libpurple/protocols/oscar/oscar.c	Sun Nov 29 16:16:49 2009 +0000
@@ -5297,7 +5297,7 @@
 	{ /* If not in server list then prune from local list */
 		GSList *cur, *next;
 		GSList *buddies = purple_find_buddies(account, NULL);
-
+		
 		/* Buddies */
 		cur = NULL;
 
@@ -5387,28 +5387,45 @@
 
 	/* Add from server list to local list */
 	for (curitem=od->ssi.local; curitem; curitem=curitem->next) {
+	  if ((curitem->name == NULL) || (g_utf8_validate(curitem->name, -1, NULL)))
 		switch (curitem->type) {
 			case AIM_SSI_TYPE_BUDDY: { /* Buddy */
 				if (curitem->name) {
 					struct aim_ssi_item *groupitem;
-					const char *gname, *alias;
+					char *gname, *gname_utf8, *alias, *alias_utf8;
 
 					groupitem = aim_ssi_itemlist_find(od->ssi.local, curitem->gid, 0x0000);
 					gname = groupitem ? groupitem->name : NULL;
-
-					g = purple_find_group(gname ? gname : _("Orphans"));
+					if (gname != NULL) {
+						if (g_utf8_validate(gname, -1, NULL))
+							gname_utf8 = g_strdup(gname);
+						else
+							gname_utf8 = oscar_utf8_try_convert(account, gname);
+					} else
+						gname_utf8 = NULL;
+
+					g = purple_find_group(gname_utf8 ? gname_utf8 : _("Orphans"));
 					if (g == NULL) {
-						g = purple_group_new(gname ? gname : _("Orphans"));
+						g = purple_group_new(gname_utf8 ? gname_utf8 : _("Orphans"));
 						purple_blist_add_group(g, NULL);
 					}
 
 					alias = aim_ssi_getalias(od->ssi.local, gname, curitem->name);
+					if (alias != NULL) {
+						if (g_utf8_validate(alias, -1, NULL))
+							alias_utf8 = g_strdup(alias);
+						else
+							alias_utf8 = oscar_utf8_try_convert(account, alias);
+						g_free(alias);
+					} else
+						alias_utf8 = NULL;
+
 					b = purple_find_buddy_in_group(account, curitem->name, g);
 					if (b) {
 						/* Get server stored alias */
-						purple_blist_alias_buddy(b, alias);
+						purple_blist_alias_buddy(b, alias_utf8);
 					} else {
-						b = purple_buddy_new(account, curitem->name, alias);
+						b = purple_buddy_new(account, curitem->name, alias_utf8);
 
 						purple_debug_info("oscar",
 								   "ssi: adding buddy %s to group %s to local list\n", curitem->name, gname);
@@ -5432,15 +5449,30 @@
 								purple_buddy_get_name(b),
 								OSCAR_STATUS_ID_MOBILE, NULL);
 					}
+
+					g_free(gname_utf8);
+					g_free(alias_utf8);
 				}
 			} break;
 
 			case AIM_SSI_TYPE_GROUP: { /* Group */
-				const char *gname = curitem->name;
-				if (gname != NULL && purple_find_group(gname) == NULL) {
-					g = purple_group_new(gname);
+				char *gname;
+				char *gname_utf8;
+
+				gname = curitem->name;
+				if (gname != NULL) {
+					if (g_utf8_validate(gname, -1, NULL))
+						gname_utf8 = g_strdup(gname);
+					else
+						gname_utf8 = oscar_utf8_try_convert(account, gname);
+				} else
+					gname_utf8 = NULL;
+
+				if (gname_utf8 != NULL && purple_find_group(gname_utf8) == NULL) {
+					g = purple_group_new(gname_utf8);
 					purple_blist_add_group(g, NULL);
 				}
+				g_free(gname_utf8);
 			} break;
 
 			case AIM_SSI_TYPE_PERMIT: { /* Permit buddy */
@@ -5579,8 +5611,7 @@
 {
 	PurpleConnection *gc;
 	PurpleAccount *account;
-	const char *gname;
-	char *alias;
+	char *gname, *gname_utf8, *alias, *alias_utf8;
 	PurpleBuddy *b;
 	PurpleGroup *g;
 	struct aim_ssi_item *ssi_item;
@@ -5601,7 +5632,19 @@
 		return 1;
 
 	gname = aim_ssi_itemlist_findparentname(od->ssi.local, name);
+	gname_utf8 = gname ? oscar_utf8_try_convert(account, gname) : NULL;
+
 	alias = aim_ssi_getalias(od->ssi.local, gname, name);
+	if (alias != NULL)
+	{
+		if (g_utf8_validate(alias, -1, NULL))
+			alias_utf8 = g_strdup(alias);
+		else
+			alias_utf8 = oscar_utf8_try_convert(account, alias);
+	}
+	else
+		alias_utf8 = NULL;
+	g_free(alias);
 
 	b = purple_find_buddy(account, name);
 	if (b) {
@@ -5610,21 +5653,21 @@
 		 * of your buddies, so update our local buddy list with
 		 * the person's new alias.
 		 */
-		purple_blist_alias_buddy(b, alias);
+		purple_blist_alias_buddy(b, alias_utf8);
 	} else if (snac_subtype == 0x0008) {
 		/*
 		 * You're logged in somewhere else and you added a buddy to
 		 * your server list, so add them to your local buddy list.
 		 */
-		b = purple_buddy_new(account, name, alias);
-
-		if (!(g = purple_find_group(gname ? gname : _("Orphans")))) {
-			g = purple_group_new(gname ? gname : _("Orphans"));
+		b = purple_buddy_new(account, name, alias_utf8);
+
+		if (!(g = purple_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) {
+			g = purple_group_new(gname_utf8 ? gname_utf8 : _("Orphans"));
 			purple_blist_add_group(g, NULL);
 		}
 
 		purple_debug_info("oscar",
-				   "ssi: adding buddy %s to group %s to local list\n", name, gname ? gname : _("Orphans"));
+				   "ssi: adding buddy %s to group %s to local list\n", name, gname_utf8 ? gname_utf8 : _("Orphans"));
 		purple_blist_add_buddy(b, NULL, g, NULL);
 
 		/* Mobile users should always be online */
@@ -5637,8 +5680,6 @@
 
 	}
 
-	g_free(alias);
-
 	ssi_item = aim_ssi_itemlist_finditem(od->ssi.local,
 			gname, name, AIM_SSI_TYPE_BUDDY);
 	if (ssi_item == NULL)
@@ -5648,6 +5689,9 @@
 				"group %s\n", name, gname);
 	}
 
+	g_free(gname_utf8);
+	g_free(alias_utf8);
+
 	return 1;
 }
 
@@ -6350,6 +6394,7 @@
 	struct name_data *data;
 	PurpleGroup *g;
 	char *comment;
+	gchar *comment_utf8;
 	gchar *title;
 	PurpleAccount *account;
 	const char *name;
@@ -6368,6 +6413,7 @@
 	data = g_new(struct name_data, 1);
 
 	comment = aim_ssi_getcomment(od->ssi.local, purple_group_get_name(g), name);
+	comment_utf8 = comment ? oscar_utf8_try_convert(account, comment) : NULL;
 
 	data->gc = gc;
 	data->name = g_strdup(name);
@@ -6375,7 +6421,7 @@
 
 	title = g_strdup_printf(_("Buddy Comment for %s"), data->name);
 	purple_request_input(gc, title, _("Buddy Comment:"), NULL,
-					   comment, TRUE, FALSE, NULL,
+					   comment_utf8, TRUE, FALSE, NULL,
 					   _("_OK"), G_CALLBACK(oscar_ssi_editcomment),
 					   _("_Cancel"), G_CALLBACK(oscar_free_name_data),
 					   account, data->name, NULL,
@@ -6383,6 +6429,7 @@
 	g_free(title);
 
 	g_free(comment);
+	g_free(comment_utf8);
 }
 
 static void