/soc/2013/ankitkv/gobjectification: c96edeed7ea7: Refactored not...

Ankit Vani a at nevitus.org
Mon Sep 16 03:00:44 EDT 2013


Changeset: c96edeed7ea7cae68cc7b474ccf3f06344fb8045
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-09-16 12:30 +0530
Branch:	 soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/c96edeed7ea7

Description:

Refactored notify_example, one_time_password, pluginpref_example plugins to use the new API

diffstat:

 libpurple/plugins/notify_example.c     |  63 +++++++++++---------------
 libpurple/plugins/one_time_password.c  |  75 +++++++++++++------------------
 libpurple/plugins/pluginpref_example.c |  80 +++++++++++++--------------------
 3 files changed, 89 insertions(+), 129 deletions(-)

diffs (298 lines):

diff --git a/libpurple/plugins/notify_example.c b/libpurple/plugins/notify_example.c
--- a/libpurple/plugins/notify_example.c
+++ b/libpurple/plugins/notify_example.c
@@ -44,7 +44,7 @@
 #endif
 
 #define PLUGIN_ID "core-notifyexample"
-#define PLUGIN_AUTHOR "John Bailey <rekkanoryo at cpw.pidgin.im>"
+#define PLUGIN_AUTHORS { "John Bailey <rekkanoryo at cpw.pidgin.im>", NULL }
 
 #include <notify.h>
 #include <plugins.h>
@@ -114,8 +114,28 @@ plugin_actions(PurplePlugin *plugin, gpo
 	return g_list_reverse(actions);
 }
 
+static PurplePluginInfo *
+plugin_query(GError **error)
+{
+	const gchar * const authors[] = PLUGIN_AUTHORS;
+
+	return purple_plugin_info_new(
+		"id",           PLUGIN_ID,
+		"name",         "Notify API Example",
+		"version",      DISPLAY_VERSION,
+		"category",     "Example",
+		"summary",      "Notify API Example",
+		"description",  "Notify API Example",
+		"authors",      authors,
+		"website",      "https://pidgin.im",
+		"abi-version",  PURPLE_ABI_VERSION,
+		"get-actions",  plugin_actions,
+		NULL
+	);
+}
+
 static gboolean
-plugin_load(PurplePlugin *plugin)
+plugin_load(PurplePlugin *plugin, GError **error)
 {
 	/* we need a handle for all the notify calls */
 	notify_example = plugin;
@@ -123,42 +143,11 @@ plugin_load(PurplePlugin *plugin)
 	return TRUE;
 }
 
-static PurplePluginInfo info = {
-	PURPLE_PLUGIN_MAGIC,        /* magic number */
-	PURPLE_MAJOR_VERSION,       /* purple major */
-	PURPLE_MINOR_VERSION,       /* purple minor */
-	PURPLE_PLUGIN_STANDARD,     /* plugin type */
-	NULL,                       /* UI requirement */
-	0,                          /* flags */
-	NULL,                       /* dependencies */
-	PURPLE_PRIORITY_DEFAULT,    /* priority */
-
-	PLUGIN_ID,                  /* id */
-	"Notify API Example",       /* name */
-	DISPLAY_VERSION,            /* version */
-	"Notify API Example",       /* summary */
-	"Notify API Example",       /* description */
-	PLUGIN_AUTHOR,              /* author */
-	"https://pidgin.im",        /* homepage */
-
-	plugin_load,                /* load */
-	NULL,                       /* unload */
-	NULL,                       /* destroy */
-
-	NULL,                       /* ui info */
-	NULL,                       /* extra info */
-	NULL,                       /* prefs info */
-	plugin_actions,             /* actions */
-	NULL,                       /* reserved */
-	NULL,                       /* reserved */
-	NULL,                       /* reserved */
-	NULL                        /* reserved */
-};
-
-static void
-init_plugin(PurplePlugin *plugin)
+static gboolean
+plugin_unload(PurplePlugin *plugin, GError **error)
 {
+	return TRUE;
 }
 
-PURPLE_INIT_PLUGIN(notifyexample, init_plugin, info)
+PURPLE_PLUGIN_INIT(notifyexample, plugin_query, plugin_load, plugin_unload);
 
