/soc/2013/ankitkv/gobjectification: e718d0eea155: Moved some loc...

Ankit Vani a at nevitus.org
Mon Jun 17 16:40:22 EDT 2013


Changeset: e718d0eea15567c645dc13c392503bb30278cbef
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-06-18 02:10 +0530
Branch:	 soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/e718d0eea155

Description:

Moved some local functions from account.c to accounts.c

diffstat:

 libpurple/account.c  |  946 +--------------------------------------------------
 libpurple/accounts.c |  944 ++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 947 insertions(+), 943 deletions(-)

diffs (truncated from 1941 to 300 lines):

diff --git a/libpurple/account.c b/libpurple/account.c
--- a/libpurple/account.c
+++ b/libpurple/account.c
@@ -33,14 +33,12 @@
 #include "notify.h"
 #include "pounce.h"
 #include "prefs.h"
-#include "privacy.h"
 #include "prpl.h"
 #include "request.h"
 #include "server.h"
 #include "signals.h"
 #include "status.h"
 #include "util.h"
-#include "xmlnode.h"
 
 #define PURPLE_ACCOUNT_GET_PRIVATE(obj) \
 	(G_TYPE_INSTANCE_GET_PRIVATE((obj), PURPLE_TYPE_ACCOUNT, PurpleAccountPrivate))
@@ -93,7 +91,8 @@ typedef struct
 	PurpleConnectionErrorInfo *current_error;	/**< Errors */
 } PurpleAccountPrivate;
 
-/* TODO: Should use PurpleValue instead of this?  What about "ui"? */
+#if 0
+/* TODO Use GValue instead */
 typedef struct
 {
 	PurplePrefType type;
@@ -109,6 +108,7 @@ typedef struct
 	} value;
 
 } PurpleAccountSetting;
+#endif
 
 typedef struct
 {
@@ -128,949 +128,9 @@ typedef struct
 	gpointer data;
 } PurpleCallbackBundle;
 
-static PurpleAccountUiOps *account_ui_ops = NULL;
-
-static GList   *accounts = NULL;
-static guint    save_timer = 0;
-static gboolean accounts_loaded = FALSE;
-
-static GList *handles = NULL;
-
 static void set_current_error(PurpleAccount *account,
 	PurpleConnectionErrorInfo *new_err);
 
