/soc/2013/ankitkv/gobjectification: a9f6ae7c308e: Refactored fin...

Ankit Vani a at nevitus.org
Mon Sep 16 13:04:52 EDT 2013


Changeset: a9f6ae7c308eccce82ed1e77a22ad9ff682bc7e6
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-09-16 22:34 +0530
Branch:	 soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/a9f6ae7c308e

Description:

Refactored finch plugins to use the new plugin API

diffstat:

 finch/plugins/gntclipboard.c |   73 ++++++++++--------------
 finch/plugins/gntgf.c        |  109 ++++++++++++++++--------------------
 finch/plugins/gnthistory.c   |   70 ++++++++++-------------
 finch/plugins/gnttinyurl.c   |  128 +++++++++++++++++-------------------------
 finch/plugins/lastlog.c      |   66 ++++++++-------------
 5 files changed, 187 insertions(+), 259 deletions(-)

diffs (truncated from 567 to 300 lines):

diff --git a/finch/plugins/gntclipboard.c b/finch/plugins/gntclipboard.c
--- a/finch/plugins/gntclipboard.c
+++ b/finch/plugins/gntclipboard.c
@@ -22,6 +22,8 @@
 #include "internal.h"
 #include <glib.h>
 
+#define PLUGIN_ID           "gntclipboard"
+#define PLUGIN_DOMAIN       (g_quark_from_static_string(PLUGIN_ID))
 #define PLUGIN_STATIC_NAME	GntClipboard
 
 #ifdef HAVE_X11
@@ -106,8 +108,31 @@ clipboard_changed(GntWM *wm, gchar *stri
 }
 #endif
 
+static FinchPluginInfo *
+plugin_query(GError **error)
+{
+	const gchar * const authors[] = {
+		"Richard Nelson <wabz at whatsbeef.net>",
+		NULL
+	};
+
+	return finch_plugin_info_new(
+		"id",           PLUGIN_ID,
+		"name",         N_("GntClipboard"),
+		"version",      DISPLAY_VERSION,
+		"category",     N_("Utility"),
+		"summary",      N_("Clipboard plugin"),
+		"description",  N_("When the gnt clipboard contents change, the "
+		                   "contents are made available to X, if possible."),
+		"authors",      authors,
+		"website",      PURPLE_WEBSITE,
+		"abi-version",  PURPLE_ABI_VERSION,
+		NULL
+	);
+}
+
 static gboolean
