cpw.darkrain42.xmpp.iq-handlers: cb69e085: disapproval of revision '5224382f81d105b...

paul at darkrain42.org paul at darkrain42.org
Sun Feb 8 02:15:47 EST 2009


-----------------------------------------------------------------
Revision: cb69e0857b1d9058d5e043a9ff3f3876c98f96f2
Ancestor: 5224382f81d105bd5d72ac3e55cc95b894bb824e
Author: paul at darkrain42.org
Date: 2009-02-08T07:04:50
Branch: im.pidgin.cpw.darkrain42.xmpp.iq-handlers
URL: http://d.pidgin.im/viewmtn/revision/info/cb69e0857b1d9058d5e043a9ff3f3876c98f96f2

Modified files:
        libpurple/protocols/jabber/iq.c
        libpurple/protocols/jabber/iq.h

ChangeLog: 

disapproval of revision '5224382f81d105bd5d72ac3e55cc95b894bb824e'
-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/iq.c	f45b12d0f2ffe36f7fd9970fdb522b56a77a2cbb
+++ libpurple/protocols/jabber/iq.c	7e028635c104f444561b7832c84f535780a8c463
@@ -39,39 +39,9 @@
 #include "utsname.h"
 #endif
 
-struct _JabberIqHandlerKey
-{
-	char *node;
-	char *xmlns;
-};
-
-typedef struct _JabberIqHandlerKey JabberIqHandlerKey;
-
 GHashTable *iq_handlers = NULL;
 
-static guint iqhandler_hash(gconstpointer data)
-{
-	const JabberIqHandlerKey *key = data;
-	return g_str_hash(key->node) ^ g_str_hash(key->xmlns);
-}
 
-static gboolean iqhandler_equal(gconstpointer a, gconstpointer b)
-{
-	const JabberIqHandlerKey *key_a = a;
-	const JabberIqHandlerKey *key_b = b;
-
-	return (g_str_equal(key_a->node, key_b->node) &&
-	        g_str_equal(key_a->xmlns, key_b->xmlns));
-}
-
-static void iqhandler_destroy(gpointer data)
-{
-	JabberIqHandlerKey *key = data;
-	g_free(key->node);
-	g_free(key->xmlns);
-	g_free(key);
-}
-
 JabberIq *jabber_iq_new(JabberStream *js, JabberIqType type)
 {
 	JabberIq *iq;
@@ -386,11 +356,7 @@ void jabber_iq_parse(JabberStream *js, x
 
 	/* Apparently not, so lets see if we have a pre-defined handler */
 	if(child && (xmlns = xmlnode_get_namespace(child))) {
-		JabberIqHandlerKey key;
-		key.node  = child->name;
-		/* xmlns isn't being modified, I promise */
-		key.xmlns = (char *)xmlns;
-		if((jih = g_hash_table_lookup(iq_handlers, &key))) {
+		if((jih = g_hash_table_lookup(iq_handlers, xmlns))) {
 			jih(js, packet);
 			return;
 		}
@@ -417,35 +383,29 @@ void jabber_iq_parse(JabberStream *js, x
 	}
 }
 
-void jabber_iq_register_handler(const char *node, const char *xmlns,
-                                JabberIqHandler *handlerfunc)
+void jabber_iq_register_handler(const char *xmlns, JabberIqHandler *handlerfunc)
 {
-	JabberIqHandlerKey *key = g_new(JabberIqHandlerKey, 1);
-	key->node  = g_strdup(node);
-	key->xmlns = g_strdup(xmlns);
-	g_hash_table_replace(iq_handlers, key, handlerfunc);
+	g_hash_table_replace(iq_handlers, g_strdup(xmlns), handlerfunc);
 }
 
 void jabber_iq_init(void)
 {
-	iq_handlers = g_hash_table_new_full(iqhandler_hash, iqhandler_equal,
-	                                    iqhandler_destroy, NULL);
+	iq_handlers = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
 
-	jabber_iq_register_handler("mailbox", "google:mail:notify", jabber_gmail_poke);
-	jabber_iq_register_handler("new-mail", "google:mail:notify", jabber_gmail_poke);
-	jabber_iq_register_handler("query", "http://jabber.org/protocol/bytestreams", jabber_bytestreams_parse);
-	jabber_iq_register_handler("query", "http://jabber.org/protocol/disco#info", jabber_disco_info_parse);
-	jabber_iq_register_handler("query", "http://jabber.org/protocol/disco#items", jabber_disco_items_parse);
-	jabber_iq_register_handler("si", "http://jabber.org/protocol/si", jabber_si_parse);
-	jabber_iq_register_handler("query", "jabber:iq:last", jabber_iq_last_parse);
-	jabber_iq_register_handler("query", "jabber:iq:oob", jabber_oob_parse);
-	jabber_iq_register_handler("query", "jabber:iq:register", jabber_register_parse);
-	jabber_iq_register_handler("query", "jabber:iq:roster", jabber_roster_parse);
-	jabber_iq_register_handler("query", "jabber:iq:time", jabber_iq_time_parse);
-	jabber_iq_register_handler("query", "jabber:iq:version", jabber_iq_version_parse);
-	jabber_iq_register_handler("data", XEP_0231_NAMESPACE, jabber_data_parse);
-	jabber_iq_register_handler("ping", "urn:xmpp:ping", jabber_ping_parse);
-	jabber_iq_register_handler("time", "urn:xmpp:time", jabber_iq_time_parse);
+	jabber_iq_register_handler("google:mail:notify", jabber_gmail_poke);
+	jabber_iq_register_handler("http://jabber.org/protocol/bytestreams", jabber_bytestreams_parse);
+	jabber_iq_register_handler("http://jabber.org/protocol/disco#info", jabber_disco_info_parse);
+	jabber_iq_register_handler("http://jabber.org/protocol/disco#items", jabber_disco_items_parse);
+	jabber_iq_register_handler("http://jabber.org/protocol/si", jabber_si_parse);
+	jabber_iq_register_handler("jabber:iq:last", jabber_iq_last_parse);
+	jabber_iq_register_handler("jabber:iq:oob", jabber_oob_parse);
+	jabber_iq_register_handler("jabber:iq:register", jabber_register_parse);
+	jabber_iq_register_handler("jabber:iq:roster", jabber_roster_parse);
+	jabber_iq_register_handler("jabber:iq:time", jabber_iq_time_parse);
+	jabber_iq_register_handler("jabber:iq:version", jabber_iq_version_parse);
+	jabber_iq_register_handler(XEP_0231_NAMESPACE, jabber_data_parse);
+	jabber_iq_register_handler("urn:xmpp:ping", jabber_ping_parse);
+	jabber_iq_register_handler("urn:xmpp:time", jabber_iq_time_parse);
 }
 
 void jabber_iq_uninit(void)
============================================================
--- libpurple/protocols/jabber/iq.h	c61208d4b8c3f2b4ed63bfcd6494bacf120df348
+++ libpurple/protocols/jabber/iq.h	58832e9bb27a29629ff83afd7fb756badfe8a79c
@@ -65,7 +65,6 @@ void jabber_iq_uninit(void);
 void jabber_iq_init(void);
 void jabber_iq_uninit(void);
 
-void jabber_iq_register_handler(const char *node, const char *xmlns,
-                                JabberIqHandler *func);
+void jabber_iq_register_handler(const char *xmlns, JabberIqHandler *func);
 
 #endif /* _PURPLE_JABBER_IQ_H_ */


More information about the Commits mailing list