/soc/2013/ankitkv/gobjectification: 3d43ca8d69ee: Refactored the...

Ankit Vani a at nevitus.org
Sat Aug 31 16:12:05 EDT 2013


Changeset: 3d43ca8d69ee1ec9f4295ff8120e2c9376cbe558
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-09-01 01:40 +0530
Branch:	 soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/3d43ca8d69ee

Description:

Refactored the protocols to use the error argument of purple_protocols_{add/remove}

diffstat:

 libpurple/protocols.h                    |   4 +++-
 libpurple/protocols/bonjour/bonjour.c    |  11 +++--------
 libpurple/protocols/bonjour/bonjour.h    |   1 -
 libpurple/protocols/gg/gg.c              |  11 +++--------
 libpurple/protocols/gg/gg.h              |   1 -
 libpurple/protocols/irc/irc.c            |  11 +++--------
 libpurple/protocols/irc/irc.h            |   1 -
 libpurple/protocols/jabber/libfacebook.c |  10 +++-------
 libpurple/protocols/jabber/libfacebook.h |   1 -
 libpurple/protocols/jabber/libgtalk.c    |  10 +++-------
 libpurple/protocols/jabber/libgtalk.h    |   1 -
 libpurple/protocols/jabber/libxmpp.c     |  10 +++-------
 libpurple/protocols/jabber/libxmpp.h     |   2 --
 libpurple/protocols/msn/msn.c            |  10 +++-------
 libpurple/protocols/mxit/mxit.c          |  11 +++--------
 libpurple/protocols/mxit/mxit.h          |   2 --
 libpurple/protocols/myspace/myspace.c    |  10 +++-------
 libpurple/protocols/myspace/myspace.h    |   1 -
 libpurple/protocols/novell/novell.c      |  12 ++++--------
 libpurple/protocols/novell/novell.h      |   1 -
 libpurple/protocols/null/nullprotocol.c  |  11 +++--------
 libpurple/protocols/null/nullprotocol.h  |   1 -
 libpurple/protocols/oscar/libaim.c       |  10 +++-------
 libpurple/protocols/oscar/libaim.h       |   2 --
 libpurple/protocols/oscar/libicq.c       |  10 +++-------
 libpurple/protocols/oscar/libicq.h       |   1 -
 libpurple/protocols/sametime/sametime.c  |  13 +++----------
 libpurple/protocols/silc/silc.c          |  11 +++--------
 libpurple/protocols/silc/silcpurple.h    |   1 -
 libpurple/protocols/simple/simple.c      |  11 +++--------
 libpurple/protocols/simple/simple.h      |   1 -
 libpurple/protocols/yahoo/libyahoo.c     |  10 +++-------
 libpurple/protocols/yahoo/libyahoo.h     |   1 -
 libpurple/protocols/yahoo/libyahoojp.c   |  11 +++--------
 libpurple/protocols/yahoo/libyahoojp.h   |   1 -
 libpurple/protocols/zephyr/zephyr.c      |  11 +++--------
 libpurple/protocols/zephyr/zephyr.h      |   1 -
 37 files changed, 61 insertions(+), 167 deletions(-)

diffs (truncated from 784 to 300 lines):

diff --git a/libpurple/protocols.h b/libpurple/protocols.h
--- a/libpurple/protocols.h
+++ b/libpurple/protocols.h
@@ -152,7 +152,9 @@ typedef enum
 
 } PurpleProtocolOptions;
 
+#include "media.h"
 #include "protocol.h"
+#include "status.h"
 
 #define PURPLE_TYPE_PROTOCOL_CHAT_ENTRY  (purple_protocol_chat_entry_get_type())
 
