[evolution-mapi] Bug #604498 - Incorrectly decoded message in UI



commit 089d1cb8efb9eae03ad618839be101ef37d15d50
Author: Milan Crha <mcrha redhat com>
Date:   Thu May 13 20:45:55 2010 +0200

    Bug #604498 - Incorrectly decoded message in UI

 src/camel/camel-mapi-folder.c                  |   18 +++++++++++++++++-
 src/libexchangemapi/exchange-mapi-mail-utils.c |   17 +++++++++--------
 2 files changed, 26 insertions(+), 9 deletions(-)
---
diff --git a/src/camel/camel-mapi-folder.c b/src/camel/camel-mapi-folder.c
index 1c45a9c..351137a 100644
--- a/src/camel/camel-mapi-folder.c
+++ b/src/camel/camel-mapi-folder.c
@@ -1194,8 +1194,24 @@ mapi_folder_get_message( CamelFolder *folder, const gchar *uid, CamelException *
 	CAMEL_MAPI_FOLDER_REC_LOCK (folder, cache_lock);
 	if ((cache_stream = camel_data_cache_add (mapi_folder->cache, "cache", uid, NULL))) {
 		if (camel_data_wrapper_write_to_stream ((CamelDataWrapper *) msg, cache_stream) == -1
-				|| camel_stream_flush (cache_stream) == -1)
+				|| camel_stream_flush (cache_stream) == -1) {
 			camel_data_cache_remove (mapi_folder->cache, "cache", uid, NULL);
+		} else {
+			CamelMimeMessage *msg2;
+
+			/* workaround to get message back from cache, as that one is properly
+			   encoded with attachments and so on. Not sure what's going wrong when
+			   composing message in memory, but when they are read from the cache
+			   they appear properly in the UI. */
+			msg2 = camel_mime_message_new ();
+			camel_stream_reset (cache_stream);
+			if (camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (msg2), cache_stream) == -1) {
+				g_object_unref (msg2);
+			} else {
+				g_object_unref (msg);
+				msg = msg2;
+			}
+		}
 		g_object_unref (cache_stream);
 	}
 
diff --git a/src/libexchangemapi/exchange-mapi-mail-utils.c b/src/libexchangemapi/exchange-mapi-mail-utils.c
index 9d671fc..a1b2f3e 100644
--- a/src/libexchangemapi/exchange-mapi-mail-utils.c
+++ b/src/libexchangemapi/exchange-mapi-mail-utils.c
@@ -616,6 +616,7 @@ mapi_mime_classify_attachments (GSList *attachments, GSList **inline_attachs, GS
 		const gchar *filename, *mime_type, *content_id = NULL;
 		CamelContentType *content_type;
 		CamelMimePart *part;
+		const uint32_t *ui32;
 
 		stream = exchange_mapi_util_find_stream (attach->streams, PR_ATTACH_DATA_BIN);
 
@@ -635,21 +636,21 @@ mapi_mime_classify_attachments (GSList *attachments, GSList **inline_attachs, GS
 		camel_content_type_set_param (((CamelDataWrapper *) part)->mime_type, "name", filename);
 
 		/*Content-Type*/
-		mime_type = (const gchar *) exchange_mapi_util_find_SPropVal_array_propval (attach->lpProps, PR_ATTACH_MIME_TAG);
-		if (!mime_type) {
-			const uint32_t *ui32 = (const uint32_t *) exchange_mapi_util_find_SPropVal_array_propval (attach->lpProps, PR_ATTACH_METHOD);
-			if (ui32 && *ui32 == ATTACH_EMBEDDED_MSG)
-				mime_type = "message/rfc822";
+		ui32 = (const uint32_t *) exchange_mapi_util_find_SPropVal_array_propval (attach->lpProps, PR_ATTACH_METHOD);
+		if (ui32 && *ui32 == ATTACH_EMBEDDED_MSG) {
+			mime_type = "message/rfc822";
+		} else {
+			mime_type = (const gchar *) exchange_mapi_util_find_SPropVal_array_propval (attach->lpProps, PR_ATTACH_MIME_TAG);
+			if (!mime_type)
+				mime_type = "application/octet-stream";
 		}
-		if (!mime_type)
-			mime_type = "application/octet-stream";
 
 		camel_mime_part_set_content (part, (const gchar *) stream->value->data, stream->value->len, mime_type);
 
 		content_type = camel_mime_part_get_content_type (part);
 		if (content_type && camel_content_type_is (content_type, "text", "*"))
 			camel_mime_part_set_encoding (part, CAMEL_TRANSFER_ENCODING_QUOTEDPRINTABLE);
-		else
+		else if (!ui32 || *ui32 != ATTACH_EMBEDDED_MSG)
 			camel_mime_part_set_encoding (part, CAMEL_TRANSFER_ENCODING_BASE64);
 
 		/*Content-ID*/



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]