cpw.malu.ft_thumbnails: 5d131ae9: Rename purple_xfer_get_thumbnail_data/si..

qulogic at pidgin.im qulogic at pidgin.im
Sun Apr 25 17:50:44 EDT 2010


-----------------------------------------------------------------
Revision: 5d131ae9721badef442e1be4b0ac14e1edd52231
Ancestor: 6d14e2d12ca51f47d95d0a80de85a260c9f6a3e2
Author: qulogic at pidgin.im
Date: 2010-04-25T21:09:34
Branch: im.pidgin.cpw.malu.ft_thumbnails
URL: http://d.pidgin.im/viewmtn/revision/info/5d131ae9721badef442e1be4b0ac14e1edd52231

Modified files:
        libpurple/ft.c libpurple/ft.h
        libpurple/protocols/jabber/si.c
        libpurple/protocols/msn/slplink.c

ChangeLog: 

Rename purple_xfer_get_thumbnail_data/size to be more D-Bus friendly.

-------------- next part --------------
============================================================
--- libpurple/ft.c	cbdb7c0b2a75f46d74dba380a7c0e1fd640ba71a
+++ libpurple/ft.c	af208435bf53b32283e800dc856804e5f5e4fdee
@@ -281,11 +281,14 @@ purple_xfer_conversation_write_internal(
 	PurpleConversation *conv = NULL;
 	PurpleMessageFlags flags = PURPLE_MESSAGE_SYSTEM;
 	char *escaped;
-	gconstpointer thumbnail_data = purple_xfer_get_thumbnail_data(xfer);
+	gconstpointer thumbnail_data;
+	gsize size;
 
 	g_return_if_fail(xfer != NULL);
 	g_return_if_fail(message != NULL);
 
+	thumbnail_data = purple_xfer_get_thumbnail(xfer, &size);
+
 	conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, xfer->who,
 											   purple_xfer_get_account(xfer));
 
@@ -299,7 +302,6 @@ purple_xfer_conversation_write_internal(
 
 	if (print_thumbnail && thumbnail_data) {
 		gchar *message_with_img;
-		gsize size = purple_xfer_get_thumbnail_size(xfer);
 		gpointer data = g_memdup(thumbnail_data, size); 
 		int id = purple_imgstore_add_with_id(data, size, NULL);
 
@@ -489,6 +491,8 @@ purple_xfer_ask_recv(PurpleXfer *xfer)
 {
 	char *buf, *size_buf;
 	size_t size;
+	gconstpointer thumb;
+	gsize thumb_size;
 
 	/* If we have already accepted the request, ask the destination file
 	   name directly */
@@ -514,11 +518,10 @@ purple_xfer_ask_recv(PurpleXfer *xfer)
 			serv_got_im(purple_account_get_connection(xfer->account),
 								 xfer->who, xfer->message, 0, time(NULL));
 
-		if (purple_xfer_get_thumbnail_data(xfer)) {
+		if ((thumb = purple_xfer_get_thumbnail(xfer, &thumb_size))) {
 			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, 
+				thumb, thumb_size, xfer, 
 				G_CALLBACK(purple_xfer_choose_file),
 				G_CALLBACK(cancel_recv_cb));
 		} else {
@@ -1630,20 +1633,15 @@ 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)
+gconstpointer
+purple_xfer_get_thumbnail(const PurpleXfer *xfer, gsize *len)
 {
 	PurpleXferPrivData *priv = g_hash_table_lookup(xfers_data, xfer);
 
-	return priv->thumbnail_data;
-}
+	if (len)
+		*len = priv->thumbnail_size;
 
-gsize
-purple_xfer_get_thumbnail_size(const PurpleXfer *xfer)
-{
-	PurpleXferPrivData *priv = g_hash_table_lookup(xfers_data, xfer);
-
-	return priv->thumbnail_size;
+	return priv->thumbnail_data;
 }
 
 const gchar *
============================================================
--- libpurple/ft.h	323cd6efd2e3f5a72db3079250bbef03c52f3d70
+++ libpurple/ft.h	84216e2937f59e43e48fb7ce0af7971168b175ab
@@ -696,19 +696,13 @@ void purple_xfer_prpl_ready(PurpleXfer *
  * Gets the thumbnail data for a transfer
  *
  * @param xfer The file transfer to get the thumbnail for
+ * @param len  If not @c NULL, the length of the thumbnail data returned
+ *             will be set in the location pointed to by this.
  * @return The thumbnail data, or NULL if there is no thumbnail
  */
-const void *purple_xfer_get_thumbnail_data(const PurpleXfer *xfer);
+gconstpointer purple_xfer_get_thumbnail(const PurpleXfer *xfer, gsize *len);
 
 /**
- * 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);
-
-/**
  * Gets the mimetype of the thumbnail preview for a transfer
  *
  * @param xfer The file transfer to get the mimetype for
============================================================
--- libpurple/protocols/jabber/si.c	140020f3f2b82fb6af6d8abf528ab180099e5b94
+++ libpurple/protocols/jabber/si.c	163e282ec09b37888c57e24add922225d65018a3
@@ -1247,6 +1247,8 @@ static void jabber_si_xfer_send_request(
 	JabberIq *iq;
 	xmlnode *si, *file, *feature, *x, *field, *option, *value;
 	char buf[32];
+	gconstpointer thumb;
+	gsize thumb_size;
 
 	xfer->filename = g_path_get_basename(xfer->local_filename);
 	purple_xfer_prepare_thumbnail(xfer, "jpeg,png");
@@ -1269,12 +1271,11 @@ static void jabber_si_xfer_send_request(
 	/* maybe later we'll do hash and date attribs */
 
 	/* add thumbnail, if appropriate */
-	if (purple_xfer_get_thumbnail_data(xfer)) {
+	if ((thumb = purple_xfer_get_thumbnail(xfer, &thumb_size))) {
 		const gchar *mimetype = purple_xfer_get_thumbnail_mimetype(xfer);
 		JabberData *thumbnail_data =
-			jabber_data_create_from_data(purple_xfer_get_thumbnail_data(xfer),
-				purple_xfer_get_thumbnail_size(xfer), mimetype, TRUE,
-				jsx->js);
+			jabber_data_create_from_data(thumb, thumb_size,
+				mimetype, TRUE, jsx->js);
 		xmlnode *thumbnail = xmlnode_new_child(file, "thumbnail");
 		xmlnode_set_namespace(thumbnail, NS_THUMBS);
 		xmlnode_set_attrib(thumbnail, "cid", 
============================================================
--- libpurple/protocols/msn/slplink.c	9cabae6a7fa45ee235e5bc17b393de87f6f1da86
+++ libpurple/protocols/msn/slplink.c	054da587e3d92717734d878781b33b3d24a80efa
@@ -720,11 +720,7 @@ gen_context(PurpleXfer *xfer, const char
 		u8 = NULL;
 	}
 
-	preview = purple_xfer_get_thumbnail_data(xfer);
-	if (preview)
-		preview_len = purple_xfer_get_thumbnail_size(xfer);
-	else
-		preview_len = 0;
+	preview = purple_xfer_get_thumbnail(xfer, &preview_len);
 	header = g_malloc(sizeof(MsnFileContext) + preview_len);
 
 	header->length = GUINT32_TO_LE(sizeof(MsnFileContext) - 1);


More information about the Commits mailing list