/soc/2013/ankitkv/gobjectification: 7ffe330ea8ea: Merged default...

Ankit Vani a at nevitus.org
Sun Mar 30 21:58:47 EDT 2014


Changeset: 7ffe330ea8eacadb6222f67afa08e97245f56548
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2014-03-31 07:25 +0530
Branch:	 soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/7ffe330ea8ea

Description:

Merged default branch

diffstat:

 .hgignore                                     |    1 +
 configure.ac                                  |   11 +
 finch/gntconv.c                               |   13 +-
 libpurple/Makefile.am                         |    4 +
 libpurple/conversationtypes.c                 |   70 +-
 libpurple/conversationtypes.h                 |   14 +-
 libpurple/memorypool.c                        |  362 ++++++++++++
 libpurple/memorypool.h                        |  156 +++++
 libpurple/plugins/joinpart.c                  |    2 +-
 libpurple/plugins/perl/common/Conversation.xs |    6 +-
 libpurple/protocols/yahoo/yahoochat.c         |   31 +-
 libpurple/protocols/yahoo/ymsg.c              |   11 +-
 libpurple/request-datasheet.c                 |    3 +-
 libpurple/tests/Makefile.am                   |    1 +
 libpurple/tests/check_libpurple.c             |    1 +
 libpurple/tests/test_trie.c                   |  172 ++++++
 libpurple/tests/tests.h                       |    1 +
 libpurple/trie.c                              |  725 ++++++++++++++++++++++++++
 libpurple/trie.h                              |  162 +++++
 pidgin/gtkblist.c                             |   11 +-
 pidgin/gtkconv.c                              |   15 +-
 pidgin/gtkdebug.c                             |   15 +
 pidgin/gtkprefs.c                             |    2 +-
 pidgin/gtkwebview.c                           |   44 +
 24 files changed, 1760 insertions(+), 73 deletions(-)

diffs (truncated from 2248 to 300 lines):

diff --git a/.hgignore b/.hgignore
--- a/.hgignore
+++ b/.hgignore
@@ -85,6 +85,7 @@ libpurple/plugins/perl/common/lib
 libpurple/purple-client-bindings.[ch]
 libpurple/purple-client-example
 libpurple/purple.h$
+libpurple/tests/core
 libpurple/tests/check_libpurple
 libpurple/tests/libpurple..
 ^libpurple/tests/test-suite\.log$
diff --git a/configure.ac b/configure.ac
--- a/configure.ac
+++ b/configure.ac
@@ -1537,6 +1537,17 @@ if test "x$enable_clang_address_sanitize
 	CFLAGS="$CFLAGS -faddress-sanitizer -g -fno-omit-frame-pointer -fno-inline -fno-optimize-sibling-calls"
 fi
 
