/soc/2013/ankitkv/gobjectification: c582c94a71ac: Refactored yah...
Ankit Vani
a at nevitus.org
Mon Aug 12 07:31:28 EDT 2013
Changeset: c582c94a71ace8b2c7138e06bdd8a03d143b29f4
Author: Ankit Vani <a at nevitus.org>
Date: 2013-08-12 16:53 +0530
Branch: soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/c582c94a71ac
Description:
Refactored yahoo to use the new plugin API
diffstat:
libpurple/protocols/yahoo/libyahoo.c | 84 +++++++++++++++------------------
libpurple/protocols/yahoo/libyahoojp.c | 75 +++++++++++++-----------------
libpurple/protocols/yahoo/libymsg.c | 28 +++++-----
libpurple/protocols/yahoo/libymsg.h | 2 +-
4 files changed, 86 insertions(+), 103 deletions(-)
diffs (truncated from 365 to 300 lines):
diff --git a/libpurple/protocols/yahoo/libyahoo.c b/libpurple/protocols/yahoo/libyahoo.c
--- a/libpurple/protocols/yahoo/libyahoo.c
+++ b/libpurple/protocols/yahoo/libyahoo.c
@@ -25,6 +25,7 @@
#include <account.h>
#include <core.h>
+#include <plugins.h>
#include "libymsg.h"
#include "yahoochat.h"
@@ -33,7 +34,7 @@
#include "yahoo_filexfer.h"
#include "yahoo_picture.h"
-static PurplePlugin *my_protocol = NULL;
+static PurplePluginProtocolInfo *my_protocol = NULL;
static void yahoo_register_commands(void)
{
@@ -100,7 +101,7 @@ static gboolean yahoo_uri_handler(const
if (g_ascii_strcasecmp(proto, "ymsgr"))
return FALSE;
- acct = find_acct(purple_plugin_get_id(my_protocol), acct_id);
+ acct = find_acct(my_protocol->id, acct_id);
if (!acct)
return FALSE;
@@ -167,13 +168,6 @@ yahoo_get_account_text_table(PurpleAccou
return table;
}
-static gboolean yahoo_unload_plugin(PurplePlugin *plugin)
-{
- yahoo_dest_colorht();
-
- return TRUE;
-}
-
static PurpleWhiteboardPrplOps yahoo_whiteboard_prpl_ops =
{
yahoo_doodle_start,
@@ -194,11 +188,14 @@ static PurpleWhiteboardPrplOps yahoo_whi
static PurplePluginProtocolInfo prpl_info =
{
+ "prpl-yahoo",
+ "Yahoo",
sizeof(PurplePluginProtocolInfo), /* struct_size */
OPT_PROTO_MAIL_CHECK | OPT_PROTO_CHAT_TOPIC | OPT_PROTO_AUTHORIZATION_DENIED_MESSAGE,
NULL, /* user_splits */
NULL, /* protocol_options */
{"png,gif,jpeg", 96, 96, 96, 96, 0, PURPLE_ICON_SCALE_SEND},
+ yahoo_get_actions,
yahoo_list_icon,
yahoo_list_emblem,
yahoo_status_text,
@@ -267,42 +264,24 @@ 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-yahoo", /**< id */
- "Yahoo", /**< name */
- DISPLAY_VERSION, /**< version */
- /** summary */
- N_("Yahoo! Protocol Plugin"),
- /** description */
- N_("Yahoo! Protocol Plugin"),
- NULL, /**< author */
- PURPLE_WEBSITE, /**< homepage */
- NULL, /**< load */
- yahoo_unload_plugin, /**< unload */
- NULL, /**< destroy */
- NULL, /**< ui_info */
- &prpl_info, /**< extra_info */
- NULL,
- yahoo_actions,
+ return purple_plugin_info_new(
+ "id", "prpl-yahoo",
+ "name", "Yahoo",
+ "version", DISPLAY_VERSION,
+ "category", N_("Protocol"),
+ "summary", N_("Yahoo! Protocol Plugin"),
+ "description", N_("Yahoo! Protocol Plugin"),
+ "website", PURPLE_WEBSITE,
+ "abi-version", PURPLE_ABI_VERSION,
+ NULL
+ );
+}
- /* padding */
- NULL,
- NULL,
- NULL,
- NULL
-};
-
-static void
-init_plugin(PurplePlugin *plugin)
+static gboolean
+plugin_load(PurplePlugin *plugin, GError **error)
{
PurpleAccountOption *option;
@@ -329,12 +308,25 @@ init_plugin(PurplePlugin *plugin)
prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
#endif
- my_protocol = plugin;
+ my_protocol = &prpl_info;
yahoo_register_commands();
yahoo_init_colorht();
- purple_signal_connect(purple_get_core(), "uri-handler", plugin,
+ purple_signal_connect(purple_get_core(), "uri-handler", my_protocol,
PURPLE_CALLBACK(yahoo_uri_handler), NULL);
+
+ purple_protocols_add(my_protocol);
+
+ return TRUE;
}
-PURPLE_INIT_PLUGIN(yahoo, init_plugin, info);
+static gboolean
+plugin_unload(PurplePlugin *plugin, GError **error)
+{
+ yahoo_dest_colorht();
+ purple_protocols_remove(my_protocol);
+
+ return TRUE;
+}
+
+PURPLE_PLUGIN_INIT(yahoo, plugin_query, plugin_load, plugin_unload);
diff --git a/libpurple/protocols/yahoo/libyahoojp.c b/libpurple/protocols/yahoo/libyahoojp.c
--- a/libpurple/protocols/yahoo/libyahoojp.c
+++ b/libpurple/protocols/yahoo/libyahoojp.c
@@ -24,6 +24,7 @@
#include "internal.h"
#include <account.h>
+#include <plugins.h>
#include "libymsg.h"
#include "yahoochat.h"
@@ -63,13 +64,6 @@ yahoojp_get_account_text_table(PurpleAcc
return table;
}
-static gboolean yahoojp_unload_plugin(PurplePlugin *plugin)
-{
- yahoo_dest_colorht();
-
- return TRUE;
-}
-
static PurpleWhiteboardPrplOps yahoo_whiteboard_prpl_ops =
{
yahoo_doodle_start,
@@ -90,11 +84,14 @@ static PurpleWhiteboardPrplOps yahoo_whi
static PurplePluginProtocolInfo prpl_info =
{
+ "prpl-yahoojp",
+ "Yahoo JAPAN",
sizeof(PurplePluginProtocolInfo), /* struct_size */
OPT_PROTO_MAIL_CHECK | OPT_PROTO_CHAT_TOPIC | OPT_PROTO_AUTHORIZATION_DENIED_MESSAGE,
NULL, /* user_splits */
NULL, /* protocol_options */
{"png,gif,jpeg", 96, 96, 96, 96, 0, PURPLE_ICON_SCALE_SEND},
+ yahoo_get_actions,
yahoo_list_icon,
yahoo_list_emblem,
yahoo_status_text,
@@ -165,42 +162,24 @@ 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-yahoojp", /**< id */
- "Yahoo JAPAN", /**< name */
- DISPLAY_VERSION, /**< version */
- /** summary */
- N_("Yahoo! JAPAN Protocol Plugin"),
- /** description */
- N_("Yahoo! JAPAN Protocol Plugin"),
- NULL, /**< author */
- PURPLE_WEBSITE, /**< homepage */
- NULL, /**< load */
- yahoojp_unload_plugin, /**< unload */
- NULL, /**< destroy */
- NULL, /**< ui_info */
- &prpl_info, /**< extra_info */
- NULL,
- yahoo_actions,
+ return purple_plugin_info_new(
+ "id", "prpl-yahoojp",
+ "name", "Yahoo JAPAN",
+ "version", DISPLAY_VERSION,
+ "category", N_("Protocol"),
+ "summary", N_("Yahoo! JAPAN Protocol Plugin"),
+ "description", N_("Yahoo! JAPAN Protocol Plugin"),
+ "website", PURPLE_WEBSITE,
+ "abi-version", PURPLE_ABI_VERSION,
+ NULL
+ );
+}
- /* padding */
- NULL,
- NULL,
- NULL,
- NULL
-};
-
-static void
-init_plugin(PurplePlugin *plugin)
+static gboolean
+plugin_load(PurplePlugin *plugin, GError **error)
{
PurpleAccountOption *option;
@@ -229,7 +208,19 @@ init_plugin(PurplePlugin *plugin)
yahoojp_register_commands();
yahoo_init_colorht();
+
+ purple_protocols_add(&prpl_info);
+ return TRUE;
}
-PURPLE_INIT_PLUGIN(yahoojp, init_plugin, info);
+static gboolean
+plugin_unload(PurplePlugin *plugin, GError **error)
+{
+ yahoo_dest_colorht();
+ purple_protocols_remove(&prpl_info);
+ return TRUE;
+}
+
+PURPLE_PLUGIN_INIT(yahoojp, plugin_query, plugin_load, plugin_unload);
+
diff --git a/libpurple/protocols/yahoo/libymsg.c b/libpurple/protocols/yahoo/libymsg.c
--- a/libpurple/protocols/yahoo/libymsg.c
+++ b/libpurple/protocols/yahoo/libymsg.c
@@ -4134,12 +4134,12 @@ yahoo_get_inbox_token_cb(PurpleHttpConne
}
-static void yahoo_show_inbox(PurplePluginAction *action)
+static void yahoo_show_inbox(PurpleProtocolAction *action)
{
/* Setup a cookie that can be used by the browser */
/* XXX I have no idea how this will work with Yahoo! Japan. */
- PurpleConnection *gc = action->context;
+ PurpleConnection *gc = action->connection;
YahooData *yd = purple_connection_get_protocol_data(gc);
PurpleHttpRequest *req;
PurpleHttpCookieJar *cookiejar;
@@ -4160,18 +4160,18 @@ static void yahoo_show_inbox(PurplePlugi
#if 0
/* XXX: it doesn't seems to work */
static void
-yahoo_set_userinfo_fn(PurplePluginAction *action)
+yahoo_set_userinfo_fn(PurpleProtocolAction *action)
{
- yahoo_set_userinfo(action->context);
+ yahoo_set_userinfo(action->connection);
}
#endif
-static void yahoo_show_act_id(PurplePluginAction *action)
+static void yahoo_show_act_id(PurpleProtocolAction *action)
{
PurpleRequestFields *fields;
More information about the Commits
mailing list