/soc/2013/ankitkv/gobjectification: b8caab360c96: Refactored osc...

Ankit Vani a at nevitus.org
Sun Aug 11 18:04:07 EDT 2013


Changeset: b8caab360c96d8d9fb05325dcb55f7a7c4db0a2c
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-08-12 03:33 +0530
Branch:	 soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/b8caab360c96

Description:

Refactored oscar to use the new plugin API

diffstat:

 libpurple/protocols/oscar/libaim.c      |  79 ++++++++++++++----------------
 libpurple/protocols/oscar/libicq.c      |  75 +++++++++++++---------------
 libpurple/protocols/oscar/oscar.c       |  84 ++++++++++++++++----------------
 libpurple/protocols/oscar/oscarcommon.h |   4 +-
 libpurple/protocols/oscar/visibility.c  |   8 +-
 libpurple/protocols/oscar/visibility.h  |   6 +-
 6 files changed, 122 insertions(+), 134 deletions(-)

diffs (truncated from 532 to 300 lines):

diff --git a/libpurple/protocols/oscar/libaim.c b/libpurple/protocols/oscar/libaim.c
--- a/libpurple/protocols/oscar/libaim.c
+++ b/libpurple/protocols/oscar/libaim.c
@@ -24,17 +24,22 @@
  * which contains all the shared implementation code with libicq
  */
 
+#include "plugins.h"
+
 #include "oscarcommon.h"
 #include "oscar.h"
 
 static PurplePluginProtocolInfo prpl_info =
 {
+	"prpl-aim",				/* id */
+	"AIM",					/* name */
 	sizeof(PurplePluginProtocolInfo),       /* struct_size */
 	OPT_PROTO_MAIL_CHECK | OPT_PROTO_IM_IMAGE | OPT_PROTO_INVITE_MESSAGE | OPT_PROTO_AUTHORIZATION_DENIED_MESSAGE,
 	NULL,					/* user_splits */
 	NULL,					/* protocol_options */
 	{"gif,jpeg,bmp,ico", 0, 0, 64, 64, 7168, PURPLE_ICON_SCALE_SEND | PURPLE_ICON_SCALE_DISPLAY}, /* icon_spec */
-	oscar_list_icon_aim,		/* list_icon */
+	oscar_get_actions,		/* get_actions */
+	oscar_list_icon_aim,	/* list_icon */
 	oscar_list_emblem,		/* list_emblems */
 	oscar_status_text,		/* status_text */
 	oscar_tooltip_text,		/* tooltip_text */
@@ -102,47 +107,37 @@ static PurplePluginProtocolInfo prpl_inf
 	NULL					/* get_public_alias */
 };
 
-static PurplePluginInfo info =
+static PurplePluginInfo *
+plugin_query(GError **error)
 {
-	PURPLE_PLUGIN_MAGIC,
-	PURPLE_MAJOR_VERSION,
-	PURPLE_MINOR_VERSION,
-	PURPLE_PLUGIN_PROTOCOL,                             /**< type           */
-	NULL,                                             /**< ui_requirement */
-	0,                                                /**< flags          */
-	NULL,                                             /**< dependencies   */
-	PURPLE_PRIORITY_DEFAULT,                            /**< priority       */
-
-	"prpl-aim",                                       /**< id             */
-	"AIM",                                            /**< name           */
-	DISPLAY_VERSION,                                  /**< version        */
-	                                                  /**  summary        */
-	N_("AIM Protocol Plugin"),
-	                                                  /**  description    */
-	N_("AIM Protocol Plugin"),
-	NULL,                                             /**< author         */
-	PURPLE_WEBSITE,                                     /**< homepage       */
-
-	NULL,                                             /**< load           */
-	NULL,                                             /**< unload         */
-	NULL,                                             /**< destroy        */
-
-	NULL,                                             /**< ui_info        */
-	&prpl_info,                                       /**< extra_info     */
-	NULL,
-	oscar_actions,
-
-	/* padding */
-	NULL,
-	NULL,
-	NULL,
-	NULL
-};
-
-static void
-init_plugin(PurplePlugin *plugin)
-{
-	oscar_init(plugin, FALSE);
+	return purple_plugin_info_new(
+		"id",           "prpl-aim",
+		"name",         "AIM",
+		"version",      DISPLAY_VERSION,
+		"category",     N_("Protocol"),
+		"summary",      N_("AIM Protocol Plugin"),
+		"description",  N_("AIM Protocol Plugin"),
+		"website",      PURPLE_WEBSITE,
+		"abi-version",  PURPLE_ABI_VERSION,
+		NULL
+	);
 }
 
