/pidgin/main: 4db2936dd842: Backport 407e0fa6f7d1: don't split c...
Tomasz Wasilczyk
twasilczyk at pidgin.im
Wed May 7 07:09:14 EDT 2014
Changeset: 4db2936dd8424770219056adb8de3ea474cfa1e1
Author: Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date: 2014-05-07 13:09 +0200
Branch: release-2.x.y
URL: https://hg.pidgin.im/pidgin/main/rev/4db2936dd842
Description:
Backport 407e0fa6f7d1: don't split contacts on default group (xmpp)
diffstat:
libpurple/protocols/jabber/google/google_roster.c | 7 ++-
libpurple/protocols/jabber/roster.c | 53 ++++++++++++++++++----
libpurple/protocols/jabber/roster.h | 6 ++
3 files changed, 53 insertions(+), 13 deletions(-)
diffs (172 lines):
diff --git a/libpurple/protocols/jabber/google/google_roster.c b/libpurple/protocols/jabber/google/google_roster.c
--- a/libpurple/protocols/jabber/google/google_roster.c
+++ b/libpurple/protocols/jabber/google/google_roster.c
@@ -24,6 +24,7 @@
#include "presence.h"
#include "debug.h"
#include "xmlnode.h"
+#include "roster.h"
void jabber_google_roster_outgoing(JabberStream *js, xmlnode *query, xmlnode *item)
{
@@ -127,7 +128,8 @@ void jabber_google_roster_add_deny(Jabbe
g = purple_buddy_get_group(b);
group = xmlnode_new_child(item, "group");
- xmlnode_insert_data(group, purple_group_get_name(g), -1);
+ xmlnode_insert_data(group,
+ jabber_roster_group_get_global_name(g), -1);
buddies = buddies->next;
}
@@ -187,7 +189,8 @@ void jabber_google_roster_rem_deny(Jabbe
g = purple_buddy_get_group(b);
group = xmlnode_new_child(item, "group");
- xmlnode_insert_data(group, purple_group_get_name(g), -1);
+ xmlnode_insert_data(group,
+ jabber_roster_group_get_global_name(g), -1);
buddies = buddies->next;
}
diff --git a/libpurple/protocols/jabber/roster.c b/libpurple/protocols/jabber/roster.c
--- a/libpurple/protocols/jabber/roster.c
+++ b/libpurple/protocols/jabber/roster.c
@@ -114,7 +114,7 @@ static void add_purple_buddy_to_groups(J
if(!groups) {
if(!buddies)
- groups = g_slist_append(groups, g_strdup(_("Buddies")));
+ groups = g_slist_append(groups, g_strdup(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
@@ -137,7 +137,15 @@ static void add_purple_buddy_to_groups(J
* 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_strcmp0(purple_group_get_name(g), _("Buddies")) == 0) {
+ l = g_slist_find_custom(groups, JABBER_ROSTER_DEFAULT_GROUP,
+ (GCompareFunc)purple_utf8_strcasecmp);
+ }
+ /* XXX: in 3.0.0 we have localized default name here too */
+
+ if (l) {
/* The buddy is already on the local list. Update info. */
const char *servernick, *balias;
@@ -156,7 +164,7 @@ static void add_purple_buddy_to_groups(J
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));
+ jabber_roster_group_get_global_name(g));
purple_blist_remove_buddy(b);
}
}
@@ -251,9 +259,12 @@ void jabber_roster_parse(JabberStream *j
for(group = xmlnode_get_child(item, "group"); group; group = xmlnode_get_next_twin(group)) {
char *group_name = xmlnode_get_data(group);
- if (group_name == NULL || *group_name == '\0')
+ if (group_name == NULL || *group_name == '\0' ||
+ g_strcmp0(group_name, _("Buddies")) == 0)
+ {
/* Changing this string? Look in add_purple_buddy_to_groups */
- group_name = g_strdup(_("Buddies"));
+ group_name = g_strdup(JABBER_ROSTER_DEFAULT_GROUP);
+ }
/*
* See the note in add_purple_buddy_to_groups; the core handles
@@ -322,7 +333,8 @@ static void jabber_roster_update(JabberS
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);
}
@@ -450,7 +462,7 @@ void jabber_roster_group_change(PurpleCo
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
@@ -468,7 +480,7 @@ void jabber_roster_group_rename(PurpleCo
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);
@@ -489,12 +501,14 @@ void jabber_roster_remove_buddy(PurpleCo
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\n", purple_buddy_get_name(buddy),
+ jabber_roster_group_get_global_name(group));
jabber_roster_update(gc->proto_data, name, groups);
} else {
@@ -512,3 +526,20 @@ void jabber_roster_remove_buddy(PurpleCo
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, _("Buddies")) == 0)
+ name = JABBER_ROSTER_DEFAULT_GROUP;
+ /* XXX: in 3.0.0 we have localized default name here too */
+
+ return name;
+}
diff --git a/libpurple/protocols/jabber/roster.h b/libpurple/protocols/jabber/roster.h
--- a/libpurple/protocols/jabber/roster.h
+++ b/libpurple/protocols/jabber/roster.h
@@ -24,6 +24,9 @@
#ifndef PURPLE_JABBER_ROSTER_H_
#define PURPLE_JABBER_ROSTER_H_
+/* it must *not* be localized */
+#define JABBER_ROSTER_DEFAULT_GROUP "Buddies"
+
#include "jabber.h"
void jabber_roster_request(JabberStream *js);
@@ -42,4 +45,7 @@ void jabber_roster_group_rename(PurpleCo
void jabber_roster_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy,
PurpleGroup *group);
+const gchar *
+jabber_roster_group_get_global_name(PurpleGroup *group);
+
#endif /* PURPLE_JABBER_ROSTER_H_ */
More information about the Commits
mailing list