changeset 30208:399756f65c88

propagate from branch 'im.pidgin.pidgin' (head 46ae10a850bb3c3ce9a3bb47a7de9edd4becdb93) to branch 'im.pidgin.cpw.malu.ft_thumbnails' (head e1429716d38c7e085c82406c5ed9d8feeeb3c7bb)
author Marcus Lundblad <ml@update.uu.se>
date Tue, 28 Jul 2009 20:51:56 +0000
parents 9e9849b56627 (current diff) 8b452039c329 (diff)
children 52cb819c6668
files libpurple/ft.c libpurple/protocols/jabber/message.c libpurple/protocols/jabber/si.c pidgin/gtkft.c pidgin/pixmaps/dialogs/64/scalable/auth.svg pidgin/pixmaps/dialogs/64/scalable/cool.svg pidgin/pixmaps/dialogs/64/scalable/dialog.svg pidgin/pixmaps/dialogs/64/scalable/error.svg pidgin/pixmaps/dialogs/64/scalable/info.svg pidgin/pixmaps/dialogs/64/scalable/mail.svg pidgin/pixmaps/dialogs/64/scalable/question.svg pidgin/pixmaps/dialogs/64/scalable/warning.svg pidgin/pixmaps/emblems/16/scalable/aol-client.svg pidgin/pixmaps/emblems/16/scalable/birthday.svg pidgin/pixmaps/emblems/16/scalable/blocked.svg pidgin/pixmaps/emblems/16/scalable/bot.svg pidgin/pixmaps/emblems/16/scalable/external.svg pidgin/pixmaps/emblems/16/scalable/female.svg pidgin/pixmaps/emblems/16/scalable/free-for-chat.svg pidgin/pixmaps/emblems/16/scalable/game.svg pidgin/pixmaps/emblems/16/scalable/male.svg pidgin/pixmaps/emblems/16/scalable/mobile.svg pidgin/pixmaps/emblems/16/scalable/music.svg pidgin/pixmaps/emblems/16/scalable/not-authorized.svg pidgin/pixmaps/emblems/16/scalable/qq-member.svg pidgin/pixmaps/emblems/16/scalable/secure.svg pidgin/pixmaps/emblems/16/scalable/unavailable.svg pidgin/pixmaps/emblems/16/scalable/video.svg pidgin/pixmaps/emblems/16/scalable/voice.svg pidgin/pixmaps/icons/hicolor/48x48/apps/scalable/pidgin.svg pidgin/pixmaps/protocols/48/scalable/aim.svg pidgin/pixmaps/protocols/48/scalable/bonjour.svg pidgin/pixmaps/protocols/48/scalable/gadu-gadu.svg pidgin/pixmaps/protocols/48/scalable/google-talk.svg pidgin/pixmaps/protocols/48/scalable/icq.svg pidgin/pixmaps/protocols/48/scalable/irc.svg pidgin/pixmaps/protocols/48/scalable/jabber.svg pidgin/pixmaps/protocols/48/scalable/meanwhile.svg pidgin/pixmaps/protocols/48/scalable/msn.svg pidgin/pixmaps/protocols/48/scalable/novell.svg pidgin/pixmaps/protocols/48/scalable/qq.svg pidgin/pixmaps/protocols/48/scalable/silc.svg pidgin/pixmaps/protocols/48/scalable/simple.svg pidgin/pixmaps/protocols/48/scalable/yahoo.svg pidgin/pixmaps/protocols/48/scalable/zephyr.svg
diffstat 10 files changed, 359 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/ft.c	Tue Jul 28 20:03:28 2009 +0000
+++ b/libpurple/ft.c	Tue Jul 28 20:51:56 2009 +0000
@@ -101,6 +101,7 @@
 	g_free(xfer->filename);
 	g_free(xfer->remote_ip);
 	g_free(xfer->local_filename);
+	g_free(xfer->thumbnail_data);
 
 	PURPLE_DBUS_UNREGISTER_POINTER(xfer);
 	g_free(xfer);
@@ -360,13 +361,20 @@
 			serv_got_im(purple_account_get_connection(xfer->account),
 								 xfer->who, xfer->message, 0, time(NULL));
 