-PURPLE_INIT_PLUGIN(aim, init_plugin, info);
+static gboolean
+plugin_load(PurplePlugin *plugin, GError **error)
+{
+	oscar_init(&prpl_info, FALSE);
+	purple_protocols_add(&prpl_info);
+
+	return TRUE;
+}
+
+static gboolean
+plugin_unload(PurplePlugin *plugin, GError **error)
+{
+	purple_protocols_remove(&prpl_info);
+
+	return TRUE;
+}
+
+PURPLE_PLUGIN_INIT(aim, plugin_query, plugin_load, plugin_unload);
diff --git a/libpurple/protocols/oscar/libicq.c b/libpurple/protocols/oscar/libicq.c
--- a/libpurple/protocols/oscar/libicq.c
+++ b/libpurple/protocols/oscar/libicq.c
@@ -24,6 +24,7 @@
  * which contains all the shared implementation code with libaim
  */
 
+#include "plugins.h"
 
 #include "oscarcommon.h"
 
@@ -38,12 +39,15 @@ icq_get_account_text_table(PurpleAccount
 
 static PurplePluginProtocolInfo prpl_info =
 {
+	"prpl-icq",				/* id */
+	"ICQ",					/* name */
 	sizeof(PurplePluginProtocolInfo),       /* struct_size */
 	OPT_PROTO_MAIL_CHECK | OPT_PROTO_IM_IMAGE | OPT_PROTO_INVITE_MESSAGE | OPT_PROTO_AUTHORIZATION_DENIED_MESSAGE,
 	NULL,					/* user_splits */
 	NULL,					/* protocol_options */
 	{"gif,jpeg,bmp,ico", 0, 0, 64, 64, 7168, PURPLE_ICON_SCALE_SEND | PURPLE_ICON_SCALE_DISPLAY}, /* icon_spec */
-	oscar_list_icon_icq,		/* list_icon */
+	oscar_get_actions,		/* get_actions */
+	oscar_list_icon_icq,	/* list_icon */
 	oscar_list_emblem,		/* list_emblems */
 	oscar_status_text,		/* status_text */
 	oscar_tooltip_text,		/* tooltip_text */
@@ -111,52 +115,43 @@ static PurplePluginProtocolInfo prpl_inf
 	NULL					/* get_public_alias */
 };
 
-static PurplePluginInfo info =
+static PurplePluginInfo *
+plugin_query(GError **error)
 {
-	PURPLE_PLUGIN_MAGIC,
-	PURPLE_MAJOR_VERSION,
-	PURPLE_MINOR_VERSION,
-	PURPLE_PLUGIN_PROTOCOL,                             /**< type           */
-	NULL,                                             /**< ui_requirement */
-	0,                                                /**< flags          */
-	NULL,                                             /**< dependencies   */
-	PURPLE_PRIORITY_DEFAULT,                            /**< priority       */
+	return purple_plugin_info_new(
+		"id",           "prpl-icq",
+		"name",         "ICQ",
+		"version",      DISPLAY_VERSION,
+		"category",     N_("Protocol"),
+		"summary",      N_("ICQ Protocol Plugin"),
+		"description",  N_("ICQ Protocol Plugin"),
+		"website",      PURPLE_WEBSITE,
+		"abi-version",  PURPLE_ABI_VERSION,
+		NULL
+	);
+}
 
-	"prpl-icq",                                     /**< id             */
-	"ICQ",                                        /**< name           */
-	DISPLAY_VERSION,                                  /**< version        */
-	                                                  /**  summary        */
-	N_("ICQ Protocol Plugin"),
-	                                                  /**  description    */
-	N_("ICQ Protocol Plugin"),
-	NULL,                                             /**< author         */
-	PURPLE_WEBSITE,                                     /**< homepage       */
-
-	NULL,                                             /**< load           */
-	NULL,                                             /**< unload         */
-	NULL,                                             /**< destroy        */
-
-	NULL,                                             /**< ui_info        */
-	&prpl_info,                                       /**< extra_info     */
-	NULL,
-	oscar_actions,
-
-	/* padding */
-	NULL,
-	NULL,
-	NULL,
-	NULL
-};
-
-static void
-init_plugin(PurplePlugin *plugin)
+static gboolean
+plugin_load(PurplePlugin *plugin, GError **error)
 {
 	PurpleAccountOption *option;
 
-	oscar_init(plugin, TRUE);
+	oscar_init(&prpl_info, TRUE);
 
 	option = purple_account_option_string_new(_("Encoding"), "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING);
 	prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
+
+	purple_protocols_add(&prpl_info);
+
+	return TRUE;
 }
 
-PURPLE_INIT_PLUGIN(icq, init_plugin, info);
+static gboolean
+plugin_unload(PurplePlugin *plugin, GError **error)
+{
+	purple_protocols_remove(&prpl_info);
+
+	return TRUE;
+}
+
+PURPLE_PLUGIN_INIT(aim, plugin_query, plugin_load, plugin_unload);
diff --git a/libpurple/protocols/oscar/oscar.c b/libpurple/protocols/oscar/oscar.c
--- a/libpurple/protocols/oscar/oscar.c
+++ b/libpurple/protocols/oscar/oscar.c
@@ -4989,9 +4989,9 @@ oscar_icq_privacy_opts(PurpleConnection 
 }
 
 static void
-oscar_show_icq_privacy_opts(PurplePluginAction *action)
+oscar_show_icq_privacy_opts(PurpleProtocolAction *action)
 {
-	PurpleConnection *gc = (PurpleConnection *) action->context;
+	PurpleConnection *gc = action->connection;
 	PurpleAccount *account = purple_connection_get_account(gc);
 	PurpleRequestFields *fields;
 	PurpleRequestFieldGroup *g;
@@ -5021,13 +5021,13 @@ oscar_show_icq_privacy_opts(PurplePlugin
 						gc);
 }
 
-static void oscar_confirm_account(PurplePluginAction *action)
+static void oscar_confirm_account(PurpleProtocolAction *action)
 {
 	PurpleConnection *gc;
 	OscarData *od;
 	FlapConnection *conn;
 
-	gc = (PurpleConnection *)action->context;
+	gc = action->connection;
 	od = purple_connection_get_protocol_data(gc);
 
 	conn = flap_connection_getbytype(od, SNAC_FAMILY_ADMIN);
@@ -5039,9 +5039,9 @@ static void oscar_confirm_account(Purple
 	}
 }
 
-static void oscar_show_email(PurplePluginAction *action)
+static void oscar_show_email(PurpleProtocolAction *action)
 {
-	PurpleConnection *gc = (PurpleConnection *) action->context;
+	PurpleConnection *gc = action->connection;
 	OscarData *od = purple_connection_get_protocol_data(gc);
 	FlapConnection *conn = flap_connection_getbytype(od, SNAC_FAMILY_ADMIN);
 
@@ -5067,9 +5067,9 @@ static void oscar_change_email(PurpleCon
 	}
 }
 
-static void oscar_show_change_email(PurplePluginAction *action)
+static void oscar_show_change_email(PurpleProtocolAction *action)
 {
-	PurpleConnection *gc = (PurpleConnection *) action->context;
+	PurpleConnection *gc = action->connection;
 	purple_request_input(gc, NULL, _("Change Address To:"), NULL, NULL,
 					   FALSE, FALSE, NULL,
 					   _("_OK"), G_CALLBACK(oscar_change_email),
@@ -5078,9 +5078,9 @@ static void oscar_show_change_email(Purp
 					   gc);
 }
 
-static void oscar_show_awaitingauth(PurplePluginAction *action)
+static void oscar_show_awaitingauth(PurpleProtocolAction *action)
 {
-	PurpleConnection *gc = (PurpleConnection *) action->context;
+	PurpleConnection *gc = action->connection;
 	OscarData *od = purple_connection_get_protocol_data(gc);
 	PurpleAccount *account = purple_connection_get_account(gc);
 	GSList *buddies, *filtered_buddies, *cur;
@@ -5121,9 +5121,9 @@ static void search_by_email_cb(PurpleCon
 	aim_search_address(od, email);
 }
 
-static void oscar_show_find_email(PurplePluginAction *action)
+static void oscar_show_find_email(PurpleProtocolAction *action)
 {
-	PurpleConnection *gc = (PurpleConnection *) action->context;
+	PurpleConnection *gc = action->connection;
 	purple_request_input(gc, _("Find Buddy by Email"),
 					   _("Search for a buddy by email address"),
 					   _("Type the email address of the buddy you are "
@@ -5135,39 +5135,39 @@ static void oscar_show_find_email(Purple
 					   gc);
 }
 



More information about the Commits mailing list