/soc/2013/ankitkv/gobjectification: 3d6f7d9dc21d: Refactored acc...

Ankit Vani a at nevitus.org
Wed Jul 17 14:34:56 EDT 2013


Changeset: 3d6f7d9dc21d99df310525f0914b530f4f956450
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-07-18 00:04 +0530
Branch:	 soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/3d6f7d9dc21d

Description:

Refactored account, buddylist, certificate to use GType and GValue instead of PurpleType and PurpleValue

diffstat:

 libpurple/account.c     |   30 +++++-----
 libpurple/accounts.c    |  122 ++++++++++++++++++-----------------------------
 libpurple/buddylist.c   |   88 ++++++++++++----------------------
 libpurple/certificate.c |   12 +---
 4 files changed, 97 insertions(+), 155 deletions(-)

diffs (truncated from 414 to 300 lines):

diff --git a/libpurple/account.c b/libpurple/account.c
--- a/libpurple/account.c
+++ b/libpurple/account.c
@@ -2433,16 +2433,16 @@ status_attr_to_xmlnode(const PurpleStatu
 	const char *id;
 	char *value = NULL;
 	PurpleStatusAttr *default_attr;
-	PurpleValue *default_value;
-	PurpleType attr_type;
-	PurpleValue *attr_value;
+	GValue *default_value;
+	GType attr_type;
+	GValue *attr_value;
 
 	id = purple_status_attr_get_id(attr);
 	g_return_val_if_fail(id, NULL);
 
 	attr_value = purple_status_get_attr_value(status, id);
 	g_return_val_if_fail(attr_value, NULL);
-	attr_type = purple_value_get_type(attr_value);
+	attr_type = G_VALUE_TYPE(attr_value);
 
 	/*
 	 * If attr_value is a different type than it should be
@@ -2450,32 +2450,32 @@ status_attr_to_xmlnode(const PurpleStatu
 	 */
 	default_attr = purple_status_type_get_attr(type, id);
 	default_value = purple_status_attr_get_value(default_attr);
-	if (attr_type != purple_value_get_type(default_value))
+	if (attr_type != G_VALUE_TYPE(default_value))
 		return NULL;
 
 	/*
 	 * If attr_value is the same as the default for this status
 	 * then there is no need to write it to the file.
 	 */
-	if (attr_type == PURPLE_TYPE_STRING)
+	if (attr_type == G_TYPE_STRING)
 	{
-		const char *string_value = purple_value_get_string(attr_value);
-		const char *default_string_value = purple_value_get_string(default_value);
+		const char *string_value = g_value_get_string(attr_value);
+		const char *default_string_value = g_value_get_string(default_value);
 		if (purple_strequal(string_value, default_string_value))
 			return NULL;
-		value = g_strdup(purple_value_get_string(attr_value));
+		value = g_strdup(g_value_get_string(attr_value));
 	}
-	else if (attr_type == PURPLE_TYPE_INT)
+	else if (attr_type == G_TYPE_INT)
 	{
-		int int_value = purple_value_get_int(attr_value);
-		if (int_value == purple_value_get_int(default_value))
+		int int_value = g_value_get_int(attr_value);
+		if (int_value == g_value_get_int(default_value))
 			return NULL;
 		value = g_strdup_printf("%d", int_value);
 	}
-	else if (attr_type == PURPLE_TYPE_BOOLEAN)
+	else if (attr_type == G_TYPE_BOOLEAN)
 	{
-		gboolean boolean_value = purple_value_get_boolean(attr_value);
-		if (boolean_value == purple_value_get_boolean(default_value))
+		gboolean boolean_value = g_value_get_boolean(attr_value);
+		if (boolean_value == g_value_get_boolean(default_value))
 			return NULL;
 		value = g_strdup(boolean_value ?
 								"true" : "false");
diff --git a/libpurple/accounts.c b/libpurple/accounts.c
--- a/libpurple/accounts.c
+++ b/libpurple/accounts.c
@@ -28,6 +28,7 @@
 #include "core.h"
 #include "dbus-maybe.h"
 #include "debug.h"
+#include "enums.h"
 #include "network.h"
 #include "pounce.h"
 
@@ -248,7 +249,7 @@ parse_status_attrs(xmlnode *node, Purple
 {
 	GList *list = NULL;
 	xmlnode *child;
-	PurpleValue *attr_value;
+	GValue *attr_value;
 
 	for (child = xmlnode_get_child(node, "attribute"); child != NULL;
 			child = xmlnode_get_next_twin(child))
@@ -265,13 +266,13 @@ parse_status_attrs(xmlnode *node, Purple
 
 		list = g_list_append(list, (char *)id);
 
-		switch (purple_value_get_type(attr_value))
+		switch (G_VALUE_TYPE(attr_value))
 		{
-			case PURPLE_TYPE_STRING:
+			case G_TYPE_STRING:
 				list = g_list_append(list, (char *)value);
 				break;
-			case PURPLE_TYPE_INT:
-			case PURPLE_TYPE_BOOLEAN:
+			case G_TYPE_INT:
+			case G_TYPE_BOOLEAN:
 			{
 				int v;
 				if (sscanf(value, "%d", &v) == 1)
@@ -909,114 +910,85 @@ purple_accounts_init(void)
 	void *conn_handle = purple_connections_get_handle();
 
 	purple_signal_register(handle, "account-connecting",
-						 purple_marshal_VOID__POINTER, NULL, 1,
-						 purple_value_new(PURPLE_TYPE_SUBTYPE,
-										PURPLE_SUBTYPE_ACCOUNT));
+						 purple_marshal_VOID__POINTER, G_TYPE_NONE, 1,
+						 PURPLE_TYPE_ACCOUNT);
 
 	purple_signal_register(handle, "account-disabled",
-						 purple_marshal_VOID__POINTER, NULL, 1,
-						 purple_value_new(PURPLE_TYPE_SUBTYPE,
-										PURPLE_SUBTYPE_ACCOUNT));
+						 purple_marshal_VOID__POINTER, G_TYPE_NONE, 1,
+						 PURPLE_TYPE_ACCOUNT);
 
 	purple_signal_register(handle, "account-enabled",
-						 purple_marshal_VOID__POINTER, NULL, 1,
-						 purple_value_new(PURPLE_TYPE_SUBTYPE,
-										PURPLE_SUBTYPE_ACCOUNT));
+						 purple_marshal_VOID__POINTER, G_TYPE_NONE, 1,
+						 PURPLE_TYPE_ACCOUNT);
 
 	purple_signal_register(handle, "account-setting-info",
-						 purple_marshal_VOID__POINTER_POINTER, NULL, 2,
-						 purple_value_new(PURPLE_TYPE_SUBTYPE,
-										PURPLE_SUBTYPE_ACCOUNT),
-						 purple_value_new(PURPLE_TYPE_STRING));
+						 purple_marshal_VOID__POINTER_POINTER, G_TYPE_NONE, 2,
+						 PURPLE_TYPE_ACCOUNT, G_TYPE_STRING);
 
 	purple_signal_register(handle, "account-set-info",
-						 purple_marshal_VOID__POINTER_POINTER, NULL, 2,
-						 purple_value_new(PURPLE_TYPE_SUBTYPE,
-										PURPLE_SUBTYPE_ACCOUNT),
-						 purple_value_new(PURPLE_TYPE_STRING));
+						 purple_marshal_VOID__POINTER_POINTER, G_TYPE_NONE, 2,
+						 PURPLE_TYPE_ACCOUNT, G_TYPE_STRING);
 
 	purple_signal_register(handle, "account-created",
-						 purple_marshal_VOID__POINTER, NULL, 1,
-						 purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_ACCOUNT));
+						 purple_marshal_VOID__POINTER, G_TYPE_NONE, 1,
+						 PURPLE_TYPE_ACCOUNT);
 
 	purple_signal_register(handle, "account-destroying",
-						 purple_marshal_VOID__POINTER, NULL, 1,
-						 purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_ACCOUNT));
+						 purple_marshal_VOID__POINTER, G_TYPE_NONE, 1,
+						 PURPLE_TYPE_ACCOUNT);
 
 	purple_signal_register(handle, "account-added",
-						 purple_marshal_VOID__POINTER, NULL, 1,
-						 purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_ACCOUNT));
+						 purple_marshal_VOID__POINTER, G_TYPE_NONE, 1,
+						 PURPLE_TYPE_ACCOUNT);
 
 	purple_signal_register(handle, "account-removed",
-						 purple_marshal_VOID__POINTER, NULL, 1,
-						 purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_ACCOUNT));
+						 purple_marshal_VOID__POINTER, G_TYPE_NONE, 1,
+						 PURPLE_TYPE_ACCOUNT);
 
 	purple_signal_register(handle, "account-status-changed",
-						 purple_marshal_VOID__POINTER_POINTER_POINTER, NULL, 3,
-						 purple_value_new(PURPLE_TYPE_SUBTYPE,
-										PURPLE_SUBTYPE_ACCOUNT),
-						 purple_value_new(PURPLE_TYPE_SUBTYPE,
-										PURPLE_SUBTYPE_STATUS),
-						 purple_value_new(PURPLE_TYPE_SUBTYPE,
-										PURPLE_SUBTYPE_STATUS));
+						 purple_marshal_VOID__POINTER_POINTER_POINTER,
+						 G_TYPE_NONE, 3, PURPLE_TYPE_ACCOUNT,
+						 PURPLE_TYPE_STATUS, PURPLE_TYPE_STATUS);
 
 	purple_signal_register(handle, "account-actions-changed",
-						 purple_marshal_VOID__POINTER, NULL, 1,
-						 purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_ACCOUNT));
+						 purple_marshal_VOID__POINTER, G_TYPE_NONE, 1,
+						 PURPLE_TYPE_ACCOUNT);
 
 	purple_signal_register(handle, "account-alias-changed",
-						 purple_marshal_VOID__POINTER_POINTER, NULL, 2,
-						 purple_value_new(PURPLE_TYPE_SUBTYPE,
-							 			PURPLE_SUBTYPE_ACCOUNT),
-						 purple_value_new(PURPLE_TYPE_STRING));
+						 purple_marshal_VOID__POINTER_POINTER, G_TYPE_NONE, 2,
+						 PURPLE_TYPE_ACCOUNT, G_TYPE_STRING);
 
 	purple_signal_register(handle, "account-authorization-requested",
 						purple_marshal_INT__POINTER_POINTER_POINTER,
-						purple_value_new(PURPLE_TYPE_INT), 4,
-						purple_value_new(PURPLE_TYPE_SUBTYPE,
-										PURPLE_SUBTYPE_ACCOUNT),
-						purple_value_new(PURPLE_TYPE_STRING),
-						purple_value_new(PURPLE_TYPE_STRING),
-						purple_value_new(PURPLE_TYPE_STRING));
+						G_TYPE_INT, 4, PURPLE_TYPE_ACCOUNT, G_TYPE_STRING,
+						G_TYPE_STRING, G_TYPE_STRING);
 
 	purple_signal_register(handle, "account-authorization-denied",
-						purple_marshal_VOID__POINTER_POINTER, NULL, 3,
-						purple_value_new(PURPLE_TYPE_SUBTYPE,
-										PURPLE_SUBTYPE_ACCOUNT),
-						purple_value_new(PURPLE_TYPE_STRING),
-						purple_value_new(PURPLE_TYPE_STRING));
+						purple_marshal_VOID__POINTER_POINTER, G_TYPE_NONE, 3,
+						PURPLE_TYPE_ACCOUNT, G_TYPE_STRING, G_TYPE_STRING);
 
 	purple_signal_register(handle, "account-authorization-granted",
-						purple_marshal_VOID__POINTER_POINTER, NULL, 3,
-						purple_value_new(PURPLE_TYPE_SUBTYPE,
-										PURPLE_SUBTYPE_ACCOUNT),
-						purple_value_new(PURPLE_TYPE_STRING),
-						purple_value_new(PURPLE_TYPE_STRING));
+						purple_marshal_VOID__POINTER_POINTER, G_TYPE_NONE, 3,
+						PURPLE_TYPE_ACCOUNT, G_TYPE_STRING, G_TYPE_STRING);
 
 	purple_signal_register(handle, "account-error-changed",
 	                       purple_marshal_VOID__POINTER_POINTER_POINTER,
-	                       NULL, 3,
-	                       purple_value_new(PURPLE_TYPE_SUBTYPE,
-	                                        PURPLE_SUBTYPE_ACCOUNT),
-	                       purple_value_new(PURPLE_TYPE_POINTER),
-	                       purple_value_new(PURPLE_TYPE_POINTER));
+	                       G_TYPE_NONE, 3, PURPLE_TYPE_ACCOUNT,
+	                       PURPLE_TYPE_CONNECTION_ERROR_INFO,
+	                       PURPLE_TYPE_CONNECTION_ERROR_INFO);
 
 	purple_signal_register(handle, "account-signed-on",
-	                       purple_marshal_VOID__POINTER, NULL, 1,
-	                       purple_value_new(PURPLE_TYPE_SUBTYPE,
-	                                        PURPLE_SUBTYPE_ACCOUNT));
+	                       purple_marshal_VOID__POINTER, G_TYPE_NONE, 1,
+	                       PURPLE_TYPE_ACCOUNT);
 
 	purple_signal_register(handle, "account-signed-off",
-	                       purple_marshal_VOID__POINTER, NULL, 1,
-	                       purple_value_new(PURPLE_TYPE_SUBTYPE,
-	                                        PURPLE_SUBTYPE_ACCOUNT));
+	                       purple_marshal_VOID__POINTER, G_TYPE_NONE, 1,
+	                       PURPLE_TYPE_ACCOUNT);
 
 	purple_signal_register(handle, "account-connection-error",
-	                       purple_marshal_VOID__POINTER_INT_POINTER, NULL, 3,
-	                       purple_value_new(PURPLE_TYPE_SUBTYPE,
-	                                        PURPLE_SUBTYPE_ACCOUNT),
-	                       purple_value_new(PURPLE_TYPE_ENUM),
-	                       purple_value_new(PURPLE_TYPE_STRING));
+	                       purple_marshal_VOID__POINTER_INT_POINTER,
+	                       G_TYPE_NONE, 3, PURPLE_TYPE_ACCOUNT,
+	                       PURPLE_TYPE_CONNECTION_ERROR, G_TYPE_STRING);
 
 	purple_signal_connect(conn_handle, "signed-on", handle,
 	                      PURPLE_CALLBACK(signed_on_cb), NULL);
