/soc/2013/ankitkv/gobjectification: ec178f7d66da: Refactored pro...
Ankit Vani
a at nevitus.org
Fri Sep 13 11:12:29 EDT 2013
Changeset: ec178f7d66da75c609d8aff51be14182bc485eb6
Author: Ankit Vani <a at nevitus.org>
Date: 2013-09-13 20:32 +0530
Branch: soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/ec178f7d66da
Description:
Refactored protocols to use the new type definition macros
diffstat:
libpurple/protocols/bonjour/bonjour.c | 13 +++++++++----
libpurple/protocols/gg/gg.c | 12 +++++++++---
libpurple/protocols/irc/irc.c | 13 +++++++++----
libpurple/protocols/jabber/facebook.c | 8 +++++---
libpurple/protocols/jabber/facebook.h | 5 +++++
libpurple/protocols/jabber/gtalk.c | 8 +++++---
libpurple/protocols/jabber/gtalk.h | 5 +++++
libpurple/protocols/jabber/jabber.c | 18 ++++++++++++------
libpurple/protocols/jabber/presence.c | 2 +-
libpurple/protocols/jabber/xmpp.c | 6 +-----
libpurple/protocols/jabber/xmpp.h | 5 +++++
libpurple/protocols/msn/msn.c | 13 +++++++++----
libpurple/protocols/mxit/mxit.c | 16 ++++++++++------
libpurple/protocols/myspace/myspace.c | 13 +++++++++----
libpurple/protocols/novell/novell.c | 13 +++++++++----
libpurple/protocols/oscar/aim.c | 8 +++++---
libpurple/protocols/oscar/aim.h | 5 +++++
libpurple/protocols/oscar/icq.c | 8 +++++---
libpurple/protocols/oscar/icq.h | 5 +++++
libpurple/protocols/oscar/oscar.c | 17 +++++++++++------
libpurple/protocols/sametime/sametime.c | 15 +++++++++++----
libpurple/protocols/silc/silc.c | 13 +++++++++----
libpurple/protocols/simple/simple.c | 13 +++++++++----
libpurple/protocols/yahoo/yahoo.c | 15 ++++++++++-----
libpurple/protocols/yahoo/yahoojp.c | 8 +++++---
libpurple/protocols/yahoo/yahoojp.h | 5 +++++
libpurple/protocols/zephyr/zephyr.c | 15 +++++++++++----
27 files changed, 194 insertions(+), 83 deletions(-)
diffs (truncated from 708 to 300 lines):
diff --git a/libpurple/protocols/bonjour/bonjour.c b/libpurple/protocols/bonjour/bonjour.c
--- a/libpurple/protocols/bonjour/bonjour.c
+++ b/libpurple/protocols/bonjour/bonjour.c
@@ -689,6 +689,12 @@ bonjour_protocol_interface_init(PurplePr
iface->get_max_message_size = bonjour_get_max_message_size;
}
+PURPLE_DEFINE_TYPE_EXTENDED(
+ BonjourProtocol, bonjour_protocol, PURPLE_TYPE_PROTOCOL, 0,
+ PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_INTERFACE,
+ bonjour_protocol_interface_init)
+);
+
static PurplePluginInfo *
plugin_query(GError **error)
{
@@ -710,6 +716,8 @@ plugin_query(GError **error)
static gboolean
plugin_load(PurplePlugin *plugin, GError **error)
{
+ bonjour_protocol_register_type(plugin);
+
my_protocol = purple_protocols_add(BONJOUR_TYPE_PROTOCOL, error);
if (!my_protocol)
return FALSE;
@@ -731,7 +739,4 @@ plugin_unload(PurplePlugin *plugin, GErr
return TRUE;
}
-static PurplePlugin *my_plugin;
-PURPLE_PROTOCOL_DEFINE(my_plugin, BonjourProtocol, bonjour_protocol);
-PURPLE_PLUGIN_INIT_VAL(my_plugin, bonjour, plugin_query, plugin_load,
- plugin_unload);
+PURPLE_PLUGIN_INIT(bonjour, plugin_query, plugin_load, plugin_unload);
diff --git a/libpurple/protocols/gg/gg.c b/libpurple/protocols/gg/gg.c
--- a/libpurple/protocols/gg/gg.c
+++ b/libpurple/protocols/gg/gg.c
@@ -1484,6 +1484,12 @@ ggp_protocol_interface_init(PurpleProtoc
iface->get_max_message_size = ggp_get_max_message_size;
}
+PURPLE_DEFINE_TYPE_EXTENDED(
+ GGPProtocol, ggp_protocol, PURPLE_TYPE_PROTOCOL, 0,
+ PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_INTERFACE,
+ ggp_protocol_interface_init)
+);
+
static PurplePluginInfo *
plugin_query(GError **error)
{
@@ -1511,6 +1517,8 @@ plugin_query(GError **error)
static gboolean
plugin_load(PurplePlugin *plugin, GError **error)
{
+ ggp_protocol_register_type(plugin);
+
my_protocol = purple_protocols_add(GGP_TYPE_PROTOCOL, error);
if (!my_protocol)
return FALSE;
@@ -1539,8 +1547,6 @@ plugin_unload(PurplePlugin *plugin, GErr
return TRUE;
}
-static PurplePlugin *my_plugin;
-PURPLE_PROTOCOL_DEFINE(my_plugin, GGPProtocol, ggp_protocol);
-PURPLE_PLUGIN_INIT_VAL(my_plugin, gg, plugin_query, plugin_load, plugin_unload);
+PURPLE_PLUGIN_INIT(gg, plugin_query, plugin_load, plugin_unload);
/* vim: set ts=8 sts=0 sw=8 noet: */
diff --git a/libpurple/protocols/irc/irc.c b/libpurple/protocols/irc/irc.c
--- a/libpurple/protocols/irc/irc.c
+++ b/libpurple/protocols/irc/irc.c
@@ -1007,6 +1007,12 @@ irc_protocol_interface_init(PurpleProtoc
iface->get_max_message_size = irc_get_max_message_size;
}
+PURPLE_DEFINE_TYPE_EXTENDED(
+ IRCProtocol, irc_protocol, PURPLE_TYPE_PROTOCOL, 0,
+ PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_INTERFACE,
+ irc_protocol_interface_init)
+);
+
static PurplePluginInfo *
plugin_query(GError **error)
{
@@ -1028,6 +1034,8 @@ plugin_query(GError **error)
static gboolean
plugin_load(PurplePlugin *plugin, GError **error)
{
+ irc_protocol_register_type(plugin);
+
_irc_protocol = purple_protocols_add(IRC_TYPE_PROTOCOL, error);
if (!_irc_protocol)
return FALSE;
@@ -1060,7 +1068,4 @@ plugin_unload(PurplePlugin *plugin, GErr
return TRUE;
}
-static PurplePlugin *my_plugin;
-PURPLE_PROTOCOL_DEFINE(my_plugin, IRCProtocol, irc_protocol);
-PURPLE_PLUGIN_INIT_VAL(my_plugin, irc, plugin_query, plugin_load,
- plugin_unload);
+PURPLE_PLUGIN_INIT(irc, plugin_query, plugin_load, plugin_unload);
diff --git a/libpurple/protocols/jabber/facebook.c b/libpurple/protocols/jabber/facebook.c
--- a/libpurple/protocols/jabber/facebook.c
+++ b/libpurple/protocols/jabber/facebook.c
@@ -131,6 +131,8 @@ facebook_protocol_interface_init(PurpleP
iface->get_moods = NULL;
}
-extern PurplePlugin *_jabber_plugin;
-PURPLE_PROTOCOL_DEFINE_EXTENDED(_jabber_plugin, FacebookProtocol,
- facebook_protocol, JABBER_TYPE_PROTOCOL, 0);
+PURPLE_DEFINE_TYPE_EXTENDED(
+ FacebookProtocol, facebook_protocol, JABBER_TYPE_PROTOCOL, 0,
+ PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_INTERFACE,
+ facebook_protocol_interface_init)
+);
diff --git a/libpurple/protocols/jabber/facebook.h b/libpurple/protocols/jabber/facebook.h
--- a/libpurple/protocols/jabber/facebook.h
+++ b/libpurple/protocols/jabber/facebook.h
@@ -42,6 +42,11 @@ typedef struct _FacebookProtocolClass
} FacebookProtocolClass;
/**
+ * Registers the FacebookProtocol type in the type system.
+ */
+void facebook_protocol_register_type(PurplePlugin *plugin);
+
+/**
* Returns the GType for the FacebookProtocol object.
*/
GType facebook_protocol_get_type(void);
diff --git a/libpurple/protocols/jabber/gtalk.c b/libpurple/protocols/jabber/gtalk.c
--- a/libpurple/protocols/jabber/gtalk.c
+++ b/libpurple/protocols/jabber/gtalk.c
@@ -124,6 +124,8 @@ gtalk_protocol_interface_init(PurpleProt
iface->unregister_user = NULL;
}
-extern PurplePlugin *_jabber_plugin;
-PURPLE_PROTOCOL_DEFINE_EXTENDED(_jabber_plugin, GTalkProtocol, gtalk_protocol,
- JABBER_TYPE_PROTOCOL, 0);
+PURPLE_DEFINE_TYPE_EXTENDED(
+ GTalkProtocol, gtalk_protocol, JABBER_TYPE_PROTOCOL, 0,
+ PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_INTERFACE,
+ gtalk_protocol_interface_init)
+);
diff --git a/libpurple/protocols/jabber/gtalk.h b/libpurple/protocols/jabber/gtalk.h
--- a/libpurple/protocols/jabber/gtalk.h
+++ b/libpurple/protocols/jabber/gtalk.h
@@ -42,6 +42,11 @@ typedef struct _GTalkProtocolClass
} GTalkProtocolClass;
/**
+ * Registers the GTalkProtocol type in the type system.
+ */
+void gtalk_protocol_register_type(PurplePlugin *plugin);
+
+/**
* Returns the GType for the GTalkProtocol object.
*/
GType gtalk_protocol_get_type(void);
diff --git a/libpurple/protocols/jabber/jabber.c b/libpurple/protocols/jabber/jabber.c
--- a/libpurple/protocols/jabber/jabber.c
+++ b/libpurple/protocols/jabber/jabber.c
@@ -81,8 +81,6 @@
*/
#define DEFAULT_INACTIVITY_TIME 120
-PurplePlugin *_jabber_plugin = NULL;
-
GList *jabber_features = NULL;
GList *jabber_identities = NULL;
@@ -4211,8 +4209,11 @@ jabber_protocol_interface_init(PurplePro
iface->get_moods = jabber_get_moods;
}
-PURPLE_PROTOCOL_DEFINE_EXTENDED(_jabber_plugin, JabberProtocol, jabber_protocol,
- PURPLE_TYPE_PROTOCOL, G_TYPE_FLAG_ABSTRACT);
+PURPLE_DEFINE_TYPE_EXTENDED(
+ JabberProtocol, jabber_protocol, PURPLE_TYPE_PROTOCOL, G_TYPE_FLAG_ABSTRACT,
+ PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_INTERFACE,
+ jabber_protocol_interface_init)
+);
static PurplePluginInfo *
plugin_query(GError **error)
@@ -4235,6 +4236,12 @@ plugin_query(GError **error)
static gboolean
plugin_load(PurplePlugin *plugin, GError **error)
{
+ jabber_protocol_register_type(plugin);
+
+ facebook_protocol_register_type(plugin);
+ gtalk_protocol_register_type(plugin);
+ xmpp_protocol_register_type(plugin);
+
xmpp_protocol = purple_protocols_add(XMPP_TYPE_PROTOCOL, error);
if (!xmpp_protocol)
return FALSE;
@@ -4280,5 +4287,4 @@ plugin_unload(PurplePlugin *plugin, GErr
return TRUE;
}
-PURPLE_PLUGIN_INIT_VAL(_jabber_plugin, jabber, plugin_query, plugin_load,
- plugin_unload);
+PURPLE_PLUGIN_INIT(jabber, plugin_query, plugin_load, plugin_unload);
diff --git a/libpurple/protocols/jabber/presence.c b/libpurple/protocols/jabber/presence.c
--- a/libpurple/protocols/jabber/presence.c
+++ b/libpurple/protocols/jabber/presence.c
@@ -600,7 +600,7 @@ handle_presence_chat(JabberStream *js, J
" you like to configure it, or"
" accept the default settings?"),
/* Default Action */ 1,
- purple_request_cpar_from_conversation(chat->conv),
+ purple_request_cpar_from_conversation(PURPLE_CONVERSATION(chat->conv)),
chat, 2,
_("_Configure Room"), G_CALLBACK(jabber_chat_request_room_configure),
_("_Accept Defaults"), G_CALLBACK(jabber_chat_create_instant_room));
diff --git a/libpurple/protocols/jabber/xmpp.c b/libpurple/protocols/jabber/xmpp.c
--- a/libpurple/protocols/jabber/xmpp.c
+++ b/libpurple/protocols/jabber/xmpp.c
@@ -107,8 +107,4 @@ xmpp_protocol_class_init(PurpleProtocolC
{
}
-static void xmpp_protocol_interface_init(PurpleProtocolInterface *iface) { }
-
-extern PurplePlugin *_jabber_plugin;
-PURPLE_PROTOCOL_DEFINE_EXTENDED(_jabber_plugin, XMPPProtocol, xmpp_protocol,
- JABBER_TYPE_PROTOCOL, 0);
+PURPLE_DEFINE_TYPE(XMPPProtocol, xmpp_protocol, JABBER_TYPE_PROTOCOL);
diff --git a/libpurple/protocols/jabber/xmpp.h b/libpurple/protocols/jabber/xmpp.h
--- a/libpurple/protocols/jabber/xmpp.h
+++ b/libpurple/protocols/jabber/xmpp.h
@@ -42,6 +42,11 @@ typedef struct _XMPPProtocolClass
} XMPPProtocolClass;
/**
+ * Registers the XMPPProtocol type in the type system.
+ */
+void xmpp_protocol_register_type(PurplePlugin *plugin);
+
+/**
* Returns the GType for the XMPPProtocol object.
*/
GType xmpp_protocol_get_type(void);
diff --git a/libpurple/protocols/msn/msn.c b/libpurple/protocols/msn/msn.c
--- a/libpurple/protocols/msn/msn.c
+++ b/libpurple/protocols/msn/msn.c
@@ -2971,6 +2971,12 @@ msn_protocol_interface_init(PurpleProtoc
iface->get_max_message_size = msn_get_max_message_size;
}
+PURPLE_DEFINE_TYPE_EXTENDED(
+ MsnProtocol, msn_protocol, PURPLE_TYPE_PROTOCOL, 0,
+ PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_INTERFACE,
+ msn_protocol_interface_init)
+);
+
static PurplePluginInfo *
plugin_query(GError **error)
{
@@ -2994,6 +3000,8 @@ plugin_load(PurplePlugin *plugin, GError
{
PurpleCmdId id;
+ msn_protocol_register_type(plugin);
+
my_protocol = purple_protocols_add(MSN_TYPE_PROTOCOL, error);
if (!my_protocol)
return FALSE;
@@ -3033,7 +3041,4 @@ plugin_unload(PurplePlugin *plugin, GErr
return TRUE;
}
-static PurplePlugin *my_plugin;
-PURPLE_PROTOCOL_DEFINE(my_plugin, MsnProtocol, msn_protocol);
-PURPLE_PLUGIN_INIT_VAL(my_plugin, msn, plugin_query, plugin_load,
- plugin_unload);
+PURPLE_PLUGIN_INIT(msn, plugin_query, plugin_load, plugin_unload);
diff --git a/libpurple/protocols/mxit/mxit.c b/libpurple/protocols/mxit/mxit.c
--- a/libpurple/protocols/mxit/mxit.c
+++ b/libpurple/protocols/mxit/mxit.c
@@ -819,6 +819,13 @@ mxit_protocol_interface_init( PurpleProt
}
+PURPLE_DEFINE_TYPE_EXTENDED(
+ MXitProtocol, mxit_protocol, PURPLE_TYPE_PROTOCOL, 0,
+ PURPLE_IMPLEMENT_INTERFACE_STATIC( PURPLE_TYPE_PROTOCOL_INTERFACE,
+ mxit_protocol_interface_init )
+);
+
+
/*------------------------------------------------------------------------
* Querying the MXit plugin.
*
More information about the Commits
mailing list