aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--em-format/e-mail-parser-message-deliverystatus.c2
-rw-r--r--em-format/e-mail-parser-message-external.c2
-rw-r--r--em-format/e-mail-parser-message-rfc822.c2
-rw-r--r--em-format/e-mail-parser-secure-button.c2
-rw-r--r--em-format/e-mail-parser-source.c2
-rw-r--r--em-format/e-mail-parser-text-html.c2
-rw-r--r--em-format/e-mail-parser-text-plain.c6
-rw-r--r--em-format/e-mail-parser.c2
-rw-r--r--em-format/e-mail-part.c13
-rw-r--r--em-format/e-mail-part.h2
-rw-r--r--modules/prefer-plain/e-mail-parser-prefer-plain.c2
11 files changed, 28 insertions, 9 deletions
diff --git a/em-format/e-mail-parser-message-deliverystatus.c b/em-format/e-mail-parser-message-deliverystatus.c
index 8e7fc8002f..9b672c52ba 100644
--- a/em-format/e-mail-parser-message-deliverystatus.c
+++ b/em-format/e-mail-parser-message-deliverystatus.c
@@ -58,7 +58,7 @@ empe_msg_deliverystatus_parse (EMailParserExtension *extension,
len = part_id->len;
g_string_append (part_id, ".delivery-status");
mail_part = e_mail_part_new (part, part_id->str);
- mail_part->mime_type = g_strdup ("text/plain");
+ e_mail_part_set_mime_type (mail_part, "text/plain");
g_string_truncate (part_id, len);
diff --git a/em-format/e-mail-parser-message-external.c b/em-format/e-mail-parser-message-external.c
index 1868796884..8668df5fba 100644
--- a/em-format/e-mail-parser-message-external.c
+++ b/em-format/e-mail-parser-message-external.c
@@ -160,7 +160,7 @@ addPart:
len = part_id->len;
g_string_append (part_id, ".msg_external");
mail_part = e_mail_part_new (part, part_id->str);
- mail_part->mime_type = g_strdup (mime_type);
+ e_mail_part_set_mime_type (mail_part, mime_type);
g_string_truncate (part_id, len);
g_queue_push_tail (out_mail_parts, mail_part);
diff --git a/em-format/e-mail-parser-message-rfc822.c b/em-format/e-mail-parser-message-rfc822.c
index 31bca87dbf..e9bfab15a3 100644
--- a/em-format/e-mail-parser-message-rfc822.c
+++ b/em-format/e-mail-parser-message-rfc822.c
@@ -66,7 +66,7 @@ empe_msg_rfc822_parse (EMailParserExtension *extension,
/* Create an empty PURI that will represent start of the RFC message */
mail_part = e_mail_part_new (part, part_id->str);
- mail_part->mime_type = g_strdup ("message/rfc822");
+ e_mail_part_set_mime_type (mail_part, "message/rfc822");
g_queue_push_tail (out_mail_parts, mail_part);
/* Sometime the actual message is encapsulated in another
diff --git a/em-format/e-mail-parser-secure-button.c b/em-format/e-mail-parser-secure-button.c
index 865bceca49..2e2d9967fb 100644
--- a/em-format/e-mail-parser-secure-button.c
+++ b/em-format/e-mail-parser-secure-button.c
@@ -55,7 +55,7 @@ empe_secure_button_parse (EMailParserExtension *extension,
len = part_id->len;
g_string_append (part_id, ".secure_button");
mail_part = e_mail_part_new (part, part_id->str);
- mail_part->mime_type = g_strdup ("application/vnd.evolution.widget.secure-button");
+ e_mail_part_set_mime_type (mail_part, parser_mime_types[0]);
g_string_truncate (part_id, len);
g_queue_push_tail (out_mail_parts, mail_part);
diff --git a/em-format/e-mail-parser-source.c b/em-format/e-mail-parser-source.c
index b13d34b92c..9a8759cb95 100644
--- a/em-format/e-mail-parser-source.c
+++ b/em-format/e-mail-parser-source.c
@@ -56,7 +56,7 @@ empe_source_parse (EMailParserExtension *extension,
g_string_append (part_id, ".source");
mail_part = e_mail_part_new (part, part_id->str);
- mail_part->mime_type = g_strdup ("application/vnd.evolution.source");
+ e_mail_part_set_mime_type (mail_part, parser_mime_types[0]);
g_string_truncate (part_id, len);
g_queue_push_tail (out_mail_parts, mail_part);
diff --git a/em-format/e-mail-parser-text-html.c b/em-format/e-mail-parser-text-html.c
index b9a4653728..bfb8cae2af 100644
--- a/em-format/e-mail-parser-text-html.c
+++ b/em-format/e-mail-parser-text-html.c
@@ -79,7 +79,7 @@ empe_text_html_parse (EMailParserExtension *extension,
g_string_append (part_id, ".text_html");
mail_part = e_mail_part_new (part, part_id->str);
- mail_part->mime_type = g_strdup ("text/html");
+ e_mail_part_set_mime_type (mail_part, "text/html");
e_mail_part_set_cid (mail_part, cid);
g_string_truncate (part_id, len);
diff --git a/em-format/e-mail-parser-text-plain.c b/em-format/e-mail-parser-text-plain.c
index 24b4b24344..c6f4d1e628 100644
--- a/em-format/e-mail-parser-text-plain.c
+++ b/em-format/e-mail-parser-text-plain.c
@@ -92,11 +92,15 @@ process_part (EMailParser *parser,
} else if (!camel_content_type_is (type, "text", "calendar")) {
GQueue work_queue = G_QUEUE_INIT;
+ gchar *mime_type;
g_string_append_printf (part_id, ".plain_text.%d", part_number);
mail_part = e_mail_part_new (part, part_id->str);
- mail_part->mime_type = camel_content_type_simple (type);
+
+ mime_type = camel_content_type_simple (type);
+ e_mail_part_set_mime_type (mail_part, mime_type);
+ g_free (mime_type);
g_string_truncate (part_id, s_len);
diff --git a/em-format/e-mail-parser.c b/em-format/e-mail-parser.c
index 08c008378c..46eec598f2 100644
--- a/em-format/e-mail-parser.c
+++ b/em-format/e-mail-parser.c
@@ -601,7 +601,7 @@ e_mail_parser_error (EMailParser *parser,
g_mutex_unlock (&parser->priv->mutex);
mail_part = e_mail_part_new (part, uri);
- mail_part->mime_type = g_strdup (mime_type);
+ e_mail_part_set_mime_type (mail_part, mime_type);
mail_part->is_error = TRUE;
g_free (uri);
diff --git a/em-format/e-mail-part.c b/em-format/e-mail-part.c
index 8633a36f11..07b606361d 100644
--- a/em-format/e-mail-part.c
+++ b/em-format/e-mail-part.c
@@ -254,6 +254,19 @@ e_mail_part_get_mime_type (EMailPart *part)
return part->mime_type;
}
+void
+e_mail_part_set_mime_type (EMailPart *part,
+ const gchar *mime_type)
+{
+ g_return_if_fail (part != NULL);
+
+ if (g_strcmp0 (mime_type, part->mime_type) == 0)
+ return;
+
+ g_free (part->mime_type);
+ part->mime_type = g_strdup (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 fb5edde58e..f4a1bcdf53 100644
--- a/em-format/e-mail-part.h
+++ b/em-format/e-mail-part.h
@@ -107,6 +107,8 @@ 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_set_mime_type (EMailPart *part,
+ const gchar *mime_type);
void e_mail_part_update_validity (EMailPart *part,
CamelCipherValidity *validity,
guint32 validity_type);
diff --git a/modules/prefer-plain/e-mail-parser-prefer-plain.c b/modules/prefer-plain/e-mail-parser-prefer-plain.c
index df23c79e19..32605dd406 100644
--- a/modules/prefer-plain/e-mail-parser-prefer-plain.c
+++ b/modules/prefer-plain/e-mail-parser-prefer-plain.c
@@ -120,7 +120,7 @@ make_part_attachment (EMailParser *parser,
len = part_id->len;
g_string_append (part_id, ".text_html");
mail_part = e_mail_part_new (part, part_id->str);
- mail_part->mime_type = g_strdup ("text/html");
+ e_mail_part_set_mime_type (mail_part, "text/html");
g_string_truncate (part_id, len);
g_queue_push_tail (&work_queue, mail_part);