/soc/2013/ankitkv/gobjectification: 728319cb659f: Merged default...
Ankit Vani
a at nevitus.org
Sat May 3 20:59:17 EDT 2014
Changeset: 728319cb659fddfaae9a17213122bd1eae67f3e1
Author: Ankit Vani <a at nevitus.org>
Date: 2014-05-04 06:28 +0530
Branch: soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/728319cb659f
Description:
Merged default branch
diffstat:
libpurple/blistnodetypes.c | 10 +-
libpurple/buddylist.c | 99 +-
libpurple/buddylist.h | 13 +-
libpurple/dnssrv.c | 2 +-
libpurple/image.c | 2 +-
libpurple/image.h | 2 +-
libpurple/internal.h | 20 +
libpurple/plugins/perl/perl-common.c | 23 +-
libpurple/protocols/gg/purplew.c | 7 +-
libpurple/protocols/gg/purplew.h | 2 -
libpurple/protocols/gg/roster.c | 6 +-
libpurple/protocols/jabber/google/google_roster.c | 7 +-
libpurple/protocols/jabber/roster.c | 63 +-
libpurple/protocols/jabber/roster.h | 6 +
libpurple/protocols/oscar/family_feedbag.c | 3 +-
libpurple/protocols/oscar/oscar.c | 12 +-
libpurple/protocols/simple/simple.c | 7 +-
libpurple/protocols/yahoo/ymsg.c | 6 +-
pidgin/gtk3compat.h | 8 +
pidgin/gtkblist.c | 3 +-
pidgin/gtkconv.c | 7 +
pidgin/gtkwebview.c | 11 +
pidgin/gtkwebview.h | 13 +-
pidgin/gtkwebviewtoolbar.c | 78 +-
pidgin/gtkwebviewtoolbar.h | 22 +
pidgin/pidginstock.c | 5 +
pidgin/pidginstock.h | 1 +
pidgin/pixmaps/Makefile.am | 1 +
pidgin/pixmaps/toolbar/16/insert-screenshot.png | Bin
pidgin/plugins/Makefile.am | 4 +
pidgin/plugins/gevolution/gevo-util.c | 10 +-
pidgin/plugins/gevolution/gevolution.c | 3 +-
pidgin/plugins/screencap.c | 1034 +++++++++++++++++++++
po/POTFILES.in | 1 +
34 files changed, 1382 insertions(+), 109 deletions(-)
diffs (truncated from 2196 to 300 lines):
diff --git a/libpurple/blistnodetypes.c b/libpurple/blistnodetypes.c
--- a/libpurple/blistnodetypes.c
+++ b/libpurple/blistnodetypes.c
@@ -531,7 +531,7 @@ PurpleGroup *purple_buddy_get_group(Purp
g_return_val_if_fail(PURPLE_IS_BUDDY(buddy), NULL);
if (PURPLE_BLIST_NODE(buddy)->parent == NULL)
- return NULL;
+ return purple_blist_get_default_group();
return PURPLE_GROUP(PURPLE_BLIST_NODE(buddy)->parent->parent);
}
@@ -1713,8 +1713,12 @@ purple_group_new(const char *name)
{
PurpleGroup *group;
- g_return_val_if_fail(name != NULL, NULL);
- g_return_val_if_fail(*name != '\0', NULL);
+ if (name == NULL || name[0] == '\0')
+ 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,11 +63,27 @@ 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 *
*********************************************************************/
+static gchar *
+purple_blist_fold_name(const gchar *name)
+{
+ gchar *res, *tmp;
+
+ if (name == NULL)
+ return NULL;
+
+ tmp = g_utf8_casefold(name, -1);
+ res = g_utf8_collate_key(tmp, -1);
+ g_free(tmp);
+
+ return res;
+}
+
static PurpleBlistNode *purple_blist_get_last_sibling(PurpleBlistNode *node)
{
PurpleBlistNode *n = node;
@@ -286,7 +302,8 @@ group_to_xmlnode(PurpleGroup *group)
PurpleBlistNode *cnode;
node = purple_xmlnode_new("group");
- purple_xmlnode_set_attrib(node, "name", purple_group_get_name(group));
+ if (group != purple_blist_get_default_group())
+ purple_xmlnode_set_attrib(node, "name", purple_group_get_name(group));
/* Write settings */
g_hash_table_foreach(purple_blist_node_get_settings(PURPLE_BLIST_NODE(group)),
@@ -346,12 +363,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))
@@ -584,9 +611,6 @@ parse_group(PurpleXmlNode *groupnode)
PurpleGroup *group;
PurpleXmlNode *cnode;
- if (!name)
- name = _("Buddies");
-
group = purple_group_new(name);
purple_blist_add_group(group,
purple_blist_get_last_sibling(purplebuddylist->root));
@@ -619,10 +643,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");
@@ -801,12 +833,14 @@ void purple_blist_update_buddies_cache(P
void purple_blist_update_groups_cache(PurpleGroup *group, const char *new_name)
{
- gchar* key = g_utf8_collate_key(purple_group_get_name(group), -1);
+ gchar* key;
+
+ key = purple_blist_fold_name(purple_group_get_name(group));
g_hash_table_remove(groups_cache, key);
g_free(key);
- key = g_utf8_collate_key(new_name, -1);
- g_hash_table_insert(groups_cache, key, group);
+ g_hash_table_insert(groups_cache,
+ purple_blist_fold_name(new_name), group);
}
void purple_blist_add_chat(PurpleChat *chat, PurpleGroup *group, PurpleBlistNode *node)
@@ -930,7 +964,7 @@ void purple_blist_add_buddy(PurpleBuddy
} else {
g = group;
if (g == NULL)
- g = purple_group_new(_("Buddies"));
+ g = purple_blist_get_default_group();
/* Add group to blist if isn't already on it. Fixes #2752. */
if (!purple_blist_find_group(purple_group_get_name(g))) {
purple_blist_add_group(g,
@@ -1074,14 +1108,8 @@ void purple_blist_add_contact(PurpleCont
g = PURPLE_GROUP(node->parent);
else if (group)
g = group;
- else {
- g = purple_blist_find_group(_("Buddies"));
- if (g == NULL) {
- g = purple_group_new(_("Buddies"));
- purple_blist_add_group(g,
- purple_blist_get_last_sibling(purplebuddylist->root));
- }
- }
+ else
+ g = purple_blist_get_default_group();
gnode = (PurpleBlistNode*)g;
cnode = (PurpleBlistNode*)contact;
@@ -1242,7 +1270,7 @@ void purple_blist_add_group(PurpleGroup
if (gnode->next)
gnode->next->prev = gnode->prev;
} else {
- key = g_utf8_collate_key(purple_group_get_name(group), -1);
+ key = purple_blist_fold_name(purple_group_get_name(group));
g_hash_table_insert(groups_cache, key, group);
}
@@ -1467,6 +1495,9 @@ void purple_blist_remove_group(PurpleGro
g_return_if_fail(PURPLE_IS_GROUP(group));
+ if (group == purple_blist_get_default_group())
+ purple_debug_warning("buddylist", "cannot remove default group");
+
node = (PurpleBlistNode *)group;
/* Make sure the group is empty */
@@ -1481,7 +1512,7 @@ void purple_blist_remove_group(PurpleGro
if (node->next)
node->next->prev = node->prev;
- key = g_utf8_collate_key(purple_group_get_name(group), -1);
+ key = purple_blist_fold_name(purple_group_get_name(group));
g_hash_table_remove(groups_cache, key);
g_free(key);
@@ -1600,15 +1631,35 @@ PurpleGroup *purple_blist_find_group(con
PurpleGroup *group;
g_return_val_if_fail(PURPLE_IS_BUDDY_LIST(purplebuddylist), NULL);
- g_return_val_if_fail((name != NULL) && (*name != '\0'), NULL);
- key = g_utf8_collate_key(name, -1);
+ if (name == NULL || name[0] == '\0')
+ 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 = purple_blist_fold_name(name);
group = g_hash_table_lookup(groups_cache, key);
g_free(key);
return group;
}
+PurpleGroup *
+purple_blist_get_default_group(void)
+{
+ PurpleGroup *group;
+
+ group = purple_blist_find_group(PURPLE_BLIST_DEFAULT_GROUP_NAME);
+ if (!group) {
+ group = purple_group_new(PURPLE_BLIST_DEFAULT_GROUP_NAME);
+ purple_blist_add_group(group, NULL);
+ }
+
+ return group;
+}
+
PurpleChat *
purple_blist_find_chat(PurpleAccount *account, const char *name)
{
@@ -1870,6 +1921,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)
@@ -2010,6 +2066,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/buddylist.h b/libpurple/buddylist.h
--- a/libpurple/buddylist.h
+++ b/libpurple/buddylist.h
@@ -47,6 +47,8 @@ typedef struct _PurpleBuddyListClass Pu
typedef struct _PurpleBlistUiOps PurpleBlistUiOps;
+#define PURPLE_BLIST_DEFAULT_GROUP_NAME _("Buddies")
+
/**************************************************************************/
/* Data Structures */
/**************************************************************************/
@@ -281,7 +283,7 @@ void purple_blist_add_chat(PurpleChat *c
*
* The buddy will be inserted right after node or prepended to the
* group if node is NULL. If both are NULL, the buddy will be added to
- * the "Buddies" group.
+ * the default group.
*/
void purple_blist_add_buddy(PurpleBuddy *buddy, PurpleContact *contact, PurpleGroup *group, PurpleBlistNode *node);
@@ -399,6 +401,15 @@ GSList *purple_blist_find_buddies(Purple
PurpleGroup *purple_blist_find_group(const char *name);
/**
+ * purple_blist_get_default_group:
+ *
+ * Finds or creates default group.
+ *
+ * Returns: The default group.
+ */
+PurpleGroup *purple_blist_get_default_group(void);
+
+/**
* purple_blist_find_chat:
* @account: The chat's account.
* @name: The chat's name.
diff --git a/libpurple/dnssrv.c b/libpurple/dnssrv.c
--- a/libpurple/dnssrv.c
+++ b/libpurple/dnssrv.c
@@ -197,11 +197,11 @@ srv_reorder(GList *list, int num)
*/
cur = list;
while (container_list) {
+ g_return_if_fail(cur);
container_list = select_random_response(container_list, &container);
cur->data = container->response;
g_free(container);
More information about the Commits
mailing list