/soc/2013/ankitkv/gobjectification: f997e5384f79: libpurple: Use...

Ankit Vani a at nevitus.org
Sun Nov 17 09:54:22 EST 2013


Changeset: f997e5384f796c25ed843a59d0c33e6e550bdf0e
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-11-17 18:11 +0530
Branch:	 soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/f997e5384f79

Description:

libpurple: Use G_PARAM_STATIC_STRINGS and ensure g_object_notify is always called

diffstat:

 libpurple/account.c                         |  26 +++++--
 libpurple/blistnode.c                       |  11 ++-
 libpurple/blistnodetypes.c                  |  47 +++++++++----
 libpurple/circularbuffer.c                  |  32 ++++++++-
 libpurple/connection.c                      |  15 ++-
 libpurple/conversation.c                    |  22 ++++-
 libpurple/conversationtypes.c               |  45 ++++++++++---
 libpurple/presence.c                        |  23 ++++--
 libpurple/protocols/jabber/jingle/content.c |   9 ++-
 libpurple/roomlist.c                        |   9 +-
 libpurple/status.c                          |  14 ++-
 libpurple/whiteboard.c                      |  10 +-
 libpurple/xfer.c                            |  94 +++++++++++++++++-----------
 13 files changed, 241 insertions(+), 116 deletions(-)

diffs (truncated from 1315 to 300 lines):

diff --git a/libpurple/account.c b/libpurple/account.c
--- a/libpurple/account.c
+++ b/libpurple/account.c
@@ -802,6 +802,7 @@ purple_account_set_private_alias(PurpleA
 		char *old = priv->alias;
 
 		priv->alias = g_strdup(alias);
+		g_object_notify(G_OBJECT(account), "private-alias");
 		purple_signal_emit(purple_accounts_get_handle(), "account-alias-changed",
 						 account, old);
 		g_free(old);
@@ -856,6 +857,8 @@ 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");
+
 	purple_accounts_schedule_save();
 }
 
@@ -868,6 +871,8 @@ purple_account_set_connection(PurpleAcco
 
 	priv = PURPLE_ACCOUNT_GET_PRIVATE(account);
 	priv->gc = gc;
+
+	g_object_notify(G_OBJECT(account), "connection");
 }
 
 void
@@ -916,6 +921,8 @@ 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");
+
 	if ((gc != NULL) && (_purple_connection_wants_to_die(gc)))
 		wants_to_die = TRUE;
 
@@ -3064,55 +3071,56 @@ purple_account_class_init(PurpleAccountC
 	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_READWRITE | G_PARAM_CONSTRUCT | 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_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_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_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_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_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_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_READWRITE | G_PARAM_STATIC_STRINGS)
 			);
 
 	g_object_class_install_property(obj_class, 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_READWRITE | G_PARAM_CONSTRUCT_ONLY |
+				G_PARAM_STATIC_STRINGS)
 			);
 
 	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
@@ -410,7 +410,7 @@ purple_blist_node_class_init(PurpleBlist
 	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)
+				FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)
 			);
 
 	g_type_class_add_private(klass, sizeof(PurpleBlistNodePrivate));
@@ -605,19 +605,22 @@ purple_counting_node_class_init(PurpleCo
 	g_object_class_install_property(obj_class, CNODE_PROP_TOTAL_SIZE,
 			g_param_spec_int("total-size", "Total size",
 				"The number of children under this node.",
-				G_MININT, G_MAXINT, 0, G_PARAM_READWRITE)
+				G_MININT, G_MAXINT, 0, G_PARAM_READWRITE |
+				G_PARAM_STATIC_STRINGS)
 			);
 
 	g_object_class_install_property(obj_class, CNODE_PROP_CURRENT_SIZE,
 			g_param_spec_int("current-size", "Current size",
 				"The number of children with online accounts.",
-				G_MININT, G_MAXINT, 0, G_PARAM_READWRITE)
+				G_MININT, G_MAXINT, 0, G_PARAM_READWRITE |
+				G_PARAM_STATIC_STRINGS)
 			);
 
 	g_object_class_install_property(obj_class, CNODE_PROP_ONLINE_COUNT,
 			g_param_spec_int("online-count", "Online count",
 				"The number of children that are online.",
-				G_MININT, G_MAXINT, 0, G_PARAM_READWRITE)
+				G_MININT, G_MAXINT, 0, G_PARAM_READWRITE |
+				G_PARAM_STATIC_STRINGS)
 			);
 
 	g_type_class_add_private(klass, sizeof(PurpleCountingNodePrivate));
