gobjectification: 1f26be32: Add some more gobject properties.

sadrul at pidgin.im sadrul at pidgin.im
Sun Jun 22 14:41:30 EDT 2008


-----------------------------------------------------------------
Revision: 1f26be3204bc9c7e4f7b7765c8b152bb71b208db
Ancestor: e353f40e3265f8b48995fd68afa7077656550554
Author: sadrul at pidgin.im
Date: 2008-06-22T17:56:59
Branch: im.pidgin.gobjectification
URL: http://d.pidgin.im/viewmtn/revision/info/1f26be3204bc9c7e4f7b7765c8b152bb71b208db

Modified files:
        libpurple/account.c libpurple/account.h
        libpurple/accountmanager.c

ChangeLog: 

Add some more gobject properties.

-------------- next part --------------
============================================================
--- libpurple/account.c	d292477a5b8f3c09a4ba8e0d7947d853c3a49979
+++ libpurple/account.c	df09cb93f3c65afc35c00df475c897aafe1d622f
@@ -46,6 +46,7 @@ struct _PurpleAccountPrivate
 struct _PurpleAccountPrivate
 {
 	PurpleConnectionErrorInfo *current_error;
+	gboolean check_mail;
 	gboolean enabled;
 	PurplePlugin *prpl;
 };
@@ -384,6 +385,10 @@ enum
 	PROP_ENABLED,
 	PROP_CONNECTION,
 	PROP_PRPL,
+	PROP_USER_INFO,
+	PROP_BUDDY_ICON_PATH,
+	PROP_REMEMBER_PASSWORD,
+	PROP_CHECK_MAIL,
 	PROP_LAST
 };
 
@@ -395,6 +400,10 @@ enum
 #define PROP_ENABLED_S         "enabled"
 #define PROP_CONNECTION_S      "connection"
 #define PROP_PRPL_S            "prpl"
+#define PROP_USER_INFO_S       "userinfo"
+#define PROP_BUDDY_ICON_PATH_S "buddy-icon-path"
+#define PROP_REMEMBER_PASSWORD_S "remember-password"
+#define PROP_CHECK_MAIL_S      "check-mail"
 
 /* GObject Signal enums */
 enum
