/soc/2013/ankitkv/gobjectification: 081733748bbc: Only initializ...
Ankit Vani
a at nevitus.org
Tue Sep 3 20:09:44 EDT 2013
Changeset: 081733748bbc49e2b19b3630a421471cc483a8de
Author: Ankit Vani <a at nevitus.org>
Date: 2013-09-04 05:26 +0530
Branch: soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/081733748bbc
Description:
Only initialize/finalize protocol class data in *_base_init/finalize for protocols.
Moved the rest to load/unload_plugin
diffstat:
libpurple/protocols/bonjour/bonjour.c | 19 +++------
libpurple/protocols/gg/gg.c | 28 +++++++--------
libpurple/protocols/irc/irc.c | 19 ++++-----
libpurple/protocols/msn/msn.c | 46 ++++++++++++-------------
libpurple/protocols/null/nullprotocol.c | 60 +++++++++++++++++---------------
libpurple/protocols/oscar/oscar.c | 14 +++---
libpurple/protocols/sametime/sametime.c | 34 ++++++++---------
libpurple/protocols/silc/silc.c | 33 ++++++++---------
libpurple/protocols/zephyr/zephyr.c | 15 +++----
9 files changed, 129 insertions(+), 139 deletions(-)
diffs (truncated from 561 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
@@ -642,8 +642,6 @@ bonjour_protocol_base_init(BonjourProtoc
0, 0, 96, 96, 65535,
PURPLE_ICON_SCALE_DISPLAY);
- initialize_default_account_values();
-
/* Creating the options for the protocol */
option = purple_account_option_int_new(_("Local Port"), "port", BONJOUR_DEFAULT_PORT);
proto_class->protocol_options = g_list_append(proto_class->protocol_options, option);
@@ -665,16 +663,6 @@ bonjour_protocol_base_init(BonjourProtoc
}
static void
-bonjour_protocol_base_finalize(BonjourProtocolClass *klass)
-{
- g_free(default_firstname);
- default_firstname = NULL;
-
- g_free(default_lastname);
- default_lastname = NULL;
-}
-
-static void
bonjour_protocol_interface_init(PurpleProtocolInterface *iface)
{
iface->list_icon = bonjour_list_icon;
@@ -697,6 +685,8 @@ bonjour_protocol_interface_init(PurplePr
iface->get_max_message_size = bonjour_get_max_message_size;
}
+static void bonjour_protocol_base_finalize(BonjourProtocolClass *klass) { }
+
static PurplePluginInfo *
plugin_query(GError **error)
{
@@ -722,6 +712,8 @@ plugin_load(PurplePlugin *plugin, GError
if (!my_protocol)
return FALSE;
+ initialize_default_account_values();
+
return TRUE;
}
@@ -731,6 +723,9 @@ plugin_unload(PurplePlugin *plugin, GErr
if (!purple_protocols_remove(my_protocol, error))
return FALSE;
+ g_free(default_firstname);
+ g_free(default_lastname);
+
return TRUE;
}
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
@@ -55,6 +55,7 @@
/* ---------------------------------------------------------------------- */
static PurpleProtocol *my_protocol = NULL;
+static PurpleAccountOption *ggp_server_option;
/* ---------------------------------------------------------------------- */
@@ -1405,7 +1406,6 @@ ggp_protocol_base_init(GGPProtocolClass
{
PurpleProtocolClass *proto_class = PURPLE_PROTOCOL_CLASS(klass);
PurpleAccountOption *option;
- PurpleAccountOption *ggp_server_option;
GList *encryption_options = NULL;
proto_class->id = "gg";
@@ -1446,20 +1446,6 @@ ggp_protocol_base_init(GGPProtocolClass
"show_links_from_strangers", 1);
proto_class->protocol_options = g_list_append(proto_class->protocol_options,
option);
-
- gg_debug_handler = purple_gg_debug_handler;
-
- 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);
-}
-
-static void
-ggp_protocol_base_finalize(GGPProtocolClass *klass)
-{
- ggp_servconn_cleanup();
}
static void
@@ -1499,6 +1485,8 @@ ggp_protocol_interface_init(PurpleProtoc
iface->get_max_message_size = ggp_get_max_message_size;
}
+static void ggp_protocol_base_finalize(GGPProtocolClass *klass) { }
+
static PurplePluginInfo *
plugin_query(GError **error)
{
@@ -1530,12 +1518,22 @@ plugin_load(PurplePlugin *plugin, GError
if (!my_protocol)
return FALSE;
+ gg_debug_handler = purple_gg_debug_handler;
+
+ 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);
+
return TRUE;
}
static gboolean
plugin_unload(PurplePlugin *plugin, GError **error)
{
+ ggp_servconn_cleanup();
+
if (!purple_protocols_remove(my_protocol, error))
return FALSE;
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
@@ -970,16 +970,6 @@ irc_protocol_base_init(IRCProtocolClass
"auth_plain_in_clear", FALSE);
proto_class->protocol_options = g_list_append(proto_class->protocol_options, option);
#endif
-
- purple_prefs_remove("/protocols/irc/quitmsg");
- purple_prefs_remove("/protocols/irc");
-
- irc_register_commands();
-}
-
-static void irc_protocol_base_finalize(IRCProtocolClass *klass)
-{
- irc_unregister_commands();
}
static void
@@ -1013,6 +1003,8 @@ irc_protocol_interface_init(PurpleProtoc
iface->get_max_message_size = irc_get_max_message_size;
}
+static void irc_protocol_base_finalize(IRCProtocolClass *klass) { }
+
static PurplePluginInfo *
plugin_query(GError **error)
{
@@ -1038,6 +1030,11 @@ plugin_load(PurplePlugin *plugin, GError
if (!_irc_protocol)
return FALSE;
+ purple_prefs_remove("/protocols/irc/quitmsg");
+ purple_prefs_remove("/protocols/irc");
+
+ irc_register_commands();
+
purple_signal_register(_irc_protocol, "irc-sending-text",
purple_marshal_VOID__POINTER_POINTER, G_TYPE_NONE, 2,
PURPLE_TYPE_CONNECTION,
@@ -1053,6 +1050,8 @@ plugin_load(PurplePlugin *plugin, GError
static gboolean
plugin_unload(PurplePlugin *plugin, GError **error)
{
+ irc_unregister_commands();
+
if (!purple_protocols_remove(_irc_protocol, error))
return FALSE;
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
@@ -2922,30 +2922,6 @@ msn_protocol_base_init(MsnProtocolClass
"mpop", TRUE);
proto_class->protocol_options = g_list_append(proto_class->protocol_options,
option);
-
- id = purple_cmd_register("nudge", "", PURPLE_CMD_P_PROTOCOL,
- PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_PROTOCOL_ONLY,
- "msn", msn_cmd_nudge,
- _("nudge: nudge a user to get their attention"), NULL);
- cmds = g_slist_prepend(cmds, GUINT_TO_POINTER(id));
-
- purple_prefs_remove("/protocols/msn");
-
- msn_notification_init();
- msn_switchboard_init();
-}
-
-static void
-msn_protocol_base_finalize(MsnProtocolClass *klass)
-{
- while (cmds) {
- PurpleCmdId id = GPOINTER_TO_UINT(cmds->data);
- purple_cmd_unregister(id);
- cmds = g_slist_delete_link(cmds, cmds);
- }
-
- msn_notification_end();
- msn_switchboard_end();
}
static void
@@ -2995,6 +2971,8 @@ msn_protocol_interface_init(PurpleProtoc
iface->get_max_message_size = msn_get_max_message_size;
}
+static void msn_protocol_base_finalize(MsnProtocolClass *klass) { }
+
static PurplePluginInfo *
plugin_query(GError **error)
{
@@ -3020,6 +2998,17 @@ plugin_load(PurplePlugin *plugin, GError
if (!my_protocol)
return FALSE;
+ id = purple_cmd_register("nudge", "", PURPLE_CMD_P_PROTOCOL,
+ PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_PROTOCOL_ONLY,
+ "msn", msn_cmd_nudge,
+ _("nudge: nudge a user to get their attention"), NULL);
+ cmds = g_slist_prepend(cmds, GUINT_TO_POINTER(id));
+
+ purple_prefs_remove("/protocols/msn");
+
+ msn_notification_init();
+ msn_switchboard_init();
+
purple_signal_connect(purple_get_core(), "uri-handler", my_protocol,
PURPLE_CALLBACK(msn_uri_handler), NULL);
@@ -3029,6 +3018,15 @@ plugin_load(PurplePlugin *plugin, GError
static gboolean
plugin_unload(PurplePlugin *plugin, GError **error)
{
+ msn_notification_end();
+ msn_switchboard_end();
+
+ while (cmds) {
+ PurpleCmdId id = GPOINTER_TO_UINT(cmds->data);
+ purple_cmd_unregister(id);
+ cmds = g_slist_delete_link(cmds, cmds);
+ }
+
if (!purple_protocols_remove(my_protocol, error))
return FALSE;
diff --git a/libpurple/protocols/null/nullprotocol.c b/libpurple/protocols/null/nullprotocol.c
--- a/libpurple/protocols/null/nullprotocol.c
+++ b/libpurple/protocols/null/nullprotocol.c
@@ -97,8 +97,7 @@ typedef struct {
/*
* stores offline messages that haven't been delivered yet. maps username
- * (char *) to GList * of GOfflineMessages. initialized in
- * null_protocol_base_init.
+ * (char *) to GList * of GOfflineMessages. initialized in plugin_load.
*/
GHashTable* goffline_messages = NULL;
@@ -1088,38 +1087,15 @@ null_protocol_base_init(NullProtocolClas
proto_class->user_splits = g_list_append(NULL, split);
proto_class->protocol_options = g_list_append(NULL, option);
-
- /* register whisper chat command, /msg */
- id = purple_cmd_register("msg",
- "ws", /* args: recipient and message */
- PURPLE_CMD_P_DEFAULT, /* priority */
- PURPLE_CMD_FLAG_CHAT,
- "null",
- send_whisper,
- "msg <username> <message>: send a private message, aka a whisper",
- NULL); /* userdata */
-
- /* add /msg command to the commands list */
- cmds = g_slist_prepend(cmds, GUINT_TO_POINTER(id));
-
- /* get ready to store offline messages */
- goffline_messages = g_hash_table_new_full(g_str_hash, /* hash fn */
- g_str_equal, /* key comparison fn */
- g_free, /* key free fn */
- NULL); /* value free fn */
}
+/*
+ * Finalize the protocol class.
+ */
static void
null_protocol_base_finalize(NullProtocolClass *klass)
{
More information about the Commits
mailing list