/soc/2013/ankitkv/gobjectification: 5d43951cabc0: More refactoring

Ankit Vani a at nevitus.org
Mon Sep 16 06:28:44 EDT 2013


Changeset: 5d43951cabc05297596b267bd44abea05194af2d
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-09-16 15:58 +0530
Branch:	 soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/5d43951cabc0

Description:

More refactoring

diffstat:

 libpurple/plugins/autoaccept.c     |  130 ++++++++++++++----------------------
 libpurple/plugins/buddynote.c      |   65 +++++++----------
 libpurple/plugins/codeinline.c     |    4 +-
 libpurple/plugins/helloworld.c     |    2 +-
 libpurple/plugins/idle.c           |   74 ++++++++------------
 libpurple/plugins/notify_example.c |    2 +-
 libpurple/plugins/signals-test.c   |   69 +++++++------------
 libpurple/plugins/simple.c         |   69 +++++++------------
 8 files changed, 162 insertions(+), 253 deletions(-)

diffs (truncated from 570 to 300 lines):

diff --git a/libpurple/plugins/autoaccept.c b/libpurple/plugins/autoaccept.c
--- a/libpurple/plugins/autoaccept.c
+++ b/libpurple/plugins/autoaccept.c
@@ -21,10 +21,11 @@
 
 #define PLUGIN_ID			"core-plugin_pack-autoaccept"
 #define PLUGIN_NAME			N_("Autoaccept")
+#define PLUGIN_CATEGORY		N_("Utility")
 #define PLUGIN_STATIC_NAME	Autoaccept
 #define PLUGIN_SUMMARY		N_("Auto-accept file transfer requests from selected users.")
 #define PLUGIN_DESCRIPTION	N_("Auto-accept file transfer requests from selected users.")
-#define PLUGIN_AUTHOR		"Sadrul H Chowdhury <sadrul at users.sourceforge.net>"
+#define PLUGIN_AUTHORS		{"Sadrul H Chowdhury <sadrul at users.sourceforge.net>", NULL}
 
 /* System headers */
 #include <glib.h>
@@ -225,37 +226,6 @@ context_menu(PurpleBlistNode *node, GLis
 	(*menu) = g_list_prepend(*menu, action);
 }
 
