/soc/2013/ankitkv/gobjectification: b4e0236019e6: Fixed more Pur...

Ankit Vani a at nevitus.org
Wed Jun 19 06:22:08 EDT 2013


Changeset: b4e0236019e63a1f56762a13febe925decd05489
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-06-19 01:40 +0530
Branch:	 soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/b4e0236019e6

Description:

Fixed more PurpleAccount stuff.
* Changed back to PurpleAccountSetting and the union for value in PurpleAccountSetting to GValue
* Removed properties for password and public alias since they require a callback to be specified

diffstat:

 libpurple/account.c  |  671 ++++++++++++++++++++++++++++++++++++--------------
 libpurple/account.h  |    9 +
 libpurple/accounts.c |  425 ++++---------------------------
 libpurple/accounts.h |    1 +
 4 files changed, 555 insertions(+), 551 deletions(-)

diffs (truncated from 1624 to 300 lines):

diff --git a/libpurple/account.c b/libpurple/account.c
--- a/libpurple/account.c
+++ b/libpurple/account.c
@@ -28,16 +28,13 @@
 #include "core.h"
 #include "dbus-maybe.h"
 #include "debug.h"
-#include "keyring.h"
 #include "network.h"
 #include "notify.h"
 #include "pounce.h"
 #include "prefs.h"
-#include "prpl.h"
 #include "request.h"
 #include "server.h"
 #include "signals.h"
-#include "status.h"
 #include "util.h"
 
 #define PURPLE_ACCOUNT_GET_PRIVATE(obj) \
@@ -93,6 +90,13 @@ typedef struct
 
 typedef struct
 {
+	char *ui;
+	GValue value;
+
+} PurpleAccountSetting;
+
+typedef struct
+{
 	PurpleAccountRequestType type;
 	PurpleAccount *account;
 	void *ui_handle;
@@ -109,16 +113,12 @@ typedef struct
 	gpointer data;
 } PurpleCallbackBundle;
 
-static GObjectClass *parent_class = NULL;
-
 /* GObject Property enums */
 enum
 {
 	PROP_0,
 	PROP_USERNAME,
-	PROP_PASSWORD,
 	PROP_PRIVATE_ALIAS,
-	PROP_PUBLIC_ALIAS,
 	PROP_ENABLED,
 	PROP_CONNECTION,
 	PROP_PROTOCOL_ID,
@@ -129,6 +129,8 @@ enum
 	PROP_LAST
 };
 
+static GObjectClass  *parent_class = NULL;
+static GList         *handles = NULL;
 
 static void set_current_error(PurpleAccount *account,
 	PurpleConnectionErrorInfo *new_err);
