changeset 31429:dc63d77fea03

Gadu-Gadu: Fix sending inline images to remote users. Also fix sending images larger than 256 KB. Fixes #13580.
author John Bailey <rekkanoryo@rekkanoryo.org>
date Fri, 25 Mar 2011 04:32:46 +0000
parents f9b34192147c
children df4f9ffb699f
files COPYRIGHT ChangeLog libpurple/protocols/gg/gg.c
diffstat 3 files changed, 17 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/COPYRIGHT	Fri Mar 25 00:13:40 2011 +0000
+++ b/COPYRIGHT	Fri Mar 25 04:32:46 2011 +0000
@@ -563,6 +563,7 @@
 Eric Warmenhoven
 Adam J. Warrington
 Denis Washington
+Tomasz Wasilczyk
 Zsombor Welker
 Andrew Wellington
 Adam Wendt
--- a/ChangeLog	Fri Mar 25 00:13:40 2011 +0000
+++ b/ChangeLog	Fri Mar 25 04:32:46 2011 +0000
@@ -28,6 +28,8 @@
 	  Klinikowski) (#13525)
 	* Suppress blank messages that happen when sending inline images. (Tomasz
 	  Wasilczyk) (#13554)
+	* Fix sending inline images, including images larger than 256 KB, to remote
+	  users. (Tomasz Wasilczyk) (#13580)
 
 	ICQ:
 	* Fix unsetting your mood when "None" is selected. (#7431)
--- a/libpurple/protocols/gg/gg.c	Fri Mar 25 00:13:40 2011 +0000
+++ b/libpurple/protocols/gg/gg.c	Fri Mar 25 04:32:46 2011 +0000
@@ -1582,9 +1582,9 @@
 {
 	GGPInfo *info = gc->proto_data;
 	PurpleStoredImage *image;
-	gint imgid = GPOINTER_TO_INT(g_hash_table_lookup(info->pending_images, &ev->event.image_request.crc32));
-
-	purple_debug_info("gg", "ggp_send_image_handler: image request received, crc32: %u\n", ev->event.image_request.crc32);
+	gint imgid = GPOINTER_TO_INT(g_hash_table_lookup(info->pending_images, GINT_TO_POINTER(ev->event.image_request.crc32)));
+
+	purple_debug_info("gg", "ggp_send_image_handler: image request received, crc32: %u, imgid: %d\n", ev->event.image_request.crc32, imgid);
 
 	if(imgid)
 	{
@@ -1599,7 +1599,7 @@
 		} else {
 			purple_debug_error("gg", "ggp_send_image_handler: image imgid: %i, crc: %u in hash but not found in imgstore!\n", imgid, ev->event.image_request.crc32);
 		}
-		g_hash_table_remove(info->pending_images, &ev->event.image_request.crc32);
+		g_hash_table_remove(info->pending_images, GINT_TO_POINTER(ev->event.image_request.crc32));
 	}
 }
 
@@ -2008,7 +2008,7 @@
 	info->token = NULL;
 	info->searches = ggp_search_new();
 	info->pending_richtext_messages = NULL;
-	info->pending_images = g_hash_table_new(g_int_hash, g_int_equal);
+	info->pending_images = g_hash_table_new(g_direct_hash, g_direct_equal);
 	info->status_broadcasting = purple_account_get_bool(account, "status_broadcasting", TRUE);
 	
 	gc->proto_data = info;
@@ -2149,9 +2149,9 @@
 				const char *image_filename = purple_imgstore_get_filename(image);
 				uint32_t crc32 = gg_crc32(0, image_bin, image_size);
 
-				g_hash_table_insert(info->pending_images, &crc32, GINT_TO_POINTER(atoi(id)));
+				g_hash_table_insert(info->pending_images, GINT_TO_POINTER(crc32), GINT_TO_POINTER(atoi(id)));
 				purple_imgstore_ref(image);
-				purple_debug_info("gg", "ggp_send_im_richtext: got crc: %i for imgid: %i\n", crc32, atoi(id));
+				purple_debug_info("gg", "ggp_send_im_richtext: got crc: %u for imgid: %i\n", crc32, atoi(id));
 
 				actformat.font = GG_FONT_IMAGE;
 				actformat.position = pos;
@@ -2162,15 +2162,14 @@
 
 				if (actimage.size > 255000) {
 					purple_debug_warning("gg", "ggp_send_im_richtext: image over 255kb!\n");
-					continue;
+				} else {
+					purple_debug_info("gg", "ggp_send_im_richtext: adding images to richtext, size: %i, crc32: %u, name: %s\n", actimage.size, actimage.crc32, image_filename);
+
+					memcpy(format + format_length, &actformat, sizeof(actformat));
+					format_length += sizeof(actformat);
+					memcpy(format + format_length, &actimage, sizeof(actimage));
+					format_length += sizeof(actimage);
 				}
-
-				purple_debug_info("gg", "ggp_send_im_richtext: adding images to richtext, size: %i, crc32: %u, name: %s\n", actimage.size, actimage.crc32, image_filename);
-
-				memcpy(format + format_length, &actformat, sizeof(actformat));
-				format_length += sizeof(actformat);
-				memcpy(format + format_length, &actimage, sizeof(actimage));
-				format_length += sizeof(actimage);
 			} else {
 				purple_debug_error("gg", "ggp_send_im_richtext: image not found in the image store!");
 			}