changeset 29823: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 6671b5e92c28
files libpurple/ft.c libpurple/ft.h libpurple/protocols/jabber/libxmpp.c libpurple/protocols/jabber/si.c libpurple/protocols/msn/msn.c libpurple/protocols/msn/slplink.c libpurple/prpl.h pidgin/gtkft.c
diffstat 8 files changed, 21 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/ft.c	Mon Mar 15 21:49:02 2010 +0000
+++ b/libpurple/ft.c	Tue Mar 16 23:14:54 2010 +0000
@@ -1649,10 +1649,10 @@
 }
 
 void
-purple_xfer_prepare_thumbnail(PurpleXfer *xfer)
+purple_xfer_prepare_thumbnail(PurpleXfer *xfer, const gchar *formats)
 {
 	if (xfer->ui_ops->add_thumbnail) {
-		xfer->ui_ops->add_thumbnail(xfer);
+		xfer->ui_ops->add_thumbnail(xfer, formats);
 	}
 }
 
--- a/libpurple/ft.h	Mon Mar 15 21:49:02 2010 +0000
+++ b/libpurple/ft.h	Tue Mar 16 23:14:54 2010 +0000
@@ -125,7 +125,7 @@
 	 *
 	 * @param xfer   The file transfer structure
 	 */
-	void (*add_thumbnail)(PurpleXfer *xfer);
+	void (*add_thumbnail)(PurpleXfer *xfer, const gchar *formats);
 } PurpleXferUiOps;
 
 /**
@@ -737,8 +737,10 @@
  * will be no-op in case the UI doesn't implement thumbnail creation
  *
  * @param xfer The file transfer to create a thumbnail for
+ * @param formats A comma-separated list of mimetypes for image formats
+ *	 	  the protocols can use for thumbnails.
  */
-void purple_xfer_prepare_thumbnail(PurpleXfer *xfer);
+void purple_xfer_prepare_thumbnail(PurpleXfer *xfer, const gchar *formats);
 
 
 /*@}*/
--- a/libpurple/protocols/jabber/libxmpp.c	Mon Mar 15 21:49:02 2010 +0000
+++ b/libpurple/protocols/jabber/libxmpp.c	Tue Mar 16 23:14:54 2010 +0000
@@ -127,8 +127,7 @@
 	NULL, /* get_account_text_table */
 	jabber_initiate_media,          /* initiate_media */
 	jabber_get_media_caps,                  /* get_media_caps */
-	jabber_get_moods,  							/* get_moods */
-	{"jpeg,png"}					/* file transfer thumbnail spec */
+	jabber_get_moods  							/* get_moods */
 };
 
 static gboolean load_plugin(PurplePlugin *plugin)
--- a/libpurple/protocols/jabber/si.c	Mon Mar 15 21:49:02 2010 +0000
+++ b/libpurple/protocols/jabber/si.c	Tue Mar 16 23:14:54 2010 +0000
@@ -1246,7 +1246,7 @@
 	char buf[32];
 
 	xfer->filename = g_path_get_basename(xfer->local_filename);
-	purple_xfer_prepare_thumbnail(xfer);
+	purple_xfer_prepare_thumbnail(xfer, "jpeg,png");
 	
 	iq = jabber_iq_new(jsx->js, JABBER_IQ_SET);
 	xmlnode_set_attrib(iq->node, "to", xfer->who);
--- a/libpurple/protocols/msn/msn.c	Mon Mar 15 21:49:02 2010 +0000
+++ b/libpurple/protocols/msn/msn.c	Tue Mar 16 23:14:54 2010 +0000
@@ -2733,8 +2733,7 @@
 	msn_get_account_text_table,             /* get_account_text_table */
 	NULL,                                   /* initiate_media */
 	NULL,                                   /* get_media_caps */
-	NULL,                                    /* get_moods */
-	{"png"}					/* file transfer thumbnail spec */
+	NULL                                    /* get_moods */
 };
 
 static PurplePluginInfo info =
--- a/libpurple/protocols/msn/slplink.c	Mon Mar 15 21:49:02 2010 +0000
+++ b/libpurple/protocols/msn/slplink.c	Tue Mar 16 23:14:54 2010 +0000
@@ -673,7 +673,7 @@
 
 	size = purple_xfer_get_size(xfer);
 
-	purple_xfer_prepare_thumbnail(xfer);
+	purple_xfer_prepare_thumbnail(xfer, "png");
 
 	if (!file_name) {
 		gchar *basename = g_path_get_basename(file_path);
--- a/libpurple/prpl.h	Mon Mar 15 21:49:02 2010 +0000
+++ b/libpurple/prpl.h	Tue Mar 16 23:14:54 2010 +0000
@@ -97,14 +97,6 @@
 	size_t max_filesize;               /**< Maximum size in bytes */
 	PurpleIconScaleRules scale_rules;  /**< How to stretch this icon */
 };
-
-/** @copydoc PurpleThumbnailSpec */
-struct _PurpleThumbnailSpec {
-	/** This is a comma-delimited list of image formats or @c NULL if the
-	 *  prpl does not support file transfer thumbnails
-	 */
-	char *format;
-};
 	
 /** Represents an entry containing information that must be supplied by the
  *  user when joining a chat.
@@ -590,11 +582,6 @@
 	 * "mood" set to @c NULL.
 	 */
 	PurpleMood *(*get_moods)(PurpleAccount *account);
-
-	/**
-	 * File transfer thumbnail spec
-	 */
-	PurpleThumbnailSpec thumbnail_spec;
 };
 
 #define PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl, member) \
--- 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);
 		}
 	}
 }