changeset 30219:cb09d358d777

Make it work again, after some new xfer UI ops where added... :) Display the thumbnail in the ongoing conversation.
author Marcus Lundblad <ml@update.uu.se>
date Wed, 21 Oct 2009 22:08:01 +0000
parents 5502f855ec2b
children bc57ec419847
files libpurple/ft.c libpurple/protocols/jabber/si.c pidgin/gtkft.c
diffstat 3 files changed, 30 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/ft.c	Tue Oct 20 22:32:09 2009 +0000
+++ b/libpurple/ft.c	Wed Oct 21 22:08:01 2009 +0000
@@ -217,7 +217,7 @@
 	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 @@
 		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);
--- a/libpurple/protocols/jabber/si.c	Tue Oct 20 22:32:09 2009 +0000
+++ b/libpurple/protocols/jabber/si.c	Wed Oct 21 22:08:01 2009 +0000
@@ -1674,6 +1674,11 @@
 		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,
--- a/pidgin/gtkft.c	Tue Oct 20 22:32:09 2009 +0000
+++ b/pidgin/gtkft.c	Wed Oct 21 22:08:01 2009 +0000
@@ -1190,10 +1190,10 @@
 	pidgin_xfer_update_progress,
 	pidgin_xfer_cancel_local,
 	pidgin_xfer_cancel_remote,
-	pidgin_xfer_add_thumbnail,
 	NULL,
 	NULL,
-	NULL
+	NULL,
+	pidgin_xfer_add_thumbnail
 };
 
 /**************************************************************************