/soc/2013/ankitkv/gobjectification: 418f1f8581de: Add/remove Yah...

Ankit Vani a at nevitus.org
Tue Sep 3 17:14:45 EDT 2013


Changeset: 418f1f8581de8ca560c54f3030f984d21cf7297e
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-09-04 02:37 +0530
Branch:	 soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/418f1f8581de

Description:

Add/remove YahooProtocol, YahooJPProtocol via the single yahoo plugin

diffstat:

 libpurple/protocols/yahoo/util.c           |   2 +-
 libpurple/protocols/yahoo/yahoo.c          |  37 ++++++++++++------
 libpurple/protocols/yahoo/yahoo_aliases.c  |   2 +-
 libpurple/protocols/yahoo/yahoo_aliases.h  |   2 +-
 libpurple/protocols/yahoo/yahoo_doodle.c   |   2 +-
 libpurple/protocols/yahoo/yahoo_filexfer.c |   2 +-
 libpurple/protocols/yahoo/yahoo_friend.h   |   2 +-
 libpurple/protocols/yahoo/yahoo_packet.c   |   2 +-
 libpurple/protocols/yahoo/yahoo_picture.c  |   2 +-
 libpurple/protocols/yahoo/yahoo_profile.c  |   2 +-
 libpurple/protocols/yahoo/yahoochat.c      |   2 +-
 libpurple/protocols/yahoo/yahoojp.c        |  56 ++---------------------------
 libpurple/protocols/yahoo/ycht.c           |   2 +-
 libpurple/protocols/yahoo/ymsg.c           |   2 +-
 14 files changed, 40 insertions(+), 77 deletions(-)

diffs (truncated from 309 to 300 lines):

diff --git a/libpurple/protocols/yahoo/util.c b/libpurple/protocols/yahoo/util.c
--- a/libpurple/protocols/yahoo/util.c
+++ b/libpurple/protocols/yahoo/util.c
@@ -28,7 +28,7 @@
 #include "internal.h"
 #include "protocol.h"
 
-#include "libymsg.h"
+#include "ymsg.h"
 
 #include <string.h>
 
diff --git a/libpurple/protocols/yahoo/yahoo.c b/libpurple/protocols/yahoo/yahoo.c
--- a/libpurple/protocols/yahoo/yahoo.c
+++ b/libpurple/protocols/yahoo/yahoo.c
@@ -27,15 +27,20 @@
 #include <core.h>
 #include <plugins.h>
 
+#include "ymsg.h"
 #include "yahoo.h"
-#include "libymsg.h"
+#include "yahoojp.h"
 #include "yahoochat.h"
 #include "yahoo_aliases.h"
 #include "yahoo_doodle.h"
 #include "yahoo_filexfer.h"
 #include "yahoo_picture.h"
 
-static PurpleProtocol *my_protocol = NULL;
+PurplePlugin *_yahoo_plugin;
+
+static PurpleProtocol *yahoo_protocol = NULL;
+static PurpleProtocol *yahoojp_protocol = NULL;
+
 static GSList *cmds = NULL;
 
 static void yahoo_register_commands(void)