@@ -435,6 +444,20 @@ purple_account_set_property(GObject *obj
 #warning use _object when the prpls are GObjects
 			account->priv->prpl = g_value_get_pointer(value);
 			break;
+		case PROP_USER_INFO:
+			purple_account_set_user_info(account, g_value_get_string(value));
+			break;
+		case PROP_BUDDY_ICON_PATH:
+			purple_account_set_buddy_icon_path(account,
+					g_value_get_string(value));
+			break;
+		case PROP_REMEMBER_PASSWORD:
+			purple_account_set_remember_password(account,
+					g_value_get_boolean(value));
+			break;
+		case PROP_CHECK_MAIL:
+			purple_account_set_check_mail(account, g_value_get_boolean(value));
+			break;
 		default:
 			G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
 			break;
@@ -472,6 +495,18 @@ purple_account_get_property(GObject *obj
 #warning Use _object when prpls are GObjects
 			g_value_set_pointer(value, account->priv->prpl);
 			break;
+		case PROP_USER_INFO:
+			g_value_set_string(value, purple_account_get_user_info(account));
+			break;
+		case PROP_BUDDY_ICON_PATH:
+			g_value_set_string(value, purple_account_get_buddy_icon_path(account));
+			break;
+		case PROP_REMEMBER_PASSWORD:
+			g_value_set_boolean(value, purple_account_get_remember_password(account));
+			break;
+		case PROP_CHECK_MAIL:
+			g_value_set_boolean(value, purple_account_get_check_mail(account));
+			break;
 		default:
 			G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
 			break;
@@ -583,12 +618,36 @@ static void purple_account_class_init(Pu
 				G_PARAM_READWRITE)
 			);
 
+	g_object_class_install_property(obj_class, PROP_USER_INFO,
+			g_param_spec_string(PROP_USER_INFO_S, _("User information"),
+				_("Detailed user information for the account."), NULL,
+				G_PARAM_READWRITE)
+			);
+
+	g_object_class_install_property(obj_class, PROP_BUDDY_ICON_PATH,
+			g_param_spec_string(PROP_BUDDY_ICON_PATH_S, _("Buddy icon path"),
+				_("Path to the buddyicon for the account."), NULL,
+				G_PARAM_READWRITE)
+			);
+
 	g_object_class_install_property(obj_class, PROP_ENABLED,
 			g_param_spec_boolean(PROP_ENABLED_S, _("Enabled"),
 				_("Whether the account is enabled or not."), FALSE,
 				G_PARAM_READWRITE | G_PARAM_CONSTRUCT)
 			);
 
+	g_object_class_install_property(obj_class, PROP_REMEMBER_PASSWORD,
+			g_param_spec_boolean(PROP_REMEMBER_PASSWORD_S, _("Remember password"),
+				_("Whether to remember and store the password for this account."), FALSE,
+				G_PARAM_READWRITE | G_PARAM_CONSTRUCT)
+			);
+
+	g_object_class_install_property(obj_class, PROP_CHECK_MAIL,
+			g_param_spec_boolean(PROP_CHECK_MAIL_S, _("Check mail"),
+				_("Whether to check mails for this account."), FALSE,
+				G_PARAM_READWRITE | G_PARAM_CONSTRUCT)
+			);
+
 	g_object_class_install_property(obj_class, PROP_CONNECTION,
 			g_param_spec_object(PROP_CONNECTION_S, _("Connection"),
 				_("The PurpleConnection object for the account."),
@@ -602,6 +661,7 @@ static void purple_account_class_init(Pu
 				G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)
 			);
 
+
 	/* Setup signals */
 	signals[SIG_SETTINGS_CHANGED] =
 		g_signal_new("settings-changed", G_OBJECT_CLASS_TYPE(klass),
@@ -663,8 +723,6 @@ purple_account_new(const char *username,
 
 	PURPLE_DBUS_REGISTER_POINTER(account, PurpleAccount);
 
-	purple_account_set_protocol_id(account, protocol_id);
-
 	prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
 	if (prpl_info != NULL && prpl_info->status_types != NULL)
 		purple_account_set_status_types(account, prpl_info->status_types(account));
@@ -1203,35 +1261,27 @@ purple_account_set_user_info(PurpleAccou
 {
 	g_return_if_fail(PURPLE_IS_ACCOUNT(account));
 
+	if (purple_util_strings_equal(account->user_info, user_info))
+		return;
+
 	g_free(account->user_info);
 	account->user_info = g_strdup(user_info);
-
-	schedule_accounts_save();
+	g_object_notify(G_OBJECT(account), PROP_USER_INFO_S);
 }
 
 void purple_account_set_buddy_icon_path(PurpleAccount *account, const char *path)
 {
 	g_return_if_fail(PURPLE_IS_ACCOUNT(account));
 
+	if (purple_util_strings_equal(account->buddy_icon_path, path))
+		return;
+
 	g_free(account->buddy_icon_path);
 	account->buddy_icon_path = g_strdup(path);
-
-	schedule_accounts_save();
+	g_object_notify(G_OBJECT(account), PROP_BUDDY_ICON_PATH_S);
 }
 
 void
-purple_account_set_protocol_id(PurpleAccount *account, const char *protocol_id)
-{
-	g_return_if_fail(account     != NULL);
-	g_return_if_fail(protocol_id != NULL);
-
-	g_free(account->protocol_id);
-	account->protocol_id = g_strdup(protocol_id);
-
-	schedule_accounts_save();
-}
-
-void
 purple_account_set_connection(PurpleAccount *account, PurpleConnection *gc)
 {
 	PurpleConnection *old;
@@ -1255,17 +1305,23 @@ purple_account_set_remember_password(Pur
 {
 	g_return_if_fail(PURPLE_IS_ACCOUNT(account));
 
+	if (account->remember_pass == value)
+		return;
 	account->remember_pass = value;
-
-	schedule_accounts_save();
+	g_object_notify(G_OBJECT(account), PROP_REMEMBER_PASSWORD_S);
 }
 
 void
 purple_account_set_check_mail(PurpleAccount *account, gboolean value)
 {
+	PurpleAccountPrivate *priv = PURPLE_ACCOUNT_GET_PRIVATE(account);
+
 	g_return_if_fail(PURPLE_IS_ACCOUNT(account));
 
-	purple_account_set_bool(account, "check-mail", value);
+	if (priv->check_mail == value)
+		return;
+	priv->check_mail = value;
+	g_object_notify(G_OBJECT(account), PROP_CHECK_MAIL_S);
 }
 
 void
@@ -1761,7 +1817,7 @@ purple_account_get_check_mail(const Purp
 {
 	g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), FALSE);
 
-	return purple_account_get_bool(account, "check-mail", FALSE);
+	return PURPLE_ACCOUNT_GET_PRIVATE(account)->check_mail;
 }
 
 gboolean
@@ -2293,6 +2349,9 @@ xmlnode * purple_account_to_xmlnode(Purp
 		xmlnode_insert_data(child, tmp, -1);
 	}
 
+	child = xmlnode_new_child(node, "check-mail");
+	xmlnode_insert_data(child, purple_account_get_check_mail(account) ? "1" : "0", -1);
+
 	if (g_hash_table_size(account->settings) > 0)
 	{
 		child = xmlnode_new_child(node, "settings");
============================================================
--- libpurple/account.h	56a7dd8c64e208f2cb70b2ec9b44ed2976f5cbb1
+++ libpurple/account.h	5c47ec2d685f633bea28d0eb02d192637e9ef82c
@@ -373,15 +373,6 @@ void purple_account_set_buddy_icon_path(
 void purple_account_set_buddy_icon_path(PurpleAccount *account, const char *path);
 
 /**
- * Sets the account's protocol ID.
- *
- * @param account     The account.
- * @param protocol_id The protocol ID.
- */
-void purple_account_set_protocol_id(PurpleAccount *account,
-								  const char *protocol_id);
-
-/**
  * Sets the account's connection.
  *
  * @param account The account.
============================================================
--- libpurple/accountmanager.c	d76d501c5c7b99794ca0b12af2d205bf4b3e5905
+++ libpurple/accountmanager.c	006585516500209f4b24707233660646e3095605
@@ -540,6 +540,13 @@ parse_account(xmlnode *node)
 		g_free(data);
 	}
 
+	child = xmlnode_get_child(node, "check-mail");
+	if (child != NULL) {
+		char *value = xmlnode_get_data(child);
+		purple_account_set_check_mail(ret, value[0] == '0' ? FALSE : TRUE);
+		g_free(value);
+	}
+
 	/* Read an old buddyicon */
 	child = xmlnode_get_child(node, "buddyicon");
 	if ((child != NULL) && ((data = xmlnode_get_data(child)) != NULL))


More information about the Commits mailing list