cpw.malu.ft_thumbnails: 1a683636: Make it work again, after some new xfer ...

malu at pidgin.im malu at pidgin.im
Wed Oct 21 18:13:08 EDT 2009


-----------------------------------------------------------------
Revision: 1a683636b8508eb82a1a5addd83b777449161fe6
Ancestor: 609d9a7d8f67154426ef1e94b3a5be40de5ce740
Author: malu at pidgin.im
Date: 2009-10-21T22:08:01
Branch: im.pidgin.cpw.malu.ft_thumbnails
URL: http://d.pidgin.im/viewmtn/revision/info/1a683636b8508eb82a1a5addd83b777449161fe6

Modified files:
        libpurple/ft.c libpurple/protocols/jabber/si.c
        pidgin/gtkft.c

ChangeLog: 

Make it work again, after some new xfer UI ops where added... :)
Display the thumbnail in the ongoing conversation.

-------------- next part --------------
============================================================
--- libpurple/ft.c	502c67f29f753c4ca3544a6401974049b1bd1cad
+++ libpurple/ft.c	1d0fc28e1b0a37de6f7548a3d851a098a8af72f3
@@ -217,7 +217,7 @@ void purple_xfer_conversation_write(Purp
 	PurpleConversation *conv = NULL;
 	PurpleMessageFlags flags = PURPLE_MESSAGE_SYSTEM;
 	char *escaped;
-
+	
 	g_return_if_fail(xfer != NULL);
 	g_return_if_fail(message != NULL);
 
@@ -478,12 +478,34 @@ purple_xfer_request(PurpleXfer *xfer)
 		else if (purple_xfer_get_filename(xfer) ||
 		           purple_xfer_get_status(xfer) == PURPLE_XFER_STATUS_ACCEPTED)
 		{
+			/* write thumbnail to the conversation, if there is one */
+			const gpointer *thumbnail_data = 
+				purple_xfer_get_thumbnail_data(xfer);
 			gchar* message = NULL;
 			PurpleBuddy *buddy = purple_find_buddy(xfer->account, xfer->who);
+
 			message = g_strdup_printf(_("%s is offering to send file %s"),
 				buddy ? purple_buddy_get_alias(buddy) : xfer->who, purple_xfer_get_filename(xfer));
 			purple_xfer_conversation_write(xfer, message, FALSE);
 			g_free(message);
+			if (thumbnail_data) {
+				PurpleConversation *conv =
+					purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM,
+						xfer->who, purple_xfer_get_account(xfer));
+				if (conv) {
+					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);
+
+					message = g_strdup_printf("<img id='%d'/>", id);
+					purple_conversation_write(conv, NULL, message,
+						PURPLE_MESSAGE_SYSTEM, time(NULL));
+					purple_imgstore_unref_by_id(id);
+					g_free(message);
+				}
+			}			
+
+
 			/* Ask for a filename to save to if it's not already given by a plugin */
 			if (xfer->local_filename == NULL)
 				purple_xfer_ask_recv(xfer);
============================================================
--- libpurple/protocols/jabber/si.c	4b646d3870b99f5aa9a5c08b048f25026d986e5e
+++ libpurple/protocols/jabber/si.c	948887a9d0f37bcdeac1bc932c9e86560c8349f7
@@ -1674,6 +1674,11 @@ jabber_si_thumbnail_cb(JabberStream *js,
 		purple_debug_error("jabber", "Unknown response to data request\n");
 	}
 	purple_xfer_request(xfer);
+	if (data) {
+		PurpleConversation *conv =
+				purple_find_conversation_with_account(PURPLE_CONV_TYPE_ANY,
+					from, js->gc->account);
+	}
 }
 
 void jabber_si_parse(JabberStream *js, const char *from, JabberIqType type,
============================================================
--- pidgin/gtkft.c	7f16dcb14c8b9bd069fe14bd925852df12b131dc
+++ pidgin/gtkft.c	35146a3d7e9187c596e10d43f104954c98b95f2f
@@ -1190,10 +1190,10 @@ static PurpleXferUiOps ops =
 	pidgin_xfer_update_progress,
 	pidgin_xfer_cancel_local,
 	pidgin_xfer_cancel_remote,
-	pidgin_xfer_add_thumbnail,
 	NULL,
 	NULL,
-	NULL
+	NULL,
+	pidgin_xfer_add_thumbnail
 };
 
 /**************************************************************************


More information about the Commits mailing list