From 21ec67eb25834ee0b37d72bafd464cb8b395efe5 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Tue, 30 Oct 2007 09:06:26 +0000 Subject: ** Fix for bug #487922 (Sometimes evolution does not recognize 2007-10-30 Milan Crha ** Fix for bug #487922 (Sometimes evolution does not recognize attachments) * prefer-plain.c: (export_as_attachments): New helper function to export message parts as attachments. This will traverse whole hierarchy of message's parts in multipart message. * prefer-plain.c: (org_gnome_prefer_plain_multipart_alternative): Use this function to export other parts as attachments. svn path=/trunk/; revision=34452 --- plugins/prefer-plain/ChangeLog | 11 ++++++++ plugins/prefer-plain/prefer-plain.c | 54 ++++++++++++++++++++++++++++++------- 2 files changed, 55 insertions(+), 10 deletions(-) diff --git a/plugins/prefer-plain/ChangeLog b/plugins/prefer-plain/ChangeLog index b9d69d4a36..82cd184dc0 100644 --- a/plugins/prefer-plain/ChangeLog +++ b/plugins/prefer-plain/ChangeLog @@ -1,3 +1,14 @@ +2007-10-30 Milan Crha + + ** Fix for bug #487922 + (Sometimes evolution does not recognize attachments) + + * prefer-plain.c: (export_as_attachments): New helper function to + export message parts as attachments. This will traverse whole + hierarchy of message's parts in multipart message. + * prefer-plain.c: (org_gnome_prefer_plain_multipart_alternative): + Use this function to export other parts as attachments. + 2007-09-05 Sankar P * prefer-plain.c: (e_plugin_lib_enable): diff --git a/plugins/prefer-plain/prefer-plain.c b/plugins/prefer-plain/prefer-plain.c index b21b69b53f..56d4bd3458 100644 --- a/plugins/prefer-plain/prefer-plain.c +++ b/plugins/prefer-plain/prefer-plain.c @@ -48,6 +48,49 @@ org_gnome_prefer_plain_text_html(void *ep, EMFormatHookTarget *t) em_format_part_as(t->format, t->stream, t->part, NULL); } +static void +export_as_attachments (CamelMultipart *mp, EMFormat *format, CamelStream *stream, CamelMimePart *except) +{ + int i, nparts, partidlen; + CamelMimePart *part; + + if (!mp || !CAMEL_IS_MULTIPART (mp)) + return; + + partidlen = format->part_id->len; + + nparts = camel_multipart_get_number(mp); + for (i = 0; i < nparts; i++) { + part = camel_multipart_get_part (mp, i); + + if (part != except) { + CamelMultipart *multipart = (CamelMultipart *)camel_medium_get_content_object((CamelMedium *)part); + + if (CAMEL_IS_MULTIPART (multipart)) { + export_as_attachments (multipart, format, stream, except); + } else { + g_string_append_printf (format->part_id, ".alternative.%d", i); + + if (camel_content_type_is (camel_mime_part_get_content_type (part), "text", "html")) { + /* always show HTML as attachments and not inline */ + camel_mime_part_set_disposition (part, "attachment"); + + if (!camel_mime_part_get_filename (part)) { + char *str = g_strdup_printf ("%s.html", _("attachment")); + camel_mime_part_set_filename (part, str); + g_free (str); + } + + em_format_part_as (format, stream, part, "application/octet-stream"); + } else + em_format_part (format, stream, part); + + g_string_truncate (format->part_id, partidlen); + } + } + } +} + void org_gnome_prefer_plain_multipart_alternative(void *ep, EMFormatHookTarget *t) { @@ -84,16 +127,7 @@ org_gnome_prefer_plain_multipart_alternative(void *ep, EMFormatHookTarget *t) } /* all other parts are attachments */ - for (i=0;iformat->part_id, ".alternative.%d", i); - - em_format_part_as(t->format, t->stream, t->part, NULL); - - g_string_truncate(t->format->part_id, partidlen); - } - } + export_as_attachments (mp, t->format, t->stream, display_part); g_string_truncate(t->format->part_id, partidlen); } -- cgit v1.2.3