/soc/2013/ankitkv/gobjectification: 8a3d21b27a22: Refactored bon...

Ankit Vani a at nevitus.org
Wed Jul 17 12:43:04 EDT 2013


Changeset: 8a3d21b27a22911ddf5eedccf9fb09e17d43690b
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-07-17 22:12 +0530
Branch:	 soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/8a3d21b27a22

Description:

Refactored bonjour, gg, irc and jabber to use GType and GValue instead of PurpleValue

diffstat:

 libpurple/protocols/bonjour/bonjour.c |    4 +-
 libpurple/protocols/gg/status.c       |   12 +-
 libpurple/protocols/irc/irc.c         |   12 +-
 libpurple/protocols/jabber/jabber.c   |  202 ++++++++++++++++-----------------
 4 files changed, 111 insertions(+), 119 deletions(-)

diffs (truncated from 410 to 300 lines):

diff --git a/libpurple/protocols/bonjour/bonjour.c b/libpurple/protocols/bonjour/bonjour.c
--- a/libpurple/protocols/bonjour/bonjour.c
+++ b/libpurple/protocols/bonjour/bonjour.c
@@ -289,14 +289,14 @@ bonjour_status_types(PurpleAccount *acco
 										   BONJOUR_STATUS_ID_AVAILABLE,
 										   NULL, TRUE, TRUE, FALSE,
 										   "message", _("Message"),
-										   purple_value_new(PURPLE_TYPE_STRING), NULL);
+										   purple_g_value_new(G_TYPE_STRING), NULL);
 	status_types = g_list_append(status_types, type);
 
 	type = purple_status_type_new_with_attrs(PURPLE_STATUS_AWAY,
 										   BONJOUR_STATUS_ID_AWAY,
 										   NULL, TRUE, TRUE, FALSE,
 										   "message", _("Message"),
-										   purple_value_new(PURPLE_TYPE_STRING), NULL);
+										   purple_g_value_new(G_TYPE_STRING), NULL);
 	status_types = g_list_append(status_types, type);
 
 	type = purple_status_type_new_full(PURPLE_STATUS_OFFLINE,
diff --git a/libpurple/protocols/gg/status.c b/libpurple/protocols/gg/status.c
--- a/libpurple/protocols/gg/status.c
+++ b/libpurple/protocols/gg/status.c
@@ -90,32 +90,32 @@ GList * ggp_status_types(PurpleAccount *
 	types = g_list_append(types, purple_status_type_new_with_attrs(
 		PURPLE_STATUS_AVAILABLE, NULL, NULL,
 		TRUE, TRUE, FALSE, "message", _("Message"),
-		purple_value_new(PURPLE_TYPE_STRING), NULL));
+		purple_g_value_new(G_TYPE_STRING), NULL));
 
 	types = g_list_append(types, purple_status_type_new_with_attrs(
 		PURPLE_STATUS_AVAILABLE, "freeforchat", _("Chatty"),
 		TRUE, TRUE, FALSE, "message", _("Message"),
-		purple_value_new(PURPLE_TYPE_STRING), NULL));
+		purple_g_value_new(G_TYPE_STRING), NULL));
 
 	types = g_list_append(types, purple_status_type_new_with_attrs(
 		PURPLE_STATUS_AWAY, NULL, NULL,
 		TRUE, TRUE, FALSE, "message", _("Message"),
-		purple_value_new(PURPLE_TYPE_STRING), NULL));
+		purple_g_value_new(G_TYPE_STRING), NULL));
 
 	types = g_list_append(types, purple_status_type_new_with_attrs(
 		PURPLE_STATUS_UNAVAILABLE, NULL, NULL,
 		TRUE, TRUE, FALSE, "message", _("Message"),
-		purple_value_new(PURPLE_TYPE_STRING), NULL));
+		purple_g_value_new(G_TYPE_STRING), NULL));
 
 	types = g_list_append(types, purple_status_type_new_with_attrs(
 		PURPLE_STATUS_INVISIBLE, NULL, NULL,
 		TRUE, TRUE, FALSE, "message", _("Message"),
-		purple_value_new(PURPLE_TYPE_STRING), NULL));
+		purple_g_value_new(G_TYPE_STRING), NULL));
 
 	types = g_list_append(types, purple_status_type_new_with_attrs(
 		PURPLE_STATUS_OFFLINE, NULL, NULL,
 		TRUE, TRUE, FALSE, "message", _("Message"),
-		purple_value_new(PURPLE_TYPE_STRING), NULL));
+		purple_g_value_new(G_TYPE_STRING), NULL));
 
 	return types;
 }