diff --git a/libpurple/buddylist.c b/libpurple/buddylist.c
--- a/libpurple/buddylist.c
+++ b/libpurple/buddylist.c
@@ -1895,89 +1895,63 @@ purple_blist_init(void)
 	void *handle = purple_blist_get_handle();
 
 	purple_signal_register(handle, "buddy-status-changed",
-	                     purple_marshal_VOID__POINTER_POINTER_POINTER, NULL,
-	                     3,
-	                     purple_value_new(PURPLE_TYPE_SUBTYPE,
-	                                    PURPLE_SUBTYPE_BLIST_BUDDY),
-	                     purple_value_new(PURPLE_TYPE_SUBTYPE,
-										PURPLE_SUBTYPE_STATUS),
-	                     purple_value_new(PURPLE_TYPE_SUBTYPE,
-										PURPLE_SUBTYPE_STATUS));
+	                     purple_marshal_VOID__POINTER_POINTER_POINTER,
+	                     G_TYPE_NONE, 3, PURPLE_TYPE_BUDDY, PURPLE_TYPE_STATUS, 
+	                     PURPLE_TYPE_STATUS);
 	purple_signal_register(handle, "buddy-privacy-changed",
-	                     purple_marshal_VOID__POINTER, NULL,
-	                     1,
-	                     purple_value_new(PURPLE_TYPE_SUBTYPE,
-	                                    PURPLE_SUBTYPE_BLIST_BUDDY));
+	                     purple_marshal_VOID__POINTER, G_TYPE_NONE,
+	                     1, PURPLE_TYPE_BUDDY);
 
 	purple_signal_register(handle, "buddy-idle-changed",
-	                     purple_marshal_VOID__POINTER_INT_INT, NULL,
-	                     3,
-	                     purple_value_new(PURPLE_TYPE_SUBTYPE,
-	                                    PURPLE_SUBTYPE_BLIST_BUDDY),
-	                     purple_value_new(PURPLE_TYPE_INT),
-	                     purple_value_new(PURPLE_TYPE_INT));
-
+	                     purple_marshal_VOID__POINTER_INT_INT, G_TYPE_NONE,
+	                     3, PURPLE_TYPE_BUDDY, G_TYPE_INT, G_TYPE_INT);
 
 	purple_signal_register(handle, "buddy-signed-on",



More information about the Commits mailing list