[evolution/wip/camel-more-gobject] Seal CamelDataWrapper properties
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/wip/camel-more-gobject] Seal CamelDataWrapper properties
- Date: Wed, 2 Nov 2016 18:38:55 +0000 (UTC)
commit cff7a6e9ae2143c31f4c1f9b6369a6bb2eeafa3e
Author: Milan Crha <mcrha redhat com>
Date: Wed Nov 2 19:39:11 2016 +0100
Seal CamelDataWrapper properties
src/composer/e-msg-composer.c | 9 ++---
src/em-format/e-mail-formatter-text-plain.c | 4 +-
src/em-format/e-mail-formatter.c | 2 +-
src/em-format/e-mail-inline-filter.c | 7 ++--
src/em-format/e-mail-parser-multipart-encrypted.c | 3 +-
src/em-format/e-mail-parser-text-plain.c | 11 +++---
src/em-format/e-mail-part-utils.c | 35 +++++++++++----------
src/plugins/mail-to-task/mail-to-task.c | 8 +++--
8 files changed, 40 insertions(+), 39 deletions(-)
---
diff --git a/src/composer/e-msg-composer.c b/src/composer/e-msg-composer.c
index a5b6eff..01a9e71 100644
--- a/src/composer/e-msg-composer.c
+++ b/src/composer/e-msg-composer.c
@@ -1308,7 +1308,7 @@ composer_build_message (EMsgComposer *composer,
/* Avoid re-encoding the data when adding it to a MIME part. */
if (context->plain_encoding == CAMEL_TRANSFER_ENCODING_QUOTEDPRINTABLE)
- context->top_level_part->encoding = context->plain_encoding;
+ camel_data_wrapper_set_encoding (context->top_level_part, context->plain_encoding);
camel_data_wrapper_set_mime_type_field (
context->top_level_part, type);
@@ -1391,8 +1391,7 @@ composer_build_message (EMsgComposer *composer,
/* Avoid re-encoding the data when adding it to a MIME part. */
if (pre_encode)
- html->encoding =
- CAMEL_TRANSFER_ENCODING_QUOTEDPRINTABLE;
+ camel_data_wrapper_set_encoding (html, CAMEL_TRANSFER_ENCODING_QUOTEDPRINTABLE);
/* Build the multipart/alternative */
body = camel_multipart_new ();
@@ -1524,7 +1523,7 @@ composer_build_message_finish (EMsgComposer *composer,
content = camel_medium_get_content (imedium);
camel_medium_set_content (omedium, content);
- omedium->parent.encoding = imedium->parent.encoding;
+ camel_data_wrapper_set_encoding (CAMEL_DATA_WRAPPER (omedium),
camel_data_wrapper_get_encoding (CAMEL_DATA_WRAPPER (imedium)));
headers = camel_medium_dup_headers (imedium);
if (headers) {
@@ -3050,7 +3049,7 @@ add_attachments_from_multipart (EMsgComposer *composer,
gint i, nparts;
related = camel_content_type_is (
- CAMEL_DATA_WRAPPER (multipart)->mime_type,
+ camel_data_wrapper_get_mime_type_field (CAMEL_DATA_WRAPPER (multipart)),
"multipart", "related");
if (CAMEL_IS_MULTIPART_SIGNED (multipart)) {
diff --git a/src/em-format/e-mail-formatter-text-plain.c b/src/em-format/e-mail-formatter-text-plain.c
index d816d98..4a540ee 100644
--- a/src/em-format/e-mail-formatter-text-plain.c
+++ b/src/em-format/e-mail-formatter-text-plain.c
@@ -92,8 +92,8 @@ emfe_text_plain_format (EMailFormatterExtension *extension,
}
/* Check for RFC 2646 flowed text. */
- if (camel_content_type_is (dw->mime_type, "text", "plain")
- && (format = camel_content_type_param (dw->mime_type, "format"))
+ if (camel_content_type_is (camel_data_wrapper_get_mime_type_field (dw), "text", "plain")
+ && (format = camel_content_type_param (camel_data_wrapper_get_mime_type_field (dw), "format"))
&& !g_ascii_strcasecmp (format, "flowed"))
flags |= CAMEL_MIME_FILTER_TOHTML_FORMAT_FLOWED;
diff --git a/src/em-format/e-mail-formatter.c b/src/em-format/e-mail-formatter.c
index dbd47e2..fc48971 100644
--- a/src/em-format/e-mail-formatter.c
+++ b/src/em-format/e-mail-formatter.c
@@ -1065,7 +1065,7 @@ e_mail_formatter_format_text (EMailFormatter *formatter,
return;
mime_part = e_mail_part_ref_mime_part (part);
- mime_type = CAMEL_DATA_WRAPPER (mime_part)->mime_type;
+ mime_type = camel_data_wrapper_get_mime_type_field (CAMEL_DATA_WRAPPER (mime_part));
if (formatter->priv->charset != NULL) {
charset = formatter->priv->charset;
diff --git a/src/em-format/e-mail-inline-filter.c b/src/em-format/e-mail-inline-filter.c
index 91bfcfc..07df17a 100644
--- a/src/em-format/e-mail-inline-filter.c
+++ b/src/em-format/e-mail-inline-filter.c
@@ -168,9 +168,8 @@ inline_filter_add_part (EMailInlineFilter *emif,
content_type->subtype = g_strdup (emif_types[emif->state].subtype);
}
- camel_data_wrapper_set_mime_type_field (dw, content_type);
- camel_content_type_unref (content_type);
- dw->encoding = encoding;
+ camel_data_wrapper_take_mime_type_field (dw, content_type);
+ camel_data_wrapper_set_encoding (dw, encoding);
part = camel_mime_part_new ();
camel_medium_set_content ((CamelMedium *) part, dw);
@@ -181,7 +180,7 @@ inline_filter_add_part (EMailInlineFilter *emif,
camel_mime_part_set_filename (part, emif->filename);
/* pre-snoop the mime type of unknown objects, and poke and hack it into place */
- if (camel_content_type_is (dw->mime_type, "application", "octet-stream")
+ if (camel_content_type_is (camel_data_wrapper_get_mime_type_field (dw), "application", "octet-stream")
&& (mimetype = e_mail_part_snoop_type (part))
&& strcmp (mimetype, "application/octet-stream") != 0) {
camel_data_wrapper_set_mime_type (dw, mimetype);
diff --git a/src/em-format/e-mail-parser-multipart-encrypted.c
b/src/em-format/e-mail-parser-multipart-encrypted.c
index 11daa2d..2baa98f 100644
--- a/src/em-format/e-mail-parser-multipart-encrypted.c
+++ b/src/em-format/e-mail-parser-multipart-encrypted.c
@@ -72,8 +72,7 @@ empe_mp_encrypted_parse (EMailParserExtension *extension,
}
/* Currently we only handle RFC2015-style PGP encryption. */
- protocol = camel_content_type_param (
- ((CamelDataWrapper *) mpe)->mime_type, "protocol");
+ protocol = camel_content_type_param (camel_data_wrapper_get_mime_type_field (CAMEL_DATA_WRAPPER
(mpe)), "protocol");
if (!protocol || g_ascii_strcasecmp (protocol, "application/pgp-encrypted") != 0) {
e_mail_parser_error (
parser, out_mail_parts,
diff --git a/src/em-format/e-mail-parser-text-plain.c b/src/em-format/e-mail-parser-text-plain.c
index 572a84f..af3e259 100644
--- a/src/em-format/e-mail-parser-text-plain.c
+++ b/src/em-format/e-mail-parser-text-plain.c
@@ -126,19 +126,20 @@ empe_text_plain_parse (EMailParserExtension *extension,
/* FIXME: We should discard this multipart if it only contains
* the original text, but it makes this hash lookup more complex */
- if (!dw->mime_type)
+ if (!camel_data_wrapper_get_mime_type_field (dw))
snoop_type = e_mail_part_snoop_type (part);
/* if we had to snoop the part type to get here, then
* use that as the base type, yuck */
if (snoop_type == NULL
|| (type = camel_content_type_decode (snoop_type)) == NULL) {
- type = dw->mime_type;
+ type = camel_data_wrapper_get_mime_type_field (dw);
camel_content_type_ref (type);
}
- if (dw->mime_type && type != dw->mime_type && camel_content_type_param (dw->mime_type, "charset")) {
- camel_content_type_set_param (type, "charset", camel_content_type_param (dw->mime_type,
"charset"));
+ if (camel_data_wrapper_get_mime_type_field (dw) && type != camel_data_wrapper_get_mime_type_field
(dw) &&
+ camel_content_type_param (camel_data_wrapper_get_mime_type_field (dw), "charset")) {
+ camel_content_type_set_param (type, "charset", camel_content_type_param
(camel_data_wrapper_get_mime_type_field (dw), "charset"));
charset_added = TRUE;
}
@@ -164,7 +165,7 @@ empe_text_plain_parse (EMailParserExtension *extension,
is_attachment = e_mail_part_is_attachment (part);
if (is_attachment && CAMEL_IS_MIME_MESSAGE (part) &&
- !(camel_content_type_is (dw->mime_type, "text", "*")
+ !(camel_content_type_is (camel_data_wrapper_get_mime_type_field (dw), "text", "*")
&& camel_mime_part_get_filename (part) == NULL)) {
EMailPartAttachment *empa;
diff --git a/src/em-format/e-mail-part-utils.c b/src/em-format/e-mail-part-utils.c
index 011a041..edcd639 100644
--- a/src/em-format/e-mail-part-utils.c
+++ b/src/em-format/e-mail-part-utils.c
@@ -203,25 +203,26 @@ e_mail_part_is_attachment (CamelMimePart *part)
{
/*CamelContentType *ct = camel_mime_part_get_content_type(part);*/
CamelDataWrapper *dw = camel_medium_get_content ((CamelMedium *) part);
+ CamelContentType *mime_type;
if (!dw)
- return 0;
-
- d (printf ("checking is attachment %s/%s\n", dw->mime_type->type, dw->mime_type->subtype));
- return !(camel_content_type_is (dw->mime_type, "multipart", "*")
- || camel_content_type_is (
- dw->mime_type, "application", "x-pkcs7-mime")
- || camel_content_type_is (
- dw->mime_type, "application", "pkcs7-mime")
- || camel_content_type_is (
- dw->mime_type, "application", "x-inlinepgp-signed")
- || camel_content_type_is (
- dw->mime_type, "application", "x-inlinepgp-encrypted")
- || camel_content_type_is (
- dw->mime_type, "x-evolution", "evolution-rss-feed")
- || camel_content_type_is (dw->mime_type, "text", "calendar")
- || camel_content_type_is (dw->mime_type, "text", "x-calendar")
- || (camel_content_type_is (dw->mime_type, "text", "*")
+ return FALSE;
+
+ mime_type = camel_data_wrapper_get_mime_type_field (dw);
+
+ if (!mime_type)
+ return FALSE;
+
+ d (printf ("checking is attachment %s/%s\n", mime_type->type, mime_type->subtype));
+ return !(camel_content_type_is (mime_type, "multipart", "*")
+ || camel_content_type_is (mime_type, "application", "x-pkcs7-mime")
+ || camel_content_type_is (mime_type, "application", "pkcs7-mime")
+ || camel_content_type_is (mime_type, "application", "x-inlinepgp-signed")
+ || camel_content_type_is (mime_type, "application", "x-inlinepgp-encrypted")
+ || camel_content_type_is (mime_type, "x-evolution", "evolution-rss-feed")
+ || camel_content_type_is (mime_type, "text", "calendar")
+ || camel_content_type_is (mime_type, "text", "x-calendar")
+ || (camel_content_type_is (mime_type, "text", "*")
&& camel_mime_part_get_filename (part) == NULL));
}
diff --git a/src/plugins/mail-to-task/mail-to-task.c b/src/plugins/mail-to-task/mail-to-task.c
index 6d6e428..7099edb 100644
--- a/src/plugins/mail-to-task/mail-to-task.c
+++ b/src/plugins/mail-to-task/mail-to-task.c
@@ -209,7 +209,7 @@ set_description (ECalComponent *comp,
{
CamelDataWrapper *content;
CamelStream *stream;
- CamelContentType *type;
+ CamelContentType *type, *mime_type;
CamelMimePart *mime_part = CAMEL_MIME_PART (message);
ECalComponentText *text = NULL;
GByteArray *byte_array;
@@ -244,11 +244,13 @@ set_description (ECalComponent *comp,
str = g_strndup ((gchar *) byte_array->data, byte_array->len);
g_object_unref (stream);
+ mime_type = camel_data_wrapper_get_mime_type_field (content);
+
/* convert to UTF-8 string */
- if (str && content->mime_type->params && content->mime_type->params->value) {
+ if (str && mime_type && mime_type->params && mime_type->params->value) {
convert_str = g_convert (
str, strlen (str),
- "UTF-8", content->mime_type->params->value,
+ "UTF-8", mime_type->params->value,
&bytes_read, &bytes_written, NULL);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]