diff --git a/libpurple/protocols/irc/irc.c b/libpurple/protocols/irc/irc.c
--- a/libpurple/protocols/irc/irc.c
+++ b/libpurple/protocols/irc/irc.c
@@ -274,7 +274,7 @@ static GList *irc_status_types(PurpleAcc
 
 	type = purple_status_type_new_with_attrs(
 		PURPLE_STATUS_AWAY, NULL, NULL, TRUE, TRUE, FALSE,
-		"message", _("Message"), purple_value_new(PURPLE_TYPE_STRING),
+		"message", _("Message"), purple_g_value_new(G_TYPE_STRING),
 		NULL);
 	types = g_list_append(types, type);
 
@@ -994,13 +994,11 @@ static PurplePluginProtocolInfo prpl_inf
 static gboolean load_plugin (PurplePlugin *plugin) {
 
 	purple_signal_register(plugin, "irc-sending-text",
-			     purple_marshal_VOID__POINTER_POINTER, NULL, 2,
-			     purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_CONNECTION),
-			     purple_value_new_outgoing(PURPLE_TYPE_STRING));
+			     purple_marshal_VOID__POINTER_POINTER, G_TYPE_NONE, 2,
+			     PURPLE_TYPE_CONNECTION, G_TYPE_STRING);
 	purple_signal_register(plugin, "irc-receiving-text",
-			     purple_marshal_VOID__POINTER_POINTER, NULL, 2,
-			     purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_CONNECTION),
-			     purple_value_new_outgoing(PURPLE_TYPE_STRING));
+			     purple_marshal_VOID__POINTER_POINTER, G_TYPE_NONE, 2,
+			     PURPLE_TYPE_CONNECTION, G_TYPE_STRING);
 	return TRUE;
 }
 
