aboutsummaryrefslogtreecommitdiffstats
path: root/em-format
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2011-06-24 22:24:19 +0800
committerMilan Crha <mcrha@redhat.com>2011-06-24 22:24:19 +0800
commit11bf8dd07dae7a8884953dfa0077fd3da7028349 (patch)
tree40ddb9eb888753a57b2773e4ecb40cb67a85a324 /em-format
parent5b80f5d73b6db5abc318db6d88c113eb398f7799 (diff)
downloadgsoc2013-evolution-11bf8dd07dae7a8884953dfa0077fd3da7028349.tar
gsoc2013-evolution-11bf8dd07dae7a8884953dfa0077fd3da7028349.tar.gz
gsoc2013-evolution-11bf8dd07dae7a8884953dfa0077fd3da7028349.tar.bz2
gsoc2013-evolution-11bf8dd07dae7a8884953dfa0077fd3da7028349.tar.lz
gsoc2013-evolution-11bf8dd07dae7a8884953dfa0077fd3da7028349.tar.xz
gsoc2013-evolution-11bf8dd07dae7a8884953dfa0077fd3da7028349.tar.zst
gsoc2013-evolution-11bf8dd07dae7a8884953dfa0077fd3da7028349.zip
Bug #637402 - No quoted mail when replying to html email
Diffstat (limited to 'em-format')
-rw-r--r--em-format/em-format.c87
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) {