-		purple_request_accept_cancel(xfer, NULL, buf, NULL,
-								  PURPLE_DEFAULT_ACTION_NONE,
-								  xfer->account, xfer->who, NULL,
-								  xfer,
-								  G_CALLBACK(purple_xfer_choose_file),
-								  G_CALLBACK(cancel_recv_cb));
-
+		if (purple_xfer_get_thumbnail_data(xfer)) {
+			purple_request_accept_cancel_with_icon(xfer, NULL, buf, NULL,
+				PURPLE_DEFAULT_ACTION_NONE, xfer->account, xfer->who, NULL,
+				purple_xfer_get_thumbnail_data(xfer),
+				purple_xfer_get_thumbnail_size(xfer), xfer, 
+				G_CALLBACK(purple_xfer_choose_file),
+				G_CALLBACK(cancel_recv_cb));
+		} else {
+			purple_request_accept_cancel(xfer, NULL, buf, NULL,
+				PURPLE_DEFAULT_ACTION_NONE, xfer->account, xfer->who, NULL,
+				xfer, G_CALLBACK(purple_xfer_choose_file),
+				G_CALLBACK(cancel_recv_cb));
+		}
+			
 		g_free(buf);
 	} else
 		purple_xfer_choose_file(xfer);
@@ -1307,6 +1315,35 @@
 		ui_ops->update_progress(xfer, purple_xfer_get_progress(xfer));
 }
 
+const void *
+purple_xfer_get_thumbnail_data(const PurpleXfer *xfer)
+{
+	return xfer->thumbnail_data;
+}
+
+gsize
+purple_xfer_get_thumbnail_size(const PurpleXfer *xfer)
+{
+	return xfer->thumbnail_size;
+}
+
+void
+purple_xfer_set_thumbnail(PurpleXfer *xfer, gconstpointer thumbnail,
+	gsize size)
+{
+	if (thumbnail && size > 0) {
+		xfer->thumbnail_data = g_memdup(thumbnail, size);
+		xfer->thumbnail_size = size;
+	}
+}
+
+void
+purple_xfer_prepare_thumbnail(PurpleXfer *xfer)
+{
+	if (xfer->ui_ops->add_thumbnail) {
+		xfer->ui_ops->add_thumbnail(xfer);
+	}
+}
 
 /**************************************************************************
  * File Transfer Subsystem API
--- a/libpurple/ft.h	Tue Jul 28 20:03:28 2009 +0000
+++ b/libpurple/ft.h	Tue Jul 28 20:51:56 2009 +0000
@@ -76,11 +76,11 @@
 	void (*update_progress)(PurpleXfer *xfer, double percent);
 	void (*cancel_local)(PurpleXfer *xfer);
 	void (*cancel_remote)(PurpleXfer *xfer);
+	void (*add_thumbnail)(PurpleXfer *xfer);
 
 	void (*_purple_reserved1)(void);
 	void (*_purple_reserved2)(void);
 	void (*_purple_reserved3)(void);
-	void (*_purple_reserved4)(void);
 } PurpleXferUiOps;
 
 /**
@@ -139,6 +139,9 @@
 	void *ui_data;                    /**< UI-specific data.       */
 
 	void *data;                       /**< prpl-specific data.     */
+
+	gpointer thumbnail_data;		/**< thumbnail image */
+	gsize thumbnail_size;
 };
 
 #ifdef __cplusplus
@@ -617,6 +620,41 @@
  */
 void purple_xfer_conversation_write(PurpleXfer *xfer, char *message, gboolean is_error);
 
+/**
+ * Gets the thumbnail data for a transfer
+ *
+ * @param xfer The file transfer to get the thumbnail for
+ * @return The thumbnail data, or NULL if there is no thumbnail
+ */
+const void *purple_xfer_get_thumbnail_data(const PurpleXfer *xfer);
+
+/**
+ * Gets the thumbnail size for a transfer
+ *
+ * @param xfer The file transfer to get the thumbnail size for
+ * @return The size, in bytes of the file transfer's thumbnail
+ */
+gsize purple_xfer_get_thumbnail_size(const PurpleXfer *xfer);
+
+
+/**
+ * Sets the thumbnail data for a transfer
+ *
+ * @param xfer The file transfer to set the data for
+ * @param thumbnail A pointer to the thumbnail data, this will be copied
+ * @param size The size in bytes of the passed in thumbnail data
+ */
+void purple_xfer_set_thumbnail(PurpleXfer *xfer, gconstpointer thumbnail,
+	gsize size);
+
+/**
+ * Prepare a thumbnail for a transfer (if the UI supports it)
+ * will be no-op in case the UI doesn't implement thumbnail creation
+ *
+ * @param xfer The file transfer to create a thumbnail for
+ */
+void purple_xfer_prepare_thumbnail(PurpleXfer *xfer);
+
 /*@}*/
 
 /**************************************************************************/
