/soc/2013/ankitkv/gobjectification: 1e87c79042a3: Refactored sil...

Ankit Vani a at nevitus.org
Sun Aug 11 20:29:30 EDT 2013


Changeset: 1e87c79042a3f44c5200b5b3e63df93e83ffb7b5
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-08-12 05:58 +0530
Branch:	 soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/1e87c79042a3

Description:

Refactored silc to use the new plugin API

diffstat:

 libpurple/protocols/silc/silc.c |  108 ++++++++++++++++++---------------------
 1 files changed, 50 insertions(+), 58 deletions(-)

diffs (219 lines):

diff --git a/libpurple/protocols/silc/silc.c b/libpurple/protocols/silc/silc.c
--- a/libpurple/protocols/silc/silc.c
+++ b/libpurple/protocols/silc/silc.c
@@ -902,9 +902,9 @@ silcpurple_attrs_cb(PurpleConnection *gc
 }
 
 static void
-silcpurple_attrs(PurplePluginAction *action)
+silcpurple_attrs(PurpleProtocolAction *action)
 {
-	PurpleConnection *gc = (PurpleConnection *) action->context;
+	PurpleConnection *gc = action->connection;
 	SilcPurple sg = purple_connection_get_protocol_data(gc);
 	SilcClient client = sg->client;
 	SilcClientConnection conn = sg->conn;
@@ -1069,9 +1069,9 @@ silcpurple_attrs(PurplePluginAction *act
 }
 
 static void
-silcpurple_detach(PurplePluginAction *action)
+silcpurple_detach(PurpleProtocolAction *action)
 {
-	PurpleConnection *gc = (PurpleConnection *) action->context;
+	PurpleConnection *gc = action->connection;
 	SilcPurple sg;
 
 	if (!gc)
@@ -1086,9 +1086,9 @@ silcpurple_detach(PurplePluginAction *ac
 }
 
 static void
-silcpurple_view_motd(PurplePluginAction *action)
+silcpurple_view_motd(PurpleProtocolAction *action)
 {
-	PurpleConnection *gc = (PurpleConnection *) action->context;
+	PurpleConnection *gc = action->connection;
 	SilcPurple sg;
 	char *tmp;
 
@@ -1209,9 +1209,9 @@ silcpurple_create_keypair_cb(PurpleConne
 }
 
 static void
-silcpurple_create_keypair(PurplePluginAction *action)
+silcpurple_create_keypair(PurpleProtocolAction *action)
 {
-	PurpleConnection *gc = (PurpleConnection *) action->context;
+	PurpleConnection *gc = action->connection;
 	SilcPurple sg = purple_connection_get_protocol_data(gc);
 	PurpleRequestFields *fields;
 	PurpleRequestFieldGroup *g;
@@ -1280,9 +1280,9 @@ silcpurple_create_keypair(PurplePluginAc
 }
 
 static void
-silcpurple_change_pass(PurplePluginAction *action)
+silcpurple_change_pass(PurpleProtocolAction *action)
 {
-	PurpleConnection *gc = (PurpleConnection *) action->context;
+	PurpleConnection *gc = action->connection;
 	purple_account_request_change_password(purple_connection_get_account(gc));
 }
 
@@ -1297,9 +1297,9 @@ silcpurple_change_passwd(PurpleConnectio
 }
 
 static void
-silcpurple_show_set_info(PurplePluginAction *action)
+silcpurple_show_set_info(PurpleProtocolAction *action)
 {
-	PurpleConnection *gc = (PurpleConnection *) action->context;
+	PurpleConnection *gc = action->connection;
 	purple_account_request_change_user_info(purple_connection_get_account(gc));
 }
 
@@ -1309,32 +1309,32 @@ silcpurple_set_info(PurpleConnection *gc
 }
 
 static GList *
-silcpurple_actions(PurplePlugin *plugin, gpointer context)
+silcpurple_get_actions(PurpleConnection *gc)
 {
 	GList *list = NULL;
-	PurplePluginAction *act;
+	PurpleProtocolAction *act;
 
-	act = purple_plugin_action_new(_("Online Status"),
+	act = purple_protocol_action_new(_("Online Status"),
 			silcpurple_attrs);
 	list = g_list_append(list, act);
 
-	act = purple_plugin_action_new(_("Detach From Server"),
+	act = purple_protocol_action_new(_("Detach From Server"),
 			silcpurple_detach);
 	list = g_list_append(list, act);
 
-	act = purple_plugin_action_new(_("View Message of the Day"),
+	act = purple_protocol_action_new(_("View Message of the Day"),
 			silcpurple_view_motd);
 	list = g_list_append(list, act);
 
-	act = purple_plugin_action_new(_("Create SILC Key Pair..."),
+	act = purple_protocol_action_new(_("Create SILC Key Pair..."),
 			silcpurple_create_keypair);
 	list = g_list_append(list, act);
 
-	act = purple_plugin_action_new(_("Change Password..."),
+	act = purple_protocol_action_new(_("Change Password..."),
 			silcpurple_change_pass);
 	list = g_list_append(list, act);
 
-	act = purple_plugin_action_new(_("Set User Info..."),
+	act = purple_protocol_action_new(_("Set User Info..."),
 			silcpurple_show_set_info);
 	list = g_list_append(list, act);
 
@@ -2053,6 +2053,8 @@ static PurpleWhiteboardPrplOps silcpurpl
 
 static PurplePluginProtocolInfo prpl_info =
 {
+	"prpl-silc",			/* id */
+	"SILC",					/* name */
 	sizeof(PurplePluginProtocolInfo),       /* struct_size */
 	OPT_PROTO_CHAT_TOPIC | OPT_PROTO_UNIQUE_CHATNAME |
 	OPT_PROTO_PASSWORD_OPTIONAL | OPT_PROTO_IM_IMAGE |
@@ -2060,6 +2062,7 @@ static PurplePluginProtocolInfo prpl_inf
 	NULL,					/* user_splits */
 	NULL,					/* protocol_options */
 	{"jpeg,gif,png,bmp", 0, 0, 96, 96, 0, PURPLE_ICON_SCALE_DISPLAY}, /* icon_spec */
+	silcpurple_get_actions,                 /* get_actions */
 	silcpurple_list_icon,	                /* list_icon */
 	NULL,					/* list_emblems */
 	silcpurple_status_text,			/* status_text */
@@ -2128,42 +2131,22 @@ 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-silc",				/**< id             */
-	"SILC",					/**< name           */
-	"1.1",					/**< version        */
-	/**  summary        */
-	N_("SILC Protocol Plugin"),
-	/**  description    */
-	N_("Secure Internet Live Conferencing (SILC) Protocol"),
-	"Pekka Riikonen",			/**< author         */
-	"http://silcnet.org/",			/**< homepage       */
-
-	NULL,					/**< load           */
-	NULL,					/**< unload         */
-	NULL,					/**< destroy        */
-
-	NULL,					/**< ui_info        */
-	&prpl_info,				/**< extra_info     */
-	NULL,					/**< prefs_info     */
-	silcpurple_actions,
-
-	/* padding */
-	NULL,
-	NULL,
-	NULL,
-	NULL
-};
+	return purple_plugin_info_new(
+		"abi-version", PURPLE_ABI_VERSION,
+		"category", N_("Protocol"),
+		"id", "prpl-silc",
+		"name", "SILC",
+		"version", "1.1",
+		"summary", N_("SILC Protocol Plugin"),
+		"description", N_("Secure Internet Live Conferencing (SILC) Protocol"),
+		"author", "Pekka Riikonen",
+		"website", "http://silcnet.org/",
+		NULL
+	);
+}
 
 #if 0
 static SilcBool silcpurple_debug_cb(char *file, char *function, int line,
@@ -2174,8 +2157,8 @@ static SilcBool silcpurple_debug_cb(char
 }
 #endif
 
-static void
-init_plugin(PurplePlugin *plugin)
+static gboolean
+plugin_load(PurplePlugin *plugin, GError **error)
 {
 	PurpleAccountOption *option;
 	PurpleAccountUserSplit *split;
@@ -2256,6 +2239,15 @@ silc_log_quick(TRUE);
 silc_log_set_debug_callbacks(silcpurple_debug_cb, NULL, NULL, NULL);
 #endif
 
+	purple_protocols_add(&prpl_info);
+	return TRUE;
 }
 
-PURPLE_INIT_PLUGIN(silc, init_plugin, info);
+static gboolean
+plugin_unload(PurplePlugin *plugin, GError **error)
+{
+	purple_protocols_remove(&prpl_info);
+	return TRUE;
+}
+
+PURPLE_PLUGIN_INIT(silc, plugin_query, plugin_load, plugin_unload);



More information about the Commits mailing list