@@ -581,7 +583,7 @@ PurpleProtocol *purple_protocols_add(GTy
  * @param protocol  The protocol to remove.
  * @param error  Return location for a #GError or @c NULL. If provided, this
  *               will be set to the reason if removing fails.
-
+ *
  * @return TRUE if the protocol was removed, else FALSE.
  */
 gboolean purple_protocols_remove(PurpleProtocol *protocol, GError **error);
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
@@ -718,12 +718,9 @@ plugin_query(GError **error)
 static gboolean
 plugin_load(PurplePlugin *plugin, GError **error)
 {
-	my_protocol = purple_protocols_add(BONJOUR_TYPE_PROTOCOL);
-
-	if (!my_protocol) {
-		g_set_error(error, BONJOUR_DOMAIN, 0, _("Failed to add bonjour protocol"));
+	my_protocol = purple_protocols_add(BONJOUR_TYPE_PROTOCOL, error);
+	if (!my_protocol)
 		return FALSE;
-	}
 
 	return TRUE;
 }
@@ -731,10 +728,8 @@ plugin_load(PurplePlugin *plugin, GError
 static gboolean
 plugin_unload(PurplePlugin *plugin, GError **error)
 {
-	if (!purple_protocols_remove(my_protocol)) {
-		g_set_error(error, BONJOUR_DOMAIN, 0, _("Failed to remove bonjour protocol"));
+	if (!purple_protocols_remove(my_protocol, error))
 		return FALSE;
-	}
 
 	return TRUE;
 }
diff --git a/libpurple/protocols/bonjour/bonjour.h b/libpurple/protocols/bonjour/bonjour.h
--- a/libpurple/protocols/bonjour/bonjour.h
+++ b/libpurple/protocols/bonjour/bonjour.h
@@ -38,7 +38,6 @@
 
 #define BONJOUR_ID     "prpl-bonjour"
 #define BONJOUR_NAME   "Bonjour"
-#define BONJOUR_DOMAIN (g_quark_from_static_string(BONJOUR_ID))
 
 #define BONJOUR_STATUS_ID_OFFLINE   "offline"
 #define BONJOUR_STATUS_ID_AVAILABLE "available"
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
@@ -1521,12 +1521,9 @@ plugin_query(GError **error)
 static gboolean
 plugin_load(PurplePlugin *plugin, GError **error)
 {
-	my_protocol = purple_protocols_add(GGP_TYPE_PROTOCOL);
-
-	if (!my_protocol) {
-		g_set_error(error, GGP_DOMAIN, 0, _("Failed to add gg protocol"));
+	my_protocol = purple_protocols_add(GGP_TYPE_PROTOCOL, error);
+	if (!my_protocol)
 		return FALSE;
-	}
 
 	return TRUE;
 }
@@ -1534,10 +1531,8 @@ plugin_load(PurplePlugin *plugin, GError
 static gboolean
 plugin_unload(PurplePlugin *plugin, GError **error)
 {
-	if (!purple_protocols_remove(my_protocol)) {
-		g_set_error(error, GGP_DOMAIN, 0, _("Failed to remove gg protocol"));
+	if (!purple_protocols_remove(my_protocol, error))
 		return FALSE;
-	}
 
 	return TRUE;
 }
diff --git a/libpurple/protocols/gg/gg.h b/libpurple/protocols/gg/gg.h
--- a/libpurple/protocols/gg/gg.h
+++ b/libpurple/protocols/gg/gg.h
@@ -42,7 +42,6 @@
 
 #define GGP_ID     "prpl-gg"
 #define GGP_NAME   "Gadu-Gadu"
-#define GGP_DOMAIN (g_quark_from_static_string(GGP_ID))
 
 #define GGP_TYPE_PROTOCOL             (ggp_protocol_get_type())
 #define GGP_PROTOCOL(obj)             (G_TYPE_CHECK_INSTANCE_CAST((obj), GGP_TYPE_PROTOCOL, GaduGaduProtocol))
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
@@ -1040,12 +1040,9 @@ plugin_query(GError **error)
 static gboolean
 plugin_load(PurplePlugin *plugin, GError **error)
 {
-	_irc_protocol = purple_protocols_add(IRC_TYPE_PROTOCOL);
-
-	if (!_irc_protocol) {
-		g_set_error(error, IRC_DOMAIN, 0, _("Failed to add irc protocol"));
+	_irc_protocol = purple_protocols_add(IRC_TYPE_PROTOCOL, error);
+	if (!_irc_protocol)
 		return FALSE;
-	}
 
 	return TRUE;
 }
@@ -1053,10 +1050,8 @@ plugin_load(PurplePlugin *plugin, GError
 static gboolean
 plugin_unload(PurplePlugin *plugin, GError **error)
 {
-	if (!purple_protocols_remove(_irc_protocol)) {
-		g_set_error(error, IRC_DOMAIN, 0, _("Failed to remove irc protocol"));
+	if (!purple_protocols_remove(_irc_protocol, error))
 		return FALSE;
-	}
 
 	return TRUE;
 }
diff --git a/libpurple/protocols/irc/irc.h b/libpurple/protocols/irc/irc.h
--- a/libpurple/protocols/irc/irc.h
+++ b/libpurple/protocols/irc/irc.h
@@ -36,7 +36,6 @@
 
 #define IRC_ID     "prpl-irc"
 #define IRC_NAME   "IRC"
-#define IRC_DOMAIN (g_quark_from_static_string(IRC_ID))
 
 #define IRC_TYPE_PROTOCOL             (irc_protocol_get_type())
 #define IRC_PROTOCOL(obj)             (G_TYPE_CHECK_INSTANCE_CAST((obj), IRC_TYPE_PROTOCOL, IRCProtocol))
diff --git a/libpurple/protocols/jabber/libfacebook.c b/libpurple/protocols/jabber/libfacebook.c
--- a/libpurple/protocols/jabber/libfacebook.c
+++ b/libpurple/protocols/jabber/libfacebook.c
@@ -222,11 +222,9 @@ plugin_query(GError **error)
 static gboolean
 plugin_load(PurplePlugin *plugin, GError **error)
 {
-	my_protocol = purple_protocols_add(FACEBOOK_TYPE_PROTOCOL);
-	if (!my_protocol) {
-		g_set_error(error, FACEBOOK_DOMAIN, 0, _("Failed to add facebook protocol"));
+	my_protocol = purple_protocols_add(FACEBOOK_TYPE_PROTOCOL, error);
+	if (!my_protocol)
 		return FALSE;
-	}
 
 	purple_signal_connect(purple_get_core(), "uri-handler", my_protocol,
 		PURPLE_CALLBACK(xmpp_uri_handler), NULL);
@@ -239,10 +237,8 @@ static gboolean
 plugin_unload(PurplePlugin *plugin, GError **error)
 {
 	jabber_protocol_uninit(my_protocol);
-	if (!purple_protocols_remove(my_protocol)) {
-		g_set_error(error, FACEBOOK_DOMAIN, 0, _("Failed to remove facebook protocol"));
+	if (!purple_protocols_remove(my_protocol, error))
 		return FALSE;
-	}
 
 	return TRUE;
 }
diff --git a/libpurple/protocols/jabber/libfacebook.h b/libpurple/protocols/jabber/libfacebook.h
--- a/libpurple/protocols/jabber/libfacebook.h
+++ b/libpurple/protocols/jabber/libfacebook.h
@@ -26,7 +26,6 @@
 
 #define FACEBOOK_ID     "prpl-facebook-xmpp"
 #define FACEBOOK_NAME   "Facebook (XMPP)"
-#define FACEBOOK_DOMAIN (g_quark_from_static_string(FACEBOOK_ID))
 
 #define FACEBOOK_TYPE_PROTOCOL             (facebook_protocol_get_type())
 #define FACEBOOK_PROTOCOL(obj)             (G_TYPE_CHECK_INSTANCE_CAST((obj), FACEBOOK_TYPE_PROTOCOL, FacebookProtocol))
diff --git a/libpurple/protocols/jabber/libgtalk.c b/libpurple/protocols/jabber/libgtalk.c
--- a/libpurple/protocols/jabber/libgtalk.c
+++ b/libpurple/protocols/jabber/libgtalk.c
@@ -215,11 +215,9 @@ plugin_query(GError **error)
 static gboolean
 plugin_load(PurplePlugin *plugin, GError **error)
 {
-	my_protocol = purple_protocols_add(GTALK_TYPE_PROTOCOL);
-	if (!my_protocol) {
-		g_set_error(error, GTALK_DOMAIN, 0, _("Failed to add gtalk protocol"));
+	my_protocol = purple_protocols_add(GTALK_TYPE_PROTOCOL, error);
+	if (!my_protocol)
 		return FALSE;
-	}
 
 	purple_signal_connect(purple_get_core(), "uri-handler", my_protocol,
 		PURPLE_CALLBACK(xmpp_uri_handler), NULL);
@@ -232,10 +230,8 @@ static gboolean
 plugin_unload(PurplePlugin *plugin, GError **error)
 {
 	jabber_protocol_uninit(my_protocol);
-	if (!purple_protocols_remove(my_protocol)) {
-		g_set_error(error, GTALK_DOMAIN, 0, _("Failed to remove gtalk protocol"));
+	if (!purple_protocols_remove(my_protocol, error))
 		return FALSE;
-	}
 
 	return TRUE;
 }
diff --git a/libpurple/protocols/jabber/libgtalk.h b/libpurple/protocols/jabber/libgtalk.h
--- a/libpurple/protocols/jabber/libgtalk.h
+++ b/libpurple/protocols/jabber/libgtalk.h
@@ -26,7 +26,6 @@
 
 #define GTALK_ID     "prpl-gtalk"
 #define GTALK_NAME   "Google Talk (XMPP)"
-#define GTALK_DOMAIN (g_quark_from_static_string(GTALK_ID))
 
 #define GTALK_TYPE_PROTOCOL             (gtalk_protocol_get_type())
 #define GTALK_PROTOCOL(obj)             (G_TYPE_CHECK_INSTANCE_CAST((obj), GTALK_TYPE_PROTOCOL, GTalkProtocol))
diff --git a/libpurple/protocols/jabber/libxmpp.c b/libpurple/protocols/jabber/libxmpp.c
--- a/libpurple/protocols/jabber/libxmpp.c
+++ b/libpurple/protocols/jabber/libxmpp.c
@@ -198,11 +198,9 @@ plugin_query(GError **error)
 static gboolean
 plugin_load(PurplePlugin *plugin, GError **error)
 {
-	my_protocol = purple_protocols_add(XMPP_TYPE_PROTOCOL);
-	if (!my_protocol) {
-		g_set_error(error, XMPP_DOMAIN, 0, _("Failed to add jabber protocol"));
+	my_protocol = purple_protocols_add(XMPP_TYPE_PROTOCOL, error);
+	if (!my_protocol)
 		return FALSE;
-	}
 
 	purple_signal_connect(purple_get_core(), "uri-handler", my_protocol,
 		PURPLE_CALLBACK(xmpp_uri_handler), NULL);
@@ -215,10 +213,8 @@ static gboolean
 plugin_unload(PurplePlugin *plugin, GError **error)
 {
 	jabber_protocol_uninit(my_protocol);
-	if (!purple_protocols_remove(my_protocol)) {
-		g_set_error(error, XMPP_DOMAIN, 0, _("Failed to remove jabber protocol"));
+	if (!purple_protocols_remove(my_protocol, error))
 		return FALSE;
-	}
 
 	return TRUE;
 }
diff --git a/libpurple/protocols/jabber/libxmpp.h b/libpurple/protocols/jabber/libxmpp.h
--- a/libpurple/protocols/jabber/libxmpp.h
+++ b/libpurple/protocols/jabber/libxmpp.h
@@ -24,8 +24,6 @@
 
 #include "jabber.h"
 
-#define XMPP_DOMAIN (g_quark_from_static_string(JABBER_ID))
-
 #define XMPP_TYPE_PROTOCOL             (xmpp_protocol_get_type())
 #define XMPP_PROTOCOL(obj)             (G_TYPE_CHECK_INSTANCE_CAST((obj), XMPP_TYPE_PROTOCOL, XMPPProtocol))
 #define XMPP_PROTOCOL_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST((klass), XMPP_TYPE_PROTOCOL, XMPPProtocolClass))
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
@@ -3007,11 +3007,9 @@ plugin_query(GError **error)
 static gboolean
 plugin_load(PurplePlugin *plugin, GError **error)
 {
-	my_protocol = purple_protocols_add(MSN_TYPE_PROTOCOL);
-	if (!my_protocol) {
-		g_set_error(error, MSN_DOMAIN, 0, _("Failed to add msn protocol"));
+	my_protocol = purple_protocols_add(MSN_TYPE_PROTOCOL, error);
+	if (!my_protocol)
 		return FALSE;
-	}
 
 	purple_signal_connect(purple_get_core(), "uri-handler", my_protocol,
 		PURPLE_CALLBACK(msn_uri_handler), NULL);
@@ -3022,10 +3020,8 @@ plugin_load(PurplePlugin *plugin, GError
 static gboolean
 plugin_unload(PurplePlugin *plugin, GError **error)
 {
-	if (!purple_protocols_remove(my_protocol)) {
-		g_set_error(error, MSN_DOMAIN, 0, _("Failed to remove msn protocol"));
+	if (!purple_protocols_remove(my_protocol, error))
 		return FALSE;
-	}
 
 	return TRUE;
 }
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
@@ -854,12 +854,9 @@ plugin_query( GError **error )
 static gboolean



More information about the Commits mailing list