libpurple/protocols/jabber/xmpp.c

branch
soc.2013.gobjectification.plugins
changeset 36668
15719256474a
parent 36665
5bef44ba334a
child 36678
ed9d10d8e45a
--- a/libpurple/protocols/jabber/xmpp.c	Wed Sep 04 01:35:00 2013 +0530
+++ b/libpurple/protocols/jabber/xmpp.c	Wed Sep 04 02:04:54 2013 +0530
@@ -20,11 +20,6 @@
  *
  */
 
-/* libxmpp is the XMPP protocol plugin. It is linked against libjabbercommon,
- * which may be used to support other protocols (Bonjour) which may need to
- * share code.
- */
-
 #include "internal.h"
 #include "chat.h"
 #include "core.h"
@@ -32,72 +27,6 @@
 
 #include "xmpp.h"
 
-static PurpleProtocol *my_protocol = NULL;
-
-static PurpleAccount *find_acct(const char *protocol, const char *acct_id)
-{
-	PurpleAccount *acct = NULL;
-
-	/* If we have a specific acct, use it */
-	if (acct_id) {
-		acct = purple_accounts_find(acct_id, protocol);
-		if (acct && !purple_account_is_connected(acct))
-			acct = NULL;
-	} else { /* Otherwise find an active account for the protocol */
-		GList *l = purple_accounts_get_all();
-		while (l) {
-			if (!strcmp(protocol, purple_account_get_protocol_id(l->data))
-					&& purple_account_is_connected(l->data)) {
-				acct = l->data;
-				break;
-			}
-			l = l->next;
-		}
-	}
-
-	return acct;
-}
-
-static gboolean xmpp_uri_handler(const char *proto, const char *user, GHashTable *params)
-{
-	char *acct_id = params ? g_hash_table_lookup(params, "account") : NULL;
-	PurpleAccount *acct;
-
-	if (g_ascii_strcasecmp(proto, "xmpp"))
-		return FALSE;
-
-	acct = find_acct(purple_protocol_get_id(my_protocol), acct_id);
-
-	if (!acct)
-		return FALSE;
-
-	/* xmpp:romeo@montague.net?message;subject=Test%20Message;body=Here%27s%20a%20test%20message */
-	/* params is NULL if the URI has no '?' (or anything after it) */
-	if (!params || g_hash_table_lookup_extended(params, "message", NULL, NULL)) {
-		char *body = g_hash_table_lookup(params, "body");
-		if (user && *user) {
-			PurpleIMConversation *im =
-					purple_im_conversation_new(acct, user);
-			purple_conversation_present(PURPLE_CONVERSATION(im));
-			if (body && *body)
-				purple_conversation_send_confirm(PURPLE_CONVERSATION(im), body);
-		}
-	} else if (g_hash_table_lookup_extended(params, "roster", NULL, NULL)) {
-		char *name = g_hash_table_lookup(params, "name");
-		if (user && *user)
-			purple_blist_request_add_buddy(acct, user, NULL, name);
-	} else if (g_hash_table_lookup_extended(params, "join", NULL, NULL)) {
-		PurpleConnection *gc = purple_account_get_connection(acct);
-		if (user && *user) {
-			GHashTable *params = jabber_chat_info_defaults(gc, user);
-			jabber_chat_join(gc, params);
-		}
-		return TRUE;
-	}
-
-	return FALSE;
-}
-
 static void
 xmpp_protocol_base_init(XMPPProtocolClass *klass)
 {
@@ -177,52 +106,6 @@
 static void xmpp_protocol_base_finalize(XMPPProtocolClass *klass) { }
 static void xmpp_protocol_interface_init(PurpleProtocolInterface *iface) { }
 
-static PurplePluginInfo *
-plugin_query(GError **error)
-{
-	return purple_plugin_info_new(
-		"id",           "protocol-xmpp",
-		"name",         "XMPP Protocol",
-		"version",      DISPLAY_VERSION,
-		"category",     N_("Protocol"),
-		"summary",      N_("XMPP Protocol Plugin"),
-		"description",  N_("XMPP 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(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);
-
-	jabber_protocol_init(my_protocol);
-	return TRUE;
-}
-
-static gboolean
-plugin_unload(PurplePlugin *plugin, GError **error)
-{
-	jabber_protocol_uninit(my_protocol);
-	if (!purple_protocols_remove(my_protocol, error))
-		return FALSE;
-
-	return TRUE;
-}
-
 extern PurplePlugin *_jabber_plugin;
-
 PURPLE_PROTOCOL_DEFINE_EXTENDED(_jabber_plugin, XMPPProtocol, xmpp_protocol,
                                 JABBER_TYPE_PROTOCOL, 0);
-
-PURPLE_PLUGIN_INIT_VAL(_jabber_plugin, jabber, plugin_query, plugin_load,
-                       plugin_unload);

mercurial