--- a/libpurple/protocols/jabber/data.c	Tue Jul 28 20:03:28 2009 +0000
+++ b/libpurple/protocols/jabber/data.c	Tue Jul 28 20:51:56 2009 +0000
@@ -31,7 +31,7 @@
 
 JabberData *
 jabber_data_create_from_data(gconstpointer rawdata, gsize size, const char *type,
-	JabberStream *js)
+	gboolean ephemeral, JabberStream *js)
 {
 	JabberData *data = g_new0(JabberData, 1);
 	gchar *checksum = purple_util_get_image_checksum(rawdata, size);
@@ -43,6 +43,7 @@
 	data->cid = g_strdup(cid);
 	data->type = g_strdup(type);
 	data->size = size;
+	data->ephemeral = ephemeral;
 
 	data->data = g_memdup(rawdata, size);
 
@@ -92,6 +93,12 @@
 	g_free(data);
 }
 
+void
+jabber_data_destroy(JabberData *data)
+{
+	jabber_data_delete(data);
+}
+
 const char *
 jabber_data_get_cid(const JabberData *data)
 {
@@ -161,21 +168,21 @@
 const JabberData *
 jabber_data_find_local_by_alt(const gchar *alt)
 {
-	purple_debug_info("jabber", "looking up local smiley with alt = %s\n", alt);
+	purple_debug_info("jabber", "looking up local data object with alt = %s\n", alt);
 	return g_hash_table_lookup(local_data_by_alt, alt);
 }
 
 const JabberData *
 jabber_data_find_local_by_cid(const gchar *cid)
 {
-	purple_debug_info("jabber", "lookup local smiley with cid = %s\n", cid);
+	purple_debug_info("jabber", "lookup local data object with cid = %s\n", cid);
 	return g_hash_table_lookup(local_data_by_cid, cid);
 }
 
 const JabberData *
 jabber_data_find_remote_by_cid(const gchar *cid)
 {
-	purple_debug_info("jabber", "lookup remote smiley with cid = %s\n", cid);
+	purple_debug_info("jabber", "lookup remote data object with cid = %s\n", cid);
 
 	return g_hash_table_lookup(remote_data_by_cid, cid);
 }
@@ -183,9 +190,10 @@
 void
 jabber_data_associate_local(JabberData *data, const gchar *alt)
 {
-	purple_debug_info("jabber", "associating local smiley\n alt = %s, cid = %s\n",
-		alt, jabber_data_get_cid(data));
-	g_hash_table_insert(local_data_by_alt, g_strdup(alt), data);
+	purple_debug_info("jabber", "associating local data object\n alt = %s, cid = %s\n",
+		alt , jabber_data_get_cid(data));
+	if (alt)
+		g_hash_table_insert(local_data_by_alt, g_strdup(alt), data);
 	g_hash_table_insert(local_data_by_cid, g_strdup(jabber_data_get_cid(data)),
 		data);
 }
@@ -193,7 +201,7 @@
 void
 jabber_data_associate_remote(JabberData *data)
 {
-	purple_debug_info("jabber", "associating remote smiley, cid = %s\n",
+	purple_debug_info("jabber", "associating remote data object, cid = %s\n",
 		jabber_data_get_cid(data));
 	g_hash_table_insert(remote_data_by_cid, g_strdup(jabber_data_get_cid(data)),
 		data);
@@ -222,6 +230,11 @@
 		xmlnode_set_attrib(result->node, "id", id);
 		xmlnode_insert_child(result->node,
 							 jabber_data_get_xml_definition(data));
+		/* if the data object is temporary, destroy it and remove the references
+		 to it */
+		if (data->ephemeral) {
+			g_hash_table_remove(local_data_by_cid, cid);
+		}
 	}
 	jabber_iq_send(result);
 }
--- a/libpurple/protocols/jabber/data.h	Tue Jul 28 20:03:28 2009 +0000
+++ b/libpurple/protocols/jabber/data.h	Tue Jul 28 20:51:56 2009 +0000
@@ -29,16 +29,21 @@
 	char *type;
 	gsize size;
 	gpointer data;
+	gboolean ephemeral;
 } JabberData;
 
 /* creates a JabberData instance from raw data */
 JabberData *jabber_data_create_from_data(gconstpointer data, gsize size,
-										 const char *type, JabberStream *js);
+	const char *type, gboolean ephemeral, JabberStream *js);
 
 /* create a JabberData instance from an XML "data" element (as defined by
   XEP 0231 */
 JabberData *jabber_data_create_from_xml(xmlnode *tag);
 
