/pidgin/main: 87fd9126902a: blist: store localized name of defau...
Tomasz Wasilczyk
twasilczyk at pidgin.im
Wed Apr 30 14:23:54 EDT 2014
Changeset: 87fd9126902a8a3a78a9b8bb29fa56a8bf9493f5
Author: Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date: 2014-04-30 20:23 +0200
Branch: default
URL: https://hg.pidgin.im/pidgin/main/rev/87fd9126902a
Description:
blist: store localized name of default group to avoid contact splitting
diffstat:
libpurple/blistnodetypes.c | 2 ++
libpurple/buddylist.c | 29 +++++++++++++++++++++++++++++
libpurple/internal.h | 14 ++++++++++++++
libpurple/protocols/jabber/roster.c | 7 +++++++
4 files changed, 52 insertions(+), 0 deletions(-)
diffs (142 lines):
diff --git a/libpurple/blistnodetypes.c b/libpurple/blistnodetypes.c
--- a/libpurple/blistnodetypes.c
+++ b/libpurple/blistnodetypes.c
@@ -1727,6 +1727,8 @@ purple_group_new(const char *name)
name = PURPLE_BLIST_DEFAULT_GROUP_NAME;
if (g_strcmp0(name, "Buddies") == 0)
name = PURPLE_BLIST_DEFAULT_GROUP_NAME;
+ if (g_strcmp0(name, _purple_blist_get_localized_default_group_name()) == 0)
+ name = PURPLE_BLIST_DEFAULT_GROUP_NAME;
group = purple_blist_find_group(name);
if (group != NULL)
diff --git a/libpurple/buddylist.c b/libpurple/buddylist.c
--- a/libpurple/buddylist.c
+++ b/libpurple/buddylist.c
@@ -63,6 +63,7 @@ static GHashTable *groups_cache = NULL;
static guint save_timer = 0;
static gboolean blist_loaded = FALSE;
+static gchar *localized_default_group_name = NULL;
/*********************************************************************
* Private utility functions *
@@ -347,12 +348,22 @@ blist_to_xmlnode(void)
PurpleXmlNode *node, *child, *grandchild;
PurpleBlistNode *gnode;
GList *cur;
+ const gchar *localized_default;
node = purple_xmlnode_new("purple");
purple_xmlnode_set_attrib(node, "version", "1.0");
/* Write groups */
child = purple_xmlnode_new_child(node, "blist");
+
+ localized_default = localized_default_group_name;
+ if (g_strcmp0(_("Buddies"), "Buddies") != 0)
+ localized_default = _("Buddies");
+ if (localized_default != NULL) {
+ purple_xmlnode_set_attrib(child,
+ "localized-default-group", localized_default);
+ }
+
for (gnode = purplebuddylist->root; gnode != NULL; gnode = gnode->next)
{
if (purple_blist_node_is_transient(gnode))
@@ -617,10 +628,18 @@ load_blist(void)
blist = purple_xmlnode_get_child(purple, "blist");
if (blist) {
PurpleXmlNode *groupnode;
+
+ localized_default_group_name = g_strdup(
+ purple_xmlnode_get_attrib(blist,
+ "localized-default-group"));
+
for (groupnode = purple_xmlnode_get_child(blist, "group"); groupnode != NULL;
groupnode = purple_xmlnode_get_next_twin(groupnode)) {
parse_group(groupnode);
}
+ } else {
+ g_free(localized_default_group_name);
+ localized_default_group_name = NULL;
}
privacy = purple_xmlnode_get_child(purple, "privacy");
@@ -1600,6 +1619,8 @@ PurpleGroup *purple_blist_find_group(con
name = PURPLE_BLIST_DEFAULT_GROUP_NAME;
if (g_strcmp0(name, "Buddies") == 0)
name = PURPLE_BLIST_DEFAULT_GROUP_NAME;
+ if (g_strcmp0(name, localized_default_group_name) == 0)
+ name = PURPLE_BLIST_DEFAULT_GROUP_NAME;
key = g_utf8_collate_key(name, -1);
group = g_hash_table_lookup(groups_cache, key);
@@ -1885,6 +1906,11 @@ purple_blist_get_ui_ops(void)
return blist_ui_ops;
}
+const gchar *
+_purple_blist_get_localized_default_group_name(void)
+{
+ return localized_default_group_name;
+}
void *
purple_blist_get_handle(void)
@@ -2025,6 +2051,9 @@ purple_blist_uninit(void)
g_object_unref(purplebuddylist);
purplebuddylist = NULL;
+ g_free(localized_default_group_name);
+ localized_default_group_name = NULL;
+
purple_signals_disconnect_by_handle(purple_blist_get_handle());
purple_signals_unregister_by_instance(purple_blist_get_handle());
}
diff --git a/libpurple/internal.h b/libpurple/internal.h
--- a/libpurple/internal.h
+++ b/libpurple/internal.h
@@ -317,4 +317,18 @@ void _purple_conversations_update_cache(
*/
int *_purple_statuses_get_primitive_scores(void);
+/**
+ * _purple_blist_get_localized_default_group_name:
+ *
+ * Returns the name of default group for previously used non-English
+ * localization. It's used for merging default group, in case when roster
+ * contains localized name.
+ *
+ * Please note, prpls shouldn't save default group name depending on current
+ * locale. So, this function is mostly for libpurple2 compatibility. And for
+ * improperly written prpls.
+ */
+const gchar *
+_purple_blist_get_localized_default_group_name(void);
+
#endif /* _PURPLE_INTERNAL_H_ */
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
@@ -143,6 +143,11 @@ static void add_purple_buddy_to_groups(J
l = g_slist_find_custom(groups, JABBER_ROSTER_DEFAULT_GROUP,
(GCompareFunc)purple_utf8_strcasecmp);
}
+ if (!l && g == purple_blist_get_default_group()) {
+ l = g_slist_find_custom(groups,
+ _purple_blist_get_localized_default_group_name(),
+ (GCompareFunc)purple_utf8_strcasecmp);
+ }
if (l) {
/* The buddy is already on the local list. Update info. */
@@ -535,6 +540,8 @@ jabber_roster_group_get_global_name(Purp
name = JABBER_ROSTER_DEFAULT_GROUP;
else if (g_strcmp0(name, PURPLE_BLIST_DEFAULT_GROUP_NAME) == 0)
name = JABBER_ROSTER_DEFAULT_GROUP;
+ else if (g_strcmp0(name, _purple_blist_get_localized_default_group_name()) == 0)
+ name = JABBER_ROSTER_DEFAULT_GROUP;
return name;
}
More information about the Commits
mailing list