diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2013-05-19 01:17:33 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2013-05-20 01:07:21 +0800 |
commit | 0ee556d346fe8976b63d9eb1c929b41a101037e1 (patch) | |
tree | 86f9c4ebce2cd4537e19f8a0db54ed3d70dd973b | |
parent | f19058ea7a002e8ebf8351c55a86d3bb17a46cbc (diff) | |
download | gsoc2013-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().
-rw-r--r-- | em-format/e-mail-formatter-image.c | 2 | ||||
-rw-r--r-- | em-format/e-mail-formatter-print.c | 2 | ||||
-rw-r--r-- | em-format/e-mail-formatter-quote-attachment.c | 3 | ||||
-rw-r--r-- | em-format/e-mail-formatter-quote-text-enriched.c | 5 | ||||
-rw-r--r-- | em-format/e-mail-formatter-quote.c | 5 | ||||
-rw-r--r-- | em-format/e-mail-formatter-text-enriched.c | 6 | ||||
-rw-r--r-- | em-format/e-mail-formatter.c | 8 | ||||
-rw-r--r-- | em-format/e-mail-parser.c | 4 | ||||
-rw-r--r-- | em-format/e-mail-part.c | 8 | ||||
-rw-r--r-- | em-format/e-mail-part.h | 1 | ||||
-rw-r--r-- | mail/e-mail-request.c | 2 | ||||
-rw-r--r-- | mail/em-utils.c | 14 | ||||
-rw-r--r-- | modules/prefer-plain/e-mail-parser-prefer-plain.c | 5 |
13 files changed, 47 insertions, 18 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); diff --git a/mail/e-mail-request.c b/mail/e-mail-request.c index 1c88b74e33..b4ecfce501 100644 --- a/mail/e-mail-request.c +++ b/mail/e-mail-request.c @@ -161,7 +161,7 @@ handle_mail_request (GSimpleAsyncResult *res, g_object_unref (mime_part); } else { if (mime_type == NULL) - mime_type = part->mime_type; + mime_type = e_mail_part_get_mime_type (part); e_mail_formatter_format_as ( formatter, &context, part, diff --git a/mail/em-utils.c b/mail/em-utils.c index 3e3f9f022b..fa6e704369 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -1215,6 +1215,7 @@ is_only_text_part_in_this_level (GList *parts, level_len = dot - text_html_part_id; for (iter = parts; iter; iter = iter->next) { EMailPart *part = E_MAIL_PART (iter->data); + const gchar *mime_type; const gchar *part_id; if (part == NULL) @@ -1229,7 +1230,8 @@ is_only_text_part_in_this_level (GList *parts, if (part->is_attachment) continue; - if (part->mime_type == NULL) + mime_type = e_mail_part_get_mime_type (part); + if (mime_type == NULL) continue; part_id = e_mail_part_get_id (part); @@ -1238,7 +1240,7 @@ is_only_text_part_in_this_level (GList *parts, strncmp (text_html_part_id, part_id, level_len) != 0) continue; - if (g_ascii_strncasecmp (part->mime_type, "text/", 5) == 0) + if (g_ascii_strncasecmp (mime_type, "text/", 5) == 0) return FALSE; } @@ -1321,12 +1323,16 @@ em_utils_message_to_html (CamelSession *session, for (link = head; link != NULL; link = g_list_next (link)) { EMailPart *part = link->data; GList *vhead, *vlink; + const gchar *mime_type; + + mime_type = e_mail_part_get_mime_type (part); /* prefer-plain can hide HTML parts, even when it's the only * text part in the email, thus show it (and hide again later) */ if (part->is_hidden && !hidden_text_html_part && - part->mime_type && !part->is_attachment && - g_ascii_strcasecmp (part->mime_type, "text/html") == 0 && + mime_type != NULL && + !part->is_attachment && + g_ascii_strcasecmp (mime_type, "text/html") == 0 && is_only_text_part_in_this_level (head, part)) { part->is_hidden = FALSE; hidden_text_html_part = part; diff --git a/modules/prefer-plain/e-mail-parser-prefer-plain.c b/modules/prefer-plain/e-mail-parser-prefer-plain.c index c09c70d7f8..df23c79e19 100644 --- a/modules/prefer-plain/e-mail-parser-prefer-plain.c +++ b/modules/prefer-plain/e-mail-parser-prefer-plain.c @@ -318,8 +318,11 @@ empe_prefer_plain_parse (EMailParserExtension *extension, for (qiter = g_queue_peek_head_link (&work_queue); qiter; qiter = g_list_next (qiter)) { EMailPart *mpart = qiter->data; + const gchar *mime_type; - if (mpart && mpart->is_hidden && g_strcmp0 (mpart->mime_type, "text/html") == 0) { + mime_type = e_mail_part_get_mime_type (mpart); + + if (mpart && mpart->is_hidden && g_strcmp0 (mime_type, "text/html") == 0) { mpart->is_attachment = TRUE; } } |