/soc/2013/ankitkv/gobjectification: 569f0d81876a: Refactored the...

Ankit Vani a at nevitus.org
Sun Sep 15 16:18:31 EDT 2013


Changeset: 569f0d81876af649a87911e6638214dc1232976d
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-09-16 01:48 +0530
Branch:	 soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/569f0d81876a

Description:

Refactored the helloworld plugin to use the new plugin API

diffstat:

 libpurple/plugins/helloworld.c |  74 ++++++++++++++++++-----------------------
 1 files changed, 32 insertions(+), 42 deletions(-)

diffs (92 lines):

diff --git a/libpurple/plugins/helloworld.c b/libpurple/plugins/helloworld.c
--- a/libpurple/plugins/helloworld.c
+++ b/libpurple/plugins/helloworld.c
@@ -88,8 +88,35 @@ plugin_actions (PurplePlugin * plugin, g
 	return list;
 }
 
+static PurplePluginInfo *
+plugin_query (GError ** error)
+{
+	const gchar * const authors[] = {
+		"John Bailey <rekkanoryo at cpw.pidgin.im>", /* correct author */
+		NULL
+	};
+
+	/* For specific notes on the meanings of each of these members, consult the
+	   C Plugin Howto on the website. */
+	return purple_plugin_info_new (
+		"id",           "core-hello_world",
+		"name",         "Hello World!",
+		"version",      DISPLAY_VERSION, /* This constant is defined in config.h, but you shouldn't use it for your
+		                                    own plugins.  We use it here because it's our plugin. And we're lazy. */
+		"category",     "Example",
+		"summary",      "Hello World Plugin",
+		"description",  "Hello World Plugin",
+		"authors",      authors,
+		"website",      "http://helloworld.tld",
+		"abi-version",  PURPLE_ABI_VERSION,
+		"get-actions",  plugin_actions, /* this tells libpurple the address of the function to call to get the list
+		                                   of plugin actions. */
+		NULL
+	);
+}
+
 static gboolean
-plugin_load (PurplePlugin * plugin)
+plugin_load (PurplePlugin * plugin, GError ** error)
 {
 	purple_notify_message (plugin, PURPLE_NOTIFY_MSG_INFO, "Hello World!",
 		"This is the Hello World! plugin :)", NULL, NULL,
@@ -100,47 +127,10 @@ plugin_load (PurplePlugin * plugin)
 	return TRUE;
 }
 
-/* For specific notes on the meanings of each of these members, consult the C Plugin Howto
- * on the website. */
-static PurplePluginInfo info = {
-	PURPLE_PLUGIN_MAGIC,
-	PURPLE_MAJOR_VERSION,
-	PURPLE_MINOR_VERSION,
-	PURPLE_PLUGIN_STANDARD,
-	NULL,
-	0,
-	NULL,
-	PURPLE_PRIORITY_DEFAULT,
-
-	"core-hello_world",
-	"Hello World!",
-	DISPLAY_VERSION, /* This constant is defined in config.h, but you shouldn't use it for
-		    your own plugins.  We use it here because it's our plugin. And we're lazy. */
-
-	"Hello World Plugin",
-	"Hello World Plugin",
-	"John Bailey <rekkanoryo at cpw.pidgin.im>", /* correct author */
-	"http://helloworld.tld",
-
-
-	plugin_load,
-	NULL,
-	NULL,
-
-	NULL,
-	NULL,
-	NULL,
-	plugin_actions,		/* this tells libpurple the address of the function to call
-				   to get the list of plugin actions. */
-	NULL,
-	NULL,
-	NULL,
-	NULL
-};
-
-static void
-init_plugin (PurplePlugin * plugin)
+static gboolean
+plugin_unload (PurplePlugin * plugin, GError ** error)
 {
+	return TRUE;
 }
 
-PURPLE_INIT_PLUGIN (hello_world, init_plugin, info)
+PURPLE_PLUGIN_INIT (hello_world, plugin_query, plugin_load, plugin_unload);



More information about the Commits mailing list