/soc/2013/ankitkv/gobjectification: ecc74498e088: Refactored oth...

Ankit Vani a at nevitus.org
Wed Sep 4 10:39:13 EDT 2013


Changeset: ecc74498e088b094a135bc0060bf321e566de05c
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-09-04 20:08 +0530
Branch:	 soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/ecc74498e088

Description:

Refactored other protocols to use instance init

diffstat:

 libpurple/protocols/bonjour/bonjour.c   |  28 +++++++++++--------
 libpurple/protocols/gg/gg.c             |  28 +++++++++++--------
 libpurple/protocols/irc/irc.c           |  36 +++++++++++++-----------
 libpurple/protocols/jabber/facebook.c   |  28 +++++++++++--------
 libpurple/protocols/jabber/gtalk.c      |  30 +++++++++++--------
 libpurple/protocols/jabber/jabber.c     |  41 +++++++++++++++-------------
 libpurple/protocols/jabber/jabber.h     |   3 --
 libpurple/protocols/jabber/xmpp.c       |  26 ++++++++++-------
 libpurple/protocols/msn/msn.c           |  30 +++++++++++--------
 libpurple/protocols/mxit/mxit.c         |  38 ++++++++++++++++---------
 libpurple/protocols/myspace/myspace.c   |  35 ++++++++++++++---------
 libpurple/protocols/novell/novell.c     |  20 ++++++++-----
 libpurple/protocols/oscar/aim.c         |  18 +++++++----
 libpurple/protocols/oscar/icq.c         |  18 +++++++----
 libpurple/protocols/oscar/oscar.c       |  27 ++++++++++--------
 libpurple/protocols/oscar/oscar.h       |   2 +-
 libpurple/protocols/sametime/sametime.c |  19 ++++++++----
 libpurple/protocols/silc/silc.c         |  48 +++++++++++++++++---------------
 libpurple/protocols/simple/simple.c     |  28 +++++++++++--------
 libpurple/protocols/yahoo/yahoo.c       |  34 +++++++++++++----------
 libpurple/protocols/yahoo/yahoojp.c     |  26 ++++++++++-------
 libpurple/protocols/zephyr/zephyr.c     |  33 +++++++++++++---------
 22 files changed, 341 insertions(+), 255 deletions(-)

diffs (truncated from 1373 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
@@ -630,36 +630,40 @@ initialize_default_account_values(void)
 }
 
 static void