-plugin_load(PurplePlugin *plugin)
+plugin_load(PurplePlugin *plugin, GError **error)
 {
 #ifdef HAVE_X11
 	if (!XOpenDisplay(NULL)) {
@@ -125,14 +150,14 @@ plugin_load(PurplePlugin *plugin)
 	sig_handle = g_signal_connect(G_OBJECT(gnt_get_clipboard()), "clipboard_changed", G_CALLBACK(clipboard_changed), NULL);
 	return TRUE;
 #else
-	purple_notify_error(NULL, _("Error"), _("Error loading the plugin."),
-			_("This plugin cannot be loaded because it was not built with X11 support."));
+	g_set_error(error, PLUGIN_DOMAIN, 0, _("This plugin cannot be loaded "
+			"because it was not built with X11 support."));
 	return FALSE;
 #endif
 }
 
 static gboolean
-plugin_unload(PurplePlugin *plugin)
+plugin_unload(PurplePlugin *plugin, GError **error)
 {
 #ifdef HAVE_X11
 	if (child) {
@@ -144,42 +169,4 @@ plugin_unload(PurplePlugin *plugin)
 	return TRUE;
 }
 
-static PurplePluginInfo info =
-{
-	PURPLE_PLUGIN_MAGIC,
-	PURPLE_MAJOR_VERSION,
-	PURPLE_MINOR_VERSION,
-	PURPLE_PLUGIN_STANDARD,
-	FINCH_PLUGIN_TYPE,
-	0,
-	NULL,
-	PURPLE_PRIORITY_DEFAULT,
-	"gntclipboard",
-	N_("GntClipboard"),
-	DISPLAY_VERSION,
-	N_("Clipboard plugin"),
-	N_("When the gnt clipboard contents change, "
-		"the contents are made available to X, if possible."),
-	"Richard Nelson <wabz at whatsbeef.net>",
-	PURPLE_WEBSITE,
-	plugin_load,
-	plugin_unload,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-
-	/* padding */
-	NULL,
-	NULL,
-	NULL,
-	NULL
-};
-
-static void
-init_plugin(PurplePlugin *plugin)
-{
-}
-
-PURPLE_INIT_PLUGIN(PLUGIN_STATIC_NAME, init_plugin, info)
+PURPLE_PLUGIN_INIT(PLUGIN_STATIC_NAME, plugin_query, plugin_load, plugin_unload);
diff --git a/finch/plugins/gntgf.c b/finch/plugins/gntgf.c
--- a/finch/plugins/gntgf.c
+++ b/finch/plugins/gntgf.c
@@ -269,35 +269,6 @@ received_chat_msg(PurpleAccount *account
 		notify(conv, _("%s sent a message in %s"), sender, purple_conversation_get_name(conv));
 }
 
-static gboolean
-plugin_load(PurplePlugin *plugin)
-{
-	purple_signal_connect(purple_blist_get_handle(), "buddy-signed-on", plugin,
-			PURPLE_CALLBACK(buddy_signed_on), NULL);
-	purple_signal_connect(purple_blist_get_handle(), "buddy-signed-off", plugin,
-			PURPLE_CALLBACK(buddy_signed_off), NULL);
-	purple_signal_connect(purple_conversations_get_handle(), "received-im-msg", plugin,
-			PURPLE_CALLBACK(received_im_msg), NULL);
-	purple_signal_connect(purple_conversations_get_handle(), "received-chat-msg", plugin,
-			PURPLE_CALLBACK(received_chat_msg), NULL);
-
-	memset(&gpsy, 0, sizeof(gpsy));
-	memset(&gpsw, 0, sizeof(gpsw));
-
-	return TRUE;
-}
-
-static gboolean
-plugin_unload(PurplePlugin *plugin)
-{
-	while (toasters)
-	{
-		GntToast *toast = toasters->data;
-		destroy_toaster(toast);
-	}
-	return TRUE;
-}
-
 static struct
 {
 	char *pref;
@@ -365,40 +336,31 @@ config_frame(void)
 	return window;
 }
 
-static PurplePluginInfo info =
+static FinchPluginInfo *
+plugin_query(GError **error)
 {
-	PURPLE_PLUGIN_MAGIC,
-	PURPLE_MAJOR_VERSION,
-	PURPLE_MINOR_VERSION,
-	PURPLE_PLUGIN_STANDARD,
-	FINCH_PLUGIN_TYPE,
-	0,
-	NULL,
-	PURPLE_PRIORITY_DEFAULT,
-	"gntgf",
-	N_("GntGf"),
-	DISPLAY_VERSION,
-	N_("Toaster plugin"),
-	N_("Toaster plugin"),
-	"Sadrul H Chowdhury <sadrul at users.sourceforge.net>",
-	PURPLE_WEBSITE,
-	plugin_load,
-	plugin_unload,
-	NULL,
-	config_frame,
-	NULL,
-	NULL,
-	NULL,
+	const gchar * const authors[] = {
+		"Sadrul H Chowdhury <sadrul at users.sourceforge.net>",
+		NULL
+	};
 
-	/* padding */
-	NULL,
-	NULL,
-	NULL,
-	NULL
-};
+	return finch_plugin_info_new(
+		"id",                      "gntgf",
+		"name",                    N_("GntGf"),
+		"version",                 DISPLAY_VERSION,
+		"category",                N_("Notification"),
+		"summary",                 N_("Toaster plugin"),
+		"description",             N_("Toaster plugin"),
+		"authors",                 authors,
+		"website",                 PURPLE_WEBSITE,
+		"abi-version",             PURPLE_ABI_VERSION,
+		"finch-preferences-frame", config_frame,
+		NULL
+	);
+}
 
-static void
-init_plugin(PurplePlugin *plugin)
+static gboolean
+plugin_load(PurplePlugin *plugin, GError **error)
 {
 	purple_prefs_add_none("/plugins");
 	purple_prefs_add_none("/plugins/gnt");
@@ -415,6 +377,31 @@ init_plugin(PurplePlugin *plugin)
 #ifdef HAVE_X11
 	purple_prefs_add_bool(PREFS_URGENT, FALSE);
 #endif
+
+	purple_signal_connect(purple_blist_get_handle(), "buddy-signed-on", plugin,
+			PURPLE_CALLBACK(buddy_signed_on), NULL);
+	purple_signal_connect(purple_blist_get_handle(), "buddy-signed-off", plugin,
+			PURPLE_CALLBACK(buddy_signed_off), NULL);
+	purple_signal_connect(purple_conversations_get_handle(), "received-im-msg", plugin,
+			PURPLE_CALLBACK(received_im_msg), NULL);
+	purple_signal_connect(purple_conversations_get_handle(), "received-chat-msg", plugin,
+			PURPLE_CALLBACK(received_chat_msg), NULL);
+
+	memset(&gpsy, 0, sizeof(gpsy));
+	memset(&gpsw, 0, sizeof(gpsw));
+
+	return TRUE;
 }
 
-PURPLE_INIT_PLUGIN(PLUGIN_STATIC_NAME, init_plugin, info)
+static gboolean
+plugin_unload(PurplePlugin *plugin, GError **error)
+{
+	while (toasters)
+	{
+		GntToast *toast = toasters->data;
+		destroy_toaster(toast);
+	}
+	return TRUE;
+}
+
+PURPLE_PLUGIN_INIT(PLUGIN_STATIC_NAME, plugin_query, plugin_load, plugin_unload);
diff --git a/finch/plugins/gnthistory.c b/finch/plugins/gnthistory.c
--- a/finch/plugins/gnthistory.c
+++ b/finch/plugins/gnthistory.c
@@ -188,8 +188,34 @@ static void history_prefs_cb(const char 
 	history_prefs_check((PurplePlugin *)data);
 }
 
+static FinchPluginInfo *
+plugin_query(GError **error)
+{
+	const gchar * const authors[] = {
+		"Sean Egan <seanegan at gmail.com>",
+		"Sadrul H Chowdhury <sadrul at users.sourceforge.net>",
+		NULL
+	};
+
+	return finch_plugin_info_new(
+		"id",           HISTORY_PLUGIN_ID,
+		"name",         N_("GntHistory"),
+		"version",      DISPLAY_VERSION,
+		"category",     N_("User interface"),
+		"summary",      N_("Shows recently logged conversations in new "
+		                   "conversations."),
+		"description",  N_("When a new conversation is opened this plugin will "
+		                   "insert the last conversation into the current "
+		                   "conversation."),
+		"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_conversations_get_handle(),
 						"conversation-created",
@@ -205,44 +231,10 @@ plugin_load(PurplePlugin *plugin)
 	return TRUE;
 }
 
-static PurplePluginInfo info =
+static gboolean
+plugin_unload(PurplePlugin *plugin, GError **error)
 {
-	PURPLE_PLUGIN_MAGIC,
-	PURPLE_MAJOR_VERSION,
-	PURPLE_MINOR_VERSION,
-	PURPLE_PLUGIN_STANDARD,
-	NULL,
-	0,
-	NULL,
-	PURPLE_PRIORITY_DEFAULT,
-	HISTORY_PLUGIN_ID,
-	N_("GntHistory"),
-	DISPLAY_VERSION,



More information about the Commits mailing list