+
+AC_ARG_ENABLE(glib-errors-trace, [AS_HELP_STRING([--enable-glib-errors-trace], [print backtraces for glib errors])], enable_glibtrace="$enableval", enable_glibtrace="no")
+if test "x$enable_glibtrace" = "xyes"; then
+	if test "x$have_clang" = "xyes"; then
+		AC_MSG_ERROR([--enable-glib-errors-trace doesn't work with clang])
+	fi
+	AC_DEFINE(ENABLE_GLIBTRACE, 1, [Define if backtraces should be printed for glib errors.])
+	dnl CFLAGS="$CFLAGS -rdynamic"
+	CFLAGS="$CFLAGS -rdynamic"
+fi
+
 dnl #######################################################################
 dnl # Check for D-Bus libraries
 dnl #######################################################################
diff --git a/finch/gntconv.c b/finch/gntconv.c
--- a/finch/gntconv.c
+++ b/finch/gntconv.c
@@ -387,22 +387,27 @@ cleared_message_history_cb(PurpleConvers
 static void
 gg_extended_menu(FinchConv *ggc)
 {
-	GntWidget *sub;
+	GntMenu *sub;
 	GList *list;
 
-	sub = gnt_menu_new(GNT_MENU_POPUP);
-	gnt_menuitem_set_submenu(ggc->plugins, GNT_MENU(sub));
+	g_return_if_fail(ggc != NULL);
+
+	sub = GNT_MENU(gnt_menu_new(GNT_MENU_POPUP));
+	gnt_menuitem_set_submenu(ggc->plugins, sub);
 
 	for (list = purple_conversation_get_extended_menu(ggc->active_conv);
 			list; list = g_list_delete_link(list, list))
 	{
-		finch_append_menu_action(GNT_MENU(sub), list->data, ggc->active_conv);
+		finch_append_menu_action(sub, list->data, ggc->active_conv);
 	}
 }
 
 static void
 conv_updated(PurpleConversation *conv, PurpleConversationUpdateType type)
 {
+	if (purple_conversation_get_ui_data(conv) == NULL)
+		return;
+
 	if (type == PURPLE_CONVERSATION_UPDATE_FEATURES) {
 		gg_extended_menu(purple_conversation_get_ui_data(conv));
 	}
diff --git a/libpurple/Makefile.am b/libpurple/Makefile.am
--- a/libpurple/Makefile.am
+++ b/libpurple/Makefile.am
@@ -81,6 +81,7 @@ purple_coresources = \
 	media/enum-types.c \
 	media.c \
 	mediamanager.c \
+	memorypool.c \
 	mime.c \
 	nat-pmp.c \
 	network.c \
@@ -114,6 +115,7 @@ purple_coresources = \
 	theme.c \
 	theme-loader.c \
 	theme-manager.c \
+	trie.c \
 	upnp.c \
 	util.c \
 	version.c \
@@ -155,6 +157,7 @@ purple_coreheaders = \
 	media.h \
 	media-gst.h \
 	mediamanager.h \
+	memorypool.h \
 	mime.h \
 	nat-pmp.h \
 	network.h \
@@ -188,6 +191,7 @@ purple_coreheaders = \
 	theme.h \
 	theme-loader.h \
 	theme-manager.h \
+	trie.h \
 	upnp.h \
 	util.h \
 	whiteboard.h \
diff --git a/libpurple/conversationtypes.c b/libpurple/conversationtypes.c
--- a/libpurple/conversationtypes.c
+++ b/libpurple/conversationtypes.c
@@ -48,8 +48,6 @@ typedef struct _PurpleChatUserPrivate  P
  */
 struct _PurpleChatConversationPrivate
 {
-	GList *in_room;     /* The users in the room.
-	                       Deprecated: Will be removed in 3.0.0 TODO */
 	GList *ignored;     /* Ignored users.                            */
 	char  *who;         /* The person who set the topic.             */
 	char  *topic;       /* The topic.                                */
@@ -616,7 +614,17 @@ purple_chat_conversation_get_users(const
 
 	g_return_val_if_fail(priv != NULL, NULL);
 
-	return priv->in_room;
+	return g_hash_table_get_values(priv->users);
+}
+
+guint
+purple_chat_conversation_get_users_count(const PurpleChatConversation *chat)
+{
+	PurpleChatConversationPrivate *priv = PURPLE_CHAT_CONVERSATION_GET_PRIVATE(chat);
+
+	g_return_val_if_fail(priv != NULL, 0);
+
+	return g_hash_table_size(priv->users);
 }
 
 void
@@ -914,9 +922,9 @@ purple_chat_conversation_add_users(Purpl
 
 		chatuser = purple_chat_user_new(chat, user, alias, flag);
 
-		priv->in_room = g_list_prepend(priv->in_room, chatuser);
 		g_hash_table_replace(priv->users,
-				g_strdup(purple_chat_user_get_name(chatuser)), chatuser);
+			g_strdup(purple_chat_user_get_name(chatuser)),
+			chatuser);
 
 		cbuddies = g_list_prepend(cbuddies, chatuser);
 
@@ -1013,20 +1021,16 @@ purple_chat_conversation_rename_user(Pur
 	flags = purple_chat_user_get_flags(purple_chat_conversation_find_user(chat, old_user));
 	cb = purple_chat_user_new(chat, new_user, new_alias, flags);
 
-	priv->in_room = g_list_prepend(priv->in_room, cb);
 	g_hash_table_replace(priv->users,
-			g_strdup(purple_chat_user_get_name(cb)), cb);
+		g_strdup(purple_chat_user_get_name(cb)), cb);
 
 	if (ops != NULL && ops->chat_rename_user != NULL)
 		ops->chat_rename_user(chat, old_user, new_user, new_alias);
 
 	cb = purple_chat_conversation_find_user(chat, old_user);
 
-	if (cb) {
-		priv->in_room = g_list_remove(priv->in_room, cb);
+	if (cb)
 		g_hash_table_remove(priv->users, purple_chat_user_get_name(cb));
-		g_object_unref(cb);
-	}
 
 	if (purple_chat_conversation_is_ignored_user(chat, old_user)) {
 		purple_chat_conversation_unignore(chat, old_user);
@@ -1120,9 +1124,8 @@ purple_chat_conversation_remove_users(Pu
 		cb = purple_chat_conversation_find_user(chat, user);
 
 		if (cb) {
-			priv->in_room = g_list_remove(priv->in_room, cb);
-			g_hash_table_remove(priv->users, purple_chat_user_get_name(cb));
-			g_object_unref(cb);
+			g_hash_table_remove(priv->users,
+				purple_chat_user_get_name(cb));
 		}
 
 		/* NOTE: Don't remove them from ignored in case they re-enter. */
@@ -1169,43 +1172,34 @@ void
 purple_chat_conversation_clear_users(PurpleChatConversation *chat)
 {
 	PurpleConversationUiOps *ops;
-	GList *users;
-	GList *l;
-	GList *names = NULL;
+	GHashTableIter it;
 	PurpleChatConversationPrivate *priv = PURPLE_CHAT_CONVERSATION_GET_PRIVATE(chat);
+	gchar *name;
 
 	g_return_if_fail(priv != NULL);
 
-	ops   = purple_conversation_get_ui_ops(PURPLE_CONVERSATION(chat));
-	users = priv->in_room;
+	ops = purple_conversation_get_ui_ops(PURPLE_CONVERSATION(chat));
 
 	if (ops != NULL && ops->chat_remove_users != NULL) {
-		for (l = users; l; l = l->next) {
-			PurpleChatUser *cb = l->data;
-			names = g_list_prepend(names,
-					(gchar *) purple_chat_user_get_name(cb));
-		}
+		GList *names = NULL;
+
+		g_hash_table_iter_init(&it, priv->users);
+		while (g_hash_table_iter_next(&it, (gpointer*)&name, NULL))
+			names = g_list_prepend(names, name);
+
 		ops->chat_remove_users(chat, names);
 		g_list_free(names);
 	}
 
-	for (l = users; l; l = l->next)
-	{
-		PurpleChatUser *cb = l->data;
-		const char *name = purple_chat_user_get_name(cb);
-
+	g_hash_table_iter_init(&it, priv->users);
+	while (g_hash_table_iter_next(&it, (gpointer*)&name, NULL)) {
 		purple_signal_emit(purple_conversations_get_handle(),
 						 "chat-user-leaving", chat, name, NULL);
 		purple_signal_emit(purple_conversations_get_handle(),
 						 "chat-user-left", chat, name, NULL);
-
-		g_object_unref(cb);
 	}
 
 	g_hash_table_remove_all(priv->users);
-
-	g_list_free(users);
-	priv->in_room = NULL;
 }
 
 void purple_chat_conversation_set_nick(PurpleChatConversation *chat, const char *nick) {
@@ -1432,7 +1426,7 @@ static void purple_chat_conversation_ini
 			PurpleChatConversation);
 
 	priv->users = g_hash_table_new_full(_purple_conversation_user_hash,
-			_purple_conversation_user_equal, g_free, NULL);
+		_purple_conversation_user_equal, g_free, g_object_unref);
 }
 
 /* Called when done constructing */
@@ -1466,11 +1460,7 @@ purple_chat_conversation_dispose(GObject
 	PurpleChatConversationPrivate *priv =
 			PURPLE_CHAT_CONVERSATION_GET_PRIVATE(object);
 
-	if (priv->in_room) {
-		g_list_foreach(priv->in_room, (GFunc)g_object_unref, NULL);
-		g_list_free(priv->in_room);
-		priv->in_room = NULL;
-	}
+	g_hash_table_remove_all(priv->users);
 
 	G_OBJECT_CLASS(parent_class)->dispose(object);
 }
diff --git a/libpurple/conversationtypes.h b/libpurple/conversationtypes.h
--- a/libpurple/conversationtypes.h
+++ b/libpurple/conversationtypes.h
@@ -380,11 +380,23 @@ PurpleChatConversation *purple_chat_conv
  * Returns a list of users in the chat room.  The members of the list
  * are PurpleChatUser objects.
  *
- * Returns: (transfer none): The list of users.
+ * Returns: (transfer container): The list of users. Use g_list_free() when done
+ *          using the list.
  */
 GList *purple_chat_conversation_get_users(const PurpleChatConversation *chat);
 
 /**
+ * purple_chat_conversation_get_users_count:
+ * @chat: The chat.
+ *
+ * Returns count of users in the chat room.
+ *
+ * Returns: The count of users in the chat room.
+ */
+guint
+purple_chat_conversation_get_users_count(const PurpleChatConversation *chat);
+
+/**
  * purple_chat_conversation_ignore:
  * @chat: The chat.
  * @name: The name of the user.
diff --git a/libpurple/memorypool.c b/libpurple/memorypool.c
new file mode 100644
--- /dev/null
+++ b/libpurple/memorypool.c
@@ -0,0 +1,362 @@
+/*
+ * Purple
+ *
+ * Purple is the legal property of its developers, whose names are too
+ * numerous to list here. Please refer to the COPYRIGHT file distributed
+ * with this source distribution
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at



More information about the Commits mailing list