+/* destroy a JabberData instance, NOT to be used on data that has been
+	associated, since they get "owned" */
+void jabber_data_destroy(JabberData *data);
+
 const char *jabber_data_get_cid(const JabberData *data);
 const char *jabber_data_get_type(const JabberData *data);
 
--- a/libpurple/protocols/jabber/message.c	Tue Jul 28 20:03:28 2009 +0000
+++ b/libpurple/protocols/jabber/message.c	Tue Jul 28 20:51:56 2009 +0000
@@ -981,7 +981,7 @@
 					JabberData *new_data =
 						jabber_data_create_from_data(purple_imgstore_get_data(image),
 							purple_imgstore_get_size(image),
-							jabber_message_get_mimetype_from_ext(ext), js);
+							jabber_message_get_mimetype_from_ext(ext), FALSE, js);
 					purple_debug_info("jabber",
 						"cache local smiley alt = %s, cid = %s\n",
 						shortcut, jabber_data_get_cid(new_data));
--- a/libpurple/protocols/jabber/si.c	Tue Jul 28 20:03:28 2009 +0000
+++ b/libpurple/protocols/jabber/si.c	Tue Jul 28 20:51:56 2009 +0000
@@ -30,6 +30,7 @@
 #include "notify.h"
 
 #include "buddy.h"
+#include "data.h"
 #include "disco.h"
 #include "jabber.h"
 #include "ibb.h"
@@ -1260,7 +1261,8 @@
 	char buf[32];
 
 	xfer->filename = g_path_get_basename(xfer->local_filename);
-
+	purple_xfer_prepare_thumbnail(xfer);
+	
 	iq = jabber_iq_new(jsx->js, JABBER_IQ_SET);
 	xmlnode_set_attrib(iq->node, "to", xfer->who);
 	si = xmlnode_new_child(iq->node, "si");
@@ -1278,6 +1280,21 @@
 	xmlnode_set_attrib(file, "size", buf);
 	/* maybe later we'll do hash and date attribs */
 
+	/* add thumbnail, if appropriate */
+	if (purple_xfer_get_thumbnail_data(xfer)) {
+		JabberData *thumbnail_data = 
+			jabber_data_create_from_data(purple_xfer_get_thumbnail_data(xfer),
+				purple_xfer_get_thumbnail_size(xfer), "image/jpeg", TRUE,
+				jsx->js);
+		xmlnode *thumbnail = xmlnode_new_child(file, "thumbnail");
+		xmlnode_set_namespace(thumbnail, "urn:xmpp:thumbs:0");
+		xmlnode_set_attrib(thumbnail, "cid", 
+			jabber_data_get_cid(thumbnail_data));
+		xmlnode_set_attrib(thumbnail, "mime-type", "image/jpeg");
+		/* cache data */
+		jabber_data_associate_local(thumbnail_data, NULL);
+	}
+						  
 	feature = xmlnode_new_child(si, "feature");
 	xmlnode_set_namespace(feature, "http://jabber.org/protocol/feature-neg");
 	x = xmlnode_new_child(feature, "x");
@@ -1659,12 +1676,37 @@
 		purple_xfer_request(xfer);
 }
 
