[evolution/webkit: 119/146] Fix loading size of attachment (bug #667541)



commit 3424e6bd732159878d5018d5d1350f1fd72f873a
Author: Dan VrÃtil <dan progdan cz>
Date:   Wed Jan 18 20:47:26 2012 +0100

    Fix loading size of attachment (bug #667541)
    
    I think I found a simple way how to get size of an attachment: just looking
    on size of the respective MIME part (and multiplying it by 0.73 if it's base64 encoded).
    This seems to be more simple and faster then the previous method, which didn't
    work for the webkit port since camel_folder_summary_guess_content_info always
    returned NULL

 mail/em-format-html-display.c |   25 +++++++++----------------
 1 files changed, 9 insertions(+), 16 deletions(-)
---
diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c
index 3a8c02d..e3b814a 100644
--- a/mail/em-format-html-display.c
+++ b/mail/em-format-html-display.c
@@ -541,22 +541,15 @@ efhd_parse_attachment (EMFormat *emf,
 	e_attachment_store_add_attachment (store, puri->attachment);
 
 	if (emf->folder && emf->folder->summary && emf->message_uid) {
-		CamelMessageInfo *mi;
-
-		mi = camel_folder_summary_get (emf->folder->summary, emf->message_uid);
-		if (mi) {
-			const CamelMessageContentInfo *ci;
-
-			ci = camel_folder_summary_guess_content_info (mi,
-					camel_mime_part_get_content_type (puri->puri.part));
-			if (ci) {
-				size = ci->size;
-				/* what if its not encoded in base64 ? is it a case to consider? */
-				if (ci->encoding && !g_ascii_strcasecmp (ci->encoding, "base64"))
-					size = size / 1.37;
-			}
-			camel_message_info_free (mi);
-		}
+                CamelDataWrapper *dw = camel_medium_get_content (CAMEL_MEDIUM (puri->puri.part));
+                GByteArray *ba;
+                ba = camel_data_wrapper_get_byte_array (dw);
+                if (ba) {
+                        size = ba->len;
+
+                        if (camel_mime_part_get_encoding (puri->puri.part) == CAMEL_TRANSFER_ENCODING_BASE64)
+                                size = size / 1.37;
+                }
 	}
 
 	load_data = g_new0 (struct attachment_load_data, 1);



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