cpw.malu.xmpp.jingle_ft: bf9674b9: Merge fix the thumbnail stuff (should mo...

malu at pidgin.im malu at pidgin.im
Wed May 5 16:35:41 EDT 2010


-----------------------------------------------------------------
Revision: bf9674b90f1f22d137925ddd1be84c0f50e35b9b
Ancestor: 466f6483668f02023cfb524c2b65eb9df9639576
Author: malu at pidgin.im
Date: 2010-05-05T20:32:43
Branch: im.pidgin.cpw.malu.xmpp.jingle_ft
URL: http://d.pidgin.im/viewmtn/revision/info/bf9674b90f1f22d137925ddd1be84c0f50e35b9b

Modified files:
        libpurple/protocols/jabber/si.c

ChangeLog: 

Merge fix the thumbnail stuff (should move these things to xfer.c when enabling those for
Jingle FTs)

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/si.c	b8caf1a81f25f526f20b81f90ba1c75f6df4a3e8
+++ libpurple/protocols/jabber/si.c	98af413f9266ee51f37d001f8648e76dba2f3707
@@ -1268,6 +1268,23 @@ static void jabber_si_xfer_send_request(
 
 	xmlnode_insert_child(si, jabber_xfer_create_file_element(xfer));
 
+#if ENABLE_FT_THUMBNAILS
+	/* add thumbnail, if appropriate */
+	if ((thumb = purple_xfer_get_thumbnail(xfer, &thumb_size))) {
+		const gchar *mimetype = purple_xfer_get_thumbnail_mimetype(xfer);
+		JabberData *thumbnail_data =
+			jabber_data_create_from_data(thumb, thumb_size,
+				mimetype, TRUE, jsx->js);
+		xmlnode *thumbnail = xmlnode_new_child(file, "thumbnail");
+		xmlnode_set_namespace(thumbnail, NS_THUMBS);
+		xmlnode_set_attrib(thumbnail, "cid", 
+			jabber_data_get_cid(thumbnail_data));
+		xmlnode_set_attrib(thumbnail, "mime-type", mimetype);
+		/* cache data */
+		jabber_data_associate_local(thumbnail_data, NULL);
+	}
+#endif
+	    
 	feature = xmlnode_new_child(si, "feature");
 	xmlnode_set_namespace(feature, "http://jabber.org/protocol/feature-neg");
 	x = xmlnode_new_child(feature, "x");
@@ -1660,8 +1677,25 @@ void jabber_si_parse(JabberStream *js, c
 
 		js->file_transfers = g_list_append(js->file_transfers, xfer);
 
+#if ENABLE_FT_THUMBNAILS
+	/* if there is a thumbnail, we should request it... */
+	if ((thumbnail = xmlnode_get_child_with_namespace(file, "thumbnail",
+		NS_THUMBS))) {
+		const char *cid = xmlnode_get_attrib(thumbnail, "cid");
+		if (cid) {
+			jabber_data_request(js, cid, purple_xfer_get_remote_user(xfer),
+			    NULL, TRUE, jabber_si_thumbnail_cb, xfer);
+		} else {
+			purple_xfer_request(xfer);
+		}
+	} else {
 		purple_xfer_request(xfer);
 	}
+#else
+	thumbnail = NULL; /* Silence warning */
+	purple_xfer_request(xfer);
+#endif
+	}
 }
 
 void


More information about the Commits mailing list