[evolution/webkit: 58/105] 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/105] Treat parts with 'attachment' or 'inline' disposition as attachments.
- Date: Mon, 9 Jan 2012 08:44:37 +0000 (UTC)
commit eb316b7de626180cacd814d2c1590d22829045be
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 4a2a4e7..adaa3e9 100644
--- a/em-format/em-format.c
+++ b/em-format/em-format.c
@@ -1048,14 +1048,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);
}
@@ -1088,6 +1091,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);
}
@@ -1191,6 +1195,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);
@@ -1887,12 +1892,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 b2da91b..261edc0 100644
--- a/mail/em-format-html-display.c
+++ b/mail/em-format-html-display.c
@@ -146,7 +146,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
@@ -443,10 +446,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);
}
@@ -462,7 +465,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 a3219c5..9d81b69 100644
--- a/mail/em-format-html-print.c
+++ b/mail/em-format-html-print.c
@@ -253,7 +253,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
@@ -299,7 +305,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 170e226..1e96f6d 100644
--- a/mail/em-format-html.c
+++ b/mail/em-format-html.c
@@ -196,6 +196,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);
@@ -309,6 +310,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 {
@@ -362,7 +364,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);
@@ -507,7 +510,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]