+static void
+jabber_si_thumbnail_cb(JabberStream *js, const char *from, JabberIqType type, 
+	const char *id, xmlnode *packet, gpointer data)
+{
+	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);
+
+		if (data) {
+			purple_xfer_set_thumbnail(xfer, jabber_data_get_data(data),
+				jabber_data_get_size(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");
+	}
+	purple_xfer_request(xfer);
+}
+
 void jabber_si_parse(JabberStream *js, const char *from, JabberIqType type,
                      const char *id, xmlnode *si)
 {
 	JabberSIXfer *jsx;
 	PurpleXfer *xfer;
-	xmlnode *file, *feature, *x, *field, *option, *value;
+	xmlnode *file, *feature, *x, *field, *option, *value, *thumbnail;
 	const char *stream_id, *filename, *filesize_c, *profile;
 	size_t filesize = 0;
 
@@ -1746,10 +1788,29 @@
 	purple_xfer_set_request_denied_fnc(xfer, jabber_si_xfer_request_denied);
 	purple_xfer_set_cancel_recv_fnc(xfer, jabber_si_xfer_cancel_recv);
 	purple_xfer_set_end_fnc(xfer, jabber_si_xfer_end);
-
+				   
 	js->file_transfers = g_list_append(js->file_transfers, xfer);
 
-	purple_xfer_request(xfer);
+	/* if there is a thumbnail, we should request it... */
+	if ((thumbnail = xmlnode_get_child(file, "thumbnail"))) {
+		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);
+		} else {
+			purple_xfer_request(xfer);
+		}
+	} else {
+		purple_xfer_request(xfer);
+	}
 }
 
 void
--- a/libpurple/request.c	Tue Jul 28 20:03:28 2009 +0000
+++ b/libpurple/request.c	Tue Jul 28 20:51:56 2009 +0000
@@ -1281,6 +1281,29 @@
 }
 
 void *
+purple_request_action_with_icon(void *handle, const char *title, 
+					const char *primary,
+					const char *secondary, int default_action,
+					PurpleAccount *account, const char *who, 
+					PurpleConversation *conv, gconstpointer icon_data,
+					gsize icon_size, void *user_data, size_t action_count, ...)
+{
+	void *ui_handle;
+	va_list args;
+
+	g_return_val_if_fail(action_count > 0, NULL);
+
+	va_start(args, action_count);
+	ui_handle = purple_request_action_varg_with_icon(handle, title, primary, 
+		secondary, default_action, account, who, conv, icon_data, icon_size,
+		user_data, action_count, args);
+	va_end(args);
+
+	return ui_handle;
+}
+
+
+void *
 purple_request_action_varg(void *handle, const char *title,
 						 const char *primary, const char *secondary,
 						 int default_action,
@@ -1312,6 +1335,41 @@
 }
 
 void *
+purple_request_action_varg_with_icon(void *handle, const char *title,
+						 const char *primary, const char *secondary,
+						 int default_action,
+						 PurpleAccount *account, const char *who, 
+						 PurpleConversation *conv, gconstpointer icon_data,
+						 gsize icon_size,
+						 void *user_data, size_t action_count, va_list actions)
+{
+	PurpleRequestUiOps *ops;
+
+	g_return_val_if_fail(action_count > 0, NULL);
+
+	ops = purple_request_get_ui_ops();
+
+	if (ops != NULL && ops->request_action != NULL) {
+		PurpleRequestInfo *info;
+
+		info            = g_new0(PurpleRequestInfo, 1);
+		info->type      = PURPLE_REQUEST_ACTION;
+		info->handle    = handle;
+		info->ui_handle = ops->request_action_with_icon(title, primary, secondary,
+											  default_action, account, who, conv,
+											  icon_data, icon_size,
+											  user_data, action_count, actions);
+
+		handles = g_list_append(handles, info);
+
+		return info->ui_handle;
+	}
+
+	return NULL;
+}
+
+
+void *
 purple_request_fields(void *handle, const char *title, const char *primary,
 					const char *secondary, PurpleRequestFields *fields,
 					const char *ok_text, GCallback ok_cb,
--- a/libpurple/request.h	Tue Jul 28 20:03:28 2009 +0000
+++ b/libpurple/request.h	Tue Jul 28 20:51:56 2009 +0000
@@ -236,10 +236,18 @@
 	                        PurpleAccount *account, const char *who,
 	                        PurpleConversation *conv, void *user_data);
 