-static gboolean
-plugin_load(PurplePlugin *plugin)
-{
-	/* migrate the old pref (we should only care if the plugin is actually *used*) */
-	/*
-	 * TODO: We should eventually call purple_prefs_remove(PREFS_STRANGER_OLD)
-	 *       to clean up after ourselves, but we don't want to do it yet
-	 *       so that we don't break users who share a .purple directory
-	 *       between old libpurple clients and new libpurple clients.
-	 *                                             --Mark Doliner, 2011-01-03
-	 */
-	if (!purple_prefs_exists(PREF_STRANGER)) {
-		if (purple_prefs_exists(PREF_STRANGER_OLD) && purple_prefs_get_bool(PREF_STRANGER_OLD))
-			purple_prefs_add_int(PREF_STRANGER, FT_REJECT);
-		else
-			purple_prefs_set_int(PREF_STRANGER, FT_ASK);
-	}
-
-	purple_signal_connect(purple_xfers_get_handle(), "file-recv-request", plugin,
-						PURPLE_CALLBACK(file_recv_request_cb), plugin);
-	purple_signal_connect(purple_blist_get_handle(), "blist-node-extended-menu", plugin,
-						PURPLE_CALLBACK(context_menu), plugin);
-	return TRUE;
-}
-
-static gboolean
-plugin_unload(PurplePlugin *plugin)
-{
-	return TRUE;
-}
-
 static PurplePluginPrefFrame *
 get_plugin_pref_frame(PurplePlugin *plugin)
 {
@@ -294,54 +264,29 @@ get_plugin_pref_frame(PurplePlugin *plug
 	return frame;
 }
 
-static PurplePluginUiInfo prefs_info = {
-	get_plugin_pref_frame,
-	0,
-	NULL,
+static PurplePluginInfo *
+plugin_query(GError **error)
+{
+	const gchar * const authors[] = PLUGIN_AUTHORS;
 
-	/* padding */
-	NULL,
-	NULL,
-	NULL,
-	NULL
-};
+	return purple_plugin_info_new(
+		"id",                 PLUGIN_ID,
+		"name",               PLUGIN_NAME,
+		"version",            DISPLAY_VERSION,
+		"category",           PLUGIN_CATEGORY,
+		"summary",            PLUGIN_SUMMARY,
+		"description",        PLUGIN_DESCRIPTION,
+		"authors",            authors,
+		"website",            PURPLE_WEBSITE,
+		"abi-version",        PURPLE_ABI_VERSION,
+		"preferences-frame",  get_plugin_pref_frame,
+		NULL
+	);
+}
 
-static PurplePluginInfo info = {
-	PURPLE_PLUGIN_MAGIC,			/* Magic				*/
-	PURPLE_MAJOR_VERSION,			/* Purple Major Version	*/
-	PURPLE_MINOR_VERSION,			/* Purple Minor Version	*/
-	PURPLE_PLUGIN_STANDARD,			/* plugin type			*/
-	NULL,					/* ui requirement		*/
-	0,					/* flags				*/
-	NULL,					/* dependencies			*/
-	PURPLE_PRIORITY_DEFAULT,			/* priority				*/
-
-	PLUGIN_ID,				/* plugin id			*/
-	PLUGIN_NAME,				/* name					*/
-	DISPLAY_VERSION,			/* version				*/
-	PLUGIN_SUMMARY,				/* summary				*/
-	PLUGIN_DESCRIPTION,			/* description			*/
-	PLUGIN_AUTHOR,				/* author				*/
-	PURPLE_WEBSITE,				/* website				*/
-
-	plugin_load,				/* load					*/
-	plugin_unload,				/* unload				*/
-	NULL,					/* destroy				*/
-
-	NULL,					/* ui_info				*/
-	NULL,					/* extra_info			*/
-	&prefs_info,				/* prefs_info			*/
-	NULL,					/* actions				*/
-
-	/* padding */
-	NULL,
-	NULL,
-	NULL,
-	NULL
-};
-
-static void
-init_plugin(PurplePlugin *plugin) {
+static gboolean
+plugin_load(PurplePlugin *plugin, GError **error)
+{
 	char *dirname;
 
 	dirname = g_build_filename(purple_user_dir(), "autoaccept", NULL);
@@ -351,6 +296,33 @@ init_plugin(PurplePlugin *plugin) {
 	purple_prefs_add_bool(PREF_NEWDIR, TRUE);
 	purple_prefs_add_bool(PREF_ESCAPE, TRUE);
 	g_free(dirname);
+
+	/* migrate the old pref (we should only care if the plugin is actually *used*) */
+	/*
+	 * TODO: We should eventually call purple_prefs_remove(PREFS_STRANGER_OLD)
+	 *       to clean up after ourselves, but we don't want to do it yet
+	 *       so that we don't break users who share a .purple directory
+	 *       between old libpurple clients and new libpurple clients.
+	 *                                             --Mark Doliner, 2011-01-03
+	 */
+	if (!purple_prefs_exists(PREF_STRANGER)) {
+		if (purple_prefs_exists(PREF_STRANGER_OLD) && purple_prefs_get_bool(PREF_STRANGER_OLD))
+			purple_prefs_add_int(PREF_STRANGER, FT_REJECT);
+		else
+			purple_prefs_set_int(PREF_STRANGER, FT_ASK);
+	}
+
+	purple_signal_connect(purple_xfers_get_handle(), "file-recv-request", plugin,
+						PURPLE_CALLBACK(file_recv_request_cb), plugin);
+	purple_signal_connect(purple_blist_get_handle(), "blist-node-extended-menu", plugin,
+						PURPLE_CALLBACK(context_menu), plugin);
+	return TRUE;
 }
 
-PURPLE_INIT_PLUGIN(PLUGIN_STATIC_NAME, init_plugin, info)
+static gboolean
+plugin_unload(PurplePlugin *plugin, GError **error)
+{
+	return TRUE;
+}
+
+PURPLE_PLUGIN_INIT(PLUGIN_STATIC_NAME, plugin_query, plugin_load, plugin_unload);
diff --git a/libpurple/plugins/buddynote.c b/libpurple/plugins/buddynote.c
--- a/libpurple/plugins/buddynote.c
+++ b/libpurple/plugins/buddynote.c
@@ -65,8 +65,31 @@ buddynote_extended_menu_cb(PurpleBlistNo
 	*m = g_list_append(*m, bna);
 }
 
+static PurplePluginInfo *
+plugin_query(GError **error)
+{
+	const gchar * const authors[] = {
+		"Stu Tomlinson <stu at nosnilmot.com>",
+		NULL
+	};
+
+	return purple_plugin_info_new(
+		"id",           "core-plugin_pack-buddynote",
+		"name",         N_("Buddy Notes"),
+		"version",      DISPLAY_VERSION,
+		"category",     N_("Utility"),
+		"summary",      N_("Store notes on particular buddies."),
+		"description",  N_("Adds the option to store notes for buddies on your "
+		                   "buddy list."),
+		"authors",      authors,
+		"website",      PURPLE_WEBSITE,
+		"abi-version",  PURPLE_ABI_VERSION,
+		NULL
+	);
+}
+
 static gboolean
-plugin_load(PurplePlugin *plugin)
+plugin_load(PurplePlugin *plugin, GError **error)
 {
 
 	purple_signal_connect(purple_blist_get_handle(), "blist-node-extended-menu",
@@ -75,42 +98,10 @@ plugin_load(PurplePlugin *plugin)
 	return TRUE;
 }
 
-static PurplePluginInfo info =
+static gboolean
+plugin_unload(PurplePlugin *plugin, GError **error)
 {
-	PURPLE_PLUGIN_MAGIC,
-	PURPLE_MAJOR_VERSION,							/**< major version	*/
-	PURPLE_MINOR_VERSION,							/**< minor version	*/
-	PURPLE_PLUGIN_STANDARD,							/**< type			*/
-	NULL,											/**< ui_requirement	*/
-	0,												/**< flags			*/
-	NULL,											/**< dependencies	*/
-	PURPLE_PRIORITY_DEFAULT,						/**< priority		*/
-	"core-plugin_pack-buddynote",					/**< id				*/
-	N_("Buddy Notes"),								/**< name			*/
-	DISPLAY_VERSION,									/**< version		*/
-	N_("Store notes on particular buddies."),		/**< summary		*/
-	N_("Adds the option to store notes for buddies "
-	   "on your buddy list."),						/**< description	*/
-	"Stu Tomlinson <stu at nosnilmot.com>",			/**< author			*/
-	PURPLE_WEBSITE,									/**< homepage		*/
-	plugin_load,									/**< load			*/
-	NULL,											/**< unload			*/
-	NULL,											/**< destroy		*/
-	NULL,											/**< ui_info		*/
-	NULL,											/**< extra_info		*/
-	NULL,											/**< prefs_info		*/
-	NULL,											/**< actions		*/
-
-	/* padding */
-	NULL,
-	NULL,
-	NULL,
-	NULL
-};
-
-
-static void
-init_plugin(PurplePlugin *plugin) {
+	return TRUE;
 }
 
-PURPLE_INIT_PLUGIN(buddynote, init_plugin, info)
+PURPLE_PLUGIN_INIT(buddynote, plugin_query, plugin_load, plugin_unload);
diff --git a/libpurple/plugins/codeinline.c b/libpurple/plugins/codeinline.c
--- a/libpurple/plugins/codeinline.c
+++ b/libpurple/plugins/codeinline.c
@@ -59,8 +59,8 @@ plugin_query(GError **error)
 		"category",     "Formatting",
 		"summary",      "Formats text as code",
 		"description",  "Changes the formatting of any outgoing text such "
-                        "that anything underlined will be received green and "
-                        "monospace.",
+		                "that anything underlined will be received green and "
+		                "monospace.",
 		"authors",      authors,
 		"website",      PURPLE_WEBSITE,
 		"abi-version",  PURPLE_ABI_VERSION,
diff --git a/libpurple/plugins/helloworld.c b/libpurple/plugins/helloworld.c
--- a/libpurple/plugins/helloworld.c
+++ b/libpurple/plugins/helloworld.c
@@ -67,7 +67,7 @@ plugin_action_test_cb (PurplePluginActio
  * get a list of plugin actions to use for the plugin.  This function gives
  * libpurple that list of actions. */
 static GList *
-plugin_actions (PurplePlugin * plugin, gpointer context)
+plugin_actions (PurplePlugin * plugin)
 {
 	/* some C89 (a.k.a. ANSI C) compilers will warn if any variable declaration
 	 * includes an initilization that calls a function.  To avoid that, we
diff --git a/libpurple/plugins/idle.c b/libpurple/plugins/idle.c
--- a/libpurple/plugins/idle.c
+++ b/libpurple/plugins/idle.c
@@ -244,7 +244,7 @@ unidle_all_action(PurplePluginAction *ac
 }
 
 static GList *
-actions(PurplePlugin *plugin, gpointer context)
+actions(PurplePlugin *plugin)
 {
 	GList *l = NULL;
 	PurplePluginAction *act = NULL;
@@ -277,8 +277,33 @@ signing_off_cb(PurpleConnection *gc, voi
 	idled_accts = g_list_remove(idled_accts, account);
 }
 
+static PurplePluginInfo *
+plugin_query(GError **error)
+{
+	const gchar * const authors[] = {
+		"Eric Warmenhoven <eric at warmenhoven.org>",
+		NULL
+	};
+
+	return purple_plugin_info_new(
+		"id",           IDLE_PLUGIN_ID,



More information about the Commits mailing list