-/*********************************************************************
- * Writing to disk                                                   *
- *********************************************************************/
-
-static void
-setting_to_xmlnode(gpointer key, gpointer value, gpointer user_data)
-{
-	const char *name;
-	PurpleAccountSetting *setting;
-	xmlnode *node, *child;
-	char buf[21];
-
-	name    = (const char *)key;
-	setting = (PurpleAccountSetting *)value;
-	node    = (xmlnode *)user_data;
-
-	child = xmlnode_new_child(node, "setting");
-	xmlnode_set_attrib(child, "name", name);
-
-	if (setting->type == PURPLE_PREF_INT) {
-		xmlnode_set_attrib(child, "type", "int");
-		g_snprintf(buf, sizeof(buf), "%d", setting->value.integer);
-		xmlnode_insert_data(child, buf, -1);
-	}
-	else if (setting->type == PURPLE_PREF_STRING && setting->value.string != NULL) {
-		xmlnode_set_attrib(child, "type", "string");
-		xmlnode_insert_data(child, setting->value.string, -1);
-	}
-	else if (setting->type == PURPLE_PREF_BOOLEAN) {
-		xmlnode_set_attrib(child, "type", "bool");
-		g_snprintf(buf, sizeof(buf), "%d", setting->value.boolean);
-		xmlnode_insert_data(child, buf, -1);
-	}
-}
-
-static void
-ui_setting_to_xmlnode(gpointer key, gpointer value, gpointer user_data)
-{
-	const char *ui;
-	GHashTable *table;
-	xmlnode *node, *child;
-
-	ui    = (const char *)key;
-	table = (GHashTable *)value;
-	node  = (xmlnode *)user_data;
-
-	if (g_hash_table_size(table) > 0)
-	{
-		child = xmlnode_new_child(node, "settings");
-		xmlnode_set_attrib(child, "ui", ui);
-		g_hash_table_foreach(table, setting_to_xmlnode, child);
-	}
-}
-
-static xmlnode *
-status_attr_to_xmlnode(const PurpleStatus *status, const PurpleStatusType *type, const PurpleStatusAttr *attr)
-{
-	xmlnode *node;
-	const char *id;
-	char *value = NULL;
-	PurpleStatusAttr *default_attr;
-	PurpleValue *default_value;
-	PurpleType attr_type;
-	PurpleValue *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);
-
-	/*
-	 * If attr_value is a different type than it should be
-	 * then don't write it to the file.
-	 */
-	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))
-		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)
-	{
-		const char *string_value = purple_value_get_string(attr_value);
-		const char *default_string_value = purple_value_get_string(default_value);
-		if (purple_strequal(string_value, default_string_value))
-			return NULL;
-		value = g_strdup(purple_value_get_string(attr_value));
-	}
-	else if (attr_type == PURPLE_TYPE_INT)
-	{
-		int int_value = purple_value_get_int(attr_value);
-		if (int_value == purple_value_get_int(default_value))
-			return NULL;
-		value = g_strdup_printf("%d", int_value);
-	}
-	else if (attr_type == PURPLE_TYPE_BOOLEAN)
-	{
-		gboolean boolean_value = purple_value_get_boolean(attr_value);
-		if (boolean_value == purple_value_get_boolean(default_value))
-			return NULL;
-		value = g_strdup(boolean_value ?
-								"true" : "false");
-	}
-	else
-	{
-		return NULL;
-	}
-
-	g_return_val_if_fail(value, NULL);
-
-	node = xmlnode_new("attribute");
-
-	xmlnode_set_attrib(node, "id", id);
-	xmlnode_set_attrib(node, "value", value);
-
-	g_free(value);
-
-	return node;
-}
-
-static xmlnode *
-status_attrs_to_xmlnode(const PurpleStatus *status)
-{
-	PurpleStatusType *type = purple_status_get_type(status);
-	xmlnode *node, *child;
-	GList *attrs, *attr;
-
-	node = xmlnode_new("attributes");
-
-	attrs = purple_status_type_get_attrs(type);
-	for (attr = attrs; attr != NULL; attr = attr->next)
-	{
-		child = status_attr_to_xmlnode(status, type, (const PurpleStatusAttr *)attr->data);
-		if (child)
-			xmlnode_insert_child(node, child);
-	}
-
-	return node;
-}
-
-static xmlnode *
-status_to_xmlnode(const PurpleStatus *status)
-{
-	xmlnode *node, *child;
-
-	node = xmlnode_new("status");
-	xmlnode_set_attrib(node, "type", purple_status_get_id(status));
-	if (purple_status_get_name(status) != NULL)
-		xmlnode_set_attrib(node, "name", purple_status_get_name(status));
-	xmlnode_set_attrib(node, "active", purple_status_is_active(status) ? "true" : "false");
-
-	child = status_attrs_to_xmlnode(status);
-	xmlnode_insert_child(node, child);
-
-	return node;
-}
-
-static xmlnode *
-statuses_to_xmlnode(const PurplePresence *presence)
-{
-	xmlnode *node, *child;
-	GList *statuses;
-	PurpleStatus *status;
-
-	node = xmlnode_new("statuses");
-
-	statuses = purple_presence_get_statuses(presence);
-	for (; statuses != NULL; statuses = statuses->next)
-	{
-		status = statuses->data;
-		if (purple_status_type_is_saveable(purple_status_get_type(status)))
-		{
-			child = status_to_xmlnode(status);
-			xmlnode_insert_child(node, child);
-		}
-	}
-
-	return node;
-}
-
-static xmlnode *
-proxy_settings_to_xmlnode(PurpleProxyInfo *proxy_info)
-{
-	xmlnode *node, *child;
-	PurpleProxyType proxy_type;
-	const char *value;
-	int int_value;
-	char buf[21];
-
-	proxy_type = purple_proxy_info_get_type(proxy_info);
-
-	node = xmlnode_new("proxy");
-
-	child = xmlnode_new_child(node, "type");
-	xmlnode_insert_data(child,
-			(proxy_type == PURPLE_PROXY_USE_GLOBAL ? "global" :
-			 proxy_type == PURPLE_PROXY_NONE       ? "none"   :
-			 proxy_type == PURPLE_PROXY_HTTP       ? "http"   :
-			 proxy_type == PURPLE_PROXY_SOCKS4     ? "socks4" :
-			 proxy_type == PURPLE_PROXY_SOCKS5     ? "socks5" :
-			 proxy_type == PURPLE_PROXY_TOR        ? "tor" :
-			 proxy_type == PURPLE_PROXY_USE_ENVVAR ? "envvar" : "unknown"), -1);
-
-	if ((value = purple_proxy_info_get_host(proxy_info)) != NULL)
-	{
-		child = xmlnode_new_child(node, "host");
-		xmlnode_insert_data(child, value, -1);
-	}
-
-	if ((int_value = purple_proxy_info_get_port(proxy_info)) != 0)
-	{
-		g_snprintf(buf, sizeof(buf), "%d", int_value);
-		child = xmlnode_new_child(node, "port");
-		xmlnode_insert_data(child, buf, -1);
-	}
-
-	if ((value = purple_proxy_info_get_username(proxy_info)) != NULL)
-	{
-		child = xmlnode_new_child(node, "username");
-		xmlnode_insert_data(child, value, -1);
-	}
-
-	if ((value = purple_proxy_info_get_password(proxy_info)) != NULL)
-	{
-		child = xmlnode_new_child(node, "password");
-		xmlnode_insert_data(child, value, -1);
-	}
-
-	return node;
-}
-
-static xmlnode *
-current_error_to_xmlnode(PurpleConnectionErrorInfo *err)
-{
-	xmlnode *node, *child;
-	char type_str[3];
-
-	node = xmlnode_new("current_error");
-
-	if(err == NULL)
-		return node;
-
-	/* It doesn't make sense to have transient errors persist across a
-	 * restart.



More information about the Commits mailing list