/soc/2013/ankitkv/gobjectification: 0b84912ce764: Refactored res...

Ankit Vani a at nevitus.org
Mon Sep 16 10:52:22 EDT 2013


Changeset: 0b84912ce764ac4be523ee4df31940fe62f739c1
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-09-16 20:20 +0530
Branch:	 soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/0b84912ce764

Description:

Refactored rest of libpurple C plugins to use the new plugin API

diffstat:

 libpurple/dbus-server.h          |   3 +-
 libpurple/plugins/dbus-example.c |  69 ++++++++++------------------
 libpurple/plugins/joinpart.c     |   2 +-
 libpurple/plugins/newline.c      |  88 ++++++++++++++----------------------
 libpurple/plugins/offlinemsg.c   |  96 +++++++++++++--------------------------
 libpurple/plugins/psychic.c      |  90 ++++++++++++++-----------------------
 libpurple/plugins/statenotify.c  |  95 ++++++++++++++-------------------------
 7 files changed, 164 insertions(+), 279 deletions(-)

diffs (truncated from 590 to 300 lines):

diff --git a/libpurple/dbus-server.h b/libpurple/dbus-server.h
--- a/libpurple/dbus-server.h
+++ b/libpurple/dbus-server.h
@@ -80,7 +80,8 @@ struct _PurpleDBusType {
 	if (purple_dbus_get_init_error() != NULL) \
 	{ \
 		gchar *title; \
-		title = g_strdup_printf("Unable to Load %s Plugin", plugin->info->name); \
+		title = g_strdup_printf("Unable to Load %s Plugin", \
+				purple_plugin_info_get_name(purple_plugin_get_info(plugin))); \
 		purple_notify_error(NULL, title, \
 				_("Purple's D-BUS server is not running for the reason listed below"), \
 				_(purple_dbus_get_init_error())); \
diff --git a/libpurple/plugins/dbus-example.c b/libpurple/plugins/dbus-example.c
--- a/libpurple/plugins/dbus-example.c
+++ b/libpurple/plugins/dbus-example.c
@@ -106,8 +106,30 @@ const char *dbus_example_get_buddy_name(
 
 /* And now standard plugin stuff */
 
+static PurplePluginInfo *
+plugin_query(GError **error)
+{
+	const gchar * const authors[] = {
+		"Piotr Zielinski (http://cl.cam.ac.uk/~pz215)",
+		NULL
+	};
+
+	return purple_plugin_info_new(
+		"id",           "dbus-example",
+		"name",         N_("DBus Example"),
+		"version",      DISPLAY_VERSION,
+		"category",     N_("Example"),
+		"summary",      N_("DBus Plugin Example"),
+		"description",  N_("DBus Plugin Example"),
+		"authors",      authors,
+		"website",      PURPLE_WEBSITE,
+		"abi-version",  PURPLE_ABI_VERSION,
+		NULL
+	);
+}
+
 static gboolean
-plugin_load(PurplePlugin *plugin)
+plugin_load(PurplePlugin *plugin, GError **error)
 {
 	PURPLE_DBUS_RETURN_FALSE_IF_DISABLED(plugin);
 
@@ -130,7 +152,7 @@ plugin_load(PurplePlugin *plugin)
 
 
 static gboolean
-plugin_unload(PurplePlugin *plugin)
+plugin_unload(PurplePlugin *plugin, GError **error)
 {
 	g_free(hello.text);
 
@@ -140,45 +162,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       */
-
-	"dbus-example",                                   /**< id             */
-	N_("DBus Example"),                               /**< name           */
-	DISPLAY_VERSION,                                  /**< version        */
-	                                                  /**  summary        */
-	N_("DBus Plugin Example"),
-	                                                  /**  description    */
-	N_("DBus Plugin Example"),
-	"Piotr Zielinski (http://cl.cam.ac.uk/~pz215)",   /**< author         */
-	PURPLE_WEBSITE,                                     /**< homepage       */
-
-	plugin_load,                                      /**< load           */
-	plugin_unload,                                    /**< unload         */
-	NULL,                                             /**< destroy        */
-
-	NULL,                                             /**< ui_info        */
-	NULL,                                             /**< extra_info     */
-	NULL,                                       /**< prefs_info     */
-	NULL,
-
-	/* padding */
-	NULL,
-	NULL,
-	NULL,
-	NULL
-};
-
-static void init_plugin(PurplePlugin *plugin)
-{
-}
-
-PURPLE_INIT_PLUGIN(dbus_example, init_plugin, info)
+PURPLE_PLUGIN_INIT(dbus_example, plugin_query, plugin_load, plugin_unload);
diff --git a/libpurple/plugins/joinpart.c b/libpurple/plugins/joinpart.c
--- a/libpurple/plugins/joinpart.c
+++ b/libpurple/plugins/joinpart.c
@@ -220,7 +220,7 @@ plugin_query(GError **error)
 		"id",                 JOINPART_PLUGIN_ID,
 		"name",               N_("Join/Part Hiding"),
 		"version",            DISPLAY_VERSION,
-		"category",           N_("Utility"),
+		"category",           N_("User interface"),
 		"summary",            N_("Hides extraneous join/part messages."),
 		"description",        N_("This plugin hides join/part messages in "
 		                         "large rooms, except for those users actively "
diff --git a/libpurple/plugins/newline.c b/libpurple/plugins/newline.c
--- a/libpurple/plugins/newline.c
+++ b/libpurple/plugins/newline.c
@@ -65,11 +65,40 @@ get_plugin_pref_frame(PurplePlugin *plug
 }
 
 
+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-newline",
+		"name",               N_("New Line"),
+		"version",            DISPLAY_VERSION,
+		"category",           N_("User interface"),
+		"summary",            N_("Prepends a newline to displayed message."),
+		"description",        N_("Prepends a newline to messages so that the "
+		                         "rest of the message appears below the "
+		                         "username in the conversation window."),
+		"authors",            authors,
+		"website",            PURPLE_WEBSITE,
+		"abi-version",        PURPLE_ABI_VERSION,
+		"preferences-frame",  get_plugin_pref_frame,
+		NULL
+	);
+}
+
 static gboolean
-plugin_load(PurplePlugin *plugin)
+plugin_load(PurplePlugin *plugin, GError **error)
 {
 	void *conversation = purple_conversations_get_handle();
 
+	purple_prefs_add_none("/plugins/core/newline");
+	purple_prefs_add_bool("/plugins/core/newline/im", TRUE);
+	purple_prefs_add_bool("/plugins/core/newline/chat", TRUE);
+
 	purple_signal_connect(conversation, "writing-im-msg",
 						plugin, PURPLE_CALLBACK(addnewline_msg_cb), NULL);
 	purple_signal_connect(conversation, "writing-chat-msg",
@@ -78,59 +107,10 @@ plugin_load(PurplePlugin *plugin)
 	return TRUE;
 }
 
-static PurplePluginUiInfo prefs_info = {
-	get_plugin_pref_frame,
-	0,   /* page_num (Reserved) */
-	NULL, /* frame (Reserved) */
-	/* Padding */
-	NULL,
-	NULL,
-	NULL,
-	NULL
-};
-
-static PurplePluginInfo info =
+static gboolean
+plugin_unload(PurplePlugin *plugin, GError **error)
 {
-	PURPLE_PLUGIN_MAGIC,							/**< 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-newline",						/**< id				*/
-	N_("New Line"),									/**< name			*/
-	DISPLAY_VERSION,								/**< version		*/
-	N_("Prepends a newline to displayed message."),	/**< summary		*/
-	N_("Prepends a newline to messages so that the "
-	   "rest of the message appears below the "
-	   "username in the conversation window."),		/**< description	*/
-	"Stu Tomlinson <stu at nosnilmot.com>",			/**< author			*/
-	PURPLE_WEBSITE,									/**< homepage		*/
-
-	plugin_load,									/**< 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) {
-	purple_prefs_add_none("/plugins/core/newline");
-	purple_prefs_add_bool("/plugins/core/newline/im", TRUE);
-	purple_prefs_add_bool("/plugins/core/newline/chat", TRUE);
+	return TRUE;
 }
 
-PURPLE_INIT_PLUGIN(newline, init_plugin, info)
+PURPLE_PLUGIN_INIT(newline, plugin_query, plugin_load, plugin_unload);
diff --git a/libpurple/plugins/offlinemsg.c b/libpurple/plugins/offlinemsg.c
--- a/libpurple/plugins/offlinemsg.c
+++ b/libpurple/plugins/offlinemsg.c
@@ -21,10 +21,11 @@
 
 #define PLUGIN_ID			"core-plugin_pack-offlinemsg"
 #define PLUGIN_NAME			N_("Offline Message Emulation")
+#define PLUGIN_CATEGORY		N_("Utility")
 #define PLUGIN_STATIC_NAME	offlinemsg
 #define PLUGIN_SUMMARY		N_("Save messages sent to an offline user as pounce.")
 #define PLUGIN_DESCRIPTION	N_("Save messages sent to an offline user as pounce.")
-#define PLUGIN_AUTHOR		"Sadrul H Chowdhury <sadrul at users.sourceforge.net>"
+#define PLUGIN_AUTHORS		{"Sadrul H Chowdhury <sadrul at users.sourceforge.net>", NULL}
 
 /* Purple headers */
 #include <version.h>
@@ -172,20 +173,6 @@ sending_msg_cb(PurpleAccount *account, c
 	}
 }
 
-static gboolean
-plugin_load(PurplePlugin *plugin)
-{
-	purple_signal_connect_priority(purple_conversations_get_handle(), "sending-im-msg",
-					plugin, PURPLE_CALLBACK(sending_msg_cb), plugin, PURPLE_SIGNAL_PRIORITY_HIGHEST);
-	return TRUE;
-}
-
-static gboolean
-plugin_unload(PurplePlugin *plugin)
-{
-	return TRUE;
-}
-
 static PurplePluginPrefFrame *
 get_plugin_pref_frame(PurplePlugin *plugin)
 {
@@ -204,58 +191,41 @@ 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	*/



More information about the Commits mailing list