cpw.malu.ft_thumbnails: e968dce6: Added a skeleton for functions to set an...

malu at pidgin.im malu at pidgin.im
Tue Jun 23 17:35:21 EDT 2009


-----------------------------------------------------------------
Revision: e968dce6e9f1a0688dff7463f0b6ec5458fd7c42
Ancestor: 74c00c33cab0e208691543b25eeae7906f6e4181
Author: malu at pidgin.im
Date: 2009-06-23T21:33:10
Branch: im.pidgin.cpw.malu.ft_thumbnails
URL: http://d.pidgin.im/viewmtn/revision/info/e968dce6e9f1a0688dff7463f0b6ec5458fd7c42

Modified files:
        libpurple/ft.c libpurple/ft.h

ChangeLog: 

Added a skeleton for functions to set and get a thumbnail image associated
with a file transfer and provision for a UI op to let a UI "manufacture"
a thumbnail.
Refs #9476

-------------- next part --------------
============================================================
--- libpurple/ft.c	001b040033429f66b53efdd5906b414ff1d4a5ce
+++ libpurple/ft.c	fccb7f3393f00887e680a03da79af0898eaaecf7
@@ -101,6 +101,7 @@ purple_xfer_destroy(PurpleXfer *xfer)
 	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);
@@ -1287,7 +1288,36 @@ purple_xfer_update_progress(PurpleXfer *
 		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
  **************************************************************************/
============================================================
--- libpurple/ft.h	3aa2704a0d52f381185179f08bd2dfab218e1d33
+++ libpurple/ft.h	3b1d4d90f4b6b09d529995f2bab51e04ed18e0c9
@@ -76,11 +76,11 @@ typedef struct
 	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 @@ struct _PurpleXfer
 	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(Purp
  */
 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);
+
 /*@}*/
 
 /**************************************************************************/


More information about the Commits mailing list