+	/** @see purple_request_action_varg_with_icon(). */
+	void *(*request_action_with_icon)(const char *title, const char *primary,
+	                        const char *secondary, int default_action,
+	                        PurpleAccount *account, const char *who,
+	                        PurpleConversation *conv, 
+							gconstpointer icon_data, gsize icon_size,
+							void *user_data,
+	                        size_t action_count, va_list actions);
+
 	void (*_purple_reserved1)(void);
 	void (*_purple_reserved2)(void);
 	void (*_purple_reserved3)(void);
-	void (*_purple_reserved4)(void);
 } PurpleRequestUiOps;
 
 typedef void (*PurpleRequestInputCb)(void *, const char *);
@@ -1367,6 +1375,27 @@
 	void *user_data, size_t action_count, va_list actions);
 
 /**
+ * Version of purple_request_action() supplying an image for the UI to 
+ * optionally display as an icon in the dialog; see its documentation
+ */
+void *purple_request_action_with_icon(void *handle, const char *title, 
+	const char *primary, const char *secondary, int default_action, 
+	PurpleAccount *account, const char *who, PurpleConversation *conv, 
+	gconstpointer icon_data, gsize icon_size, void *user_data, 
+	size_t action_count, ...);
+
+/**
+ * <tt>va_list</tt> version of purple_request_action_with_icon(); 
+ * see its documentation.
+ */
+void *purple_request_action_varg_with_icon(void *handle, const char *title,
+	const char *primary, const char *secondary, int default_action,
+	PurpleAccount *account, const char *who, PurpleConversation *conv,
+	gconstpointer icon_data, gsize icon_size,
+	void *user_data, size_t action_count, va_list actions);
+
+
+/**
  * Displays groups of fields for the user to fill in.
  *
  * @param handle      The plugin or connection handle.  For some things this
@@ -1451,6 +1480,19 @@
 						_("_Accept"), (accept_cb), _("_Cancel"), (cancel_cb))
 
 /**
+ * A wrapper for purple_request_action_with_icon() that uses Accept and Cancel 
+ * buttons.
+ */
+#define purple_request_accept_cancel_with_icon(handle, title, primary, secondary, \
+								   default_action, account, who, conv, \
+								   icon_data, icon_size, \
+								   user_data, accept_cb, cancel_cb) \
+	purple_request_action_with_icon((handle), (title), (primary), (secondary), \
+						(default_action), account, who, conv, icon_data, icon_size, \
+						(user_data), 2, \
+						_("_Accept"), (accept_cb), _("_Cancel"), (cancel_cb))
+
+/**
  * Displays a file selector request dialog.  Returns the selected filename to
  * the callback.  Can be used for either opening a file or saving a file.
  *
--- a/pidgin/gtkft.c	Tue Jul 28 20:03:28 2009 +0000
+++ b/pidgin/gtkft.c	Tue Jul 28 20:51:56 2009 +0000
@@ -42,6 +42,9 @@
 #define PIDGINXFER(xfer) \
 	(PidginXferUiData *)(xfer)->ui_data
 
+/* the maximum size of files we will try to make a thumbnail for */
+#define PIDGIN_XFER_MAX_SIZE_IMAGE_THUMBNAIL 10 * 1024 * 1024
+
 struct _PidginXferDialog
 {
 	gboolean keep_open;
@@ -1150,6 +1153,49 @@
 		pidgin_xfer_dialog_cancel_xfer(xfer_dialog, xfer);
 }
 
