/soc/2013/ankitkv/gobjectification: e6fa1bd96d43: Add/remove AIM...

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


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

Description:

Add/remove AIMProtocol, ICQProtocol via the single oscar plugin

diffstat:

 libpurple/protocols/oscar/aim.c   |  50 -------------------------------
 libpurple/protocols/oscar/icq.c   |  60 +-------------------------------------
 libpurple/protocols/oscar/oscar.c |  61 +++++++++++++++++++++++++++++++++++++-
 3 files changed, 61 insertions(+), 110 deletions(-)

diffs (237 lines):

diff --git a/libpurple/protocols/oscar/aim.c b/libpurple/protocols/oscar/aim.c
--- a/libpurple/protocols/oscar/aim.c
+++ b/libpurple/protocols/oscar/aim.c
@@ -20,10 +20,6 @@
  *
  */
 
-/* libaim is the AIM protocol plugin. It is linked against liboscar,
- * which contains all the shared implementation code with libicq
- */
-
 #include "aim.h"
 
 #include "core.h"
@@ -32,8 +28,6 @@
 
 #include "oscarcommon.h"
 
-static PurpleProtocol *my_protocol = NULL;
-
 static void
 aim_protocol_base_init(AIMProtocolClass *klass)
 {
@@ -65,50 +59,6 @@ aim_protocol_interface_init(PurpleProtoc
 
 static void aim_protocol_base_finalize(AIMProtocolClass *klass) { }
 
-static PurplePluginInfo *
-plugin_query(GError **error)
-{
-	return purple_plugin_info_new(
-		"id",           "protocol-aim",
-		"name",         "AIM Protocol",
-		"version",      DISPLAY_VERSION,
-		"category",     N_("Protocol"),
-		"summary",      N_("AIM Protocol Plugin"),
-		"description",  N_("AIM Protocol Plugin"),
-		"website",      PURPLE_WEBSITE,
-		"abi-version",  PURPLE_ABI_VERSION,
-		"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(AIM_TYPE_PROTOCOL, error);
-	if (!my_protocol)
-		return FALSE;
-
-	purple_signal_connect(purple_get_core(), "uri-handler", my_protocol,
-		PURPLE_CALLBACK(oscar_uri_handler), NULL);
-
-	return TRUE;
-}
-
-static gboolean
-plugin_unload(PurplePlugin *plugin, GError **error)
-{
-	if (!purple_protocols_remove(my_protocol, error))
-		return FALSE;
-
-	return TRUE;
-}
-
 extern PurplePlugin *_oscar_plugin;
-
 PURPLE_PROTOCOL_DEFINE_EXTENDED(_oscar_plugin, AIMProtocol, aim_protocol,
                                 OSCAR_TYPE_PROTOCOL, 0);
-
-PURPLE_PLUGIN_INIT_VAL(_oscar_plugin, aim, plugin_query, plugin_load,
-                       plugin_unload);
diff --git a/libpurple/protocols/oscar/icq.c b/libpurple/protocols/oscar/icq.c
--- a/libpurple/protocols/oscar/icq.c
+++ b/libpurple/protocols/oscar/icq.c
@@ -20,10 +20,6 @@
  *
  */
 
-/* libicq is the ICQ protocol plugin. It is linked against liboscar,
- * which contains all the shared implementation code with libaim
- */
-
 #include "icq.h"
 
 #include "core.h"
@@ -32,8 +28,6 @@
 
 #include "oscarcommon.h"
 
-static PurpleProtocol *my_protocol = NULL;
-
 static GHashTable *
 icq_get_account_text_table(PurpleAccount *account)
 {
@@ -79,56 +73,6 @@ icq_protocol_interface_init(PurpleProtoc
 
 static void icq_protocol_base_finalize(ICQProtocolClass *klass) { }
 
-static PurplePluginInfo *
-plugin_query(GError **error)
-{
-	const gchar * const dependencies[] = {
-		"protocol-aim",
-		NULL
-	};
-
-	return purple_plugin_info_new(
-		"id",            "protocol-icq",
-		"name",          "ICQ Protocol",
-		"version",       DISPLAY_VERSION,
-		"category",      N_("Protocol"),
-		"summary",       N_("ICQ Protocol Plugin"),
-		"description",   N_("ICQ 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(ICQ_TYPE_PROTOCOL, error);
-	if (!my_protocol)
-		return FALSE;
-
-	purple_signal_connect(purple_get_core(), "uri-handler", my_protocol,
-		PURPLE_CALLBACK(oscar_uri_handler), NULL);
-
-	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, ICQProtocol, icq_protocol,
+extern PurplePlugin *_oscar_plugin;
+PURPLE_PROTOCOL_DEFINE_EXTENDED(_oscar_plugin, ICQProtocol, icq_protocol,
                                 OSCAR_TYPE_PROTOCOL, 0);
-
-PURPLE_PLUGIN_INIT_VAL(my_plugin, icq, plugin_query, plugin_load,
-                       plugin_unload);
diff --git a/libpurple/protocols/oscar/oscar.c b/libpurple/protocols/oscar/oscar.c
--- a/libpurple/protocols/oscar/oscar.c
+++ b/libpurple/protocols/oscar/oscar.c
@@ -48,10 +48,17 @@
 #include "version.h"
 #include "visibility.h"
 
+#include "aim.h"
+#include "icq.h"
 #include "oscarcommon.h"
 #include "oscar.h"
 #include "peer.h"
 
+PurplePlugin *_oscar_plugin = NULL;
+
+static PurpleProtocol *aim_protocol = NULL;
+static PurpleProtocol *icq_protocol = NULL;
+
 static guint64 purple_caps =
 	OSCAR_CAPABILITY_CHAT
 		| OSCAR_CAPABILITY_BUDDYICON
@@ -5638,7 +5645,57 @@ oscar_protocol_interface_init(PurpleProt
 
 static void oscar_protocol_base_finalize(OscarProtocolClass *klass) { }
 
-PurplePlugin *_oscar_plugin = NULL;
-
 PURPLE_PROTOCOL_DEFINE_EXTENDED(_oscar_plugin, OscarProtocol, oscar_protocol,
                                 PURPLE_TYPE_PROTOCOL, G_TYPE_FLAG_ABSTRACT);
+
+static PurplePluginInfo *
+plugin_query(GError **error)
+{
+	return purple_plugin_info_new(
+		"id",           "protocol-oscar",
+		"name",         "Oscar Protocols",
+		"version",      DISPLAY_VERSION,
+		"category",     N_("Protocol"),
+		"summary",      N_("Oscar (AIM/ICQ) Protocols Plugin"),
+		"description",  N_("Oscar (AIM/ICQ) Protocols Plugin"),
+		"website",      PURPLE_WEBSITE,
+		"abi-version",  PURPLE_ABI_VERSION,
+		"flags",        PURPLE_PLUGIN_INFO_FLAGS_INTERNAL |
+		                PURPLE_PLUGIN_INFO_FLAGS_AUTO_LOAD,
+		NULL
+	);
+}
+
+static gboolean
+plugin_load(PurplePlugin *plugin, GError **error)
+{
+	aim_protocol = purple_protocols_add(AIM_TYPE_PROTOCOL, error);
+	if (!aim_protocol)
+		return FALSE;
+
+	icq_protocol = purple_protocols_add(ICQ_TYPE_PROTOCOL, error);
+	if (!icq_protocol)
+		return FALSE;
+
+	purple_signal_connect(purple_get_core(), "uri-handler", aim_protocol,
+		PURPLE_CALLBACK(oscar_uri_handler), NULL);
+	purple_signal_connect(purple_get_core(), "uri-handler", icq_protocol,
+		PURPLE_CALLBACK(oscar_uri_handler), NULL);
+
+	return TRUE;
+}
+
+static gboolean
+plugin_unload(PurplePlugin *plugin, GError **error)
+{
+	if (!purple_protocols_remove(icq_protocol, error))
+		return FALSE;
+
+	if (!purple_protocols_remove(aim_protocol, error))
+		return FALSE;
+
+	return TRUE;
+}
+
+PURPLE_PLUGIN_INIT_VAL(_oscar_plugin, oscar, plugin_query, plugin_load,
+                       plugin_unload);



More information about the Commits mailing list