diff pidgin/gtkft.c @ 30238:79bb2804a19e

Set desired image formats for thumbnails as a parameter to purple_xfer_prepare_thumbnail instead of putting it in PrplInfo
author Marcus Lundblad <ml@update.uu.se>
date Tue, 16 Mar 2010 23:14:54 +0000
parents 25a53c299713
children 0bc8e250ae0d
line wrap: on
line diff
--- a/pidgin/gtkft.c	Mon Mar 15 21:49:02 2010 +0000
+++ b/pidgin/gtkft.c	Tue Mar 16 23:14:54 2010 +0000
@@ -1161,23 +1161,17 @@
 }
 
 static void
-pidgin_xfer_add_thumbnail(PurpleXfer *xfer)
-{
-	PurpleAccount *account = purple_xfer_get_account(xfer);
-	PurpleConnection *gc = purple_account_get_connection(account);
-	PurplePluginProtocolInfo *prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl);
-	const char *thumbnail_format = prpl_info->thumbnail_spec.format;
-	
+pidgin_xfer_add_thumbnail(PurpleXfer *xfer, const gchar *formats)
+{	
 	purple_debug_info("pidgin", "creating thumbnail for transfer\n");
 
-	if (thumbnail_format != NULL &&
-	    purple_xfer_get_size(xfer) <= PIDGIN_XFER_MAX_SIZE_IMAGE_THUMBNAIL) {
+	if (purple_xfer_get_size(xfer) <= PIDGIN_XFER_MAX_SIZE_IMAGE_THUMBNAIL) {
 		GdkPixbuf *thumbnail = 
 			gdk_pixbuf_new_from_file_at_size(
 				purple_xfer_get_local_filename(xfer), 128, 128, NULL);
 
 		if (thumbnail) {
-			gchar **formats = g_strsplit(thumbnail_format, ",", 0);
+			gchar **formats_split = g_strsplit(formats, ",", 0);
 			gchar *buffer = NULL;
 			gsize size;
 			char *option_keys[2] = {NULL, NULL};
@@ -1187,10 +1181,10 @@
 			int i;
 			gchar *format = NULL;
 			
-			for (i = 0 ; formats[i] ; i++) {
-				if (purple_strequal(formats[i], "jpeg")) {
+			for (i = 0 ; formats_split[i] ; i++) {
+				if (purple_strequal(formats_split[i], "jpeg")) {
 					supports_jpeg = TRUE;
-				} else if (purple_strequal(formats[i], "png")) {
+				} else if (purple_strequal(formats_split[i], "png")) {
 					supports_png = TRUE;
 				}
 			}
@@ -1214,15 +1208,15 @@
 			} else {
 				purple_debug_info("pidgin",
 				    "creating thumbnail of format %s as demanded by PRPL\n",
-				    formats[0]);
-				format = formats[0];
+				    formats_split[0]);
+				format = formats_split[0];
 			}
 
 			gdk_pixbuf_save_to_bufferv(thumbnail, &buffer, &size, format, 
 				option_keys, option_values, NULL);
 
 			if (buffer) {
-				const gchar *mimetype = g_strdup_printf("image/%s", format);
+				const gchar *mimetype = g_strdup_printf("image/%s", format);				
 				purple_debug_info("pidgin",
 				                  "created thumbnail of %" G_GSIZE_FORMAT " bytes\n",
 					size);
@@ -1231,7 +1225,7 @@
 				g_free(mimetype);
 			}
 			g_object_unref(thumbnail);
-			g_strfreev(formats);
+			g_strfreev(formats_split);
 		}
 	}
 }