Mercurial > pidgin.yaz
changeset 29034:6c333c1d20b9
disapproval of revision '661db628ce40c3548058f062ea72d9687654d53a'
This is causing a ton of crashes for Adium. Clearly this needs to be done differently.
author | John Bailey <rekkanoryo@rekkanoryo.org> |
---|---|
date | Sun, 29 Nov 2009 16:16:40 +0000 |
parents | 86ff30fb8ae3 |
children | c06e1f777e42 |
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 Wed Nov 04 22:16:46 2009 +0000 +++ b/libpurple/protocols/oscar/oscar.c Sun Nov 29 16:16:40 2009 +0000 @@ -5225,7 +5225,7 @@ { /* If not in server list then prune from local list */ GSList *cur, *next; GSList *buddies = purple_find_buddies(account, NULL); - + /* Buddies */ cur = NULL; @@ -5315,28 +5315,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); @@ -5360,15 +5377,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 */ @@ -5503,8 +5535,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; @@ -5525,7 +5556,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) { @@ -5534,21 +5577,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 */ @@ -5561,8 +5604,6 @@ } - g_free(alias); - ssi_item = aim_ssi_itemlist_finditem(od->ssi.local, gname, name, AIM_SSI_TYPE_BUDDY); if (ssi_item == NULL) @@ -5572,6 +5613,9 @@ "group %s\n", name, gname); } + g_free(gname_utf8); + g_free(alias_utf8); + return 1; } @@ -6274,6 +6318,7 @@ struct name_data *data; PurpleGroup *g; char *comment; + gchar *comment_utf8; gchar *title; PurpleAccount *account; const char *name; @@ -6292,6 +6337,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); @@ -6299,7 +6345,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, @@ -6307,6 +6353,7 @@ g_free(title); g_free(comment); + g_free(comment_utf8); } static void