Mon, 12 Aug 2013 00:17:56 +0530
Refactored gg to use the new plugin API
| libpurple/protocols/gg/gg.c | file | annotate | diff | comparison | revisions |
--- a/libpurple/protocols/gg/gg.c Mon Aug 12 00:01:09 2013 +0530 +++ b/libpurple/protocols/gg/gg.c Mon Aug 12 00:17:56 2013 +0530 @@ -146,10 +146,10 @@ /* */ -/* static void ggp_action_buddylist_save(PurplePluginAction *action) {{{ */ -static void ggp_action_buddylist_save(PurplePluginAction *action) +/* static void ggp_action_buddylist_save(PurpleProtocolAction *action) {{{ */ +static void ggp_action_buddylist_save(PurpleProtocolAction *action) { - PurpleConnection *gc = (PurpleConnection *)action->context; + PurpleConnection *gc = action->connection; purple_request_file(action, _("Save buddylist..."), NULL, TRUE, G_CALLBACK(ggp_callback_buddylist_save_ok), NULL, @@ -157,9 +157,9 @@ gc); } -static void ggp_action_buddylist_load(PurplePluginAction *action) +static void ggp_action_buddylist_load(PurpleProtocolAction *action) { - PurpleConnection *gc = (PurpleConnection *)action->context; + PurpleConnection *gc = action->connection; purple_request_file(action, _("Load buddylist from file..."), NULL, FALSE, @@ -1288,56 +1288,56 @@ } } -static void ggp_action_chpass(PurplePluginAction *action) +static void ggp_action_chpass(PurpleProtocolAction *action) { - ggp_account_chpass((PurpleConnection *)action->context); + ggp_account_chpass(action->connection); } -static void ggp_action_status_broadcasting(PurplePluginAction *action) +static void ggp_action_status_broadcasting(PurpleProtocolAction *action) { - ggp_status_broadcasting_dialog((PurpleConnection *)action->context); + ggp_status_broadcasting_dialog(action->connection); } -static void ggp_action_search(PurplePluginAction *action) +static void ggp_action_search(PurpleProtocolAction *action) { - ggp_pubdir_search((PurpleConnection *)action->context, NULL); + ggp_pubdir_search(action->connection, NULL); } -static void ggp_action_set_info(PurplePluginAction *action) +static void ggp_action_set_info(PurpleProtocolAction *action) { - ggp_pubdir_set_info((PurpleConnection *)action->context); + ggp_pubdir_set_info(action->connection); } -static GList *ggp_actions(PurplePlugin *plugin, gpointer context) +static GList *ggp_get_actions(PurpleConnection *gc) { GList *m = NULL; - PurplePluginAction *act; + PurpleProtocolAction *act; - act = purple_plugin_action_new(_("Change password..."), + act = purple_protocol_action_new(_("Change password..."), ggp_action_chpass); m = g_list_append(m, act); - act = purple_plugin_action_new(_("Show status only for buddies"), + act = purple_protocol_action_new(_("Show status only for buddies"), ggp_action_status_broadcasting); m = g_list_append(m, act); m = g_list_append(m, NULL); - act = purple_plugin_action_new(_("Find buddies..."), + act = purple_protocol_action_new(_("Find buddies..."), ggp_action_search); m = g_list_append(m, act); - act = purple_plugin_action_new(_("Set User Info"), + act = purple_protocol_action_new(_("Set User Info"), ggp_action_set_info); m = g_list_append(m, act); m = g_list_append(m, NULL); - act = purple_plugin_action_new(_("Save buddylist to file..."), + act = purple_protocol_action_new(_("Save buddylist to file..."), ggp_action_buddylist_save); m = g_list_append(m, act); - act = purple_plugin_action_new(_("Load buddylist from file..."), + act = purple_protocol_action_new(_("Load buddylist from file..."), ggp_action_buddylist_load); m = g_list_append(m, act); @@ -1369,11 +1369,14 @@ static PurplePluginProtocolInfo prpl_info = { + "prpl-gg", /* id */ + "Gadu-Gadu", /* name */ sizeof(PurplePluginProtocolInfo), /* struct_size */ OPT_PROTO_REGISTER_NOSCREENNAME | OPT_PROTO_IM_IMAGE, NULL, /* user_splits */ NULL, /* protocol_options */ {"png", 1, 1, 200, 200, 0, PURPLE_ICON_SCALE_DISPLAY | PURPLE_ICON_SCALE_SEND}, /* icon_spec */ + ggp_get_actions, /* get_actions */ ggp_list_icon, /* list_icon */ ggp_list_emblem, /* list_emblem */ ggp_status_buddy_text, /* status_text */ @@ -1442,44 +1445,6 @@ NULL /* get_public_alias */ }; -static gboolean ggp_load(PurplePlugin *plugin); -static gboolean ggp_unload(PurplePlugin *plugin); - -static PurplePluginInfo info = { - PURPLE_PLUGIN_MAGIC, /* magic */ - PURPLE_MAJOR_VERSION, /* major_version */ - PURPLE_MINOR_VERSION, /* minor_version */ - PURPLE_PLUGIN_PROTOCOL, /* plugin type */ - NULL, /* ui_requirement */ - 0, /* flags */ - NULL, /* dependencies */ - PURPLE_PRIORITY_DEFAULT, /* priority */ - - "prpl-gg", /* id */ - "Gadu-Gadu", /* name */ - DISPLAY_VERSION, /* version */ - - N_("Gadu-Gadu Protocol Plugin"), /* summary */ - N_("Polish popular IM"), /* description */ - "boler@sourceforge.net", /* author */ - PURPLE_WEBSITE, /* homepage */ - - ggp_load, /* load */ - ggp_unload, /* unload */ - NULL, /* destroy */ - - NULL, /* ui_info */ - &prpl_info, /* extra_info */ - NULL, /* prefs_info */ - ggp_actions, /* actions */ - - /* padding */ - NULL, - NULL, - NULL, - NULL -}; - static void purple_gg_debug_handler(int level, const char * format, va_list args) { PurpleDebugLevel purple_level; char *msg = g_strdup_vprintf(format, args); @@ -1503,9 +1468,27 @@ g_free(msg); } +static PurplePluginInfo * +plugin_query(GError **error) +{ + return purple_plugin_info_new( + "id", "prpl-gg", + "name", "Gadu-Gadu", + "version", DISPLAY_VERSION, + "category", N_("Protocol"), + "summary", N_("Gadu-Gadu Protocol Plugin"), + "description", N_("Polish popular IM"), + "author", "boler@sourceforge.net", + "website", PURPLE_WEBSITE, + "abi-version", PURPLE_ABI_VERSION, + NULL + ); +} + static PurpleAccountOption *ggp_server_option; -static void init_plugin(PurplePlugin *plugin) +static gboolean +plugin_load(PurplePlugin *plugin, GError **error) { PurpleAccountOption *option; GList *encryption_options = NULL; @@ -1541,25 +1524,27 @@ option); gg_debug_handler = purple_gg_debug_handler; -} -static gboolean ggp_load(PurplePlugin *plugin) -{ purple_debug_info("gg", "Loading Gadu-Gadu protocol plugin with " "libgadu %s...\n", gg_libgadu_version()); ggp_resolver_purple_setup(); ggp_servconn_setup(ggp_server_option); - + + purple_protocols_add(&prpl_info); + return TRUE; } -static gboolean ggp_unload(PurplePlugin *plugin) +static gboolean +plugin_unload(PurplePlugin *plugin, GError **error) { ggp_servconn_cleanup(); + purple_protocols_remove(&prpl_info); + return TRUE; } -PURPLE_INIT_PLUGIN(gg, init_plugin, info); +PURPLE_PLUGIN_INIT(gg, plugin_query, plugin_load, plugin_unload); /* vim: set ts=8 sts=0 sw=8 noet: */