diff options
author | Milan Crha <mcrha@redhat.com> | 2011-06-24 22:24:19 +0800 |
---|---|---|
committer | Rodrigo Moya <rodrigo@gnome-db.org> | 2011-06-30 00:42:32 +0800 |
commit | f9de46563e474030f40db59ba9c1544c321bbabd (patch) | |
tree | f39e0294773e743789b550796ce189bf61558a19 | |
parent | 72a59651b8cd1383bb74bdc5ccbc1c49d5d25168 (diff) | |
download | gsoc2013-evolution-f9de46563e474030f40db59ba9c1544c321bbabd.tar gsoc2013-evolution-f9de46563e474030f40db59ba9c1544c321bbabd.tar.gz gsoc2013-evolution-f9de46563e474030f40db59ba9c1544c321bbabd.tar.bz2 gsoc2013-evolution-f9de46563e474030f40db59ba9c1544c321bbabd.tar.lz gsoc2013-evolution-f9de46563e474030f40db59ba9c1544c321bbabd.tar.xz gsoc2013-evolution-f9de46563e474030f40db59ba9c1544c321bbabd.tar.zst gsoc2013-evolution-f9de46563e474030f40db59ba9c1544c321bbabd.zip |
Bug #637402 - No quoted mail when replying to html email
-rw-r--r-- | em-format/em-format.c | 87 |
1 files changed, 60 insertions, 27 deletions
diff --git a/em-format/em-format.c b/em-format/em-format.c index be3e935728..1f9634d29f 100644 --- a/em-format/em-format.c +++ b/em-format/em-format.c @@ -1655,6 +1655,8 @@ emf_multipart_mixed (EMFormat *emf, } } +static gboolean related_display_part_is_attachment (EMFormat *emf, CamelMimePart *part); + /* RFC 1740 */ static void emf_multipart_alternative (EMFormat *emf, @@ -1712,6 +1714,8 @@ emf_multipart_alternative (EMFormat *emf, return part;*/ if (!em_format_is_attachment (emf, part) && + (!camel_content_type_is (type, "multipart", "related") || + !related_display_part_is_attachment (emf, part)) && (em_format_find_handler (emf, mime_type) || (best == NULL && em_format_fallback_handler (emf, mime_type)))) { best = part; @@ -1819,6 +1823,60 @@ emf_multipart_encrypted (EMFormat *emf, g_object_unref (context); } +static CamelMimePart * +get_related_display_part (CamelMimePart *part, gint *out_displayid) +{ + CamelMultipart *mp; + CamelMimePart *body_part, *display_part = NULL; + CamelContentType *content_type; + const gchar *start; + gint i, nparts, displayid = 0; + + mp = (CamelMultipart *) camel_medium_get_content ((CamelMedium *) part); + + if (!CAMEL_IS_MULTIPART (mp)) + return NULL; + + nparts = camel_multipart_get_number (mp); + content_type = camel_mime_part_get_content_type (part); + start = camel_content_type_param (content_type, "start"); + if (start && strlen (start) > 2) { + gint len; + const gchar *cid; + + /* strip <>'s */ + len = strlen (start) - 2; + start++; + + for (i = 0; i < nparts; i++) { + body_part = camel_multipart_get_part (mp, i); + cid = camel_mime_part_get_content_id (body_part); + + if (cid && !strncmp (cid, start, len) && strlen (cid) == len) { + display_part = body_part; + displayid = i; + break; + } + } + } else { + display_part = camel_multipart_get_part (mp, 0); + } + + if (out_displayid) + *out_displayid = displayid; + + return display_part; +} + +static gboolean +related_display_part_is_attachment (EMFormat *emf, CamelMimePart *part) +{ + CamelMimePart *display_part; + + display_part = get_related_display_part (part, NULL); + return display_part && em_format_is_attachment (emf, display_part); +} + static void emf_write_related (EMFormat *emf, CamelStream *stream, @@ -1840,8 +1898,6 @@ emf_multipart_related (EMFormat *emf, { CamelMultipart *mp; CamelMimePart *body_part, *display_part = NULL; - CamelContentType *content_type; - const gchar *start; gint i, nparts, partidlen, displayid = 0; gchar *oldpartid; GList *link; @@ -1853,31 +1909,7 @@ emf_multipart_related (EMFormat *emf, return; } - /* FIXME: put this stuff in a shared function */ - nparts = camel_multipart_get_number (mp); - content_type = camel_mime_part_get_content_type (part); - start = camel_content_type_param (content_type, "start"); - if (start && strlen (start)>2) { - gint len; - const gchar *cid; - - /* strip <>'s */ - len = strlen (start) - 2; - start++; - - for (i=0; i<nparts; i++) { - body_part = camel_multipart_get_part (mp, i); - cid = camel_mime_part_get_content_id (body_part); - - if (cid && !strncmp (cid, start, len) && strlen (cid) == len) { - display_part = body_part; - displayid = i; - break; - } - } - } else { - display_part = camel_multipart_get_part (mp, 0); - } + display_part = get_related_display_part (part, &displayid); if (display_part == NULL) { emf_multipart_mixed ( @@ -1891,6 +1923,7 @@ emf_multipart_related (EMFormat *emf, partidlen = emf->part_id->len; /* queue up the parts for possible inclusion */ + nparts = camel_multipart_get_number (mp); for (i = 0; i < nparts; i++) { body_part = camel_multipart_get_part (mp, i); if (body_part != display_part) { |