-bonjour_protocol_base_init(BonjourProtocolClass *klass)
+bonjour_protocol_init(PurpleProtocol *protocol)
 {
-	PurpleProtocolClass *proto_class = PURPLE_PROTOCOL_CLASS(klass);
 	PurpleAccountOption *option;
 
-	proto_class->id        = "bonjour";
-	proto_class->name      = "Bonjour";
-	proto_class->options   = OPT_PROTO_NO_PASSWORD;
-	proto_class->icon_spec = purple_buddy_icon_spec_new("png,gif,jpeg",
+	protocol->id        = "bonjour";
+	protocol->name      = "Bonjour";
+	protocol->options   = OPT_PROTO_NO_PASSWORD;
+	protocol->icon_spec = purple_buddy_icon_spec_new("png,gif,jpeg",
 	                                                 0, 0, 96, 96, 65535,
 	                                                 PURPLE_ICON_SCALE_DISPLAY);
 
 	/* 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);
+	protocol->protocol_options = g_list_append(protocol->protocol_options, option);
 
 	option = purple_account_option_string_new(_("First name"), "first", default_firstname);
-	proto_class->protocol_options = g_list_append(proto_class->protocol_options, option);
+	protocol->protocol_options = g_list_append(protocol->protocol_options, option);
 
 	option = purple_account_option_string_new(_("Last name"), "last", default_lastname);
-	proto_class->protocol_options = g_list_append(proto_class->protocol_options, option);
+	protocol->protocol_options = g_list_append(protocol->protocol_options, option);
 
 	option = purple_account_option_string_new(_("Email"), "email", "");
-	proto_class->protocol_options = g_list_append(proto_class->protocol_options, option);
+	protocol->protocol_options = g_list_append(protocol->protocol_options, option);
 
 	option = purple_account_option_string_new(_("AIM Account"), "AIM", "");
-	proto_class->protocol_options = g_list_append(proto_class->protocol_options, option);
+	protocol->protocol_options = g_list_append(protocol->protocol_options, option);
 
 	option = purple_account_option_string_new(_("XMPP Account"), "jid", "");
-	proto_class->protocol_options = g_list_append(proto_class->protocol_options, option);
+	protocol->protocol_options = g_list_append(protocol->protocol_options, option);
+}
+
+static void
+bonjour_protocol_class_init(PurpleProtocolClass *klass)
+{
 }
 
 static void
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
@@ -1402,26 +1402,23 @@ static void purple_gg_debug_handler(int 
 }
 
 static void
-ggp_protocol_base_init(GGPProtocolClass *klass)
+ggp_protocol_init(PurpleProtocol *protocol)
 {
-	PurpleProtocolClass *proto_class = PURPLE_PROTOCOL_CLASS(klass);
 	PurpleAccountOption *option;
 	GList *encryption_options = NULL;
 
-	proto_class->id        = "gg";
-	proto_class->name      = "Gadu-Gadu";
-	proto_class->options   = OPT_PROTO_REGISTER_NOSCREENNAME |
-	                         OPT_PROTO_IM_IMAGE;
-	proto_class->icon_spec = purple_buddy_icon_spec_new("png",
+	protocol->id        = "gg";
+	protocol->name      = "Gadu-Gadu";
+	protocol->options   = OPT_PROTO_REGISTER_NOSCREENNAME |
+	                      OPT_PROTO_IM_IMAGE;
+	protocol->icon_spec = purple_buddy_icon_spec_new("png",
 	                                                 1, 1, 200, 200, 0,
 	                                                 PURPLE_ICON_SCALE_DISPLAY |
 	                                                 PURPLE_ICON_SCALE_SEND);
 
-	purple_prefs_add_none("/protocols/gg");
-
 	option = purple_account_option_string_new(_("GG server"),
 			"gg_server", "");
-	proto_class->protocol_options = g_list_append(proto_class->protocol_options,
+	protocol->protocol_options = g_list_append(protocol->protocol_options,
 			option);
 	ggp_server_option = option;
 
@@ -1439,16 +1436,21 @@ ggp_protocol_base_init(GGPProtocolClass 
 
 	option = purple_account_option_list_new(_("Connection security"),
 		"encryption", encryption_options);
-	proto_class->protocol_options = g_list_append(proto_class->protocol_options,
+	protocol->protocol_options = g_list_append(protocol->protocol_options,
 		option);
 
 	option = purple_account_option_bool_new(_("Show links from strangers"),
 		"show_links_from_strangers", 1);
-	proto_class->protocol_options = g_list_append(proto_class->protocol_options,
+	protocol->protocol_options = g_list_append(protocol->protocol_options,
 		option);
 }
 
 static void
+ggp_protocol_class_init(PurpleProtocolClass *klass)
+{
+}
+
+static void
 ggp_protocol_interface_init(PurpleProtocolInterface *iface)
 {
 	iface->get_actions            = ggp_get_actions;
@@ -1516,6 +1518,8 @@ plugin_load(PurplePlugin *plugin, GError
 	if (!my_protocol)
 		return FALSE;
 
+	purple_prefs_add_none("/protocols/gg");
+
 	gg_debug_handler = purple_gg_debug_handler;
 
 	purple_debug_info("gg", "Loading Gadu-Gadu protocol plugin with "
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
@@ -924,55 +924,59 @@ irc_get_max_message_size(PurpleConversat
 }
 
 static void
-irc_protocol_base_init(IRCProtocolClass *klass)
+irc_protocol_init(PurpleProtocol *protocol)
 {
-	PurpleProtocolClass *proto_class = PURPLE_PROTOCOL_CLASS(klass);
 	PurpleAccountUserSplit *split;
 	PurpleAccountOption *option;
 
-	proto_class->id        = "irc";
-	proto_class->name      = "IRC";
-	proto_class->options   = OPT_PROTO_CHAT_TOPIC | OPT_PROTO_PASSWORD_OPTIONAL
-	                         | OPT_PROTO_SLASH_COMMANDS_NATIVE;
+	protocol->id        = "irc";
+	protocol->name      = "IRC";
+	protocol->options   = OPT_PROTO_CHAT_TOPIC | OPT_PROTO_PASSWORD_OPTIONAL |
+	                      OPT_PROTO_SLASH_COMMANDS_NATIVE;
 
 	split = purple_account_user_split_new(_("Server"), IRC_DEFAULT_SERVER, '@');
-	proto_class->user_splits = g_list_append(proto_class->user_splits, split);
+	protocol->user_splits = g_list_append(protocol->user_splits, split);
 
 	option = purple_account_option_int_new(_("Port"), "port", IRC_DEFAULT_PORT);
-	proto_class->protocol_options = g_list_append(proto_class->protocol_options, option);
+	protocol->protocol_options = g_list_append(protocol->protocol_options, option);
 
 	option = purple_account_option_string_new(_("Encodings"), "encoding", IRC_DEFAULT_CHARSET);
-	proto_class->protocol_options = g_list_append(proto_class->protocol_options, option);
+	protocol->protocol_options = g_list_append(protocol->protocol_options, option);
 
 	option = purple_account_option_bool_new(_("Auto-detect incoming UTF-8"), "autodetect_utf8", IRC_DEFAULT_AUTODETECT);
-	proto_class->protocol_options = g_list_append(proto_class->protocol_options, option);
+	protocol->protocol_options = g_list_append(protocol->protocol_options, option);
 
 	option = purple_account_option_string_new(_("Username"), "username", "");
-	proto_class->protocol_options = g_list_append(proto_class->protocol_options, option);
+	protocol->protocol_options = g_list_append(protocol->protocol_options, option);
 
 	option = purple_account_option_string_new(_("Real name"), "realname", "");
-	proto_class->protocol_options = g_list_append(proto_class->protocol_options, option);
+	protocol->protocol_options = g_list_append(protocol->protocol_options, option);
 
 	/*
 	option = purple_account_option_string_new(_("Quit message"), "quitmsg", IRC_DEFAULT_QUIT);
-	proto_class->protocol_options = g_list_append(proto_class->protocol_options, option);
+	protocol->protocol_options = g_list_append(protocol->protocol_options, option);
 	*/
 
 	option = purple_account_option_bool_new(_("Use SSL"), "ssl", FALSE);
-	proto_class->protocol_options = g_list_append(proto_class->protocol_options, option);
+	protocol->protocol_options = g_list_append(protocol->protocol_options, option);
 
 #ifdef HAVE_CYRUS_SASL
 	option = purple_account_option_bool_new(_("Authenticate with SASL"), "sasl", FALSE);
-	proto_class->protocol_options = g_list_append(proto_class->protocol_options, option);
+	protocol->protocol_options = g_list_append(protocol->protocol_options, option);
 
 	option = purple_account_option_bool_new(
 						_("Allow plaintext SASL auth over unencrypted connection"),
 						"auth_plain_in_clear", FALSE);
-	proto_class->protocol_options = g_list_append(proto_class->protocol_options, option);
+	protocol->protocol_options = g_list_append(protocol->protocol_options, option);
 #endif
 }
 
 static void
+irc_protocol_class_init(PurpleProtocolClass *klass)
+{
+}
+
+static void
 irc_protocol_interface_init(PurpleProtocolInterface *iface)
 {
 	iface->get_actions          = irc_get_actions;
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
@@ -34,24 +34,23 @@ facebook_list_icon(PurpleAccount *a, Pur
 }
 
 static void
-facebook_protocol_base_init(FacebookProtocolClass *klass)
+facebook_protocol_init(PurpleProtocol *protocol)
 {
-	PurpleProtocolClass *proto_class = PURPLE_PROTOCOL_CLASS(klass);
 	PurpleAccountUserSplit *split;
 	PurpleAccountOption *option;
 	GList *encryption_values = NULL;
 
-	proto_class->id        = "facebook-xmpp";
-	proto_class->name      = "Facebook (XMPP)";
+	protocol->id        = "facebook-xmpp";
+	protocol->name      = "Facebook (XMPP)";
 
 	/* Translators: 'domain' is used here in the context of Internet domains, e.g. pidgin.im */
 	split = purple_account_user_split_new(_("Domain"), "chat.facebook.com", '@');
 	purple_account_user_split_set_reverse(split, FALSE);
-	proto_class->user_splits = g_list_append(proto_class->user_splits, split);
+	protocol->user_splits = g_list_append(protocol->user_splits, split);
 
 	split = purple_account_user_split_new(_("Resource"), "", '/');
 	purple_account_user_split_set_reverse(split, FALSE);
-	proto_class->user_splits = g_list_append(proto_class->user_splits, split);
+	protocol->user_splits = g_list_append(protocol->user_splits, split);
 
 #define ADD_VALUE(list, desc, v) { \
 	PurpleKeyValuePair *kvp = g_new0(PurpleKeyValuePair, 1); \
@@ -71,38 +70,43 @@ facebook_protocol_base_init(FacebookProt
 #undef ADD_VALUE
 
 	option = purple_account_option_list_new(_("Connection security"), "connection_security", encryption_values);
-	proto_class->protocol_options = g_list_append(proto_class->protocol_options,
+	protocol->protocol_options = g_list_append(protocol->protocol_options,
 						   option);
 
 	option = purple_account_option_bool_new(
 						_("Allow plaintext auth over unencrypted streams"),
 						"auth_plain_in_clear", FALSE);
-	proto_class->protocol_options = g_list_append(proto_class->protocol_options,
+	protocol->protocol_options = g_list_append(protocol->protocol_options,
 						   option);
 
 	option = purple_account_option_int_new(_("Connect port"), "port", 5222);
-	proto_class->protocol_options = g_list_append(proto_class->protocol_options,
+	protocol->protocol_options = g_list_append(protocol->protocol_options,
 						   option);
 
 	option = purple_account_option_string_new(_("Connect server"),
 						  "connect_server", NULL);
-	proto_class->protocol_options = g_list_append(proto_class->protocol_options,
+	protocol->protocol_options = g_list_append(protocol->protocol_options,
 						  option);
 
 	option = purple_account_option_string_new(_("BOSH URL"),
 						  "bosh_url", NULL);
-	proto_class->protocol_options = g_list_append(proto_class->protocol_options,
+	protocol->protocol_options = g_list_append(protocol->protocol_options,
 						  option);
 
 	/* this should probably be part of global smiley theme settings later on,
 	  shared with MSN */
 	option = purple_account_option_bool_new(_("Show Custom Smileys"),
 		"custom_smileys", TRUE);
-	proto_class->protocol_options = g_list_append(proto_class->protocol_options,
+	protocol->protocol_options = g_list_append(protocol->protocol_options,
 		option);
 }
 
 static void
+facebook_protocol_class_init(PurpleProtocolClass *klass)
+{
+}
+
+static void
 facebook_protocol_interface_init(PurpleProtocolInterface *iface)
 {
 	iface->list_icon           = facebook_list_icon;
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
@@ -34,24 +34,23 @@ gtalk_list_icon(PurpleAccount *a, Purple
 }
 
 static void
-gtalk_protocol_base_init(GTalkProtocolClass *klass)
+gtalk_protocol_init(PurpleProtocol *protocol)
 {
-	PurpleProtocolClass *proto_class = PURPLE_PROTOCOL_CLASS(klass);
 	PurpleAccountUserSplit *split;



More information about the Commits mailing list