diff options
author | Milan Crha <mcrha@redhat.com> | 2007-10-30 17:06:26 +0800 |
---|---|---|
committer | Milan Crha <mcrha@src.gnome.org> | 2007-10-30 17:06:26 +0800 |
commit | 21ec67eb25834ee0b37d72bafd464cb8b395efe5 (patch) | |
tree | d9f791a536290bc4183725a0c7528726406be30c /plugins | |
parent | 69c8f40f0919bf60dc39ea5d0e905e446a619870 (diff) | |
download | gsoc2013-evolution-21ec67eb25834ee0b37d72bafd464cb8b395efe5.tar.gz gsoc2013-evolution-21ec67eb25834ee0b37d72bafd464cb8b395efe5.tar.zst gsoc2013-evolution-21ec67eb25834ee0b37d72bafd464cb8b395efe5.zip |
** Fix for bug #487922 (Sometimes evolution does not recognize
2007-10-30 Milan Crha <mcrha@redhat.com>
** 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
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/prefer-plain/ChangeLog | 11 | ||||
-rw-r--r-- | 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 <mcrha@redhat.com> + + ** 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 <psankar@novell.com> * 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;i<nparts; i++) { - part = camel_multipart_get_part(mp, i); - if (part != display_part) { - g_string_append_printf(t->format->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); } |