diff --git a/libpurple/protocols/jabber/jabber.c b/libpurple/protocols/jabber/jabber.c
--- a/libpurple/protocols/jabber/jabber.c
+++ b/libpurple/protocols/jabber/jabber.c
@@ -2351,21 +2351,21 @@ GList *jabber_status_types(PurpleAccount
 {
 	PurpleStatusType *type;
 	GList *types = NULL;
-	PurpleValue *priority_value;
-	PurpleValue *buzz_enabled;
-
-	priority_value = purple_value_new(PURPLE_TYPE_INT);
-	purple_value_set_int(priority_value, 1);
-	buzz_enabled = purple_value_new(PURPLE_TYPE_BOOLEAN);
-	purple_value_set_boolean(buzz_enabled, TRUE);
+	GValue *priority_value;
+	GValue *buzz_enabled;
+
+	priority_value = purple_g_value_new(G_TYPE_INT);
+	g_value_set_int(priority_value, 1);
+	buzz_enabled = purple_g_value_new(G_TYPE_BOOLEAN);
+	g_value_set_boolean(buzz_enabled, TRUE);
 	type = purple_status_type_new_with_attrs(PURPLE_STATUS_AVAILABLE,
 			jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_ONLINE),
 			NULL, TRUE, TRUE, FALSE,
 			"priority", _("Priority"), priority_value,
-			"message", _("Message"), purple_value_new(PURPLE_TYPE_STRING),
-			"mood", _("Mood"), purple_value_new(PURPLE_TYPE_STRING),
-			"moodtext", _("Mood Text"), purple_value_new(PURPLE_TYPE_STRING),
-			"nick", _("Nickname"), purple_value_new(PURPLE_TYPE_STRING),
+			"message", _("Message"), purple_g_value_new(G_TYPE_STRING),
+			"mood", _("Mood"), purple_g_value_new(G_TYPE_STRING),
+			"moodtext", _("Mood Text"), purple_g_value_new(G_TYPE_STRING),
+			"nick", _("Nickname"), purple_g_value_new(G_TYPE_STRING),
 			"buzz", _("Allow Buzz"), buzz_enabled,
 			NULL);
 	types = g_list_prepend(types, type);
@@ -2373,69 +2373,69 @@ GList *jabber_status_types(PurpleAccount
 
 	type = purple_status_type_new_with_attrs(PURPLE_STATUS_MOOD,
 	    "mood", NULL, TRUE, TRUE, TRUE,
-			PURPLE_MOOD_NAME, _("Mood Name"), purple_value_new(PURPLE_TYPE_STRING),
-			PURPLE_MOOD_COMMENT, _("Mood Comment"), purple_value_new(PURPLE_TYPE_STRING),
+			PURPLE_MOOD_NAME, _("Mood Name"), purple_g_value_new(G_TYPE_STRING),
+			PURPLE_MOOD_COMMENT, _("Mood Comment"), purple_g_value_new(G_TYPE_STRING),
 			NULL);
 	types = g_list_prepend(types, type);
 
-	priority_value = purple_value_new(PURPLE_TYPE_INT);
-	purple_value_set_int(priority_value, 1);
-	buzz_enabled = purple_value_new(PURPLE_TYPE_BOOLEAN);
-	purple_value_set_boolean(buzz_enabled, TRUE);
+	priority_value = purple_g_value_new(G_TYPE_INT);
+	g_value_set_int(priority_value, 1);
+	buzz_enabled = purple_g_value_new(G_TYPE_BOOLEAN);
+	g_value_set_boolean(buzz_enabled, TRUE);
 	type = purple_status_type_new_with_attrs(PURPLE_STATUS_AVAILABLE,
 			jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_CHAT),
 			_("Chatty"), TRUE, TRUE, FALSE,
 			"priority", _("Priority"), priority_value,
-			"message", _("Message"), purple_value_new(PURPLE_TYPE_STRING),
-			"mood", _("Mood"), purple_value_new(PURPLE_TYPE_STRING),
-			"moodtext", _("Mood Text"), purple_value_new(PURPLE_TYPE_STRING),
-			"nick", _("Nickname"), purple_value_new(PURPLE_TYPE_STRING),
+			"message", _("Message"), purple_g_value_new(G_TYPE_STRING),
+			"mood", _("Mood"), purple_g_value_new(G_TYPE_STRING),
+			"moodtext", _("Mood Text"), purple_g_value_new(G_TYPE_STRING),
+			"nick", _("Nickname"), purple_g_value_new(G_TYPE_STRING),
 			"buzz", _("Allow Buzz"), buzz_enabled,
 			NULL);
 	types = g_list_prepend(types, type);
 
-	priority_value = purple_value_new(PURPLE_TYPE_INT);
-	purple_value_set_int(priority_value, 0);
-	buzz_enabled = purple_value_new(PURPLE_TYPE_BOOLEAN);
-	purple_value_set_boolean(buzz_enabled, TRUE);
+	priority_value = purple_g_value_new(G_TYPE_INT);
+	g_value_set_int(priority_value, 0);
+	buzz_enabled = purple_g_value_new(G_TYPE_BOOLEAN);
+	g_value_set_boolean(buzz_enabled, TRUE);
 	type = purple_status_type_new_with_attrs(PURPLE_STATUS_AWAY,
 			jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_AWAY),
 			NULL, TRUE, TRUE, FALSE,
 			"priority", _("Priority"), priority_value,
-			"message", _("Message"), purple_value_new(PURPLE_TYPE_STRING),
-			"mood", _("Mood"), purple_value_new(PURPLE_TYPE_STRING),
-			"moodtext", _("Mood Text"), purple_value_new(PURPLE_TYPE_STRING),
-			"nick", _("Nickname"), purple_value_new(PURPLE_TYPE_STRING),
+			"message", _("Message"), purple_g_value_new(G_TYPE_STRING),
+			"mood", _("Mood"), purple_g_value_new(G_TYPE_STRING),
+			"moodtext", _("Mood Text"), purple_g_value_new(G_TYPE_STRING),
+			"nick", _("Nickname"), purple_g_value_new(G_TYPE_STRING),
 			"buzz", _("Allow Buzz"), buzz_enabled,
 			NULL);
 	types = g_list_prepend(types, type);
 
