comparison 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
comparison
equal deleted inserted replaced
25647:969c89c09ad7 25648:050052891c55
185 185
186 static void jabber_oob_xfer_recv_canceled(PurpleXfer *xfer) { 186 static void jabber_oob_xfer_recv_canceled(PurpleXfer *xfer) {
187 jabber_oob_xfer_recv_error(xfer, "404"); 187 jabber_oob_xfer_recv_error(xfer, "404");
188 } 188 }
189 189
190 void jabber_oob_parse(JabberStream *js, xmlnode *packet) { 190 void jabber_oob_parse(JabberStream *js, const char *from, JabberIqType type,
191 const char *id, xmlnode *querynode) {
191 JabberOOBXfer *jox; 192 JabberOOBXfer *jox;
192 PurpleXfer *xfer; 193 PurpleXfer *xfer;
193 char *filename; 194 char *filename;
194 char *url; 195 char *url;
195 const char *type; 196 xmlnode *urlnode;
196 xmlnode *querynode, *urlnode; 197
197 198 if(type != JABBER_IQ_SET)
198 if(!(type = xmlnode_get_attrib(packet, "type")) || strcmp(type, "set")) 199 return;
199 return; 200
200 201 if(!querynode)
201 if(!(querynode = xmlnode_get_child(packet, "query")))
202 return; 202 return;
203 203
204 if(!(urlnode = xmlnode_get_child(querynode, "url"))) 204 if(!(urlnode = xmlnode_get_child(querynode, "url")))
205 return; 205 return;
206 206
209 jox = g_new0(JabberOOBXfer, 1); 209 jox = g_new0(JabberOOBXfer, 1);
210 purple_url_parse(url, &jox->address, &jox->port, &jox->page, NULL, NULL); 210 purple_url_parse(url, &jox->address, &jox->port, &jox->page, NULL, NULL);
211 g_free(url); 211 g_free(url);
212 jox->js = js; 212 jox->js = js;
213 jox->headers = g_string_new(""); 213 jox->headers = g_string_new("");
214 jox->iq_id = g_strdup(xmlnode_get_attrib(packet, "id")); 214 jox->iq_id = g_strdup(id);
215 215
216 xfer = purple_xfer_new(js->gc->account, PURPLE_XFER_RECEIVE, 216 xfer = purple_xfer_new(js->gc->account, PURPLE_XFER_RECEIVE, from);
217 xmlnode_get_attrib(packet, "from"));
218 if (xfer) 217 if (xfer)
219 { 218 {
220 xfer->data = jox; 219 xfer->data = jox;
221 220
222 if(!(filename = g_strdup(g_strrstr(jox->page, "/")))) 221 if(!(filename = g_strdup(g_strrstr(jox->page, "/"))))