/soc/2013/ankitkv/gobjectification: 8250d6be8c02: Started refact...
Ankit Vani
a at nevitus.org
Tue Sep 17 02:51:36 EDT 2013
Changeset: 8250d6be8c025813063b5b393ffad4c59ec7957c
Author: Ankit Vani <a at nevitus.org>
Date: 2013-09-17 12:21 +0530
Branch: soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/8250d6be8c02
Description:
Started refactoring pidgin plugins to use the new plugin API
diffstat:
finch/plugins/gntclipboard.c | 2 +-
pidgin/plugins/disco/gtkdisco.c | 2 +-
pidgin/plugins/disco/xmppdisco.c | 80 +++++------
pidgin/plugins/disco/xmppdisco.h | 3 +
pidgin/plugins/gestures/gestures.c | 168 ++++++++++--------------
pidgin/plugins/musicmessaging/musicmessaging.c | 170 ++++++++++--------------
pidgin/plugins/ticker/ticker.c | 70 +++------
7 files changed, 206 insertions(+), 289 deletions(-)
diffs (truncated from 638 to 300 lines):
diff --git a/finch/plugins/gntclipboard.c b/finch/plugins/gntclipboard.c
--- a/finch/plugins/gntclipboard.c
+++ b/finch/plugins/gntclipboard.c
@@ -24,7 +24,7 @@
#define PLUGIN_ID "gntclipboard"
#define PLUGIN_DOMAIN (g_quark_from_static_string(PLUGIN_ID))
-#define PLUGIN_STATIC_NAME GntClipboard
+#define PLUGIN_STATIC_NAME GntClipboard
#ifdef HAVE_X11
#include <X11/Xlib.h>
diff --git a/pidgin/plugins/disco/gtkdisco.c b/pidgin/plugins/disco/gtkdisco.c
--- a/pidgin/plugins/disco/gtkdisco.c
+++ b/pidgin/plugins/disco/gtkdisco.c
@@ -423,7 +423,7 @@ static void close_button_cb(GtkButton *b
static gboolean account_filter_func(PurpleAccount *account)
{
- return purple_strequal(purple_account_get_protocol_id(account), XMPP_PLUGIN_ID);
+ return purple_strequal(purple_account_get_protocol_id(account), XMPP_PROTOCOL_ID);
}
static gboolean
diff --git a/pidgin/plugins/disco/xmppdisco.c b/pidgin/plugins/disco/xmppdisco.c
--- a/pidgin/plugins/disco/xmppdisco.c
+++ b/pidgin/plugins/disco/xmppdisco.c
@@ -151,7 +151,7 @@ xmpp_iq_register_callback(PurpleConnecti
g_hash_table_insert(iq_callbacks, id, cbdata);
if (!iq_listening) {
- PurpleProtocol *protocol = purple_plugins_find_with_id(XMPP_PROTOCOL_ID);
+ PurpleProtocol *protocol = purple_protocols_find(XMPP_PROTOCOL_ID);
iq_listening = TRUE;
purple_signal_connect(protocol, "jabber-receiving-iq", my_plugin,
PURPLE_CALLBACK(xmpp_iq_received), NULL);
@@ -592,7 +592,7 @@ create_dialog(PurplePluginAction *action
}
static GList *
-actions(PurplePlugin *plugin, gpointer context)
+actions(PurplePlugin *plugin)
{
GList *l = NULL;
PurplePluginAction *action = NULL;
@@ -614,16 +614,42 @@ signed_off_cb(PurpleConnection *pc, gpoi
g_hash_table_foreach_remove(iq_callbacks, remove_iq_callbacks_by_pc, pc);
}
+static PidginPluginInfo *
+plugin_query(GError **error)
+{
+ const gchar * const authors[] = {
+ "Paul Aurich <paul at darkrain42.org>",
+ NULL
+ };
+
+ return pidgin_plugin_info_new(
+ "id", PLUGIN_ID,
+ "name", N_("XMPP Service Discovery"),
+ "version", DISPLAY_VERSION,
+ "category", N_("Protocol utility"),
+ "summary", N_("Allows browsing and registering services."),
+ "description", N_("This plugin is useful for registering with legacy "
+ "transports or other XMPP services."),
+ "authors", authors,
+ "website", PURPLE_WEBSITE,
+ "abi-version", PURPLE_ABI_VERSION,
+ "get-actions", actions,
+ NULL
+ );
+}
+
static gboolean
-plugin_load(PurplePlugin *plugin)
+plugin_load(PurplePlugin *plugin, GError **error)
{
- PurplePlugin *xmpp_protocol;
+ PurpleProtocol *xmpp_protocol;
my_plugin = plugin;
- xmpp_protocol = purple_plugins_find_with_id(XMPP_PROTOCOL_ID);
- if (NULL == xmpp_protocol)
+ xmpp_protocol = purple_protocols_find(XMPP_PROTOCOL_ID);
+ if (NULL == xmpp_protocol) {
+ g_set_error(error, PLUGIN_DOMAIN, 0, _("XMPP protocol is not loaded."));
return FALSE;
+ }
purple_signal_connect(purple_connections_get_handle(), "signing-off",
plugin, PURPLE_CALLBACK(signed_off_cb), NULL);
@@ -634,7 +660,7 @@ plugin_load(PurplePlugin *plugin)
}
static gboolean
-plugin_unload(PurplePlugin *plugin)
+plugin_unload(PurplePlugin *plugin, GError **error)
{
g_hash_table_destroy(iq_callbacks);
iq_callbacks = NULL;
@@ -645,42 +671,4 @@ plugin_unload(PurplePlugin *plugin)
return TRUE;
}
-static PurplePluginInfo info =
-{
- PURPLE_PLUGIN_MAGIC,
- PURPLE_MAJOR_VERSION,
- PURPLE_MINOR_VERSION,
- PURPLE_PLUGIN_STANDARD,
- PIDGIN_PLUGIN_TYPE,
- 0,
- NULL,
- PURPLE_PRIORITY_DEFAULT,
- "gtk-xmppdisco",
- N_("XMPP Service Discovery"),
- DISPLAY_VERSION,
- N_("Allows browsing and registering services."),
- N_("This plugin is useful for registering with legacy transports or other "
- "XMPP services."),
- "Paul Aurich <paul at darkrain42.org>",
- PURPLE_WEBSITE,
- plugin_load,
- plugin_unload,
- NULL, /**< destroy */
- NULL, /**< ui_info */
- NULL, /**< extra_info */
- NULL, /**< prefs_info */
- actions,
-
- /* padding */
- NULL,
- NULL,
- NULL,
- NULL
-};
-
-static void
-init_plugin(PurplePlugin *plugin)
-{
-}
-
-PURPLE_INIT_PLUGIN(xmppdisco, init_plugin, info)
+PURPLE_PLUGIN_INIT(xmppdisco, plugin_query, plugin_load, plugin_unload);
diff --git a/pidgin/plugins/disco/xmppdisco.h b/pidgin/plugins/disco/xmppdisco.h
--- a/pidgin/plugins/disco/xmppdisco.h
+++ b/pidgin/plugins/disco/xmppdisco.h
@@ -32,6 +32,9 @@ typedef struct _XmppDiscoService XmppDis
#define NS_MUC "http://jabber.org/protocol/muc"
#define NS_REGISTER "jabber:iq:register"
+#define PLUGIN_ID "gtk-xmppdisco"
+#define PLUGIN_DOMAIN (g_quark_from_static_string(PLUGIN_ID))
+
#include "plugins.h"
extern PurplePlugin *my_plugin;
diff --git a/pidgin/plugins/gestures/gestures.c b/pidgin/plugins/gestures/gestures.c
--- a/pidgin/plugins/gestures/gestures.c
+++ b/pidgin/plugins/gestures/gestures.c
@@ -168,50 +168,6 @@ visual_pref_cb(const char *name, PurpleP
gstroke_set_draw_strokes((gboolean) GPOINTER_TO_INT(value) );
}
-static gboolean
-plugin_load(PurplePlugin *plugin)
-{
- PurpleConversation *conv;
- GList *l;
-
- for (l = purple_conversations_get_all(); l != NULL; l = l->next) {
- conv = (PurpleConversation *)l->data;
-
- if (!PIDGIN_IS_PIDGIN_CONVERSATION(conv))
- continue;
-
- attach_signals(conv);
- }
-
- purple_signal_connect(purple_conversations_get_handle(),
- "conversation-created",
- plugin, PURPLE_CALLBACK(new_conv_cb), NULL);
-
- return TRUE;
-}
-
-static gboolean
-plugin_unload(PurplePlugin *plugin)
-{
- PurpleConversation *conv;
- PidginConversation *gtkconv;
- GList *l;
-
- for (l = purple_conversations_get_all(); l != NULL; l = l->next) {
- conv = (PurpleConversation *)l->data;
-
- if (!PIDGIN_IS_PIDGIN_CONVERSATION(conv))
- continue;
-
- gtkconv = PIDGIN_CONVERSATION(conv);
-
- gstroke_cleanup(gtkconv->webview);
- gstroke_disable(gtkconv->webview);
- }
-
- return TRUE;
-}
-
static GtkWidget *
get_config_frame(PurplePlugin *plugin)
{
@@ -256,64 +212,43 @@ get_config_frame(PurplePlugin *plugin)
return ret;
}
-static PidginPluginUiInfo ui_info =
+static PidginPluginInfo *
+plugin_query(GError **error)
{
- get_config_frame,
- 0, /* page_num (Reserved) */
+ const gchar * const authors[] = {
+ "Christian Hammond <chipx86 at gnupdate.org>",
+ NULL
+ };
- /* padding */
- NULL,
- NULL,
- NULL,
- NULL
-};
+ return pidgin_plugin_info_new(
+ "id", GESTURES_PLUGIN_ID,
+ "name", N_("Mouse Gestures"),
+ "version", DISPLAY_VERSION,
+ "category", N_("User interface"),
+ "summary", N_("Provides support for mouse gestures"),
+ "description", N_("Allows support for mouse gestures in "
+ "conversation windows. Drag the middle "
+ "mouse button to perform certain actions:\n"
+ " ⢠Drag down and then to the right to "
+ "close a conversation.\n"
+ " ⢠Drag up and then to the left to switch "
+ "to the previous conversation.\n"
+ " ⢠Drag up and then to the right to switch "
+ "to the next conversation."),
+ "authors", authors,
+ "website", PURPLE_WEBSITE,
+ "abi-version", PURPLE_ABI_VERSION,
+ "pidgin-config-frame", get_config_frame,
+ NULL
+ );
+}
-static PurplePluginInfo info =
+static gboolean
+plugin_load(PurplePlugin *plugin, GError **error)
{
- PURPLE_PLUGIN_MAGIC,
- PURPLE_MAJOR_VERSION,
- PURPLE_MINOR_VERSION,
- PURPLE_PLUGIN_STANDARD, /**< type */
- PIDGIN_PLUGIN_TYPE, /**< ui_requirement */
- 0, /**< flags */
- NULL, /**< dependencies */
- PURPLE_PRIORITY_DEFAULT, /**< priority */
+ PurpleConversation *conv;
+ GList *l;
- GESTURES_PLUGIN_ID, /**< id */
- N_("Mouse Gestures"), /**< name */
- DISPLAY_VERSION, /**< version */
- /** summary */
- N_("Provides support for mouse gestures"),
- /** description */
- N_("Allows support for mouse gestures in conversation windows. "
- "Drag the middle mouse button to perform certain actions:\n"
- " ⢠Drag down and then to the right to close a conversation.\n"
- " ⢠Drag up and then to the left to switch to the previous "
- "conversation.\n"
- " ⢠Drag up and then to the right to switch to the next "
- "conversation."),
- "Christian Hammond <chipx86 at gnupdate.org>", /**< author */
- PURPLE_WEBSITE, /**< homepage */
-
- plugin_load, /**< load */
- plugin_unload, /**< unload */
- NULL, /**< destroy */
-
- &ui_info, /**< ui_info */
- NULL, /**< extra_info */
- NULL,
- NULL,
-
- /* padding */
- NULL,
- NULL,
- NULL,
More information about the Commits
mailing list