-	priority_value = purple_value_new(PURPLE_TYPE_INT);
-	purple_value_set_int(priority_value, 0);
-	buzz_enabled = purple_value_new(PURPLE_TYPE_BOOLEAN);
-	purple_value_set_boolean(buzz_enabled, TRUE);
+	priority_value = purple_g_value_new(G_TYPE_INT);
+	g_value_set_int(priority_value, 0);
+	buzz_enabled = purple_g_value_new(G_TYPE_BOOLEAN);
+	g_value_set_boolean(buzz_enabled, TRUE);
 	type = purple_status_type_new_with_attrs(PURPLE_STATUS_EXTENDED_AWAY,
 			jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_XA),
 			NULL, TRUE, TRUE, FALSE,
 			"priority", _("Priority"), priority_value,
-			"message", _("Message"), purple_value_new(PURPLE_TYPE_STRING),
-			"mood", _("Mood"), purple_value_new(PURPLE_TYPE_STRING),
-			"moodtext", _("Mood Text"), purple_value_new(PURPLE_TYPE_STRING),
-			"nick", _("Nickname"), purple_value_new(PURPLE_TYPE_STRING),
+			"message", _("Message"), purple_g_value_new(G_TYPE_STRING),
+			"mood", _("Mood"), purple_g_value_new(G_TYPE_STRING),
+			"moodtext", _("Mood Text"), purple_g_value_new(G_TYPE_STRING),
+			"nick", _("Nickname"), purple_g_value_new(G_TYPE_STRING),
 			"buzz", _("Allow Buzz"), buzz_enabled,
 			NULL);
 	types = g_list_prepend(types, type);
 
-	priority_value = purple_value_new(PURPLE_TYPE_INT);
-	purple_value_set_int(priority_value, 0);
+	priority_value = purple_g_value_new(G_TYPE_INT);
+	g_value_set_int(priority_value, 0);
 	type = purple_status_type_new_with_attrs(PURPLE_STATUS_UNAVAILABLE,
 			jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_DND),
 			_("Do Not Disturb"), TRUE, TRUE, FALSE,
 			"priority", _("Priority"), priority_value,
-			"message", _("Message"), purple_value_new(PURPLE_TYPE_STRING),
-			"mood", _("Mood"), purple_value_new(PURPLE_TYPE_STRING),
-			"moodtext", _("Mood Text"), purple_value_new(PURPLE_TYPE_STRING),
-			"nick", _("Nickname"), purple_value_new(PURPLE_TYPE_STRING),
+			"message", _("Message"), purple_g_value_new(G_TYPE_STRING),
+			"mood", _("Mood"), purple_g_value_new(G_TYPE_STRING),
+			"moodtext", _("Mood Text"), purple_g_value_new(G_TYPE_STRING),
+			"nick", _("Nickname"), purple_g_value_new(G_TYPE_STRING),
 			NULL);
 	types = g_list_prepend(types, type);
 