diff --git a/libpurple/blistnodetypes.c b/libpurple/blistnodetypes.c
--- a/libpurple/blistnodetypes.c
+++ b/libpurple/blistnodetypes.c
@@ -154,6 +154,8 @@ purple_buddy_set_icon(PurpleBuddy *buddy
 	{
 		purple_buddy_icon_unref(priv->icon);
 		priv->icon = (icon != NULL ? purple_buddy_icon_ref(icon) : NULL);
+
+		g_object_notify(G_OBJECT(buddy), "icon");
 	}
 
 	purple_signal_emit(purple_blist_get_handle(), "buddy-icon-changed", buddy);
@@ -195,14 +197,14 @@ purple_buddy_set_name(PurpleBuddy *buddy
 	g_free(priv->name);
 	priv->name = purple_utf8_strip_unprintables(name);
 
+	g_object_notify(G_OBJECT(buddy), "name");
+
 	if (ops) {
 		if (ops->save_node)
 			ops->save_node(PURPLE_BLIST_NODE(buddy));
 		if (ops->update)
 			ops->update(purple_blist_get_buddy_list(), PURPLE_BLIST_NODE(buddy));
 	}
-
-	g_object_notify(G_OBJECT(buddy), "name");
 }
 
 const char *
@@ -324,6 +326,8 @@ purple_buddy_set_local_alias(PurpleBuddy
 		g_free(new_alias); /* could be "\0" */
 	}
 
+	g_object_notify(G_OBJECT(buddy), "local-alias");
+
 	if (ops && ops->save_node)
 		ops->save_node(PURPLE_BLIST_NODE(buddy));
 
@@ -377,6 +381,8 @@ purple_buddy_set_server_alias(PurpleBudd
 		g_free(new_alias); /* could be "\0"; */
 	}
 
+	g_object_notify(G_OBJECT(buddy), "server-alias");
+
 	if (ops) {
 		if (ops->save_node)
 			ops->save_node(PURPLE_BLIST_NODE(buddy));
@@ -682,44 +688,45 @@ static void purple_buddy_class_init(Purp
 	g_object_class_install_property(obj_class, BUDDY_PROP_NAME,
 			g_param_spec_string("name", "Name",
 				"The name of the buddy.", NULL,
-				G_PARAM_READWRITE | G_PARAM_CONSTRUCT)
+				G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS)
 			);
 
 	g_object_class_install_property(obj_class, BUDDY_PROP_LOCAL_ALIAS,
 			g_param_spec_string("local-alias", "Local alias",
 				"Local alias of thee buddy.", NULL,
-				G_PARAM_READWRITE | G_PARAM_CONSTRUCT)
+				G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS)
 			);
 
 	g_object_class_install_property(obj_class, BUDDY_PROP_SERVER_ALIAS,
 			g_param_spec_string("server-alias", "Server alias",
 				"Server-side alias of the buddy.", NULL,
-				G_PARAM_READWRITE)
+				G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)
 			);
 
 	g_object_class_install_property(obj_class, BUDDY_PROP_ICON,
 			g_param_spec_pointer("icon", "Buddy icon",
 				"The icon for the buddy.",
-				G_PARAM_READWRITE)
+				G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)
 			);
 
 	g_object_class_install_property(obj_class, BUDDY_PROP_ACCOUNT,
 			g_param_spec_object("account", "Account",
 				"The account for the buddy.", PURPLE_TYPE_ACCOUNT,
-				G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)
+				G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
+				G_PARAM_STATIC_STRINGS)
 			);
 
 	g_object_class_install_property(obj_class, BUDDY_PROP_PRESENCE,
 			g_param_spec_object("presence", "Presence",
 				"The status information for the buddy.", PURPLE_TYPE_PRESENCE,
-				G_PARAM_READABLE)
+				G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)
 			);
 
 	g_object_class_install_property(obj_class, BUDDY_PROP_MEDIA_CAPS,
 			g_param_spec_enum("media-caps", "Media capabilities",
 				"The media capabilities of the buddy.",
 				PURPLE_MEDIA_TYPE_CAPS, PURPLE_MEDIA_CAPS_NONE,
-				G_PARAM_READWRITE)
+				G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)
 			);
 
 	g_type_class_add_private(klass, sizeof(PurpleBuddyPrivate));
@@ -813,6 +820,8 @@ purple_contact_compute_priority_buddy(Pu
 
 	priv->priority_buddy = new_priority;
 	priv->priority_valid = TRUE;
+
+	g_object_notify(G_OBJECT(contact), "priority-buddy");
 }
 
 PurpleGroup *
@@ -852,6 +861,8 @@ purple_contact_set_alias(PurpleContact *
 		g_free(new_alias); /* could be "\0" */
 	}
 
+	g_object_notify(G_OBJECT(contact), "alias");
+
 	if (ops) {
 		if (ops->save_node)
 			ops->save_node(PURPLE_BLIST_NODE(contact));
@@ -1043,13 +1054,13 @@ static void purple_contact_class_init(Pu
 	g_object_class_install_property(obj_class, CONTACT_PROP_ALIAS,
 			g_param_spec_string("alias", "Alias",
 				"The alias for the contact.", NULL,
-				G_PARAM_READWRITE)
+				G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)
 			);
 
 	g_object_class_install_property(obj_class, CONTACT_PROP_PRIORITY_BUDDY,
 			g_param_spec_object("priority-buddy",
 				"Priority buddy", "The priority buddy of the contact.",
-				PURPLE_TYPE_BUDDY, G_PARAM_READABLE)
+				PURPLE_TYPE_BUDDY, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)
 			);
 
 	g_type_class_add_private(klass, sizeof(PurpleContactPrivate));
@@ -1155,6 +1166,8 @@ purple_chat_set_alias(PurpleChat *chat, 
 		g_free(new_alias); /* could be "\0" */
 	}
 
+	g_object_notify(G_OBJECT(chat), "alias");
+
 	if (ops) {
 		if (ops->save_node)
 			ops->save_node(PURPLE_BLIST_NODE(chat));
@@ -1299,19 +1312,21 @@ static void purple_chat_class_init(Purpl
 	g_object_class_install_property(obj_class, CHAT_PROP_ALIAS,
 			g_param_spec_string("alias", "Alias",
 				"The alias for the chat.", NULL,
-				G_PARAM_READWRITE | G_PARAM_CONSTRUCT)
+				G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS)
 			);
 
 	g_object_class_install_property(obj_class, CHAT_PROP_ACCOUNT,
 			g_param_spec_object("account", "Account",
 				"The account that the chat belongs to.", PURPLE_TYPE_ACCOUNT,
-				G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)
+				G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
+				G_PARAM_STATIC_STRINGS)
 			);



More information about the Commits mailing list