/soc/2013/ankitkv/gobjectification: 472bef54ba0a: Started refact...

Ankit Vani a at nevitus.org
Sun Sep 15 15:58:30 EDT 2013


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

Description:

Started refactoring plugins to use the new plugin API

diffstat:

 libpurple/plugins/ciphertest.c    |  67 +++++++++++++-----------------------
 libpurple/plugins/codeinline.c    |  70 +++++++++++++++++---------------------
 libpurple/plugins/debug_example.c |  62 +++++++++++++--------------------
 3 files changed, 80 insertions(+), 119 deletions(-)

diffs (257 lines):

diff --git a/libpurple/plugins/ciphertest.c b/libpurple/plugins/ciphertest.c
--- a/libpurple/plugins/ciphertest.c
+++ b/libpurple/plugins/ciphertest.c
@@ -580,8 +580,29 @@ cipher_test_aes(void)
 /**************************************************************************
  * Plugin stuff
  **************************************************************************/
+static PurplePluginInfo *
+plugin_query(GError **error) {
+	const gchar * const authors[] = {
+		"Gary Kramlich <amc_grim at users.sf.net>",
+		NULL
+	};
+
+	return purple_plugin_info_new(
+		"id",           "core-cipher-test",
+		"name",         N_("Cipher Test"),
+		"version",      DISPLAY_VERSION,
+		"category",     N_("Testing"),
+		"summary",      N_("Tests the ciphers that ship with libpurple."),
+		"description",  N_("Tests the ciphers that ship with libpurple."),
+		"authors",      authors,
+		"website",      PURPLE_WEBSITE,
+		"abi-version",  PURPLE_ABI_VERSION,
+		NULL
+	);
+}
+
 static gboolean
-plugin_load(PurplePlugin *plugin) {
+plugin_load(PurplePlugin *plugin, GError **error) {
 	cipher_test_md5();
 	cipher_test_sha1();
 	cipher_test_digest();
@@ -592,48 +613,8 @@ plugin_load(PurplePlugin *plugin) {
 }
 
 static gboolean
-plugin_unload(PurplePlugin *plugin) {
+plugin_unload(PurplePlugin *plugin, GError **error) {
 	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       */
-
-	"core-cipher-test",									/**< id             */
-	N_("Cipher Test"),									/**< name           */
-	DISPLAY_VERSION,										/**< version        */
-														/**  summary        */
-	N_("Tests the ciphers that ship with libpurple."),
-														/**  description    */
-	N_("Tests the ciphers that ship with libpurple."),
-	"Gary Kramlich <amc_grim at users.sf.net>",			/**< author         */
-	PURPLE_WEBSITE,										/**< homepage       */
-
-	plugin_load,										/**< load           */
-	plugin_unload,										/**< unload         */
-	NULL,												/**< destroy        */
-
-	NULL,												/**< ui_info        */
-	NULL,												/**< extra_info     */
-	NULL,
-	NULL,
-	/* padding */
-	NULL,
-	NULL,
-	NULL,
-	NULL
-};
-
-static void
-init_plugin(PurplePlugin *plugin) {
-}
-
-PURPLE_INIT_PLUGIN(cipher_test, init_plugin, info)
+PURPLE_PLUGIN_INIT(cipher_test, 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
@@ -44,8 +44,32 @@ static gboolean outgoing_msg_cb(PurpleAc
   return FALSE;
 }
 
+static PurplePluginInfo *
+plugin_query(GError **error)
+{
+	const gchar * const authors[] = {
+		"Sean Egan <seanegan at gmail.com>",
+		NULL
+	};
+
+	return purple_plugin_info_new(
+		"id",           "codeinline",
+		"name",         "Code Inline",
+		"version",      "1.0",
+		"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.",
+		"authors",      authors,
+		"website",      PURPLE_WEBSITE,
+		"abi-version",  PURPLE_ABI_VERSION,
+		NULL
+	);
+}
+
 static gboolean
-plugin_load(PurplePlugin *plugin)
+plugin_load(PurplePlugin *plugin, GError **error)
 {
      void *handle = purple_conversations_get_handle();
      plugin_handle = plugin;
@@ -57,42 +81,10 @@ plugin_load(PurplePlugin *plugin)
      return TRUE;
 }
 
+static gboolean
+plugin_unload(PurplePlugin *plugin, GError **error)
+{
+	return TRUE;
+}
 
-static PurplePluginInfo info =
-{
-     PURPLE_PLUGIN_MAGIC,
-     PURPLE_MAJOR_VERSION,
-     PURPLE_MINOR_VERSION,
-     PURPLE_PLUGIN_STANDARD,
-     NULL,
-     0,
-     NULL,
-     PURPLE_PRIORITY_DEFAULT,
-     "codeinline",
-     "Code Inline",
-     "1.0",
-     "Formats text as code",
-     "Changes the formatting of any outgoing text such that "
-     "anything underlined will be received green and monospace.",
-     "Sean Egan <seanegan at gmail.com>",
-     PURPLE_WEBSITE,
-     plugin_load,
-     NULL,
-     NULL,
-     NULL,
-     NULL,
-     NULL,
-     NULL,
-	 /* padding */
-     NULL,
-     NULL,
-     NULL,
-     NULL
-};
-
- static void
- init_plugin(PurplePlugin *plugin)
- {
- }
-
-PURPLE_INIT_PLUGIN(codeinline, init_plugin, info)
+PURPLE_PLUGIN_INIT(codeinline, plugin_query, plugin_load, plugin_unload);
diff --git a/libpurple/plugins/debug_example.c b/libpurple/plugins/debug_example.c
--- a/libpurple/plugins/debug_example.c
+++ b/libpurple/plugins/debug_example.c
@@ -58,14 +58,33 @@
 /* Common practice in third-party plugins is to define convenience macros for
  * many of the fields of the plugin info struct, so we'll do that for the
  * purposes of demonstration. */
-#define PLUGIN_AUTHOR "John Bailey <rekkanoryo at cpw.pidgin.im>"
+#define PLUGIN_AUTHORS { "John Bailey <rekkanoryo at cpw.pidgin.im>", NULL }
+
+static PurplePluginInfo *
+plugin_query(GError **error)
+{
+	const gchar * const authors[] = PLUGIN_AUTHORS;
+
+	return purple_plugin_info_new(
+		"id",           PLUGIN_ID,
+		"name",         "Debug API Example",
+		"version",      DISPLAY_VERSION,
+		"category",     "Example",
+		"summary",      "Debug API Example",
+		"description",  "Debug API Example",
+		"authors",      authors,
+		"website",      "https://pidgin.im",
+		"abi-version",  PURPLE_ABI_VERSION,
+		NULL
+	);
+}
 
 /* As we've covered before, libpurple calls this function, if present, when it
  * loads the plugin.  Here we're using it to show off the capabilities of the
  * debug API and just blindly returning TRUE to tell libpurple it's safe to
  * continue loading. */
 static gboolean
-plugin_load(PurplePlugin *plugin)
+plugin_load(PurplePlugin *plugin, GError **error)
 {
 	/* Define these for convenience--we're just using them to show the
 	 * similarities of the debug functions to the standard printf(). */
@@ -97,42 +116,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 */
-	"Debug API Example",        /* name */
-	DISPLAY_VERSION,            /* version */
-	"Debug API Example",        /* summary */
-	"Debug 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 */
-	NULL,                       /* 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(debugexample, init_plugin, info)
+PURPLE_PLUGIN_INIT(debugexample, plugin_query, plugin_load, plugin_unload);
 



More information about the Commits mailing list