cpw.malu.ft_thumbnails: d4a668fc: Set desired image formats for thumbnails...

malu at pidgin.im malu at pidgin.im
Tue Mar 16 19:20:48 EDT 2010


-----------------------------------------------------------------
Revision: d4a668fc64166df2856ce7a0b4dced035fb98fa5
Ancestor: bf054a034768bfc7ccbb15069ff35119ad966c54
Author: malu at pidgin.im
Date: 2010-03-16T23:14:54
Branch: im.pidgin.cpw.malu.ft_thumbnails
URL: http://d.pidgin.im/viewmtn/revision/info/d4a668fc64166df2856ce7a0b4dced035fb98fa5

Modified 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

ChangeLog: 

Set desired image formats for thumbnails as a parameter to 
purple_xfer_prepare_thumbnail instead of putting it in PrplInfo

-------------- next part --------------
============================================================
--- libpurple/ft.c	90d872b2df114f026ae8025a9bfa006eb1da30a8
+++ libpurple/ft.c	c1dffbd12251206be74ea25aba800fdfbb952659
@@ -1649,10 +1649,10 @@ void
 }
 
 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);
 	}
 }
 
============================================================
--- libpurple/ft.h	0c611773b01e5d2a465f6993857e6ab5b5fc0105
+++ libpurple/ft.h	c22e24544c7cc023d99b0f4236d875305d963e74
@@ -125,7 +125,7 @@ typedef struct
 	 *
 	 * @param xfer   The file transfer structure
 	 */
-	void (*add_thumbnail)(PurpleXfer *xfer);
+	void (*add_thumbnail)(PurpleXfer *xfer, const gchar *formats);
 } PurpleXferUiOps;
 
 /**
@@ -737,8 +737,10 @@ void purple_xfer_set_thumbnail(PurpleXfe
  * 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);
 
 
 /*@}*/
============================================================
--- libpurple/protocols/jabber/libxmpp.c	b51b4468b6f840bbba4ec145211789786bc548a6
+++ libpurple/protocols/jabber/libxmpp.c	eb3c713d4904a50323e1e11e5474a3c5af410cef
@@ -127,8 +127,7 @@ static PurplePluginProtocolInfo prpl_inf
 	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)
============================================================
--- libpurple/protocols/jabber/si.c	000854e8663e3814adddf346bf4e1f518cf7fe9a
+++ libpurple/protocols/jabber/si.c	9da84fcfbd2cf2c9d388ecb61f8f72bdf0c575a0
@@ -1246,7 +1246,7 @@ static void jabber_si_xfer_send_request(
 	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);
============================================================
--- libpurple/protocols/msn/msn.c	f5987ad55632c2518575b7dc185696515995c709
+++ libpurple/protocols/msn/msn.c	5a8106a51928918380677fbe201ed78c92bc4735
@@ -2733,8 +2733,7 @@ static PurplePluginProtocolInfo prpl_inf
 	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 =
============================================================
--- libpurple/protocols/msn/slplink.c	af7ebe58dc0e19213d1bf0fb1a560eabb397d8a7
+++ libpurple/protocols/msn/slplink.c	768fbbc5e7ed2ddaeefb633265a531bb8bc974ac
@@ -673,7 +673,7 @@ gen_context(PurpleXfer *xfer, const char
 
 	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);
============================================================
--- libpurple/prpl.h	ade31d168fd6e6fcafdb59ba3adc7935098f6d2a
+++ libpurple/prpl.h	44fbc9d711bdeaedac22d9b13ccc69785aee04aa
@@ -97,14 +97,6 @@ struct _PurpleBuddyIconSpec {
 	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 @@ struct _PurplePluginProtocolInfo
 	 * "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) \
============================================================
--- pidgin/gtkft.c	dedca28500ef823175c034694522a9eb83baf2e7
+++ pidgin/gtkft.c	b922d0b77bae4ec1af690151244d9a6c25585cba
@@ -1161,23 +1161,17 @@ static void
 }
 
 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 @@ pidgin_xfer_add_thumbnail(PurpleXfer *xf
 			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 @@ pidgin_xfer_add_thumbnail(PurpleXfer *xf
 			} 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 @@ pidgin_xfer_add_thumbnail(PurpleXfer *xf
 				g_free(mimetype);
 			}
 			g_object_unref(thumbnail);
-			g_strfreev(formats);
+			g_strfreev(formats_split);
 		}
 	}
 }


More information about the Commits mailing list