diff --git a/libpurple/plugins/one_time_password.c b/libpurple/plugins/one_time_password.c
--- a/libpurple/plugins/one_time_password.c
+++ b/libpurple/plugins/one_time_password.c
@@ -52,8 +52,34 @@ signed_on_cb(PurpleConnection *conn, voi
 	}
 }
 
+static PurplePluginInfo *
+plugin_query(GError **error)
+{
+	const gchar * const authors[] = {
+		"Daniel Atallah <datallah at pidgin.im>",
+		NULL
+	};
+
+	return purple_plugin_info_new(
+		"id",           PLUGIN_ID,
+		"name",         N_("One Time Password Support"),
+		"version",      DISPLAY_VERSION,
+		"category",     N_("Security"),
+		"summary",      N_("Enforce that passwords are used only once."),
+		"description",  N_("Allows you to enforce on a per-account basis that "
+		                   "passwords not being saved are only used in a "
+		                   "single successful connection.\n"
+		                   "Note: The account password must not be saved for "
+		                   "this to work."),
+		"authors",      authors,
+		"website",      PURPLE_WEBSITE,
+		"abi-version",  PURPLE_ABI_VERSION,
+		NULL
+	);
+}
+
 static gboolean
-plugin_load(PurplePlugin *plugin)
+plugin_load(PurplePlugin *plugin, GError **error)
 {
 	PurpleProtocol *protocol;
 	PurpleAccountOption *option;
@@ -67,7 +93,7 @@ plugin_load(PurplePlugin *plugin)
 		if (protocol != NULL && !(purple_protocol_get_options(protocol) & OPT_PROTO_NO_PASSWORD)) {
 			option = purple_account_option_bool_new(_("One Time Password"),
 								PREF_NAME, FALSE);
-			purple_protocol_get_protocol_options(protocol) = g_list_append(purple_protocol_get_protocol_options(protocol), option);
+			protocol->protocol_options = g_list_append(protocol->protocol_options, option);
 		}
 	}
 	g_list_free(list);
@@ -80,7 +106,7 @@ plugin_load(PurplePlugin *plugin)
 }
 
 static gboolean
