diff -r 37f787f5d4ac -r 407e0fa6f7d1 libpurple/protocols/jabber/roster.c --- a/libpurple/protocols/jabber/roster.c Wed Apr 30 18:49:53 2014 +0200 +++ b/libpurple/protocols/jabber/roster.c Wed Apr 30 19:44:02 2014 +0200 @@ -114,8 +114,7 @@ if(!groups) { if(!buddies) { - groups = g_slist_append(groups, - g_strdup(PURPLE_BLIST_DEFAULT_GROUP_NAME)); + groups = g_slist_append(groups, JABBER_ROSTER_DEFAULT_GROUP); } else { /* TODO: What should we do here? Removing the local buddies * is wrong, but so is letting the group state get out of sync with @@ -138,7 +137,14 @@ * to the server, the buddy will be dropped from one of the groups. * Not optimal, but better than the alternative, I think. */ - if((l = g_slist_find_custom(groups, purple_group_get_name(g), (GCompareFunc)purple_utf8_strcasecmp))) { + l = g_slist_find_custom(groups, purple_group_get_name(g), + (GCompareFunc)purple_utf8_strcasecmp); + if (!l && g == purple_blist_get_default_group()) { + l = g_slist_find_custom(groups, JABBER_ROSTER_DEFAULT_GROUP, + (GCompareFunc)purple_utf8_strcasecmp); + } + + if (l) { /* The buddy is already on the local list. Update info. */ const char *servernick, *balias; @@ -154,10 +160,10 @@ groups = g_slist_delete_link(groups, l); } else { /* This buddy isn't in the group on the server anymore */ - purple_debug_info("jabber", "jabber_roster_parse(): Removing %s " - "from group '%s' on the local list\n", - purple_buddy_get_name(b), - purple_group_get_name(g)); + purple_debug_info("jabber", "jabber_roster_parse(): " + "Removing %s from group '%s' on the local list", + purple_buddy_get_name(b), + jabber_roster_group_get_global_name(g)); purple_blist_remove_buddy(b); } } @@ -254,7 +260,7 @@ if (group_name == NULL || *group_name == '\0') /* Changing this string? Look in add_purple_buddy_to_groups */ - group_name = g_strdup(PURPLE_BLIST_DEFAULT_GROUP_NAME); + group_name = g_strdup(JABBER_ROSTER_DEFAULT_GROUP); /* * See the note in add_purple_buddy_to_groups; the core handles @@ -323,7 +329,8 @@ while(buddies) { b = buddies->data; g = purple_buddy_get_group(b); - groups = g_slist_append(groups, (char *)purple_group_get_name(g)); + groups = g_slist_append(groups, + (char *)jabber_roster_group_get_global_name(g)); buddies = g_slist_remove(buddies, b); } @@ -451,7 +458,7 @@ while(buddies) { b = buddies->data; g = purple_buddy_get_group(b); - gname = purple_group_get_name(g); + gname = jabber_roster_group_get_global_name(g); if(!strcmp(gname, old_group)) groups = g_slist_append(groups, (char*)new_group); /* ick */ else @@ -469,7 +476,7 @@ PurpleGroup *group, GList *moved_buddies) { GList *l; - const char *gname = purple_group_get_name(group); + const char *gname = jabber_roster_group_get_global_name(group); for(l = moved_buddies; l; l = l->next) { PurpleBuddy *buddy = l->data; jabber_roster_group_change(gc, purple_buddy_get_name(buddy), old_name, gname); @@ -490,12 +497,14 @@ while(buddies) { tmpbuddy = buddies->data; tmpgroup = purple_buddy_get_group(tmpbuddy); - groups = g_slist_append(groups, (char *)purple_group_get_name(tmpgroup)); + groups = g_slist_append(groups, + (char *)jabber_roster_group_get_global_name(tmpgroup)); buddies = g_slist_remove(buddies, tmpbuddy); } - purple_debug_info("jabber", "jabber_roster_remove_buddy(): Removing %s from %s\n", - purple_buddy_get_name(buddy), purple_group_get_name(group)); + purple_debug_info("jabber", "jabber_roster_remove_buddy(): " + "Removing %s from %s", purple_buddy_get_name(buddy), + jabber_roster_group_get_global_name(group)); jabber_roster_update(purple_connection_get_protocol_data(gc), name, groups); } else { @@ -513,3 +522,19 @@ jabber_iq_send(iq); } } + +const gchar * +jabber_roster_group_get_global_name(PurpleGroup *group) +{ + const gchar *name = NULL; + + if (group) + name = purple_group_get_name(group); + + if (name == NULL) + name = JABBER_ROSTER_DEFAULT_GROUP; + else if (g_strcmp0(name, PURPLE_BLIST_DEFAULT_GROUP_NAME) == 0) + name = JABBER_ROSTER_DEFAULT_GROUP; + + return name; +}