@@ -1118,7 +1120,7 @@ purple_account_remove_setting(PurpleAcco
 void
 purple_account_set_int(PurpleAccount *account, const char *name, int value)
 {
-	GValue *setting;
+	PurpleAccountSetting *setting;
 	PurpleAccountPrivate *priv;
 
 	g_return_if_fail(account != NULL);
@@ -1126,10 +1128,10 @@ purple_account_set_int(PurpleAccount *ac
 
 	priv = PURPLE_ACCOUNT_GET_PRIVATE(account);
 
-	setting = g_new0(GValue, 1);
-
-	setting->type          = PURPLE_PREF_INT;
-	setting->value.integer = value;
+	setting = g_new0(PurpleAccountSetting, 1);
+
+	g_value_init(&setting->value, G_TYPE_INT);
+	g_value_set_int(&setting->value, value);
 
 	g_hash_table_insert(priv->settings, g_strdup(name), setting);
 
@@ -1140,7 +1142,7 @@ void
 purple_account_set_string(PurpleAccount *account, const char *name,
 						const char *value)
 {
-	GValue *setting;
+	PurpleAccountSetting *setting;
 	PurpleAccountPrivate *priv;
 
 	g_return_if_fail(account != NULL);
@@ -1148,10 +1150,10 @@ purple_account_set_string(PurpleAccount 
 
 	priv = PURPLE_ACCOUNT_GET_PRIVATE(account);
 
-	setting = g_new0(GValue, 1);
-
-	setting->type         = PURPLE_PREF_STRING;
-	setting->value.string = g_strdup(value);
+	setting = g_new0(PurpleAccountSetting, 1);
+
+	g_value_init(&setting->value, G_TYPE_STRING);
+	g_value_set_string(&setting->value, value);
 
 	g_hash_table_insert(priv->settings, g_strdup(name), setting);
 
@@ -1161,7 +1163,7 @@ purple_account_set_string(PurpleAccount 
 void
 purple_account_set_bool(PurpleAccount *account, const char *name, gboolean value)
 {
-	GValue *setting;
+	PurpleAccountSetting *setting;
 	PurpleAccountPrivate *priv;
 
 	g_return_if_fail(account != NULL);
@@ -1169,10 +1171,10 @@ purple_account_set_bool(PurpleAccount *a
 
 	priv = PURPLE_ACCOUNT_GET_PRIVATE(account);
 
-	setting = g_new0(GValue, 1);
-
-	setting->type       = PURPLE_PREF_BOOLEAN;
-	setting->value.boolean = value;
+	setting = g_new0(PurpleAccountSetting, 1);
+
+	g_value_init(&setting->value, G_TYPE_BOOLEAN);
+	g_value_set_boolean(&setting->value, value);
 
 	g_hash_table_insert(priv->settings, g_strdup(name), setting);
 
@@ -1200,18 +1202,18 @@ void
 purple_account_set_ui_int(PurpleAccount *account, const char *ui,
 						const char *name, int value)
 {
-	GValue *setting;
+	PurpleAccountSetting *setting;
 	GHashTable *table;
 
 	g_return_if_fail(account != NULL);
 	g_return_if_fail(ui      != NULL);
 	g_return_if_fail(name    != NULL);
 
-	setting = g_new0(GValue, 1);
-
-	setting->type          = PURPLE_PREF_INT;
+	setting = g_new0(PurpleAccountSetting, 1);
+
 	setting->ui            = g_strdup(ui);
-	setting->value.integer = value;
+	g_value_init(&setting->value, G_TYPE_INT);
+	g_value_set_int(&setting->value, value);
 
 	table = get_ui_settings_table(account, ui);
 
@@ -1224,18 +1226,18 @@ void
 purple_account_set_ui_string(PurpleAccount *account, const char *ui,
 						   const char *name, const char *value)
 {
-	GValue *setting;
+	PurpleAccountSetting *setting;
 	GHashTable *table;
 
 	g_return_if_fail(account != NULL);
 	g_return_if_fail(ui      != NULL);
 	g_return_if_fail(name    != NULL);
 
-	setting = g_new0(GValue, 1);
-
-	setting->type         = PURPLE_PREF_STRING;
+	setting = g_new0(PurpleAccountSetting, 1);
+
 	setting->ui           = g_strdup(ui);
-	setting->value.string = g_strdup(value);
+	g_value_init(&setting->value, G_TYPE_STRING);
+	g_value_set_string(&setting->value, value);
 
 	table = get_ui_settings_table(account, ui);
 
@@ -1248,18 +1250,18 @@ void
 purple_account_set_ui_bool(PurpleAccount *account, const char *ui,
 						 const char *name, gboolean value)
 {
-	GValue *setting;
+	PurpleAccountSetting *setting;
 	GHashTable *table;
 
 	g_return_if_fail(account != NULL);
 	g_return_if_fail(ui      != NULL);
 	g_return_if_fail(name    != NULL);
 
-	setting = g_new0(GValue, 1);
-
-	setting->type       = PURPLE_PREF_BOOLEAN;
+	setting = g_new0(PurpleAccountSetting, 1);
+
 	setting->ui         = g_strdup(ui);
-	setting->value.boolean = value;
+	g_value_init(&setting->value, G_TYPE_BOOLEAN);
+	g_value_set_boolean(&setting->value, value);
 
 	table = get_ui_settings_table(account, ui);
 
@@ -1511,7 +1513,7 @@ purple_account_get_privacy_type(const Pu
 {
 	PurpleAccountPrivate *priv;
 
-	g_return_val_if_fail(account != NULL, PURPLE_PRIVACY_ALLOW_ALL);
+	g_return_val_if_fail(account != NULL, PURPLE_ACCOUNT_PRIVACY_ALLOW_ALL);
 
 	priv = PURPLE_ACCOUNT_GET_PRIVATE(account);
 	return priv->perm_deny;
@@ -1526,6 +1528,7 @@ purple_account_privacy_permit_add(Purple
 	PurpleBuddy *buddy;
 	PurpleBlistUiOps *blist_ops;
 	PurpleAccountPrivate *priv;
+	PurpleAccountUiOps *ui_ops = purple_accounts_get_ui_ops();
 
 	g_return_val_if_fail(account != NULL, FALSE);
 	g_return_val_if_fail(who     != NULL, FALSE);
@@ -1551,8 +1554,8 @@ purple_account_privacy_permit_add(Purple
 	if (!local_only && purple_account_is_connected(account))
 		serv_add_permit(purple_account_get_connection(account), who);
 
-	if (privacy_ops != NULL && privacy_ops->permit_added != NULL)
-		privacy_ops->permit_added(account, who);
+	if (ui_ops != NULL && ui_ops->permit_added != NULL)
+		ui_ops->permit_added(account, who);
 
 	blist_ops = purple_blist_get_ui_ops();
 	if (blist_ops != NULL && blist_ops->save_account != NULL)
@@ -1577,6 +1580,7 @@ purple_account_privacy_permit_remove(Pur
 	char *del;
 	PurpleBlistUiOps *blist_ops;
 	PurpleAccountPrivate *priv;
+	PurpleAccountUiOps *ui_ops = purple_accounts_get_ui_ops();
 
 	g_return_val_if_fail(account != NULL, FALSE);
 	g_return_val_if_fail(who     != NULL, FALSE);
@@ -1603,8 +1607,8 @@ purple_account_privacy_permit_remove(Pur
 	if (!local_only && purple_account_is_connected(account))
 		serv_rem_permit(purple_account_get_connection(account), who);
 
-	if (privacy_ops != NULL && privacy_ops->permit_removed != NULL)
-		privacy_ops->permit_removed(account, who);
+	if (ui_ops != NULL && ui_ops->permit_removed != NULL)
+		ui_ops->permit_removed(account, who);
 
 	blist_ops = purple_blist_get_ui_ops();
 	if (blist_ops != NULL && blist_ops->save_account != NULL)
@@ -1628,6 +1632,7 @@ purple_account_privacy_deny_add(PurpleAc
 	PurpleBuddy *buddy;
 	PurpleBlistUiOps *blist_ops;
 	PurpleAccountPrivate *priv;
+	PurpleAccountUiOps *ui_ops = purple_accounts_get_ui_ops();
 
 	g_return_val_if_fail(account != NULL, FALSE);
 	g_return_val_if_fail(who     != NULL, FALSE);
@@ -1653,8 +1658,8 @@ purple_account_privacy_deny_add(PurpleAc
 	if (!local_only && purple_account_is_connected(account))
 		serv_add_deny(purple_account_get_connection(account), who);
 
-	if (privacy_ops != NULL && privacy_ops->deny_added != NULL)
-		privacy_ops->deny_added(account, who);
+	if (ui_ops != NULL && ui_ops->deny_added != NULL)
+		ui_ops->deny_added(account, who);
 
 	blist_ops = purple_blist_get_ui_ops();
 	if (blist_ops != NULL && blist_ops->save_account != NULL)
@@ -1678,6 +1683,7 @@ purple_account_privacy_deny_remove(Purpl
 	PurpleBuddy *buddy;
 	PurpleBlistUiOps *blist_ops;
 	PurpleAccountPrivate *priv;
+	PurpleAccountUiOps *ui_ops = purple_accounts_get_ui_ops();
 
 	g_return_val_if_fail(account != NULL, FALSE);
 	g_return_val_if_fail(who     != NULL, FALSE);
@@ -1703,8 +1709,8 @@ purple_account_privacy_deny_remove(Purpl
 	if (!local_only && purple_account_is_connected(account))
 		serv_rem_deny(purple_account_get_connection(account), name);
 
-	if (privacy_ops != NULL && privacy_ops->deny_removed != NULL)
-		privacy_ops->deny_removed(account, who);
+	if (ui_ops != NULL && ui_ops->deny_removed != NULL)
+		ui_ops->deny_removed(account, who);
 
 	if (buddy != NULL) {
 		purple_signal_emit(purple_blist_get_handle(),
@@ -1768,16 +1774,18 @@ purple_account_privacy_allow(PurpleAccou
 			purple_account_privacy_deny_remove(account, who, FALSE);
 			break;
 		case PURPLE_ACCOUNT_PRIVACY_DENY_ALL:
-			/* Empty the allow-list. */
-			const char *norm = purple_normalize(account, who);
-			for (list = priv->permit; list != NULL;) {
-				char *person = list->data;
-				list = list->next;
-				if (!purple_strequal(norm, person))
-					purple_account_privacy_permit_remove(account, person, FALSE);



More information about the Commits mailing list