@@ -2447,21 +2447,21 @@ GList *jabber_status_types(PurpleAccount
 	type = purple_status_type_new_with_attrs(PURPLE_STATUS_OFFLINE,
 			jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_UNAVAILABLE),
 			NULL, TRUE, TRUE, FALSE,
-			"message", _("Message"), purple_value_new(PURPLE_TYPE_STRING),
+			"message", _("Message"), purple_g_value_new(G_TYPE_STRING),
 			NULL);
 	types = g_list_prepend(types, type);
 
 	type = purple_status_type_new_with_attrs(PURPLE_STATUS_TUNE,
 			"tune", NULL, FALSE, TRUE, TRUE,
-			PURPLE_TUNE_ARTIST, _("Tune Artist"), purple_value_new(PURPLE_TYPE_STRING),
-			PURPLE_TUNE_TITLE, _("Tune Title"), purple_value_new(PURPLE_TYPE_STRING),
-			PURPLE_TUNE_ALBUM, _("Tune Album"), purple_value_new(PURPLE_TYPE_STRING),
-			PURPLE_TUNE_GENRE, _("Tune Genre"), purple_value_new(PURPLE_TYPE_STRING),
-			PURPLE_TUNE_COMMENT, _("Tune Comment"), purple_value_new(PURPLE_TYPE_STRING),
-			PURPLE_TUNE_TRACK, _("Tune Track"), purple_value_new(PURPLE_TYPE_STRING),
-			PURPLE_TUNE_TIME, _("Tune Time"), purple_value_new(PURPLE_TYPE_INT),
-			PURPLE_TUNE_YEAR, _("Tune Year"), purple_value_new(PURPLE_TYPE_INT),
-			PURPLE_TUNE_URL, _("Tune URL"), purple_value_new(PURPLE_TYPE_STRING),
+			PURPLE_TUNE_ARTIST, _("Tune Artist"), purple_g_value_new(G_TYPE_STRING),
+			PURPLE_TUNE_TITLE, _("Tune Title"), purple_g_value_new(G_TYPE_STRING),
+			PURPLE_TUNE_ALBUM, _("Tune Album"), purple_g_value_new(G_TYPE_STRING),
+			PURPLE_TUNE_GENRE, _("Tune Genre"), purple_g_value_new(G_TYPE_STRING),
+			PURPLE_TUNE_COMMENT, _("Tune Comment"), purple_g_value_new(G_TYPE_STRING),
+			PURPLE_TUNE_TRACK, _("Tune Track"), purple_g_value_new(G_TYPE_STRING),
+			PURPLE_TUNE_TIME, _("Tune Time"), purple_g_value_new(G_TYPE_INT),
+			PURPLE_TUNE_YEAR, _("Tune Year"), purple_g_value_new(G_TYPE_INT),
+			PURPLE_TUNE_URL, _("Tune URL"), purple_g_value_new(G_TYPE_STRING),
 			NULL);
 	types = g_list_prepend(types, type);
 
@@ -3950,41 +3950,38 @@ void jabber_plugin_init(PurplePlugin *pl
 	/* IPC functions */
 	purple_plugin_ipc_register(plugin, "contact_has_feature", PURPLE_CALLBACK(jabber_ipc_contact_has_feature),
 							 purple_marshal_BOOLEAN__POINTER_POINTER_POINTER,
-							 purple_value_new(PURPLE_TYPE_BOOLEAN), 3,
-							 purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_ACCOUNT),
-							 purple_value_new(PURPLE_TYPE_STRING),
-							 purple_value_new(PURPLE_TYPE_STRING));
+							 G_TYPE_BOOLEAN, 3,
+							 PURPLE_TYPE_ACCOUNT, G_TYPE_STRING, G_TYPE_STRING);
 
 	purple_plugin_ipc_register(plugin, "add_feature", PURPLE_CALLBACK(jabber_ipc_add_feature),
 							 purple_marshal_VOID__POINTER,
-							 NULL, 1,
-							 purple_value_new(PURPLE_TYPE_STRING));
+							 G_TYPE_NONE, 1, G_TYPE_STRING);
 
 	purple_plugin_ipc_register(plugin, "register_namespace_watcher",
 	                           PURPLE_CALLBACK(jabber_iq_signal_register),
 	                           purple_marshal_VOID__POINTER_POINTER,
-	                           NULL, 2,
-	                           purple_value_new(PURPLE_TYPE_STRING),  /* node */
-	                           purple_value_new(PURPLE_TYPE_STRING)); /* namespace */
+	                           G_TYPE_NONE, 2,
+	                           G_TYPE_STRING,  /* node */
+	                           G_TYPE_STRING); /* namespace */
 
 	purple_plugin_ipc_register(plugin, "unregister_namespace_watcher",
 	                           PURPLE_CALLBACK(jabber_iq_signal_unregister),
 	                           purple_marshal_VOID__POINTER_POINTER,
-	                           NULL, 2,
-	                           purple_value_new(PURPLE_TYPE_STRING),  /* node */
-	                           purple_value_new(PURPLE_TYPE_STRING)); /* namespace */
+	                           G_TYPE_NONE, 2,
+	                           G_TYPE_STRING,  /* node */
+	                           G_TYPE_STRING); /* namespace */
 
 	purple_signal_register(plugin, "jabber-register-namespace-watcher",



More information about the Commits mailing list