/soc/2013/ankitkv/gobjectification: 58bddd91956c: libpurple: use...
Ankit Vani
a at nevitus.org
Sat Nov 23 14:49:17 EST 2013
Changeset: 58bddd91956c9ae6406e601bf3997e94978c662e
Author: Ankit Vani <a at nevitus.org>
Date: 2013-11-24 00:33 +0530
Branch: soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/58bddd91956c
Description:
libpurple: use g_object_notify_by_pspec instead of g_object_notify
diffstat:
libpurple/account.c | 119 +++++++++++++-----------
libpurple/blistnode.c | 54 ++++++----
libpurple/blistnodetypes.c | 143 ++++++++++++++++------------
libpurple/connection.c | 58 ++++++-----
libpurple/conversation.c | 55 ++++++-----
libpurple/conversationtypes.c | 121 +++++++++++++-----------
libpurple/presence.c | 78 +++++++++-------
libpurple/roomlist.c | 33 +++---
libpurple/status.c | 36 ++++---
libpurple/whiteboard.c | 38 ++++---
libpurple/xfer.c | 202 +++++++++++++++++++++--------------------
11 files changed, 515 insertions(+), 422 deletions(-)
diffs (truncated from 1895 to 300 lines):
diff --git a/libpurple/account.c b/libpurple/account.c
--- a/libpurple/account.c
+++ b/libpurple/account.c
@@ -24,6 +24,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
*/
#include "internal.h"
+#include "glibcompat.h"
+
#include "accounts.h"
#include "core.h"
#include "dbus-maybe.h"
@@ -133,6 +135,7 @@ enum
};
static GObjectClass *parent_class = NULL;
+static GParamSpec *properties[PROP_LAST];
static GList *handles = NULL;
void _purple_account_set_current_error(PurpleAccount *account,
@@ -742,7 +745,7 @@ purple_account_set_username(PurpleAccoun
g_free(priv->username);
priv->username = g_strdup(username);
- g_object_notify(G_OBJECT(account), "username");
+ g_object_notify_by_pspec(G_OBJECT(account), properties[PROP_USERNAME]);
purple_accounts_schedule_save();
@@ -802,7 +805,8 @@ purple_account_set_private_alias(PurpleA
char *old = priv->alias;
priv->alias = g_strdup(alias);
- g_object_notify(G_OBJECT(account), "private-alias");
+ g_object_notify_by_pspec(G_OBJECT(account),
+ properties[PROP_PRIVATE_ALIAS]);
purple_signal_emit(purple_accounts_get_handle(), "account-alias-changed",
account, old);
g_free(old);
@@ -823,7 +827,7 @@ purple_account_set_user_info(PurpleAccou
g_free(priv->user_info);
priv->user_info = g_strdup(user_info);
- g_object_notify(G_OBJECT(account), "user-info");
+ g_object_notify_by_pspec(G_OBJECT(account), properties[PROP_USER_INFO]);
purple_accounts_schedule_save();
}
@@ -839,7 +843,8 @@ void purple_account_set_buddy_icon_path(
g_free(priv->buddy_icon_path);
priv->buddy_icon_path = g_strdup(path);
- g_object_notify(G_OBJECT(account), "buddy-icon-path");
+ g_object_notify_by_pspec(G_OBJECT(account),
+ properties[PROP_BUDDY_ICON_PATH]);
purple_accounts_schedule_save();
}
@@ -857,7 +862,7 @@ purple_account_set_protocol_id(PurpleAcc
g_free(priv->protocol_id);
priv->protocol_id = g_strdup(protocol_id);
- g_object_notify(G_OBJECT(account), "protocol-id");
+ g_object_notify_by_pspec(G_OBJECT(account), properties[PROP_PROTOCOL_ID]);
purple_accounts_schedule_save();
}
@@ -872,7 +877,7 @@ purple_account_set_connection(PurpleAcco
priv = PURPLE_ACCOUNT_GET_PRIVATE(account);
priv->gc = gc;
- g_object_notify(G_OBJECT(account), "connection");
+ g_object_notify_by_pspec(G_OBJECT(account), properties[PROP_CONNECTION]);
}
void
@@ -885,7 +890,8 @@ purple_account_set_remember_password(Pur
priv = PURPLE_ACCOUNT_GET_PRIVATE(account);
priv->remember_pass = value;
- g_object_notify(G_OBJECT(account), "remember-password");
+ g_object_notify_by_pspec(G_OBJECT(account),
+ properties[PROP_REMEMBER_PASSWORD]);
purple_accounts_schedule_save();
}
@@ -897,7 +903,7 @@ purple_account_set_check_mail(PurpleAcco
purple_account_set_bool(account, "check-mail", value);
- g_object_notify(G_OBJECT(account), "check-mail");
+ g_object_notify_by_pspec(G_OBJECT(account), properties[PROP_CHECK_MAIL]);
}
void
@@ -921,7 +927,7 @@ purple_account_set_enabled(PurpleAccount
else if(!was_enabled && value)
purple_signal_emit(purple_accounts_get_handle(), "account-enabled", account);
- g_object_notify(G_OBJECT(account), "enabled");
+ g_object_notify_by_pspec(G_OBJECT(account), properties[PROP_ENABLED]);
if ((gc != NULL) && (_purple_connection_wants_to_die(gc)))
wants_to_die = TRUE;
@@ -3068,60 +3074,67 @@ purple_account_class_init(PurpleAccountC
obj_class->get_property = purple_account_get_property;
obj_class->set_property = purple_account_set_property;
+ properties[PROP_USERNAME] = g_param_spec_string("username", "Username",
+ "The username for the account.", NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
g_object_class_install_property(obj_class, PROP_USERNAME,
- g_param_spec_string("username", "Username",
- "The username for the account.", NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS)
- );
-
+ properties[PROP_USERNAME]);
+
+ properties[PROP_PRIVATE_ALIAS] = g_param_spec_string("private-alias",
+ "Private Alias",
+ "The private alias for the account.", NULL,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property(obj_class, PROP_PRIVATE_ALIAS,
- g_param_spec_string("private-alias", "Private Alias",
- "The private alias for the account.", NULL,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)
- );
-
+ properties[PROP_PRIVATE_ALIAS]);
+
+ properties[PROP_USER_INFO] = g_param_spec_string("user-info",
+ "User information",
+ "Detailed user information for the account.", NULL,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property(obj_class, PROP_USER_INFO,
- g_param_spec_string("user-info", "User information",
- "Detailed user information for the account.", NULL,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)
- );
-
+ properties[PROP_USER_INFO]);
+
+ properties[PROP_BUDDY_ICON_PATH] = g_param_spec_string("buddy-icon-path",
+ "Buddy icon path",
+ "Path to the buddyicon for the account.", NULL,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property(obj_class, PROP_BUDDY_ICON_PATH,
- g_param_spec_string("buddy-icon-path", "Buddy icon path",
- "Path to the buddyicon for the account.", NULL,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)
- );
-
+ properties[PROP_BUDDY_ICON_PATH]);
+
+ properties[PROP_ENABLED] = g_param_spec_boolean("enabled", "Enabled",
+ "Whether the account is enabled or not.", FALSE,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property(obj_class, PROP_ENABLED,
- g_param_spec_boolean("enabled", "Enabled",
- "Whether the account is enabled or not.", FALSE,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)
- );
-
+ properties[PROP_ENABLED]);
+
+ properties[PROP_REMEMBER_PASSWORD] = g_param_spec_boolean(
+ "remember-password", "Remember password",
+ "Whether to remember and store the password for this account.",
+ FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property(obj_class, PROP_REMEMBER_PASSWORD,
- g_param_spec_boolean("remember-password", "Remember password",
- "Whether to remember and store the password for this account.", FALSE,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)
- );
-
+ properties[PROP_REMEMBER_PASSWORD]);
+
+ properties[PROP_CHECK_MAIL] = g_param_spec_boolean("check-mail",
+ "Check mail",
+ "Whether to check mails for this account.", FALSE,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property(obj_class, PROP_CHECK_MAIL,
- g_param_spec_boolean("check-mail", "Check mail",
- "Whether to check mails for this account.", FALSE,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)
- );
-
+ properties[PROP_CHECK_MAIL]);
+
+ properties[PROP_CONNECTION] = g_param_spec_object("connection",
+ "Connection",
+ "The connection for the account.", PURPLE_TYPE_CONNECTION,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property(obj_class, PROP_CONNECTION,
- g_param_spec_object("connection", "Connection",
- "The connection for the account.", PURPLE_TYPE_CONNECTION,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)
- );
-
- g_object_class_install_property(obj_class, PROP_PROTOCOL_ID,
- g_param_spec_string("protocol-id", "Protocol ID",
+ properties[PROP_CONNECTION]);
+
+ properties[PROP_PROTOCOL_ID] = g_param_spec_string("protocol-id",
+ "Protocol ID",
"ID of the protocol that is responsible for the account.", NULL,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS)
- );
+ G_PARAM_STATIC_STRINGS);
+ g_object_class_install_property(obj_class, PROP_PROTOCOL_ID,
+ properties[PROP_PROTOCOL_ID]);
g_type_class_add_private(klass, sizeof(PurpleAccountPrivate));
}
diff --git a/libpurple/blistnode.c b/libpurple/blistnode.c
--- a/libpurple/blistnode.c
+++ b/libpurple/blistnode.c
@@ -20,8 +20,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
*
*/
+#include "internal.h"
+#include "glibcompat.h"
#include "blistnodetypes.h"
-#include "internal.h"
#define PURPLE_BLIST_NODE_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE((obj), PURPLE_TYPE_BLIST_NODE, PurpleBlistNodePrivate))
@@ -70,6 +71,9 @@ enum
static GObjectClass *parent_class;
+static GParamSpec *bn_properties[BLNODE_PROP_LAST];
+static GParamSpec *cn_properties[CNODE_PROP_LAST];
+
/**************************************************************************/
/* Buddy list node API */
/**************************************************************************/
@@ -163,7 +167,8 @@ purple_blist_node_set_transient(PurpleBl
priv->transient = transient;
- g_object_notify(G_OBJECT(node), "transient");
+ g_object_notify_by_pspec(G_OBJECT(node),
+ bn_properties[BLNODE_PROP_TRANSIENT]);
}
gboolean
@@ -407,11 +412,12 @@ purple_blist_node_class_init(PurpleBlist
obj_class->get_property = purple_blist_node_get_property;
obj_class->set_property = purple_blist_node_set_property;
+ bn_properties[BLNODE_PROP_TRANSIENT] = g_param_spec_boolean("transient",
+ "Transient",
+ "Whether node should not be saved with the buddy list.",
+ FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property(obj_class, BLNODE_PROP_TRANSIENT,
- g_param_spec_boolean("transient", "Transient",
- "Whether node should not be saved with the buddy list.",
- FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)
- );
+ bn_properties[BLNODE_PROP_TRANSIENT]);
g_type_class_add_private(klass, sizeof(PurpleBlistNodePrivate));
}
@@ -515,7 +521,8 @@ purple_counting_node_set_total_size(Purp
priv->totalsize = totalsize;
- g_object_notify(G_OBJECT(counter), "total-size");
+ g_object_notify_by_pspec(G_OBJECT(counter),
+ cn_properties[CNODE_PROP_TOTAL_SIZE]);
}
void
@@ -527,7 +534,8 @@ purple_counting_node_set_current_size(Pu
priv->currentsize = currentsize;
- g_object_notify(G_OBJECT(counter), "current-size");
+ g_object_notify_by_pspec(G_OBJECT(counter),
+ cn_properties[CNODE_PROP_CURRENT_SIZE]);
}
void
@@ -539,7 +547,8 @@ purple_counting_node_set_online_count(Pu
priv->onlinecount = onlinecount;
- g_object_notify(G_OBJECT(counter), "online-count");
+ g_object_notify_by_pspec(G_OBJECT(counter),
+ cn_properties[CNODE_PROP_ONLINE_COUNT]);
}
/**************************************************************************
@@ -602,26 +611,29 @@ purple_counting_node_class_init(PurpleCo
obj_class->get_property = purple_counting_node_get_property;
obj_class->set_property = purple_counting_node_set_property;
More information about the Commits
mailing list