/pidgin/main: 407e0fa6f7d1: blist: don't localize roster group n...
Tomasz Wasilczyk
twasilczyk at pidgin.im
Wed Apr 30 13:44:09 EDT 2014
Changeset: 407e0fa6f7d12959c012a80e68fb80eb5ea842a8
Author: Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date: 2014-04-30 19:44 +0200
Branch: default
URL: https://hg.pidgin.im/pidgin/main/rev/407e0fa6f7d1
Description:
blist: don't localize roster group name to avoid contact splitting
diffstat:
libpurple/protocols/jabber/google/google_roster.c | 7 ++-
libpurple/protocols/jabber/roster.c | 53 ++++++++++++++++------
libpurple/protocols/jabber/roster.h | 6 ++
3 files changed, 50 insertions(+), 16 deletions(-)
diffs (171 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, PurpleXmlNode *query, PurpleXmlNode *item)
{
@@ -127,7 +128,8 @@ void jabber_google_roster_add_deny(Jabbe
g = purple_buddy_get_group(b);
group = purple_xmlnode_new_child(item, "group");
- purple_xmlnode_insert_data(group, purple_group_get_name(g), -1);
+ purple_xmlnode_insert_data(group,
+ jabber_roster_group_get_global_name(g), -1);
buddies = g_slist_delete_link(buddies, buddies);
} while (buddies);
@@ -185,7 +187,8 @@ void jabber_google_roster_rem_deny(Jabbe
g = purple_buddy_get_group(b);
group = purple_xmlnode_new_child(item, "group");
- purple_xmlnode_insert_data(group, purple_group_get_name(g), -1);
+ purple_xmlnode_insert_data(group,
+ jabber_roster_group_get_global_name(g), -1);
buddies = g_slist_delete_link(buddies, buddies);
} while (buddies);
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,8 +114,7 @@ static void add_purple_buddy_to_groups(J
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 @@ 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 == 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 @@ static void add_purple_buddy_to_groups(J
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 @@ void jabber_roster_parse(JabberStream *j
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 @@ 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);
}
@@ -451,7 +458,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
@@ -469,7 +476,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);
@@ -490,12 +497,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", 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 @@ 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, PURPLE_BLIST_DEFAULT_GROUP_NAME) == 0)
+ name = JABBER_ROSTER_DEFAULT_GROUP;
+
+ 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