[evolution/webkit: 58/171] Treat parts with 'attachment' or 'inline' disposition as attachments.
- From: Dan VrÃtil <dvratil src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/webkit: 58/171] Treat parts with 'attachment' or 'inline' disposition as attachments.
- Date: Fri, 24 Feb 2012 12:39:19 +0000 (UTC)
commit 1a58ec904d4bcd0b5f5d7a3d73d392caf78a8166
Author: Dan VrÃtil <dvratil redhat com>
Date: Thu Nov 24 18:25:26 2011 +0100
Treat parts with 'attachment' or 'inline' disposition as attachments.
The attachments parser can then decided how to display them.
em-format/em-format.c | 22 +++++++++++++++++++++-
em-format/em-format.h | 3 +++
mail/em-format-html-display.c | 9 ++++++---
mail/em-format-html-print.c | 12 ++++++++++--
mail/em-format-html.c | 8 ++++++--
5 files changed, 46 insertions(+), 8 deletions(-)
---
diff --git a/em-format/em-format.c b/em-format/em-format.c
index e923ce3..4ed5ed4 100644
--- a/em-format/em-format.c
+++ b/em-format/em-format.c
@@ -1052,14 +1052,17 @@ emf_parse_message (EMFormat *emf,
GCancellable *cancellable)
{
/* Headers */
+ info->force_handler = TRUE;
em_format_parse_part_as (emf, part, part_id, info,
"x-evolution/message/headers", cancellable);
/* Anything that comes between headers and message body */
+ info->force_handler = TRUE;
em_format_parse_part_as (emf, part, part_id, info,
"x-evolution/message/post-headers", cancellable);
/* Begin parsing the message */
+ info->force_handler = FALSE;
em_format_parse_part (emf, part, part_id, info, cancellable);
}
@@ -1092,6 +1095,7 @@ emf_parse_post_headers (EMFormat *emf,
GCancellable *cancellable)
{
/* Add attachment bar */
+ info->force_handler = TRUE;
em_format_parse_part_as (emf, part, part_id, info,
"x-evolution/message/attachment-bar", cancellable);
}
@@ -1195,6 +1199,7 @@ emf_parse (EMFormat *emf,
puri->mime_type = g_strdup ("text/html");
em_format_add_puri (emf, puri);
+ info.force_handler = TRUE;
em_format_parse_part_as (emf, CAMEL_MIME_PART (message), part_id, &info,
"x-evolution/message", cancellable);
@@ -1891,12 +1896,27 @@ em_format_parse_part_as (EMFormat *emf,
GCancellable *cancellable)
{
const EMFormatHandler *handler;
+ const CamelContentDisposition *disposition;
EMFormatParserInfo ninfo = {
0,
info ? info->validity_type : 0,
- info ? info->validity : 0
+ info ? info->validity : 0,
+ 0,
};
+ /* Let everything that claims to be an attachment or inlined part to be parsed
+ * as an attachment. The parser will decide how to display it. */
+ disposition = camel_mime_part_get_content_disposition (part);
+ if (!info->force_handler && disposition &&
+ ((g_strcmp0 (disposition->disposition, "attachment") == 0) ||
+ (g_strcmp0 (disposition->disposition, "inline") == 0))) {
+ ninfo.is_attachment = TRUE;
+ handler = em_format_find_handler (emf, "x-evolution/message/attachment");
+ ninfo.handler = handler;
+ handler->parse_func (emf, part, part_id, &ninfo, cancellable);
+ return;
+ }
+
handler = em_format_find_handler (emf, mime_type);
if (handler) {
ninfo.handler = handler;
diff --git a/em-format/em-format.h b/em-format/em-format.h
index 1422b18..dacf7b0 100644
--- a/em-format/em-format.h
+++ b/em-format/em-format.h
@@ -113,6 +113,9 @@ struct _EMFormatParserInfo {
/* EM_FORMAT_VALIDITY_* flags */
guint32 validity_type;
CamelCipherValidity *validity;
+
+ gint is_attachment : 1;
+ gint force_handler: 1;
};
struct _EMFormatWriterInfo {
diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c
index bd37e32..48a81d7 100644
--- a/mail/em-format-html-display.c
+++ b/mail/em-format-html-display.c
@@ -150,7 +150,10 @@ find_parent_attachment_store (EMFormatHTMLDisplay *efhd, GString *part_id)
abp = (EMFormatAttachmentBarPURI *) puri;
- return abp->store;
+ if (abp)
+ return abp->store;
+ else
+ return NULL;
}
static void
@@ -457,10 +460,10 @@ efhd_parse_attachment (EMFormat *emf,
len = part_id->len;
g_string_append (part_id, ".attachment");
+ /* Try to find handler for the mime part */
ct = camel_mime_part_get_content_type (part);
if (ct) {
mime_type = camel_content_type_simple (ct);
-
handler = em_format_find_handler (emf, mime_type);
}
@@ -476,7 +479,7 @@ efhd_parse_attachment (EMFormat *emf,
emf, sizeof (EMFormatAttachmentPURI), part, part_id->str);
puri->puri.free = efhd_free_attach_puri_data;
puri->puri.widget_func = efhd_attachment_button;
- puri->shown = em_format_is_inline (emf, part_id->str, part, info->handler);
+ puri->shown = em_format_is_inline (emf, part_id->str, part, handler);
puri->snoop_mime_type = em_format_snoop_type (part);
puri->attachment = e_attachment_new ();
puri->attachment_view_part_id = g_strdup (part_id->str);
diff --git a/mail/em-format-html-print.c b/mail/em-format-html-print.c
index c9fedcd..b5051c7 100644
--- a/mail/em-format-html-print.c
+++ b/mail/em-format-html-print.c
@@ -256,7 +256,13 @@ efhp_write_inline_attachment (EMFormat *emf,
EMFormatWriterInfo *info,
GCancellable *cancellable)
{
-
+ GString *str;
+
+ str = g_string_new ("<div style=\"border: 1px solid #000; width: 100%\">");
+ g_string_append_printf (str, "<p>Inlining PURI <code>%s</code></p></div>", puri->uri);
+
+ camel_stream_write_string (stream, str->str, cancellable, NULL);
+ g_string_free (str, TRUE);
}
static void
@@ -302,7 +308,9 @@ efhp_write_print_layout (EMFormat *emf,
gchar *mime_type = camel_content_type_simple (ct);
handler = em_format_find_handler (puri->emf, mime_type);
- g_free (mime_type);
+ g_message ("Handler for PURI %s (%s): %s", puri->uri, mime_type,
+ handler ? handler->mime_type : "(null)");
+ g_free (mime_type);
efhp->priv->attachments =
g_list_append (efhp->priv->attachments, puri);
diff --git a/mail/em-format-html.c b/mail/em-format-html.c
index 4abfbae..1268dbd 100644
--- a/mail/em-format-html.c
+++ b/mail/em-format-html.c
@@ -199,6 +199,7 @@ efh_parse_text_enriched (EMFormat *emf,
puri->write_func = efh_write_text_enriched;
puri->validity = info->validity ? camel_cipher_validity_clone (info->validity) : NULL;
puri->validity_type = info->validity_type;
+ puri->is_attachment = info->is_attachment;
em_format_add_puri (emf, puri);
g_string_truncate (part_id, len);
@@ -312,6 +313,7 @@ efh_parse_text_plain (EMFormat *emf,
puri->mime_type = g_strdup ("text/html");
puri->validity = info->validity ? camel_cipher_validity_clone (info->validity) : NULL;
puri->validity_type = info->validity_type;
+ puri->is_attachment = info->is_attachment;
g_string_truncate (part_id, s_len);
em_format_add_puri (emf, puri);
} else {
@@ -365,7 +367,8 @@ efh_parse_text_html (EMFormat *emf,
puri = em_format_puri_new (emf, sizeof (EMFormatPURI), part, part_id->str);
puri->write_func = efh_write_text_html;
puri->validity = info->validity ? camel_cipher_validity_clone (info->validity) : NULL;
- puri->validity_type = info->validity_type;
+ puri->validity_type = info->validity_type;
+ puri->is_attachment = info->is_attachment;
em_format_add_puri (emf, puri);
g_string_truncate (part_id, len);
@@ -510,7 +513,8 @@ efh_parse_message_deliverystatus (EMFormat *emf,
puri->write_func = efh_write_source;
puri->mime_type = g_strdup ("text/html");
puri->validity = info->validity ? camel_cipher_validity_clone (info->validity) : NULL;
- puri->validity_type = info->validity_type;
+ puri->validity_type = info->validity_type;
+ puri->is_attachment = info->is_attachment;
em_format_add_puri (emf, puri);
g_string_truncate (part_id, len);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]