+static void
+pidgin_xfer_add_thumbnail(PurpleXfer *xfer)
+{
+	purple_debug_info("pidgin", "creating thumbnail for transfer\n");
+
+	if (purple_xfer_get_size(xfer) <= PIDGIN_XFER_MAX_SIZE_IMAGE_THUMBNAIL) {
+#if GTK_CHECK_VERSION(2, 4, 0)
+		GdkPixbuf *thumbnail = 
+			gdk_pixbuf_new_from_file_at_size(
+				purple_xfer_get_local_filename(xfer), 128, 128, NULL);
+#else
+		GdkPixbuf *full_size =
+			gdk_pixbuf_from_file(purple_xfer_get_local_filename(xfer), NULL);
+		GdkPixbuf *thumbnail = NULL;
+		
+		if (full_size) {
+			thumbnail = gdk_pixbuf_scale_simple(full_size, 128, 128, 
+				GDK_INTERP_BILINEAR);
+			g_object_unref(full_size);
+		}
+#endif
+		if (thumbnail) {
+			gpointer *buffer = NULL;
+			gsize size;
+#if GTK_CHECK_VERSION(2, 4, 0)
+			char *option_keys[2] = {"quality", NULL};
+			char *option_values[2] = {"75", NULL};
+			gdk_pixbuf_save_to_bufferv(thumbnail, &buffer, &size, "jpeg", 
+				option_keys, option_values, NULL);
+#else
+			/* TODO: */
+#endif
+			if (buffer) {
+				purple_debug_info("pidgin", "created thumbnail of %d bytes\n",
+					size);
+				purple_xfer_set_thumbnail(xfer, buffer, size);
+				g_free(buffer);
+			}
+			g_object_unref(thumbnail);
+		}
+	}
+}
+
 static PurpleXferUiOps ops =
 {
 	pidgin_xfer_new_xfer,
@@ -1158,7 +1204,7 @@
 	pidgin_xfer_update_progress,
 	pidgin_xfer_cancel_local,
 	pidgin_xfer_cancel_remote,
-	NULL,
+	pidgin_xfer_add_thumbnail,
 	NULL,
 	NULL,
 	NULL
--- a/pidgin/gtkrequest.c	Tue Jul 28 20:03:28 2009 +0000
+++ b/pidgin/gtkrequest.c	Tue Jul 28 20:51:56 2009 +0000
@@ -26,6 +26,7 @@
 #include "internal.h"
 #include "pidgin.h"
 
+#include "debug.h"
 #include "prefs.h"
 #include "util.h"
 
@@ -561,9 +562,11 @@
 }
 
 static void *
-pidgin_request_action(const char *title, const char *primary,
+pidgin_request_action_with_icon(const char *title, const char *primary,
 						const char *secondary, int default_action,
-					    PurpleAccount *account, const char *who, PurpleConversation *conv,
+					    PurpleAccount *account, const char *who, 
+						PurpleConversation *conv, gconstpointer icon_data,
+						gsize icon_size,
 						void *user_data, size_t action_count, va_list actions)
 {
 	PidginRequestData *data;
@@ -571,7 +574,7 @@
 	GtkWidget *vbox;
 	GtkWidget *hbox;
 	GtkWidget *label;
-	GtkWidget *img;
+	GtkWidget *img = NULL;
 	void **buttons;
 	char *label_text;
 	char *primary_esc, *secondary_esc;
@@ -630,8 +633,25 @@
 	gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), hbox);
 
 	/* Dialog icon. */
-	img = gtk_image_new_from_stock(PIDGIN_STOCK_DIALOG_QUESTION,
+	if (icon_data) {
+		GdkPixbufLoader *loader = gdk_pixbuf_loader_new();
+		GdkPixbuf *pixbuf = NULL;
+		if (gdk_pixbuf_loader_write(loader, icon_data, icon_size, NULL)) {
+			pixbuf = gdk_pixbuf_loader_get_pixbuf(loader);
+			if (pixbuf) {
+				img = gtk_image_new_from_pixbuf(pixbuf);
+			}
+		} else {
+			purple_debug_info("pidgin", "failed to parse dialog icon\n");
+		}
+		gdk_pixbuf_loader_close(loader, NULL);
+		g_object_unref(loader);
+	}
+	
+	if (!img) {
+		img = gtk_image_new_from_stock(PIDGIN_STOCK_DIALOG_QUESTION,
 				       gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_HUGE));
+	}
 	gtk_misc_set_alignment(GTK_MISC(img), 0, 0);
 	gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0);
 
@@ -681,6 +701,16 @@
 	return data;
 }
 
+static void *
+pidgin_request_action(const char *title, const char *primary,
+						const char *secondary, int default_action,
+					    PurpleAccount *account, const char *who, PurpleConversation *conv,
+						void *user_data, size_t action_count, va_list actions)
+{
+	pidgin_request_action_with_icon(title, primary, secondary, default_action,
+		account, who, conv, NULL, 0, user_data, action_count, actions);
+}
+
 static void
 req_entry_field_changed_cb(GtkWidget *entry, PurpleRequestField *field)
 {
@@ -1721,7 +1751,7 @@
 	pidgin_request_file,
 	pidgin_close_request,
 	pidgin_request_folder,
-	NULL,
+	pidgin_request_action_with_icon,
 	NULL,
 	NULL,
 	NULL