-plugin_unload(PurplePlugin *plugin)
+plugin_unload(PurplePlugin *plugin, GError **error)
 {
 	PurpleProtocol *protocol;
 	PurpleAccountOption *option;
@@ -96,7 +122,7 @@ plugin_unload(PurplePlugin *plugin)
 			while (options != NULL) {
 				option = (PurpleAccountOption *) options->data;
 				if (strcmp(PREF_NAME, purple_account_option_get_setting(option)) == 0) {
-					purple_protocol_get_protocol_options(protocol) = g_list_delete_link(purple_protocol_get_protocol_options(protocol), options);
+					protocol->protocol_options = g_list_delete_link(protocol->protocol_options, options);
 					purple_account_option_destroy(option);
 					break;
 				}
@@ -111,43 +137,4 @@ plugin_unload(PurplePlugin *plugin)
 	return TRUE;
 }
 
-static PurplePluginInfo info =
-{
-	PURPLE_PLUGIN_MAGIC,
-	PURPLE_MAJOR_VERSION,
-	PURPLE_MINOR_VERSION,
-	PURPLE_PLUGIN_STANDARD,				/**< type           */
-	NULL,						/**< ui_requirement */
-	0,						/**< flags          */
-	NULL,						/**< dependencies   */
-	PURPLE_PRIORITY_DEFAULT,			/**< priority       */
-	PLUGIN_ID,					/**< id             */
-	N_("One Time Password Support"),		/**< name           */
-	DISPLAY_VERSION,				/**< version        */
-							/**  summary        */
-	N_("Enforce that passwords are used only once."),
-							/**  description    */
-	N_("Allows you to enforce on a per-account basis that passwords not "
-	   "being saved are only used in a single successful connection.\n"
-	   "Note: The account password must not be saved for this to work."),
-	"Daniel Atallah <datallah at pidgin.im>",		/**< author         */
-	PURPLE_WEBSITE,					/**< homepage       */
-	plugin_load,					/**< load           */
-	plugin_unload,					/**< unload         */
-	NULL,						/**< destroy        */
-	NULL,						/**< ui_info        */
-	NULL,						/**< extra_info     */
-	NULL,						/**< prefs_info     */
-	NULL,						/**< actions        */
-	NULL,						/**< reserved 1     */
-	NULL,						/**< reserved 2     */
-	NULL,						/**< reserved 3     */
-	NULL						/**< reserved 4     */
-};
-
-static void
-init_plugin(PurplePlugin *plugin)
-{
-}
-
-PURPLE_INIT_PLUGIN(one_time_password, init_plugin, info)
+PURPLE_PLUGIN_INIT(one_time_password, plugin_query, plugin_load, plugin_unload);
diff --git a/libpurple/plugins/pluginpref_example.c b/libpurple/plugins/pluginpref_example.c
--- a/libpurple/plugins/pluginpref_example.c
+++ b/libpurple/plugins/pluginpref_example.c
@@ -107,55 +107,31 @@ get_plugin_pref_frame(PurplePlugin *plug
 	return frame;
 }
 
-static PurplePluginUiInfo prefs_info = {
-	get_plugin_pref_frame,
-	0,   /* page_num (Reserved) */
-	NULL, /* frame (Reserved) */
-	/* Padding */
-	NULL,
-	NULL,
-	NULL,
-	NULL
-};
+static PurplePluginInfo *
+plugin_query(GError **error)
+{
+	const gchar * const authors[] = {
+		"Gary Kramlich <amc_grim at users.sf.net>",
+		NULL
+	};
 
-static PurplePluginInfo info =
-{
-	PURPLE_PLUGIN_MAGIC,
-	PURPLE_MAJOR_VERSION,
-	PURPLE_MINOR_VERSION,
-	PURPLE_PLUGIN_STANDARD,                             /**< type           */
-	NULL,                                             /**< ui_requirement */
-	0,                                                /**< flags          */
-	NULL,                                             /**< dependencies   */
-	PURPLE_PRIORITY_DEFAULT,                            /**< priority       */
+	return purple_plugin_info_new(
+		"id",                 "core-pluginpref_example",
+		"name",               "Pluginpref Example",
+		"version",            DISPLAY_VERSION,
+		"category",           "Example",
+		"summary",            "An example of how to use pluginprefs",
+		"description",        "An example of how to use pluginprefs",
+		"authors",            authors,
+		"website",            PURPLE_WEBSITE,
+		"abi-version",        PURPLE_ABI_VERSION,
+		"preferences-frame",  get_plugin_pref_frame,
+		NULL
+	);
+}
 
-	"core-pluginpref_example",                     /**< id             */
-	"Pluginpref Example",                           /**< name           */
-	DISPLAY_VERSION,                                  /**< version        */
-	                                                  /**  summary        */
-	"An example of how to use pluginprefs",
-	                                                  /**  description    */
-	"An example of how to use pluginprefs",
-	"Gary Kramlich <amc_grim at users.sf.net>",      /**< author         */
-	PURPLE_WEBSITE,                                     /**< homepage       */
-
-	NULL,                                             /**< load           */
-	NULL,                                             /**< 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)
 {
 	purple_prefs_add_none("/plugins/core/pluginpref_example");
 	purple_prefs_add_bool("/plugins/core/pluginpref_example/bool", TRUE);
@@ -167,6 +143,14 @@ init_plugin(PurplePlugin *plugin)
 							"max length string");
 	purple_prefs_add_string("/plugins/core/pluginpref_example/masked_string", "masked");
 	purple_prefs_add_string("/plugins/core/pluginpref_example/string_choice", "red");
+
+	return TRUE;
 }
 
-PURPLE_INIT_PLUGIN(ppexample, init_plugin, info)
+static gboolean
+plugin_unload(PurplePlugin *plugin, GError **error)
+{
+	return TRUE;
+}
+
+PURPLE_PLUGIN_INIT(ppexample, plugin_query, plugin_load, plugin_unload);



More information about the Commits mailing list