aboutsummaryrefslogtreecommitdiffstats
path: root/em-format
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2013-05-19 01:17:33 +0800
committerMatthew Barnes <mbarnes@redhat.com>2013-05-20 01:07:21 +0800
commit0ee556d346fe8976b63d9eb1c929b41a101037e1 (patch)
tree86f9c4ebce2cd4537e19f8a0db54ed3d70dd973b /em-format
parentf19058ea7a002e8ebf8351c55a86d3bb17a46cbc (diff)
downloadgsoc2013-evolution-0ee556d346fe8976b63d9eb1c929b41a101037e1.tar
gsoc2013-evolution-0ee556d346fe8976b63d9eb1c929b41a101037e1.tar.gz
gsoc2013-evolution-0ee556d346fe8976b63d9eb1c929b41a101037e1.tar.bz2
gsoc2013-evolution-0ee556d346fe8976b63d9eb1c929b41a101037e1.tar.lz
gsoc2013-evolution-0ee556d346fe8976b63d9eb1c929b41a101037e1.tar.xz
gsoc2013-evolution-0ee556d346fe8976b63d9eb1c929b41a101037e1.tar.zst
gsoc2013-evolution-0ee556d346fe8976b63d9eb1c929b41a101037e1.zip
Add e_mail_part_get_mime_type().
Diffstat (limited to 'em-format')
-rw-r--r--em-format/e-mail-formatter-image.c2
-rw-r--r--em-format/e-mail-formatter-print.c2
-rw-r--r--em-format/e-mail-formatter-quote-attachment.c3
-rw-r--r--em-format/e-mail-formatter-quote-text-enriched.c5
-rw-r--r--em-format/e-mail-formatter-quote.c5
-rw-r--r--em-format/e-mail-formatter-text-enriched.c6
-rw-r--r--em-format/e-mail-formatter.c8
-rw-r--r--em-format/e-mail-parser.c4
-rw-r--r--em-format/e-mail-part.c8
-rw-r--r--em-format/e-mail-part.h1
10 files changed, 32 insertions, 12 deletions
diff --git a/em-format/e-mail-formatter-image.c b/em-format/e-mail-formatter-image.c
index c504881f27..c3330e0db3 100644
--- a/em-format/e-mail-formatter-image.c
+++ b/em-format/e-mail-formatter-image.c
@@ -123,7 +123,7 @@ emfe_image_format (EMailFormatterExtension *extension,
content = g_base64_encode ((guchar *) ba->data, ba->len);
}
- mime_type = part->mime_type;
+ mime_type = e_mail_part_get_mime_type (part);
if (mime_type == NULL)
mime_type = "image/*";
diff --git a/em-format/e-mail-formatter-print.c b/em-format/e-mail-formatter-print.c
index ccbdeea9de..d193c062d8 100644
--- a/em-format/e-mail-formatter-print.c
+++ b/em-format/e-mail-formatter-print.c
@@ -144,7 +144,7 @@ mail_formatter_print_run (EMailFormatter *formatter,
continue;
}
- mime_type = part->mime_type;
+ mime_type = e_mail_part_get_mime_type (part);
if (mime_type == NULL)
continue;
diff --git a/em-format/e-mail-formatter-quote-attachment.c b/em-format/e-mail-formatter-quote-attachment.c
index 3443392555..e098a02ae3 100644
--- a/em-format/e-mail-formatter-quote-attachment.c
+++ b/em-format/e-mail-formatter-quote-attachment.c
@@ -78,7 +78,8 @@ emfqe_attachment_format (EMailFormatterExtension *extension,
mime_part = e_mail_part_ref_mime_part (part);
text = e_mail_part_describe (
mime_part,
- empa ? empa->snoop_mime_type : part->mime_type);
+ empa ? empa->snoop_mime_type :
+ e_mail_part_get_mime_type (part));
g_object_unref (mime_part);
html = camel_text_to_html (
diff --git a/em-format/e-mail-formatter-quote-text-enriched.c b/em-format/e-mail-formatter-quote-text-enriched.c
index 780548b1f0..06a67592a7 100644
--- a/em-format/e-mail-formatter-quote-text-enriched.c
+++ b/em-format/e-mail-formatter-quote-text-enriched.c
@@ -55,9 +55,12 @@ emqfe_text_enriched_format (EMailFormatterExtension *extension,
{
CamelStream *filtered_stream;
CamelMimeFilter *enriched;
+ const gchar *mime_type;
guint32 camel_flags = 0;
- if (g_strcmp0 (part->mime_type, "text/richtext") == 0) {
+ mime_type = e_mail_part_get_mime_type (part);
+
+ if (g_strcmp0 (mime_type, "text/richtext") == 0) {
camel_flags = CAMEL_MIME_FILTER_ENRICHED_IS_RICHTEXT;
camel_stream_write_string (
stream, "\n<!-- text/richtext -->\n",
diff --git a/em-format/e-mail-formatter-quote.c b/em-format/e-mail-formatter-quote.c
index 837b810267..12978f6978 100644
--- a/em-format/e-mail-formatter-quote.c
+++ b/em-format/e-mail-formatter-quote.c
@@ -104,6 +104,7 @@ mail_formatter_quote_run (EMailFormatter *formatter,
for (link = head; link != NULL; link = g_list_next (link)) {
EMailPart *part = E_MAIL_PART (link->data);
+ const gchar *mime_type;
if (e_mail_part_id_has_suffix (part, ".headers") &&
!(qf_context->qf_flags & E_MAIL_FORMATTER_QUOTE_FLAG_HEADERS)) {
@@ -121,9 +122,11 @@ mail_formatter_quote_run (EMailFormatter *formatter,
if (part->is_attachment)
continue;
+ mime_type = e_mail_part_get_mime_type (part);
+
e_mail_formatter_format_as (
formatter, context, part, stream,
- part->mime_type, cancellable);
+ mime_type, cancellable);
}
while (!g_queue_is_empty (&queue))
diff --git a/em-format/e-mail-formatter-text-enriched.c b/em-format/e-mail-formatter-text-enriched.c
index 3859558aaf..6c3b033171 100644
--- a/em-format/e-mail-formatter-text-enriched.c
+++ b/em-format/e-mail-formatter-text-enriched.c
@@ -53,15 +53,17 @@ emfe_text_enriched_format (EMailFormatterExtension *extension,
{
CamelStream *filtered_stream;
CamelMimeFilter *enriched;
+ const gchar *mime_type;
guint32 filter_flags = 0;
GString *buffer;
if (g_cancellable_is_cancelled (cancellable))
return FALSE;
- if (!g_strcmp0 (part->mime_type, "text/richtext")) {
+ mime_type = e_mail_part_get_mime_type (part);
+
+ if (g_strcmp0 (mime_type, "text/richtext") == 0)
filter_flags = CAMEL_MIME_FILTER_ENRICHED_IS_RICHTEXT;
- }
enriched = camel_mime_filter_enriched_new (filter_flags);
filtered_stream = camel_stream_filter_new (stream);
diff --git a/em-format/e-mail-formatter.c b/em-format/e-mail-formatter.c
index 4ce93a7db2..5b00753130 100644
--- a/em-format/e-mail-formatter.c
+++ b/em-format/e-mail-formatter.c
@@ -417,13 +417,15 @@ mail_formatter_run (EMailFormatter *formatter,
/* Force formatting as source if needed */
if (context->mode != E_MAIL_FORMATTER_MODE_SOURCE) {
+ const gchar *mime_type;
- if (!part->mime_type)
+ mime_type = e_mail_part_get_mime_type (part);
+ if (mime_type == NULL)
continue;
ok = e_mail_formatter_format_as (
formatter, context, part, stream,
- part->mime_type, cancellable);
+ mime_type, cancellable);
/* If the written part was message/rfc822 then
* jump to the end of the message, because content
@@ -967,7 +969,7 @@ e_mail_formatter_format_as (EMailFormatter *formatter,
g_return_val_if_fail (CAMEL_IS_STREAM (stream), FALSE);
if (as_mime_type == NULL || *as_mime_type == '\0')
- as_mime_type = part->mime_type;
+ as_mime_type = e_mail_part_get_mime_type (part);
if (as_mime_type == NULL || *as_mime_type == '\0')
return FALSE;
diff --git a/em-format/e-mail-parser.c b/em-format/e-mail-parser.c
index dbff9e5f77..08c008378c 100644
--- a/em-format/e-mail-parser.c
+++ b/em-format/e-mail-parser.c
@@ -365,7 +365,7 @@ e_mail_parser_parse_sync (EMailParser *parser,
"is_hidden: %d | is_attachment: %d\n",
e_mail_part_get_id (part),
e_mail_part_get_cid (part),
- part->mime_type,
+ e_mail_part_get_mime_type (part),
part->is_hidden ? 1 : 0,
part->is_attachment ? 1 : 0);
@@ -469,7 +469,7 @@ e_mail_parser_parse_finish (EMailParser *parser,
"is_hidden: %d | is_attachment: %d\n",
e_mail_part_get_id (part),
e_mail_part_get_cid (part),
- part->mime_type,
+ e_mail_part_get_mime_type (part),
part->is_hidden ? 1 : 0,
part->is_attachment ? 1 : 0);
diff --git a/em-format/e-mail-part.c b/em-format/e-mail-part.c
index 68434d0ce9..8633a36f11 100644
--- a/em-format/e-mail-part.c
+++ b/em-format/e-mail-part.c
@@ -246,6 +246,14 @@ e_mail_part_ref_mime_part (EMailPart *part)
return mime_part;
}
+const gchar *
+e_mail_part_get_mime_type (EMailPart *part)
+{
+ g_return_val_if_fail (part != NULL, NULL);
+
+ return part->mime_type;
+}
+
static EMailPartValidityPair *
mail_part_find_validity_pair (EMailPart *part,
guint32 validity_type)
diff --git a/em-format/e-mail-part.h b/em-format/e-mail-part.h
index 3e9c7111d7..fb5edde58e 100644
--- a/em-format/e-mail-part.h
+++ b/em-format/e-mail-part.h
@@ -106,6 +106,7 @@ gboolean e_mail_part_id_has_suffix (EMailPart *part,
gboolean e_mail_part_id_has_substr (EMailPart *part,
const gchar *substr);
CamelMimePart * e_mail_part_ref_mime_part (EMailPart *part);
+const gchar * e_mail_part_get_mime_type (EMailPart *part);
void e_mail_part_update_validity (EMailPart *part,
CamelCipherValidity *validity,
guint32 validity_type);