diff options
author | Dan Vrátil <dvratil@redhat.com> | 2012-04-13 23:22:22 +0800 |
---|---|---|
committer | Dan Vrátil <dvratil@redhat.com> | 2012-04-13 23:22:56 +0800 |
commit | 7c0200eacd19539e27bfb47f30b28b114d1e5ce5 (patch) | |
tree | df11af7d7729ab2fcf875a8e8adceb1a69f3f3e5 | |
parent | 7c1a7df115abbfe389d224c9adc3261c3eb771da (diff) | |
download | gsoc2013-evolution-7c0200eacd19539e27bfb47f30b28b114d1e5ce5.tar.gz gsoc2013-evolution-7c0200eacd19539e27bfb47f30b28b114d1e5ce5.tar.zst gsoc2013-evolution-7c0200eacd19539e27bfb47f30b28b114d1e5ce5.zip |
Bug #674034 - Attached images from IMAP provider email not shown
-rw-r--r-- | mail/em-format-html.c | 50 |
1 files changed, 18 insertions, 32 deletions
diff --git a/mail/em-format-html.c b/mail/em-format-html.c index 77e9c65bb3..cb98aa2b9e 100644 --- a/mail/em-format-html.c +++ b/mail/em-format-html.c @@ -568,6 +568,7 @@ efh_write_image (EMFormat *emf, EMFormatHTML *efh; CamelDataWrapper *dw; GByteArray *ba; + CamelStream *raw_content; if (g_cancellable_is_cancelled (cancellable)) return; @@ -577,7 +578,9 @@ efh_write_image (EMFormat *emf, dw = camel_medium_get_content (CAMEL_MEDIUM (puri->part)); g_return_if_fail (dw); - ba = camel_data_wrapper_get_byte_array (dw); + raw_content = camel_stream_mem_new (); + camel_data_wrapper_decode_to_stream_sync (dw, raw_content, cancellable, NULL); + ba = camel_stream_mem_get_byte_array (CAMEL_STREAM_MEM (raw_content)); if (info->mode == EM_FORMAT_WRITE_MODE_RAW) { @@ -585,34 +588,16 @@ efh_write_image (EMFormat *emf, gchar *buff; gsize len; - gchar *data; - GByteArray anim; - data = g_strndup ((gchar *) ba->data, (gsize) ba->len); - anim.data = g_base64_decode (data, (gsize *) &(anim.len)); - g_free (data); - - em_format_html_animation_extract_frame (&anim, &buff, &len); + em_format_html_animation_extract_frame (ba, &buff, &len); camel_stream_write (stream, buff, len, cancellable, NULL); g_free (buff); - g_free (anim.data); } else { - CamelStream *stream_filter; - CamelMimeFilter *filter; - - stream_filter = camel_stream_filter_new (stream); - filter = camel_mime_filter_basic_new ( - CAMEL_MIME_FILTER_BASIC_BASE64_DEC); - - camel_stream_write ( - stream_filter, - (gchar *) ba->data, ba->len, - cancellable, NULL); - g_object_unref (stream_filter); - g_object_unref (filter); + + camel_stream_write_to_stream (raw_content, stream, cancellable, NULL); } } else { @@ -623,22 +608,15 @@ efh_write_image (EMFormat *emf, gchar *buff; gsize len; - gchar *data; - GByteArray raw_data; - data = g_strndup ((gchar *) ba->data, ba->len); - raw_data.data = (guint8 *) g_base64_decode ( - data, (gsize *) &(raw_data.len)); - g_free (data); - - em_format_html_animation_extract_frame (&raw_data, &buff, &len); + em_format_html_animation_extract_frame (ba, &buff, &len); content = g_base64_encode ((guchar *) buff, len); g_free (buff); - g_free (raw_data.data); + } else { - content = g_strndup ((gchar *) ba->data, ba->len); + content = g_base64_encode ((guchar *) ba->data, ba->len); } /* The image is already base64-encrypted so we can directly @@ -651,6 +629,8 @@ efh_write_image (EMFormat *emf, g_free (buffer); g_free (content); } + + g_object_unref (raw_content); } static void @@ -2935,6 +2915,12 @@ em_format_html_animation_extract_frame (const GByteArray *anim, 0x50, 0x45, 0x32, 0x2E, 0x30 }; const gint GIF_APPEXT_LEN = sizeof (GIF_APPEXT); + if ((anim == NULL) || (anim->data == NULL)) { + *frame = NULL; + *len = 0; + return; + } + /* Check if the image is an animated GIF. We don't care about any * other animated formats (APNG or MNG) as WebKit does not support them * and displays only the first frame. */ |