@@ -121,7 +126,7 @@ static gboolean yahoo_uri_handler(const 
 	if (g_ascii_strcasecmp(proto, "ymsgr"))
 		return FALSE;
 
-	acct = find_acct(purple_protocol_get_id(my_protocol), acct_id);
+	acct = find_acct(purple_protocol_get_id(yahoo_protocol), acct_id);
 
 	if (!acct)
 		return FALSE;
@@ -309,11 +314,11 @@ plugin_query(GError **error)
 {
 	return purple_plugin_info_new(
 		"id",           "protocol-yahoo",
-		"name",         "Yahoo Protocol",
+		"name",         "Yahoo Protocols",
 		"version",      DISPLAY_VERSION,
 		"category",     N_("Protocol"),
-		"summary",      N_("Yahoo! Protocol Plugin"),
-		"description",  N_("Yahoo! Protocol Plugin"),
+		"summary",      N_("Yahoo! and Yahoo! JAPAN Protocols Plugin"),
+		"description",  N_("Yahoo! and Yahoo! JAPAN Protocols Plugin"),
 		"website",      PURPLE_WEBSITE,
 		"abi-version",  PURPLE_ABI_VERSION,
 		"flags",        PURPLE_PLUGIN_INFO_FLAGS_INTERNAL |
@@ -325,11 +330,15 @@ plugin_query(GError **error)
 static gboolean
 plugin_load(PurplePlugin *plugin, GError **error)
 {
-	my_protocol = purple_protocols_add(YAHOO_TYPE_PROTOCOL, error);
-	if (!my_protocol)
+	yahoo_protocol = purple_protocols_add(YAHOO_TYPE_PROTOCOL, error);
+	if (!yahoo_protocol)
 		return FALSE;
 
-	purple_signal_connect(purple_get_core(), "uri-handler", my_protocol,
+	yahoojp_protocol = purple_protocols_add(YAHOOJP_TYPE_PROTOCOL, error);
+	if (!yahoojp_protocol)
+		return FALSE;
+
+	purple_signal_connect(purple_get_core(), "uri-handler", yahoo_protocol,
 		PURPLE_CALLBACK(yahoo_uri_handler), NULL);
 
 	return TRUE;
@@ -338,13 +347,15 @@ plugin_load(PurplePlugin *plugin, GError
 static gboolean
 plugin_unload(PurplePlugin *plugin, GError **error)
 {
-	if (!purple_protocols_remove(my_protocol, error))
+	if (!purple_protocols_remove(yahoojp_protocol, error))
+		return FALSE;
+
+	if (!purple_protocols_remove(yahoo_protocol, error))
 		return FALSE;
 
 	return TRUE;
 }
 
-static PurplePlugin *my_plugin;
-PURPLE_PROTOCOL_DEFINE(my_plugin, YahooProtocol, yahoo_protocol);
-PURPLE_PLUGIN_INIT_VAL(my_plugin, yahoo, plugin_query, plugin_load,
+PURPLE_PROTOCOL_DEFINE(_yahoo_plugin, YahooProtocol, yahoo_protocol);
+PURPLE_PLUGIN_INIT_VAL(_yahoo_plugin, yahoo, plugin_query, plugin_load,
                        plugin_unload);
diff --git a/libpurple/protocols/yahoo/yahoo_aliases.c b/libpurple/protocols/yahoo/yahoo_aliases.c
--- a/libpurple/protocols/yahoo/yahoo_aliases.c
+++ b/libpurple/protocols/yahoo/yahoo_aliases.c
@@ -32,7 +32,7 @@
 #include "util.h"
 #include "request.h"
 #include "version.h"
-#include "libymsg.h"
+#include "ymsg.h"
 #include "yahoo_aliases.h"
 #include "yahoo_friend.h"
 #include "yahoo_packet.h"
diff --git a/libpurple/protocols/yahoo/yahoo_aliases.h b/libpurple/protocols/yahoo/yahoo_aliases.h
--- a/libpurple/protocols/yahoo/yahoo_aliases.h
+++ b/libpurple/protocols/yahoo/yahoo_aliases.h
@@ -30,7 +30,7 @@
 #include "debug.h"
 #include "util.h"
 #include "version.h"
-#include "libymsg.h"
+#include "ymsg.h"
 #include "yahoo_packet.h"
 
 void yahoo_update_alias(PurpleConnection *gc, const char *who, const char *alias);
diff --git a/libpurple/protocols/yahoo/yahoo_doodle.c b/libpurple/protocols/yahoo/yahoo_doodle.c
--- a/libpurple/protocols/yahoo/yahoo_doodle.c
+++ b/libpurple/protocols/yahoo/yahoo_doodle.c
@@ -40,7 +40,7 @@
 #include "util.h"
 #include "version.h"
 
-#include "libymsg.h"
+#include "ymsg.h"
 #include "yahoo_packet.h"
 #include "yahoo_friend.h"
 #include "yahoochat.h"
diff --git a/libpurple/protocols/yahoo/yahoo_filexfer.c b/libpurple/protocols/yahoo/yahoo_filexfer.c
--- a/libpurple/protocols/yahoo/yahoo_filexfer.c
+++ b/libpurple/protocols/yahoo/yahoo_filexfer.c
@@ -33,7 +33,7 @@
 #include "notify.h"
 #include "proxy.h"
 #include "ft.h"
-#include "libymsg.h"
+#include "ymsg.h"
 #include "yahoo_packet.h"
 #include "yahoo_filexfer.h"
 #include "yahoo_doodle.h"
diff --git a/libpurple/protocols/yahoo/yahoo_friend.h b/libpurple/protocols/yahoo/yahoo_friend.h
--- a/libpurple/protocols/yahoo/yahoo_friend.h
+++ b/libpurple/protocols/yahoo/yahoo_friend.h
@@ -25,7 +25,7 @@
 #ifndef _YAHOO_FRIEND_H_
 #define _YAHOO_FRIEND_H_
 
-#include "libymsg.h"
+#include "ymsg.h"
 #include "yahoo_packet.h"
 
 typedef enum {
diff --git a/libpurple/protocols/yahoo/yahoo_packet.c b/libpurple/protocols/yahoo/yahoo_packet.c
--- a/libpurple/protocols/yahoo/yahoo_packet.c
+++ b/libpurple/protocols/yahoo/yahoo_packet.c
@@ -24,7 +24,7 @@
 #include "internal.h"
 #include "debug.h"
 
-#include "libymsg.h"
+#include "ymsg.h"
 #include "yahoo_packet.h"
 
 struct yahoo_packet *yahoo_packet_new(enum yahoo_service service, enum yahoo_status status, int id)
diff --git a/libpurple/protocols/yahoo/yahoo_picture.c b/libpurple/protocols/yahoo/yahoo_picture.c
--- a/libpurple/protocols/yahoo/yahoo_picture.c
+++ b/libpurple/protocols/yahoo/yahoo_picture.c
@@ -32,7 +32,7 @@
 #include "proxy.h"
 #include "util.h"
 
-#include "libymsg.h"
+#include "ymsg.h"
 #include "yahoo_packet.h"
 #include "yahoo_friend.h"
 #include "yahoo_picture.h"
diff --git a/libpurple/protocols/yahoo/yahoo_profile.c b/libpurple/protocols/yahoo/yahoo_profile.c
--- a/libpurple/protocols/yahoo/yahoo_profile.c
+++ b/libpurple/protocols/yahoo/yahoo_profile.c
@@ -32,7 +32,7 @@
 #include "imgstore.h"
 #endif /* PHOTO_SUPPORT */
 
-#include "libymsg.h"
+#include "ymsg.h"
 #include "yahoo_friend.h"
 
 typedef struct {
diff --git a/libpurple/protocols/yahoo/yahoochat.c b/libpurple/protocols/yahoo/yahoochat.c
--- a/libpurple/protocols/yahoo/yahoochat.c
+++ b/libpurple/protocols/yahoo/yahoochat.c
@@ -40,7 +40,7 @@
 #include "notify.h"
 #include "util.h"
 
-#include "libymsg.h"
+#include "ymsg.h"
 #include "yahoo_packet.h"
 #include "yahoochat.h"
 #include "ycht.h"
diff --git a/libpurple/protocols/yahoo/yahoojp.c b/libpurple/protocols/yahoo/yahoojp.c
--- a/libpurple/protocols/yahoo/yahoojp.c
+++ b/libpurple/protocols/yahoo/yahoojp.c
@@ -27,14 +27,13 @@
 #include <plugins.h>
 
 #include "yahoojp.h"
-#include "libymsg.h"
+#include "ymsg.h"
 #include "yahoochat.h"
 #include "yahoo_aliases.h"
 #include "yahoo_doodle.h"
 #include "yahoo_filexfer.h"
 #include "yahoo_picture.h"
 
-static PurpleProtocol *my_protocol = NULL;
 static GSList *cmds = NULL;
 
 static void yahoojp_register_commands(void)
@@ -136,53 +135,6 @@ yahoojp_protocol_interface_init(PurplePr
 	iface->can_receive_file         = NULL;
 }
 
-static PurplePluginInfo *
-plugin_query(GError **error)
-{
-	const gchar * const dependencies[] = {
-		"protocol-yahoo",
-		NULL
-	};
-
-	return purple_plugin_info_new(
-		"id",            "protocol-yahoojp",
-		"name",          "Yahoo JAPAN Protocol",
-		"version",       DISPLAY_VERSION,
-		"category",      N_("Protocol"),
-		"summary",       N_("Yahoo! JAPAN Protocol Plugin"),
-		"description",   N_("Yahoo! JAPAN Protocol Plugin"),
-		"website",       PURPLE_WEBSITE,
-		"abi-version",   PURPLE_ABI_VERSION,
-		"dependencies",  dependencies,
-		"flags",         PURPLE_PLUGIN_INFO_FLAGS_INTERNAL |
-		                 PURPLE_PLUGIN_INFO_FLAGS_AUTO_LOAD,
-		NULL
-	);
-}
-
-static gboolean
-plugin_load(PurplePlugin *plugin, GError **error)
-{
-	my_protocol = purple_protocols_add(YAHOOJP_TYPE_PROTOCOL, error);
-	if (!my_protocol)
-		return FALSE;
-
-	return TRUE;
-}
-
-static gboolean
-plugin_unload(PurplePlugin *plugin, GError **error)
-{
-	if (!purple_protocols_remove(my_protocol, error))
-		return FALSE;
-
-	return TRUE;
-}
-
-static PurplePlugin *my_plugin;
-
-PURPLE_PROTOCOL_DEFINE_EXTENDED(my_plugin, YahooJPProtocol, yahoojp_protocol,
-                                YAHOO_TYPE_PROTOCOL, 0);
-
-PURPLE_PLUGIN_INIT_VAL(my_plugin, yahoojp, plugin_query, plugin_load,
-                       plugin_unload);
+static PurplePlugin *_yahoo_plugin;
+PURPLE_PROTOCOL_DEFINE_EXTENDED(_yahoo_plugin, YahooJPProtocol,
+                                yahoojp_protocol, YAHOO_TYPE_PROTOCOL, 0);
diff --git a/libpurple/protocols/yahoo/ycht.c b/libpurple/protocols/yahoo/ycht.c
--- a/libpurple/protocols/yahoo/ycht.c
+++ b/libpurple/protocols/yahoo/ycht.c
@@ -34,7 +34,7 @@
 #include "conversation.h"
 #include "util.h"
 
-#include "libymsg.h"
+#include "ymsg.h"
 #include "yahoo_packet.h"
 #include "ycht.h"
 #include "yahoochat.h"
diff --git a/libpurple/protocols/yahoo/ymsg.c b/libpurple/protocols/yahoo/ymsg.c
--- a/libpurple/protocols/yahoo/ymsg.c
+++ b/libpurple/protocols/yahoo/ymsg.c



More information about the Commits mailing list