changeset 30242:93f6a5d48a46

Updated to use new BoB request functionallity
author Marcus Lundblad <ml@update.uu.se>
date Sun, 21 Mar 2010 20:57:29 +0000
parents d6af24bcf107
children f14cbb6a28a7
files libpurple/protocols/jabber/si.c
diffstat 1 files changed, 10 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/jabber/si.c	Sun Mar 21 20:54:57 2010 +0000
+++ b/libpurple/protocols/jabber/si.c	Sun Mar 21 20:57:29 2010 +0000
@@ -1663,27 +1663,17 @@
 }
 
 static void
-jabber_si_thumbnail_cb(JabberStream *js, const char *from, JabberIqType type, 
-	const char *id, xmlnode *packet, gpointer data)
+jabber_si_thumbnail_cb(JabberData *data, gchar *alt, gpointer userdata)
 {
-	PurpleXfer *xfer = (PurpleXfer *) data;
-	xmlnode *data_element = xmlnode_get_child(packet, "data");
-	xmlnode *item_not_found = xmlnode_get_child(packet, "item-not-found");
-
-	if (data_element) {
-		JabberData *data = jabber_data_create_from_xml(data_element);
+	PurpleXfer *xfer = (PurpleXfer *) userdata;
 
-		if (data) {
-			purple_xfer_set_thumbnail(xfer, jabber_data_get_data(data),
-				jabber_data_get_size(data), jabber_data_get_type(data));
-			jabber_data_destroy(data);
-		}
-	} else if (item_not_found) {
-		purple_debug_info("jabber",
-			"Responder didn't recognize requested data\n");
-	} else {
-		purple_debug_error("jabber", "Unknown response to data request\n");
+	if (data) {
+		purple_xfer_set_thumbnail(xfer, jabber_data_get_data(data),
+			jabber_data_get_size(data), jabber_data_get_type(data));
+		/* data is ephemeral, get rid of now (the xfer re-owned the thumbnail */
+		jabber_data_destroy(data);
 	}
+
 	purple_xfer_request(xfer);
 }
 
@@ -1782,16 +1772,8 @@
 		NS_THUMBS))) {
 		const char *cid = xmlnode_get_attrib(thumbnail, "cid");
 		if (cid) {
-			JabberIq *request = 
-				jabber_iq_new(jsx->js, JABBER_IQ_GET);
-
-			purple_debug_info("jabber", "got file thumbnail, request it\n");
-			xmlnode_insert_child(request->node, 
-				jabber_data_get_xml_request(cid));
-			xmlnode_set_attrib(request->node, "to", 
-				purple_xfer_get_remote_user(xfer));
-			jabber_iq_set_callback(request, jabber_si_thumbnail_cb, xfer);
-			jabber_iq_send(request);
+			jabber_data_request(js, cid, purple_xfer_get_remote_user(xfer),
+			    NULL, TRUE, jabber_si_thumbnail_cb, xfer);
 		} else {
 			purple_xfer_request(xfer);
 		}