diff libpurple/protocols/jabber/oob.c @ 25648:050052891c55

Pass IQ handlers type, from, id, and the child node As QuLogic pointed out in 8a80f271, it's pointless for the handlers to re-get the information from the IQ stanza. Additionally, instead of string-matching the type everywhere, pass around a JabberIqType. Last, 'child' cannot be NULL, but 'from' may be.
author Paul Aurich <paul@darkrain42.org>
date Sun, 08 Feb 2009 06:31:18 +0000
parents 44b4e8bd759b
children c8606917787a
line wrap: on
line diff
--- a/libpurple/protocols/jabber/oob.c	Sun Feb 08 04:30:23 2009 +0000
+++ b/libpurple/protocols/jabber/oob.c	Sun Feb 08 06:31:18 2009 +0000
@@ -187,18 +187,18 @@
 	jabber_oob_xfer_recv_error(xfer, "404");
 }
 
-void jabber_oob_parse(JabberStream *js, xmlnode *packet) {
+void jabber_oob_parse(JabberStream *js, const char *from, JabberIqType type,
+                      const char *id, xmlnode *querynode) {
 	JabberOOBXfer *jox;
 	PurpleXfer *xfer;
 	char *filename;
 	char *url;
-	const char *type;
-	xmlnode *querynode, *urlnode;
+	xmlnode *urlnode;
 
-	if(!(type = xmlnode_get_attrib(packet, "type")) || strcmp(type, "set"))
+	if(type != JABBER_IQ_SET)
 		return;
 
-	if(!(querynode = xmlnode_get_child(packet, "query")))
+	if(!querynode)
 		return;
 
 	if(!(urlnode = xmlnode_get_child(querynode, "url")))
@@ -211,10 +211,9 @@
 	g_free(url);
 	jox->js = js;
 	jox->headers = g_string_new("");
-	jox->iq_id = g_strdup(xmlnode_get_attrib(packet, "id"));
+	jox->iq_id = g_strdup(id);
 
-	xfer = purple_xfer_new(js->gc->account, PURPLE_XFER_RECEIVE,
-			xmlnode_get_attrib(packet, "from"));
+	xfer = purple_xfer_new(js->gc->account, PURPLE_XFER_RECEIVE, from);
 	if (xfer)
 	{
 		xfer->data = jox;