[evolution] Bug 764065 - [Camel] Port more classes to GObject
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] Bug 764065 - [Camel] Port more classes to GObject
- Date: Tue, 8 Nov 2016 14:51:44 +0000 (UTC)
commit 8b74f914600ad958c5c1696b98221611a1a0f4f4
Author: Milan Crha <mcrha redhat com>
Date: Tue Nov 8 15:51:20 2016 +0100
Bug 764065 - [Camel] Port more classes to GObject
src/composer/e-msg-composer.c | 89 ++++++-------
src/e-util/e-attachment.c | 9 +-
src/em-format/e-mail-formatter-headers.c | 71 ++++++----
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 +-
.../e-mail-parser-multipart-alternative.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-headers.c | 28 ++--
src/em-format/e-mail-part-utils.c | 35 +++---
src/libemail-engine/e-mail-folder-utils.c | 48 +++----
src/libemail-engine/e-mail-session-utils.c | 77 ++++--------
src/libemail-engine/e-mail-session.c | 6 +-
src/libemail-engine/e-mail-utils.c | 6 +-
src/libemail-engine/mail-folder-cache.c | 55 +++++----
src/libemail-engine/mail-ops.c | 46 +++----
src/libemail-engine/mail-tools.c | 62 ++++++---
src/libemail-engine/mail-tools.h | 17 ++-
src/libemail-engine/mail-vfolder.c | 4 +-
src/mail/e-mail-backend.c | 2 +-
src/mail/e-mail-browser.c | 5 +-
src/mail/e-mail-config-defaults-page.c | 2 +-
src/mail/e-mail-display.c | 2 +-
src/mail/e-mail-folder-create-dialog.c | 2 +-
src/mail/e-mail-folder-pane.c | 2 +-
src/mail/e-mail-notes.c | 8 +-
src/mail/e-mail-properties.c | 6 +-
src/mail/e-mail-reader-utils.c | 93 ++++++++------
src/mail/e-mail-reader.c | 14 +-
src/mail/e-mail-remote-content.c | 6 +-
src/mail/e-mail-tag-editor.c | 139 ++++++++------------
src/mail/e-mail-tag-editor.h | 10 +-
src/mail/em-composer-utils.c | 4 +-
src/mail/em-folder-properties.c | 8 +-
src/mail/em-utils.c | 54 +++++---
src/mail/importers/mail-importer.c | 4 +-
src/mail/mail-autofilter.c | 9 +-
src/mail/message-list.c | 84 +++++++-----
src/modules/itip-formatter/itip-view.c | 2 +-
src/modules/mail/e-mail-shell-backend.c | 2 +-
src/modules/mail/e-mail-shell-view-actions.c | 4 +-
src/modules/mail/e-mail-shell-view-private.c | 17 ++-
src/modules/mdn/evolution-mdn.c | 19 +--
src/plugins/dbx-import/dbx-importer.c | 2 +-
src/plugins/mail-to-task/mail-to-task.c | 30 ++--
src/plugins/pst-import/pst-importer.c | 2 +-
src/plugins/templates/e-templates-store.c | 12 +-
src/plugins/templates/templates.c | 87 +++++++-----
49 files changed, 611 insertions(+), 607 deletions(-)
---
diff --git a/src/composer/e-msg-composer.c b/src/composer/e-msg-composer.c
index 8f096aa..4833496 100644
--- a/src/composer/e-msg-composer.c
+++ b/src/composer/e-msg-composer.c
@@ -265,22 +265,6 @@ emcu_part_to_html (EMsgComposer *composer,
return text;
}
-/* copy of mail_tool_remove_xevolution_headers */
-static struct _camel_header_raw *
-emcu_remove_xevolution_headers (CamelMimeMessage *message)
-{
- struct _camel_header_raw *scan, *list = NULL;
-
- for (scan = ((CamelMimePart *) message)->headers; scan; scan = scan->next)
- if (!strncmp (scan->name, "X-Evolution", 11))
- camel_header_raw_append (&list, scan->name, scan->value, scan->offset);
-
- for (scan = list; scan; scan = scan->next)
- camel_medium_remove_header ((CamelMedium *) message, scan->name);
-
- return list;
-}
-
static EDestination **
destination_list_to_vector_sized (GList *list,
gint n)
@@ -1311,7 +1295,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);
@@ -1394,8 +1378,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 ();
@@ -1520,26 +1503,27 @@ composer_build_message_finish (EMsgComposer *composer,
CAMEL_IS_MIME_PART (context->top_level_part)) {
CamelDataWrapper *content;
CamelMedium *imedium, *omedium;
- GArray *headers;
+ const CamelNameValueArray *headers;
imedium = CAMEL_MEDIUM (context->top_level_part);
omedium = CAMEL_MEDIUM (context->message);
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_get_headers (imedium);
if (headers) {
- gint ii;
+ gint ii, length;
+ length = camel_name_value_array_get_length (headers);
- for (ii = 0; ii < headers->len; ii++) {
- CamelMediumHeader *hdr = &g_array_index (headers, CamelMediumHeader,
ii);
+ for (ii = 0; ii < length; ii++) {
+ const gchar *header_name = NULL;
+ const gchar *header_value = NULL;
- camel_medium_set_header (omedium, hdr->name, hdr->value);
+ if (camel_name_value_array_get (headers, ii, &header_name,
&header_value))
+ camel_medium_set_header (omedium, header_name, header_value);
}
-
- camel_medium_free_headers (imedium, headers);
}
} else {
camel_medium_set_content (
@@ -3063,7 +3047,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)) {
@@ -3556,7 +3540,7 @@ e_msg_composer_setup_with_message (EMsgComposer *composer,
EDestination **Tov, **Ccv, **Bccv;
GHashTable *auto_cc, *auto_bcc;
CamelContentType *content_type;
- struct _camel_header_raw *headers;
+ const CamelNameValueArray *headers;
CamelDataWrapper *content;
EMsgComposerPrivate *priv;
EComposerHeaderTable *table;
@@ -3564,23 +3548,27 @@ e_msg_composer_setup_with_message (EMsgComposer *composer,
EHTMLEditor *editor;
EContentEditor *cnt_editor;
GtkToggleAction *action;
- struct _camel_header_raw *xev;
gchar *identity_uid, *tmp = NULL;
gint len, i;
+ guint jj, jjlen;
gboolean is_message_from_draft = FALSE;
g_return_if_fail (E_IS_MSG_COMPOSER (composer));
- headers = CAMEL_MIME_PART (message)->headers;
- while (headers != NULL) {
+ headers = camel_medium_get_headers (CAMEL_MEDIUM (message));
+ jjlen = camel_name_value_array_get_length (headers);
+ for (jj = 0; jj < jjlen; jj++) {
+ const gchar *header_name = NULL, *header_value = NULL;
gchar *value;
- if (strcmp (headers->name, "X-Evolution-PostTo") == 0) {
- value = g_strstrip (g_strdup (headers->value));
+ if (!camel_name_value_array_get (headers, jj, &header_name, &header_value) ||
+ !header_name)
+ continue;
+
+ if (g_ascii_strcasecmp (header_name, "X-Evolution-PostTo") == 0) {
+ value = g_strstrip (g_strdup (header_value));
postto = g_list_append (postto, value);
}
-
- headers = headers->next;
}
priv = E_MSG_COMPOSER_GET_PRIVATE (composer);
@@ -3645,7 +3633,7 @@ e_msg_composer_setup_with_message (EMsgComposer *composer,
cc = camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_CC);
bcc = camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_BCC);
- len = CAMEL_ADDRESS (to)->addresses->len;
+ len = camel_address_length (CAMEL_ADDRESS (to));
for (i = 0; i < len; i++) {
const gchar *name, *addr;
@@ -3660,7 +3648,7 @@ e_msg_composer_setup_with_message (EMsgComposer *composer,
Tov = destination_list_to_vector (To);
g_list_free (To);
- len = CAMEL_ADDRESS (cc)->addresses->len;
+ len = camel_address_length (CAMEL_ADDRESS (cc));
for (i = 0; i < len; i++) {
const gchar *name, *addr;
@@ -3680,7 +3668,7 @@ e_msg_composer_setup_with_message (EMsgComposer *composer,
g_hash_table_destroy (auto_cc);
g_list_free (Cc);
- len = CAMEL_ADDRESS (bcc)->addresses->len;
+ len = camel_address_length (CAMEL_ADDRESS (bcc));
for (i = 0; i < len; i++) {
const gchar *name, *addr;
@@ -3796,8 +3784,7 @@ e_msg_composer_setup_with_message (EMsgComposer *composer,
}
/* Remove any other X-Evolution-* headers that may have been set */
- xev = emcu_remove_xevolution_headers (message);
- camel_header_raw_clear (&xev);
+ camel_name_value_array_free (mail_tool_remove_xevolution_headers (message));
/* Check for receipt request */
if (camel_medium_get_header (
@@ -3813,19 +3800,23 @@ e_msg_composer_setup_with_message (EMsgComposer *composer,
}
/* set extra headers */
- headers = CAMEL_MIME_PART (message)->headers;
- while (headers) {
- if (g_ascii_strcasecmp (headers->name, "References") == 0 ||
- g_ascii_strcasecmp (headers->name, "In-Reply-To") == 0) {
+ headers = camel_medium_get_headers (CAMEL_MEDIUM (message));
+ jjlen = camel_name_value_array_get_length (headers);
+ for (jj = 0; jj < jjlen; jj++) {
+ const gchar *header_name = NULL, *header_value = NULL;
+
+ if (!camel_name_value_array_get (headers, jj, &header_name, &header_value) || !header_name)
+ continue;
+
+ if (g_ascii_strcasecmp (header_name, "References") == 0 ||
+ g_ascii_strcasecmp (header_name, "In-Reply-To") == 0) {
g_ptr_array_add (
composer->priv->extra_hdr_names,
- g_strdup (headers->name));
+ g_strdup (header_name));
g_ptr_array_add (
composer->priv->extra_hdr_values,
- camel_header_unfold (headers->value));
+ camel_header_unfold (header_value));
}
-
- headers = headers->next;
}
/* Restore the attachments and body text */
diff --git a/src/e-util/e-attachment.c b/src/e-util/e-attachment.c
index 2c3ec5b..a45302d 100644
--- a/src/e-util/e-attachment.c
+++ b/src/e-util/e-attachment.c
@@ -2168,7 +2168,7 @@ attachment_load_from_mime_part_thread (GSimpleAsyncResult *simple,
const gchar *attribute;
const gchar *string;
gchar *allocated, *decoded_string = NULL;
- CamelStream *null;
+ gsize bytes_written;
CamelDataWrapper *dw;
load_context = g_object_get_data (
@@ -2267,12 +2267,9 @@ attachment_load_from_mime_part_thread (GSimpleAsyncResult *simple,
file_info, attribute, string);
dw = camel_medium_get_content (CAMEL_MEDIUM (mime_part));
- null = camel_stream_null_new ();
/* this actually downloads the part and makes it available later */
- camel_data_wrapper_decode_to_stream_sync (
- dw, null, attachment->priv->cancellable, NULL);
- g_file_info_set_size (file_info, CAMEL_STREAM_NULL (null)->written);
- g_object_unref (null);
+ bytes_written = camel_data_wrapper_calculate_decoded_size_sync (dw, attachment->priv->cancellable,
NULL);
+ g_file_info_set_size (file_info, bytes_written);
load_context->mime_part = g_object_ref (mime_part);
diff --git a/src/em-format/e-mail-formatter-headers.c b/src/em-format/e-mail-formatter-headers.c
index a397cb0..0346865 100644
--- a/src/em-format/e-mail-formatter-headers.c
+++ b/src/em-format/e-mail-formatter-headers.c
@@ -59,7 +59,8 @@ format_short_headers (EMailFormatter *formatter,
gchar *evolution_imagesdir;
gchar *subject = NULL;
struct _camel_header_address *addrs = NULL;
- struct _camel_header_raw *header;
+ const CamelNameValueArray *headers;
+ guint ii, len;
GString *from;
if (g_cancellable_is_cancelled (cancellable))
@@ -81,17 +82,23 @@ format_short_headers (EMailFormatter *formatter,
"id=\"__evo-short-headers\" style=\"display: %s\">",
flags & E_MAIL_FORMATTER_HEADER_FLAG_COLLAPSED ? "table" : "none");
- header = mime_part->headers;
- while (header) {
- if (!g_ascii_strcasecmp (header->name, "From")) {
+ headers = camel_medium_get_headers (CAMEL_MEDIUM (mime_part));
+ len = camel_name_value_array_get_length (headers);
+ for (ii = 0; ii < len; ii++) {
+ const gchar *header_name = NULL, *header_value = NULL;
+
+ if (!camel_name_value_array_get (headers, ii, &header_name, &header_value) ||
+ !header_name)
+ continue;
+
+ if (!g_ascii_strcasecmp (header_name, "From")) {
GString *tmp;
- if (!(addrs = camel_header_address_decode (header->value, hdr_charset))) {
- header = header->next;
+ if (!(addrs = camel_header_address_decode (header_value, hdr_charset))) {
continue;
}
tmp = g_string_new ("");
e_mail_formatter_format_address (
- formatter, tmp, addrs, header->name, FALSE,
+ formatter, tmp, addrs, header_name, FALSE,
!(flags & E_MAIL_FORMATTER_HEADER_FLAG_NOELIPSIZE));
if (tmp->len > 0)
@@ -100,16 +107,15 @@ format_short_headers (EMailFormatter *formatter,
_("From"), tmp->str);
g_string_free (tmp, TRUE);
- } else if (!g_ascii_strcasecmp (header->name, "Subject")) {
+ } else if (!g_ascii_strcasecmp (header_name, "Subject")) {
gchar *buf = NULL;
- subject = camel_header_unfold (header->value);
+ subject = camel_header_unfold (header_value);
buf = camel_header_decode_string (subject, hdr_charset);
g_free (subject);
subject = camel_text_to_html (
buf, CAMEL_MIME_FILTER_TOHTML_PRESERVE_8BIT, 0);
g_free (buf);
}
- header = header->next;
}
g_free (hdr_charset);
@@ -209,7 +215,7 @@ format_full_headers (EMailFormatter *formatter,
CamelMimePart *mime_part;
const gchar *charset;
CamelContentType *ct;
- struct _camel_header_raw *header;
+ const CamelNameValueArray *headers;
const gchar *photo_name = NULL;
guchar *face_header_value = NULL;
gsize face_header_len = 0;
@@ -219,6 +225,7 @@ format_full_headers (EMailFormatter *formatter,
gchar *hdr_charset;
gchar *evolution_imagesdir;
const gchar *direction;
+ guint ii, len;
g_return_if_fail (E_IS_MAIL_PART_HEADERS (part));
@@ -257,18 +264,25 @@ format_full_headers (EMailFormatter *formatter,
flags & E_MAIL_FORMATTER_HEADER_FLAG_COLLAPSED ? "none" : "table",
direction);
- header = mime_part->headers;
- while (header != NULL) {
- if (!g_ascii_strcasecmp (header->name, "Sender")) {
+ headers = camel_medium_get_headers (CAMEL_MEDIUM (mime_part));
+ len = camel_name_value_array_get_length (headers);
+ for (ii = 0; ii < len; ii++) {
+ const gchar *header_name = NULL, *header_value = NULL;
+
+ if (!camel_name_value_array_get (headers, ii, &header_name, &header_value) ||
+ !header_name)
+ continue;
+
+ if (!g_ascii_strcasecmp (header_name, "Sender")) {
struct _camel_header_address *addrs;
GString *html;
- if (!(addrs = camel_header_address_decode (header->value, hdr_charset)))
+ if (!(addrs = camel_header_address_decode (header_value, hdr_charset)))
break;
html = g_string_new ("");
name = e_mail_formatter_format_address (
- formatter, html, addrs, header->name, FALSE,
+ formatter, html, addrs, header_name, FALSE,
~(flags & E_MAIL_FORMATTER_HEADER_FLAG_NOELIPSIZE));
header_sender = html->str;
@@ -277,16 +291,16 @@ format_full_headers (EMailFormatter *formatter,
g_string_free (html, FALSE);
g_free (name);
- } else if (!g_ascii_strcasecmp (header->name, "From")) {
+ } else if (!g_ascii_strcasecmp (header_name, "From")) {
struct _camel_header_address *addrs;
GString *html;
- if (!(addrs = camel_header_address_decode (header->value, hdr_charset)))
+ if (!(addrs = camel_header_address_decode (header_value, hdr_charset)))
break;
html = g_string_new ("");
name = e_mail_formatter_format_address (
- formatter, html, addrs, header->name, FALSE,
+ formatter, html, addrs, header_name, FALSE,
!(flags & E_MAIL_FORMATTER_HEADER_FLAG_NOELIPSIZE));
header_from = html->str;
@@ -295,11 +309,9 @@ format_full_headers (EMailFormatter *formatter,
g_string_free (html, FALSE);
g_free (name);
- } else if (!g_ascii_strcasecmp (header->name, "X-Evolution-Mail-From-Delegate")) {
+ } else if (!g_ascii_strcasecmp (header_name, "X-Evolution-Mail-From-Delegate")) {
mail_from_delegate = TRUE;
}
-
- header = header->next;
}
g_free (hdr_charset);
@@ -343,14 +355,13 @@ format_full_headers (EMailFormatter *formatter,
/* dump selected headers */
if (mode & E_MAIL_FORMATTER_MODE_ALL_HEADERS) {
- header = mime_part->headers;
- while (header != NULL) {
- e_mail_formatter_format_header (
- formatter, buffer,
- header->name,
- header->value,
- E_MAIL_FORMATTER_HEADER_FLAG_NOCOLUMNS, charset);
- header = header->next;
+ for (ii = 0; ii < len; ii++) {
+ const gchar *header_name = NULL, *header_value = NULL;
+
+ if (camel_name_value_array_get (headers, ii, &header_name, &header_value) &&
header_name) {
+ e_mail_formatter_format_header (formatter, buffer, header_name, header_value,
+ E_MAIL_FORMATTER_HEADER_FLAG_NOCOLUMNS, charset);
+ }
}
e_mail_formatter_format_security_header (formatter, context, buffer, part,
E_MAIL_FORMATTER_HEADER_FLAG_NOCOLUMNS);
} else {
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-alternative.c
b/src/em-format/e-mail-parser-multipart-alternative.c
index 5853b12..e777588 100644
--- a/src/em-format/e-mail-parser-multipart-alternative.c
+++ b/src/em-format/e-mail-parser-multipart-alternative.c
@@ -77,7 +77,6 @@ empe_mp_alternative_parse (EMailParserExtension *extension,
CamelMimePart *mpart;
CamelDataWrapper *data_wrapper;
CamelContentType *type;
- CamelStream *null_stream;
gchar *mime_type;
gsize content_size;
@@ -93,12 +92,8 @@ empe_mp_alternative_parse (EMailParserExtension *extension,
/* This may block even though the stream does not.
* XXX Pretty inefficient way to test if the MIME part
* is empty. Surely there's a quicker way? */
- null_stream = camel_stream_null_new ();
data_wrapper = camel_medium_get_content (CAMEL_MEDIUM (mpart));
- camel_data_wrapper_decode_to_stream_sync (
- data_wrapper, null_stream, cancellable, NULL);
- content_size = CAMEL_STREAM_NULL (null_stream)->written;
- g_object_unref (null_stream);
+ content_size = camel_data_wrapper_calculate_decoded_size_sync (data_wrapper, cancellable,
NULL);
if (content_size == 0)
continue;
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-headers.c b/src/em-format/e-mail-part-headers.c
index da37b81..f56edaa 100644
--- a/src/em-format/e-mail-part-headers.c
+++ b/src/em-format/e-mail-part-headers.c
@@ -61,7 +61,7 @@ mail_part_headers_build_print_model (EMailPartHeaders *part)
GtkListStore *list_store;
EMailPartList *part_list;
CamelMimeMessage *message;
- GArray *array;
+ const CamelNameValueArray *headers;
gint default_position = 0;
guint ii, length = 0;
@@ -78,34 +78,35 @@ mail_part_headers_build_print_model (EMailPartHeaders *part)
G_TYPE_STRING); /* HEADER_VALUE */
message = e_mail_part_list_get_message (part_list);
- array = camel_medium_get_headers (CAMEL_MEDIUM (message));
-
- if (array != NULL)
- length = array->len;
+ headers = camel_medium_get_headers (CAMEL_MEDIUM (message));
+ length = camel_name_value_array_get_length (headers);
for (ii = 0; ii < length; ii++) {
- CamelMediumHeader *header;
GtkTreeIter iter;
gboolean include = FALSE;
gint position = -1;
+ const gchar *header_name = NULL;
+ const gchar *header_value = NULL;
- header = &g_array_index (array, CamelMediumHeader, ii);
+ if (!camel_name_value_array_get (headers, ii, &header_name, &header_value) ||
+ !header_name || !header_value)
+ continue;
/* EMailFormatterPrintHeaders excludes "Subject" from
* its header table (because it puts it in an <h1> tag
* at the top of the page), so we'll exclude it too. */
- if (g_ascii_strncasecmp (header->name, "Subject", 7) == 0)
+ if (g_ascii_strncasecmp (header_name, "Subject", 7) == 0)
continue;
/* Also skip the 'Face' header, which includes only
base64 encoded data anyway. */
- if (g_ascii_strcasecmp (header->name, "Face") == 0)
+ if (g_ascii_strcasecmp (header_value, "Face") == 0)
continue;
/* Arrange default headers first and select them to be
* included in the final printout. All other headers
* are excluded by default in the final printout. */
- if (e_mail_part_headers_is_default (part, header->name)) {
+ if (e_mail_part_headers_is_default (part, header_name)) {
position = default_position++;
include = TRUE;
}
@@ -117,15 +118,12 @@ mail_part_headers_build_print_model (EMailPartHeaders *part)
E_MAIL_PART_HEADERS_PRINT_MODEL_COLUMN_INCLUDE,
include,
E_MAIL_PART_HEADERS_PRINT_MODEL_COLUMN_HEADER_NAME,
- header->name,
+ header_name,
E_MAIL_PART_HEADERS_PRINT_MODEL_COLUMN_HEADER_VALUE,
- header->value,
+ header_value,
-1);
}
- if (array != NULL)
- camel_medium_free_headers (CAMEL_MEDIUM (message), array);
-
g_object_unref (part_list);
/* Stash the print model internally. */
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/libemail-engine/e-mail-folder-utils.c b/src/libemail-engine/e-mail-folder-utils.c
index 0667962..a1ba050 100644
--- a/src/libemail-engine/e-mail-folder-utils.c
+++ b/src/libemail-engine/e-mail-folder-utils.c
@@ -47,23 +47,16 @@ struct _AsyncContext {
static void
async_context_free (AsyncContext *context)
{
- if (context->message != NULL)
- g_object_unref (context->message);
-
- if (context->info != NULL)
- camel_message_info_unref (context->info);
-
- if (context->part != NULL)
- g_object_unref (context->part);
-
if (context->hash_table != NULL)
g_hash_table_unref (context->hash_table);
if (context->ptr_array != NULL)
g_ptr_array_unref (context->ptr_array);
- if (context->destination != NULL)
- g_object_unref (context->destination);
+ g_clear_object (&context->message);
+ g_clear_object (&context->info);
+ g_clear_object (&context->part);
+ g_clear_object (&context->destination);
g_free (context->fwd_subject);
g_free (context->message_uid);
@@ -146,7 +139,7 @@ e_mail_folder_append_message (CamelFolder *folder,
context->message = g_object_ref (message);
if (info != NULL)
- context->info = camel_message_info_ref (info);
+ context->info = g_object_ref (info);
simple = g_simple_async_result_new (
G_OBJECT (folder), callback, user_data,
@@ -249,7 +242,7 @@ mail_folder_expunge_pop3_stores (CamelFolder *folder,
if (info != NULL) {
flags = camel_message_info_get_flags (info);
- camel_message_info_unref (info);
+ g_clear_object (&info);
}
/* Only interested in deleted messages. */
@@ -792,7 +785,7 @@ e_mail_folder_find_duplicate_messages_sync (CamelFolder *folder,
g_hash_table_iter_init (&iter, hash_table);
while (g_hash_table_iter_next (&iter, &key, &value)) {
- const CamelSummaryMessageID *message_id;
+ CamelSummaryMessageID message_id;
CamelMessageFlags flags;
CamelMessageInfo *info;
gboolean duplicate;
@@ -802,13 +795,13 @@ e_mail_folder_find_duplicate_messages_sync (CamelFolder *folder,
if (!info)
continue;
- message_id = camel_message_info_get_message_id (info);
+ message_id.id.id = camel_message_info_get_message_id (info);
flags = camel_message_info_get_flags (info);
/* Skip messages marked for deletion. */
if (flags & CAMEL_MESSAGE_DELETED) {
g_queue_push_tail (&trash, key);
- camel_message_info_unref (info);
+ g_clear_object (&info);
continue;
}
@@ -816,13 +809,13 @@ e_mail_folder_find_duplicate_messages_sync (CamelFolder *folder,
if (digest == NULL) {
g_queue_push_tail (&trash, key);
- camel_message_info_unref (info);
+ g_clear_object (&info);
continue;
}
/* Determine if the message a duplicate. */
- value = g_hash_table_lookup (unique_ids, &message_id->id.id);
+ value = g_hash_table_lookup (unique_ids, &message_id.id.id);
duplicate = (value != NULL) && g_str_equal (digest, value);
if (!duplicate) {
@@ -832,13 +825,13 @@ e_mail_folder_find_duplicate_messages_sync (CamelFolder *folder,
* of 64-bit integers and have the hash
* table keys point to array elements. */
v_int64 = g_new0 (gint64, 1);
- *v_int64 = (gint64) message_id->id.id;
+ *v_int64 = (gint64) message_id.id.id;
g_hash_table_insert (unique_ids, v_int64, g_strdup (digest));
g_queue_push_tail (&trash, key);
}
- camel_message_info_unref (info);
+ g_clear_object (&info);
}
/* Delete all non-duplicate messages from the hash table. */
@@ -1165,7 +1158,7 @@ e_mail_folder_remove_sync (CamelFolder *folder,
transparent_cancellable, NULL);
}
- if ((parent_store->flags & CAMEL_STORE_CAN_DELETE_FOLDERS_AT_ONCE) != 0) {
+ if ((camel_store_get_flags (parent_store) & CAMEL_STORE_CAN_DELETE_FOLDERS_AT_ONCE) != 0) {
success = camel_store_delete_folder_sync (
parent_store, full_name, transparent_cancellable, error);
} else {
@@ -1377,12 +1370,11 @@ mail_folder_strip_message (CamelFolder *folder,
CamelMessageInfo *orig_info;
CamelMessageInfo *copy_info;
CamelMessageFlags flags;
+ const CamelNameValueArray *headers;
- orig_info =
- camel_folder_get_message_info (folder, message_uid);
- copy_info =
- camel_message_info_new_from_header (
- NULL, CAMEL_MIME_PART (message)->headers);
+ headers = camel_medium_get_headers (CAMEL_MEDIUM (message));
+ orig_info = camel_folder_get_message_info (folder, message_uid);
+ copy_info = camel_message_info_new_from_headers (NULL, headers);
flags = camel_folder_get_message_flags (folder, message_uid);
camel_message_info_set_flags (copy_info, flags, flags);
@@ -1395,8 +1387,8 @@ mail_folder_strip_message (CamelFolder *folder,
CAMEL_MESSAGE_DELETED,
CAMEL_MESSAGE_DELETED);
- camel_message_info_unref (orig_info);
- camel_message_info_unref (copy_info);
+ g_clear_object (&orig_info);
+ g_clear_object (©_info);
}
return success;
diff --git a/src/libemail-engine/e-mail-session-utils.c b/src/libemail-engine/e-mail-session-utils.c
index 20ba4aa..1eba77e 100644
--- a/src/libemail-engine/e-mail-session-utils.c
+++ b/src/libemail-engine/e-mail-session-utils.c
@@ -51,7 +51,7 @@ struct _AsyncContext {
gint io_priority;
/* X-Evolution headers */
- struct _camel_header_raw *xev;
+ CamelNameValueArray *xev_headers;
GPtrArray *post_to_uris;
@@ -64,34 +64,20 @@ struct _AsyncContext {
static void
async_context_free (AsyncContext *context)
{
- if (context->folder != NULL)
- g_object_unref (context->folder);
-
- if (context->message != NULL)
- g_object_unref (context->message);
-
- if (context->info != NULL)
- camel_message_info_unref (context->info);
-
- if (context->from != NULL)
- g_object_unref (context->from);
-
- if (context->recipients != NULL)
- g_object_unref (context->recipients);
-
- if (context->driver != NULL)
- g_object_unref (context->driver);
-
- if (context->transport != NULL)
- g_object_unref (context->transport);
+ g_clear_object (&context->folder);
+ g_clear_object (&context->message);
+ g_clear_object (&context->info);
+ g_clear_object (&context->from);
+ g_clear_object (&context->recipients);
+ g_clear_object (&context->driver);
+ g_clear_object (&context->transport);
if (context->cancellable != NULL) {
camel_operation_pop_message (context->cancellable);
g_object_unref (context->cancellable);
}
- if (context->xev != NULL)
- camel_header_raw_clear (&context->xev);
+ camel_name_value_array_free (context->xev_headers);
if (context->post_to_uris != NULL) {
g_ptr_array_foreach (
@@ -192,7 +178,7 @@ e_mail_session_append_to_local_folder (EMailSession *session,
context->message = g_object_ref (message);
if (info != NULL)
- context->info = camel_message_info_ref (info);
+ context->info = g_object_ref (info);
simple = g_simple_async_result_new (
G_OBJECT (session), callback, user_data,
@@ -646,7 +632,7 @@ skip_send:
/* This accumulates error messages during post-processing. */
error_messages = g_string_sized_new (256);
- mail_tool_restore_xevolution_headers (context->message, context->xev);
+ mail_tool_restore_xevolution_headers (context->message, context->xev_headers);
/* Run filters on the outgoing message. */
if (context->driver != NULL) {
@@ -798,22 +784,6 @@ exit:
g_string_free (error_messages, TRUE);
}
-static guint32
-get_message_size (CamelMimeMessage *message,
- GCancellable *cancellable)
-{
- CamelStream *null;
- guint32 size;
-
- null = camel_stream_null_new ();
- camel_data_wrapper_write_to_stream_sync (
- CAMEL_DATA_WRAPPER (message), null, cancellable, NULL);
- size = CAMEL_STREAM_NULL (null)->written;
- g_object_unref (null);
-
- return size;
-}
-
void
e_mail_session_send_to (EMailSession *session,
CamelMimeMessage *message,
@@ -832,9 +802,9 @@ e_mail_session_send_to (EMailSession *session,
CamelMessageInfo *info;
CamelService *transport;
GPtrArray *post_to_uris;
- struct _camel_header_raw *xev;
- struct _camel_header_raw *header;
+ CamelNameValueArray *xev_headers;
const gchar *resent_from;
+ guint ii, len;
GError *error = NULL;
g_return_if_fail (E_IS_MAIL_SESSION (session));
@@ -848,18 +818,22 @@ e_mail_session_send_to (EMailSession *session,
transport = e_mail_session_ref_transport_for_message (
session, message);
- xev = mail_tool_remove_xevolution_headers (message);
+ xev_headers = mail_tool_remove_xevolution_headers (message);
+ len = camel_name_value_array_get_length (xev_headers);
/* Extract directives from X-Evolution headers. */
post_to_uris = g_ptr_array_new ();
- for (header = xev; header != NULL; header = header->next) {
+ for (ii = 0; ii < len; ii++) {
+ const gchar *header_name = NULL, *header_value = NULL;
gchar *folder_uri;
- if (g_strcmp0 (header->name, "X-Evolution-PostTo") != 0)
+ if (!camel_name_value_array_get (xev_headers, ii, &header_name, &header_value) ||
+ !header_name ||
+ g_ascii_strcasecmp (header_name, "X-Evolution-PostTo") != 0)
continue;
- folder_uri = g_strstrip (g_strdup (header->value));
+ folder_uri = g_strstrip (g_strdup (header_value));
g_ptr_array_add (post_to_uris, folder_uri);
}
@@ -909,10 +883,9 @@ e_mail_session_send_to (EMailSession *session,
/* Miscellaneous preparations. */
- info = camel_message_info_new_from_header (
- NULL, CAMEL_MIME_PART (message)->headers);
- ((CamelMessageInfoBase *) info)->size =
- get_message_size (message, cancellable);
+ info = camel_message_info_new_from_headers (NULL, camel_medium_get_headers (CAMEL_MEDIUM (message)));
+
+ camel_message_info_set_size (info, camel_data_wrapper_calculate_size_sync (CAMEL_DATA_WRAPPER
(message), cancellable, NULL));
camel_message_info_set_flags (info, CAMEL_MESSAGE_SEEN |
(camel_mime_message_has_attachment (message) ? CAMEL_MESSAGE_ATTACHMENTS : 0), ~0);
@@ -927,7 +900,7 @@ e_mail_session_send_to (EMailSession *session,
context->from = from;
context->recipients = recipients;
context->info = info;
- context->xev = xev;
+ context->xev_headers = xev_headers;
context->post_to_uris = post_to_uris;
context->transport = transport;
diff --git a/src/libemail-engine/e-mail-session.c b/src/libemail-engine/e-mail-session.c
index b34edab..d142f4f 100644
--- a/src/libemail-engine/e-mail-session.c
+++ b/src/libemail-engine/e-mail-session.c
@@ -1373,7 +1373,6 @@ mail_session_forward_to_sync (CamelSession *session,
const gchar *from_address;
const gchar *from_name;
const gchar *header_name;
- struct _camel_header_raw *xev;
gboolean success;
gchar *subject;
gchar *alias_name = NULL, *alias_address = NULL;
@@ -1455,8 +1454,7 @@ mail_session_forward_to_sync (CamelSession *session,
camel_medium_remove_header (medium, header_name);
/* remove any X-Evolution-* headers that may have been set */
- xev = mail_tool_remove_xevolution_headers (forward);
- camel_header_raw_clear (&xev);
+ camel_name_value_array_free (mail_tool_remove_xevolution_headers (forward));
/* from */
addr = camel_internet_address_new ();
@@ -1524,7 +1522,7 @@ mail_session_forward_to_sync (CamelSession *session,
g_mutex_unlock (&priv->preparing_flush_lock);
}
- camel_message_info_unref (info);
+ g_clear_object (&info);
g_object_unref (source);
g_free (alias_address);
diff --git a/src/libemail-engine/e-mail-utils.c b/src/libemail-engine/e-mail-utils.c
index 8fc3632..888f420 100644
--- a/src/libemail-engine/e-mail-utils.c
+++ b/src/libemail-engine/e-mail-utils.c
@@ -306,7 +306,7 @@ guess_mail_account_from_folder (ESourceRegistry *registry,
location = camel_vee_folder_get_location (CAMEL_VEE_FOLDER (folder),
(CamelVeeMessageInfo *) mi, NULL);
if (location)
store = camel_folder_get_parent_store (location);
- camel_message_info_unref (mi);
+ g_clear_object (&mi);
}
}
@@ -842,7 +842,7 @@ em_utils_get_real_folder_and_message_uid (CamelFolder *folder,
else
g_free (real_uid);
- camel_message_info_unref (mi);
+ g_clear_object (&mi);
if (out_real_folder)
*out_real_folder = g_object_ref (real_folder);
@@ -850,7 +850,7 @@ em_utils_get_real_folder_and_message_uid (CamelFolder *folder,
return;
}
- camel_message_info_unref (mi);
+ g_clear_object (&mi);
}
}
diff --git a/src/libemail-engine/mail-folder-cache.c b/src/libemail-engine/mail-folder-cache.c
index 8c8b380..cb17722 100644
--- a/src/libemail-engine/mail-folder-cache.c
+++ b/src/libemail-engine/mail-folder-cache.c
@@ -271,10 +271,10 @@ store_info_new (CamelStore *store)
/* If these are vfolders then they need to be opened
* now, otherwise they won't keep track of all folders. */
- if (store->flags & CAMEL_STORE_VJUNK)
+ if (camel_store_get_flags (store) & CAMEL_STORE_VJUNK)
store_info->vjunk = camel_store_get_junk_folder_sync (
store, NULL, NULL);
- if (store->flags & CAMEL_STORE_VTRASH)
+ if (camel_store_get_flags (store) & CAMEL_STORE_VTRASH)
store_info->vtrash = camel_store_get_trash_folder_sync (
store, NULL, NULL);
@@ -819,7 +819,7 @@ update_1folder (MailFolderCache *cache,
if (deleted > 0)
unread -= deleted;
- junked = camel_folder_summary_get_junk_count (folder->summary);
+ junked = camel_folder_summary_get_junk_count (camel_folder_get_folder_summary
(folder));
if (junked > 0)
unread -= junked;
}
@@ -859,31 +859,37 @@ folder_cache_check_ignore_thread (CamelFolder *folder,
GCancellable *cancellable,
GError **error)
{
- const CamelSummaryReferences *references;
+ GArray *references;
gboolean has_ignore_thread = FALSE, first_ignore_thread = FALSE, found_first_msgid = FALSE;
guint64 first_msgid;
GString *expr = NULL;
- gint ii;
+ guint ii;
g_return_val_if_fail (CAMEL_IS_FOLDER (folder), FALSE);
g_return_val_if_fail (info != NULL, FALSE);
- references = camel_message_info_get_references (info);
- if (!references || references->size <= 0)
+ references = camel_message_info_dup_references (info);
+ if (!references || references->len <= 0) {
+ if (references)
+ g_array_unref (references);
return FALSE;
+ }
+
+ first_msgid = g_array_index (references, guint64, 0);
- first_msgid = references->references[0].id.id;
+ for (ii = 0; ii < references->len; ii++) {
+ CamelSummaryMessageID msgid;
- for (ii = 0; ii < references->size; ii++) {
- if (references->references[ii].id.id == 0)
+ msgid.id.id = g_array_index (references, guint64, ii);
+ if (!msgid.id.id)
continue;
if (!expr)
expr = g_string_new ("(match-all (or ");
g_string_append_printf (expr, "(= \"msgid\" \"%lu %lu\")",
- (gulong) references->references[ii].id.part.hi,
- (gulong) references->references[ii].id.part.lo);
+ (gulong) msgid.id.part.hi,
+ (gulong) msgid.id.part.lo);
}
if (expr) {
@@ -901,19 +907,18 @@ folder_cache_check_ignore_thread (CamelFolder *folder,
if (!refrinfo)
continue;
- if (first_msgid && camel_message_info_get_message_id (refrinfo) &&
- camel_message_info_get_message_id (refrinfo)->id.id == first_msgid) {
+ if (first_msgid && camel_message_info_get_message_id (refrinfo) ==
first_msgid) {
/* The first msgid in the references is In-ReplyTo, which is the
master;
the rest is just a guess. */
found_first_msgid = TRUE;
first_ignore_thread = camel_message_info_get_user_flag (refrinfo,
"ignore-thread");
- camel_message_info_unref (refrinfo);
+ g_clear_object (&refrinfo);
break;
}
has_ignore_thread = has_ignore_thread || camel_message_info_get_user_flag
(refrinfo, "ignore-thread");
- camel_message_info_unref (refrinfo);
+ g_clear_object (&refrinfo);
}
camel_folder_search_free (folder, uids);
@@ -922,6 +927,8 @@ folder_cache_check_ignore_thread (CamelFolder *folder,
g_string_free (expr, TRUE);
}
+ g_array_unref (references);
+
return (found_first_msgid && first_ignore_thread) || (!found_first_msgid && has_ignore_thread);
}
@@ -1019,7 +1026,7 @@ folder_cache_process_folder_changes_thread (CamelFolder *folder,
}
}
- camel_message_info_unref (info);
+ g_clear_object (&info);
if (local_error) {
g_propagate_error (error, local_error);
@@ -1434,12 +1441,12 @@ mail_folder_cache_folder_available (MailFolderCache *cache,
return;
/* Disregard virtual Junk folders. */
- if (store->flags & CAMEL_STORE_VJUNK)
+ if (camel_store_get_flags (store) & CAMEL_STORE_VJUNK)
if (g_strcmp0 (folder_name, CAMEL_VJUNK_NAME) == 0)
return;
/* Disregard virtual Trash folders. */
- if (store->flags & CAMEL_STORE_VTRASH)
+ if (camel_store_get_flags (store) & CAMEL_STORE_VTRASH)
if (g_strcmp0 (folder_name, CAMEL_VTRASH_NAME) == 0)
return;
@@ -1484,12 +1491,12 @@ mail_folder_cache_folder_unavailable (MailFolderCache *cache,
return;
/* Disregard virtual Junk folders. */
- if (store->flags & CAMEL_STORE_VJUNK)
+ if (camel_store_get_flags (store) & CAMEL_STORE_VJUNK)
if (g_strcmp0 (folder_name, CAMEL_VJUNK_NAME) == 0)
return;
/* Disregard virtual Trash folders. */
- if (store->flags & CAMEL_STORE_VTRASH)
+ if (camel_store_get_flags (store) & CAMEL_STORE_VTRASH)
if (g_strcmp0 (folder_name, CAMEL_VTRASH_NAME) == 0)
return;
@@ -1536,12 +1543,12 @@ mail_folder_cache_folder_deleted (MailFolderCache *cache,
return;
/* Disregard virtual Junk folders. */
- if (store->flags & CAMEL_STORE_VJUNK)
+ if (camel_store_get_flags (store) & CAMEL_STORE_VJUNK)
if (g_strcmp0 (folder_name, CAMEL_VJUNK_NAME) == 0)
return;
/* Disregard virtual Trash folders. */
- if (store->flags & CAMEL_STORE_VTRASH)
+ if (camel_store_get_flags (store) & CAMEL_STORE_VTRASH)
if (g_strcmp0 (folder_name, CAMEL_VTRASH_NAME) == 0)
return;
@@ -1901,7 +1908,7 @@ mail_folder_cache_maybe_run_initial_setup_sync (CamelService *service,
/* The store doesn't support the function, thus silently pretend success.
Still update the ESource flag, in case the store would implement
the function in the future. */
- if (!(store->flags & CAMEL_STORE_SUPPORTS_INITIAL_SETUP))
+ if (!(camel_store_get_flags (store) & CAMEL_STORE_SUPPORTS_INITIAL_SETUP))
success = TRUE;
else
success = camel_store_initial_setup_sync (store, &save_setup, cancellable,
error);
diff --git a/src/libemail-engine/mail-ops.c b/src/libemail-engine/mail-ops.c
index 7790e3a..9d99d3f 100644
--- a/src/libemail-engine/mail-ops.c
+++ b/src/libemail-engine/mail-ops.c
@@ -568,22 +568,6 @@ static void report_status (struct _send_queue_msg *m,
const gchar *desc,
...);
-static guint32
-get_message_size (CamelMimeMessage *message,
- GCancellable *cancellable)
-{
- CamelStream *null;
- guint32 size;
-
- null = camel_stream_null_new ();
- camel_data_wrapper_write_to_stream_sync (
- CAMEL_DATA_WRAPPER (message), null, cancellable, NULL);
- size = CAMEL_STREAM_NULL (null)->written;
- g_object_unref (null);
-
- return size;
-}
-
/* send 1 message to a specific transport */
static void
mail_send_message (struct _send_queue_msg *m,
@@ -601,9 +585,10 @@ mail_send_message (struct _send_queue_msg *m,
const gchar *resent_from;
CamelFolder *folder = NULL;
GString *err = NULL;
- struct _camel_header_raw *xev, *header;
+ CamelNameValueArray *xev_headers = NULL;
CamelMimeMessage *message;
gint i;
+ guint jj, len;
GError *local_error = NULL;
gboolean did_connect = FALSE;
gboolean sent_message_saved = FALSE;
@@ -637,7 +622,7 @@ mail_send_message (struct _send_queue_msg *m,
}
err = g_string_new ("");
- xev = mail_tool_remove_xevolution_headers (message);
+ xev_headers = mail_tool_remove_xevolution_headers (message);
/* Check for email sending */
from = (CamelAddress *) camel_internet_address_new ();
@@ -701,17 +686,21 @@ mail_send_message (struct _send_queue_msg *m,
/* Now check for posting, failures are ignored */
info = camel_message_info_new (NULL);
- ((CamelMessageInfoBase *) info)->size = get_message_size (message, cancellable);
+ camel_message_info_set_size (info, camel_data_wrapper_calculate_size_sync (CAMEL_DATA_WRAPPER
(message), cancellable, NULL));
camel_message_info_set_flags (info, CAMEL_MESSAGE_SEEN |
(camel_mime_message_has_attachment (message) ? CAMEL_MESSAGE_ATTACHMENTS : 0), ~0);
- for (header = xev; header && !local_error; header = header->next) {
+ len = camel_name_value_array_get_length (xev_headers);
+ for (jj = 0; jj < len && !local_error; jj++) {
+ const gchar *header_name = NULL, *header_value = NULL;
gchar *uri;
- if (strcmp (header->name, "X-Evolution-PostTo") != 0)
+ if (!camel_name_value_array_get (xev_headers, jj, &header_name, &header_value) ||
+ !header_name ||
+ g_ascii_strcasecmp (header_name, "X-Evolution-PostTo") != 0)
continue;
- uri = g_strstrip (g_strdup (header->value));
+ uri = g_strstrip (g_strdup (header_value));
folder = e_mail_session_uri_to_folder_sync (
m->session, uri, 0, cancellable, &local_error);
if (folder != NULL) {
@@ -729,7 +718,7 @@ mail_send_message (struct _send_queue_msg *m,
}
/* post process */
- mail_tool_restore_xevolution_headers (message, xev);
+ mail_tool_restore_xevolution_headers (message, xev_headers);
if (local_error == NULL && driver) {
camel_filter_driver_filter_message (
@@ -902,15 +891,12 @@ exit:
g_object_unref (folder);
}
- if (info != NULL)
- camel_message_info_unref (info);
-
- if (service != NULL)
- g_object_unref (service);
+ g_clear_object (&info);
+ g_clear_object (&service);
g_object_unref (recipients);
g_object_unref (from);
- camel_header_raw_clear (&xev);
+ camel_name_value_array_free (xev_headers);
g_string_free (err, TRUE);
g_object_unref (message);
}
@@ -978,7 +964,7 @@ send_queue_exec (struct _send_queue_msg *m,
if ((camel_message_info_get_flags (info) & CAMEL_MESSAGE_DELETED) == 0 &&
(!delay_send || camel_message_info_get_date_sent (info) <= delay_send))
send_uids->pdata[j++] = uids->pdata[i];
- camel_message_info_unref (info);
+ g_clear_object (&info);
}
}
diff --git a/src/libemail-engine/mail-tools.c b/src/libemail-engine/mail-tools.c
index 5f3334d..243e583 100644
--- a/src/libemail-engine/mail-tools.c
+++ b/src/libemail-engine/mail-tools.c
@@ -186,39 +186,63 @@ mail_tool_generate_forward_subject (CamelMimeMessage *msg)
return fwd_subj;
}
-struct _camel_header_raw *
+CamelNameValueArray *
mail_tool_remove_xevolution_headers (CamelMimeMessage *message)
{
- struct _camel_header_raw *headers;
- struct _camel_header_raw *scan, *list = NULL;
+ CamelNameValueArray *orig_headers, *removed_headers = NULL;
+ CamelMedium *medium;
+ guint ii, len;
- headers = CAMEL_MIME_PART (message)->headers;
+ g_return_val_if_fail (CAMEL_IS_MIME_MESSAGE (message), NULL);
- for (scan = headers; scan != NULL; scan = scan->next) {
- if (strncmp (scan->name, "X-Evolution", 11) == 0)
- camel_header_raw_append (
- &list, scan->name,
- scan->value, scan->offset);
- }
+ medium = CAMEL_MEDIUM (message);
+ orig_headers = camel_medium_dup_headers (medium);
+ len = camel_name_value_array_get_length (orig_headers);
+
+ for (ii = 0; ii < len; ii++) {
+ const gchar *header_name = NULL, *header_value = NULL;
+
+ if (!camel_name_value_array_get (orig_headers, ii, &header_name, &header_value) ||
!header_name)
+ continue;
+
+ if (g_ascii_strncasecmp (header_name, "X-Evolution", 11) == 0) {
+ if (!removed_headers)
+ removed_headers = camel_name_value_array_new ();
+
+ camel_name_value_array_append (removed_headers, header_name, header_value);
- for (scan = list; scan; scan = scan->next) {
- camel_medium_remove_header (
- CAMEL_MEDIUM (message), scan->name);
+ camel_medium_remove_header (medium, header_name);
+ }
}
- return list;
+ camel_name_value_array_free (orig_headers);
+
+ return removed_headers;
}
void
mail_tool_restore_xevolution_headers (CamelMimeMessage *message,
- struct _camel_header_raw *xev)
+ CamelNameValueArray *headers)
{
CamelMedium *medium;
+ guint ii, len;
+
+ g_return_if_fail (CAMEL_IS_MIME_MESSAGE (message));
+
+ if (!headers)
+ return;
medium = CAMEL_MEDIUM (message);
+ len = camel_name_value_array_get_length (headers);
- for (; xev; xev = xev->next)
- camel_medium_add_header (medium, xev->name, xev->value);
+ for (ii = 0; ii < len; ii++) {
+ const gchar *header_name = NULL, *header_value = NULL;
+
+ if (!camel_name_value_array_get (headers, ii, &header_name, &header_value) || !header_name)
+ continue;
+
+ camel_medium_add_header (medium, header_name, header_value);
+ }
}
CamelMimePart *
@@ -226,7 +250,6 @@ mail_tool_make_message_attachment (CamelMimeMessage *message)
{
CamelMimePart *part;
const gchar *subject;
- struct _camel_header_raw *xev;
gchar *desc;
subject = camel_mime_message_get_subject (message);
@@ -236,8 +259,7 @@ mail_tool_make_message_attachment (CamelMimeMessage *message)
desc = g_strdup (_("Forwarded message"));
/* rip off the X-Evolution headers */
- xev = mail_tool_remove_xevolution_headers (message);
- camel_header_raw_clear (&xev);
+ camel_name_value_array_free (mail_tool_remove_xevolution_headers (message));
/* remove Bcc headers */
camel_medium_remove_header (CAMEL_MEDIUM (message), "Bcc");
diff --git a/src/libemail-engine/mail-tools.h b/src/libemail-engine/mail-tools.h
index b5b79f8..172d94c 100644
--- a/src/libemail-engine/mail-tools.h
+++ b/src/libemail-engine/mail-tools.h
@@ -30,15 +30,22 @@
/* Does a camel_movemail into the local movemail folder
* and returns the path to the new movemail folder that was created. which shoudl be freed later */
-gchar *mail_tool_do_movemail (CamelStore *store, GError **error);
+gchar * mail_tool_do_movemail (CamelStore *store,
+ GError **error);
-struct _camel_header_raw *mail_tool_remove_xevolution_headers (CamelMimeMessage *message);
-void mail_tool_restore_xevolution_headers (CamelMimeMessage *message, struct _camel_header_raw *);
+CamelNameValueArray *
+ mail_tool_remove_xevolution_headers
+ (CamelMimeMessage *message);
+void mail_tool_restore_xevolution_headers
+ (CamelMimeMessage *message,
+ CamelNameValueArray *headers);
/* Generates the subject for a message forwarding @msg */
-gchar *mail_tool_generate_forward_subject (CamelMimeMessage *msg);
+gchar * mail_tool_generate_forward_subject
+ (CamelMimeMessage *msg);
/* Make a message into an attachment */
-CamelMimePart *mail_tool_make_message_attachment (CamelMimeMessage *message);
+CamelMimePart * mail_tool_make_message_attachment
+ (CamelMimeMessage *message);
#endif
diff --git a/src/libemail-engine/mail-vfolder.c b/src/libemail-engine/mail-vfolder.c
index eadd318..2e15c1c 100644
--- a/src/libemail-engine/mail-vfolder.c
+++ b/src/libemail-engine/mail-vfolder.c
@@ -414,11 +414,11 @@ folder_is_spethal (CamelStore *store,
/* This is a bit of a hack, but really the only way it can be done
* at the moment. */
- if (store->flags & CAMEL_STORE_VTRASH)
+ if (camel_store_get_flags (store) & CAMEL_STORE_VTRASH)
if (g_strcmp0 (folder_name, CAMEL_VTRASH_NAME) == 0)
return TRUE;
- if (store->flags & CAMEL_STORE_VJUNK)
+ if (camel_store_get_flags (store) & CAMEL_STORE_VJUNK)
if (g_strcmp0 (folder_name, CAMEL_VJUNK_NAME) == 0)
return TRUE;
diff --git a/src/mail/e-mail-backend.c b/src/mail/e-mail-backend.c
index 9e76425..242576d 100644
--- a/src/mail/e-mail-backend.c
+++ b/src/mail/e-mail-backend.c
@@ -510,7 +510,7 @@ mail_backend_quit_requested_cb (EShell *shell,
if (folder == NULL)
return;
- if (camel_folder_summary_get_visible_count (folder->summary) == 0)
+ if (camel_folder_summary_get_visible_count (camel_folder_get_folder_summary (folder)) == 0)
return;
app_windows = gtk_application_get_windows (GTK_APPLICATION (shell));
diff --git a/src/mail/e-mail-browser.c b/src/mail/e-mail-browser.c
index 5809256..989a8df 100644
--- a/src/mail/e-mail-browser.c
+++ b/src/mail/e-mail-browser.c
@@ -293,8 +293,7 @@ mail_browser_message_selected_cb (EMailBrowser *browser,
if (g_settings_get_boolean (settings, "mark-seen"))
camel_message_info_set_flags (info, CAMEL_MESSAGE_SEEN, CAMEL_MESSAGE_SEEN);
g_clear_object (&settings);
-
- camel_message_info_unref (info);
+ g_clear_object (&info);
}
g_clear_object (&folder);
@@ -912,7 +911,7 @@ mail_browser_set_message (EMailReader *reader,
gtk_window_set_title (
GTK_WINDOW (reader),
camel_message_info_get_subject (info));
- camel_message_info_unref (info);
+ g_clear_object (&info);
}
g_clear_object (&folder);
diff --git a/src/mail/e-mail-config-defaults-page.c b/src/mail/e-mail-config-defaults-page.c
index ed33f85..c9f0842 100644
--- a/src/mail/e-mail-config-defaults-page.c
+++ b/src/mail/e-mail-config-defaults-page.c
@@ -978,7 +978,7 @@ mail_config_defaults_page_constructed (GObject *object)
service = camel_session_ref_service (CAMEL_SESSION (session), e_source_get_uid
(page->priv->original_source));
if (service && CAMEL_IS_STORE (service) &&
- (CAMEL_STORE (service)->flags & CAMEL_STORE_SUPPORTS_INITIAL_SETUP) != 0) {
+ (camel_store_get_flags (CAMEL_STORE (service)) & CAMEL_STORE_SUPPORTS_INITIAL_SETUP) !=
0) {
widget = gtk_button_new_with_mnemonic (_("_Lookup Folders"));
gtk_widget_set_halign (widget, GTK_ALIGN_START);
gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
diff --git a/src/mail/e-mail-display.c b/src/mail/e-mail-display.c
index 46f4f70..79324bc 100644
--- a/src/mail/e-mail-display.c
+++ b/src/mail/e-mail-display.c
@@ -2080,7 +2080,7 @@ e_mail_display_claim_attachment (EMailFormatter *formatter,
if (info) {
if (!camel_message_info_get_user_flag (info, E_MAIL_NOTES_USER_FLAG))
camel_message_info_set_user_flag (info,
E_MAIL_NOTES_USER_FLAG, TRUE);
- camel_message_info_unref (info);
+ g_clear_object (&info);
}
}
}
diff --git a/src/mail/e-mail-folder-create-dialog.c b/src/mail/e-mail-folder-create-dialog.c
index 9d32b54..53f0891 100644
--- a/src/mail/e-mail-folder-create-dialog.c
+++ b/src/mail/e-mail-folder-create-dialog.c
@@ -315,7 +315,7 @@ mail_folder_create_dialog_constructed (GObject *object)
service = g_queue_pop_head (&queue);
g_warn_if_fail (CAMEL_IS_STORE (service));
- flags = CAMEL_STORE (service)->flags;
+ flags = camel_store_get_flags (CAMEL_STORE (service));
if ((flags & CAMEL_STORE_CAN_EDIT_FOLDERS) == 0)
continue;
diff --git a/src/mail/e-mail-folder-pane.c b/src/mail/e-mail-folder-pane.c
index 1c689a7..ad6f1b3 100644
--- a/src/mail/e-mail-folder-pane.c
+++ b/src/mail/e-mail-folder-pane.c
@@ -139,7 +139,7 @@ mail_paned_view_open_selected_mail (EMailPanedView *view)
g_ptr_array_add (views, g_strdup (uid));
}
- camel_message_info_unref (info);
+ g_clear_object (&info);
}
n_views = views->len;
diff --git a/src/mail/e-mail-notes.c b/src/mail/e-mail-notes.c
index a917360..54aa982 100644
--- a/src/mail/e-mail-notes.c
+++ b/src/mail/e-mail-notes.c
@@ -621,7 +621,9 @@ e_mail_notes_replace_message_in_folder_sync (CamelFolder *folder,
CamelMessageInfo *clone;
gchar *appended_uid = NULL;
- clone = camel_message_info_clone (mi);
+ clone = camel_message_info_clone (mi, NULL);
+ camel_message_info_set_abort_notifications (clone, TRUE);
+
camel_message_info_set_user_flag (clone, E_MAIL_NOTES_USER_FLAG, has_note);
success = camel_folder_append_message_sync (folder, message, clone,
@@ -630,8 +632,8 @@ e_mail_notes_replace_message_in_folder_sync (CamelFolder *folder,
if (success)
camel_message_info_set_flags (mi, CAMEL_MESSAGE_DELETED, CAMEL_MESSAGE_DELETED);
- camel_message_info_unref (clone);
- camel_message_info_unref (mi);
+ g_clear_object (&clone);
+ g_clear_object (&mi);
g_free (appended_uid);
} else {
g_set_error_literal (error, CAMEL_ERROR, CAMEL_ERROR_GENERIC, _("Cannot find message in its
folder summary"));
diff --git a/src/mail/e-mail-properties.c b/src/mail/e-mail-properties.c
index 588eff7..3c21c9e 100644
--- a/src/mail/e-mail-properties.c
+++ b/src/mail/e-mail-properties.c
@@ -21,6 +21,7 @@
#include <string.h>
#include <camel/camel.h>
+#include <sqlite3.h>
#include <libemail-engine/libemail-engine.h>
@@ -154,7 +155,7 @@ e_mail_properties_set_config_filename (EMailProperties *properties,
g_return_if_fail (config_filename != NULL);
g_return_if_fail (properties->priv->db == NULL);
- properties->priv->db = camel_db_open (config_filename, &error);
+ properties->priv->db = camel_db_new (config_filename, &error);
if (error) {
g_warning ("%s: Failed to open '%s': %s", G_STRFUNC, config_filename, error->message);
@@ -219,8 +220,7 @@ mail_properties_finalize (GObject *object)
g_clear_error (&error);
}
- camel_db_close (properties->priv->db);
- properties->priv->db = NULL;
+ g_clear_object (&properties->priv->db);
}
/* Chain up to parent's finalize() method. */
diff --git a/src/mail/e-mail-reader-utils.c b/src/mail/e-mail-reader-utils.c
index 9132459..b3409e2 100644
--- a/src/mail/e-mail-reader-utils.c
+++ b/src/mail/e-mail-reader-utils.c
@@ -934,15 +934,15 @@ mark_ignore_thread_data_free (gpointer ptr)
static void
insert_to_checked_msgids (GHashTable *checked_msgids,
- const CamelSummaryMessageID *msgid)
+ const CamelSummaryMessageID msgid)
{
CamelSummaryMessageID *msgid_copy;
- if (!msgid)
+ if (!msgid.id.id)
return;
msgid_copy = g_new0 (CamelSummaryMessageID, 1);
- memcpy (msgid_copy, msgid, sizeof (CamelSummaryMessageID));
+ msgid_copy->id.id = msgid.id.id;
g_hash_table_insert (checked_msgids, msgid_copy, GINT_TO_POINTER (1));
}
@@ -959,7 +959,7 @@ mark_ignore_thread_traverse_uids (CamelFolder *folder,
{
GSList *to_check;
GPtrArray *uids;
- gint ii;
+ guint ii;
gboolean success;
success = !g_cancellable_set_error_if_cancelled (cancellable, error);
@@ -973,8 +973,7 @@ mark_ignore_thread_traverse_uids (CamelFolder *folder,
while (to_check != NULL && !g_cancellable_set_error_if_cancelled (cancellable, error)) {
CamelMessageInfo *mi;
- const CamelSummaryMessageID *msgid;
- const CamelSummaryReferences *references;
+ CamelSummaryMessageID msgid;
const gchar *uid = to_check->data;
gchar *sexp;
GError *local_error = NULL;
@@ -990,36 +989,40 @@ mark_ignore_thread_traverse_uids (CamelFolder *folder,
mi = camel_folder_get_message_info (folder, uid);
if (!mi || !camel_message_info_get_message_id (mi)) {
- if (mi)
- camel_message_info_unref (mi);
+ g_clear_object (&mi);
camel_pstring_free (uid);
continue;
}
camel_message_info_set_user_flag (mi, "ignore-thread", ignore_thread);
- msgid = camel_message_info_get_message_id (mi);
+ msgid.id.id = camel_message_info_get_message_id (mi);
insert_to_checked_msgids (checked_msgids, msgid);
if (whole_thread) {
+ GArray *references;
+
/* Search for parents */
- references = camel_message_info_get_references (mi);
+ references = camel_message_info_dup_references (mi);
if (references) {
GString *expr = NULL;
- for (ii = 0; ii < references->size; ii++) {
- if (references->references[ii].id.id == 0 ||
- g_hash_table_contains (checked_msgids,
&references->references[ii]))
+ for (ii = 0; ii < references->len; ii++) {
+ CamelSummaryMessageID ref_msgid;
+
+ ref_msgid.id.id = g_array_index (references, guint64, ii);
+ if (!ref_msgid.id.id ||
+ g_hash_table_contains (checked_msgids, &ref_msgid))
continue;
- insert_to_checked_msgids (checked_msgids,
&references->references[ii]);
+ insert_to_checked_msgids (checked_msgids, ref_msgid);
if (!expr)
expr = g_string_new ("(match-all (or ");
g_string_append_printf (expr, "(= \"msgid\" \"%lu %lu\")",
- (gulong) references->references[ii].id.part.hi,
- (gulong) references->references[ii].id.part.lo);
+ (gulong) ref_msgid.id.part.hi,
+ (gulong) ref_msgid.id.part.lo);
}
if (expr) {
@@ -1041,17 +1044,19 @@ mark_ignore_thread_traverse_uids (CamelFolder *folder,
if (local_error) {
g_propagate_error (error, local_error);
- camel_message_info_unref (mi);
+ g_clear_object (&mi);
camel_pstring_free (uid);
success = FALSE;
break;
}
}
+
+ g_array_unref (references);
}
}
/* Search for children */
- sexp = g_strdup_printf ("(match-all (= \"references\" \"%lu %lu\"))", (gulong)
msgid->id.part.hi, (gulong) msgid->id.part.lo);
+ sexp = g_strdup_printf ("(match-all (= \"references\" \"%lu %lu\"))", (gulong)
msgid.id.part.hi, (gulong) msgid.id.part.lo);
uids = camel_folder_search_by_expression (folder, sexp, cancellable, &local_error);
if (uids) {
for (ii = 0; ii < uids->len; ii++) {
@@ -1059,25 +1064,34 @@ mark_ignore_thread_traverse_uids (CamelFolder *folder,
if (refruid && !g_hash_table_contains (checked_uids, refruid)) {
CamelMessageInfo *refrmi = camel_folder_get_message_info (folder,
refruid);
+ guint64 msg_id = 0;
+
+ if (refrmi)
+ msg_id = camel_message_info_get_message_id (refrmi);
+
+ if (refrmi && msg_id && !g_hash_table_contains (checked_msgids,
&msg_id)) {
+ GArray *references;
- if (refrmi && camel_message_info_get_message_id (refrmi) &&
- !g_hash_table_contains (checked_msgids,
camel_message_info_get_message_id (refrmi))) {
/* The 'references' filter search can return false positives
*/
- references = camel_message_info_get_references (refrmi);
+ references = camel_message_info_dup_references (refrmi);
if (references) {
- gint jj;
+ guint jj;
+
+ for (jj = 0; jj < references->len; jj++) {
+ guint64 ref_msgid;
- for (jj = 0; jj < references->size; jj++) {
- if (references->references[jj].id.id ==
msgid->id.id) {
+ ref_msgid = g_array_index (references,
guint64, jj);
+ if (ref_msgid == msgid.id.id) {
to_check = g_slist_prepend (to_check,
(gpointer) camel_pstring_strdup (refruid));
break;
}
}
+
+ g_array_unref (references);
}
}
- if (refrmi)
- camel_message_info_unref (refrmi);
+ g_clear_object (&refrmi);
}
}
@@ -1085,7 +1099,7 @@ mark_ignore_thread_traverse_uids (CamelFolder *folder,
}
g_free (sexp);
- camel_message_info_unref (mi);
+ g_clear_object (&mi);
camel_pstring_free (uid);
if (local_error) {
@@ -1298,7 +1312,7 @@ e_mail_reader_open_selected (EMailReader *reader)
g_ptr_array_add (views, g_strdup (uid));
}
- camel_message_info_unref (info);
+ g_clear_object (&info);
}
for (ii = 0; ii < views->len; ii++) {
@@ -2397,8 +2411,9 @@ e_mail_reader_reply_to_message (EMailReader *reader,
CamelFolder *folder;
EMailReplyStyle reply_style;
EWebView *web_view;
- struct _camel_header_raw *header;
gboolean src_is_text_html = FALSE;
+ const CamelNameValueArray *headers;
+ guint ii, len;
const gchar *uid;
gchar *selection = NULL;
gint length;
@@ -2523,14 +2538,16 @@ e_mail_reader_reply_to_message (EMailReader *reader,
new_message = camel_mime_message_new ();
/* Filter out "content-*" headers. */
- header = CAMEL_MIME_PART (src_message)->headers;
- while (header != NULL) {
- if (g_ascii_strncasecmp (header->name, "content-", 8) != 0)
- camel_medium_add_header (
- CAMEL_MEDIUM (new_message),
- header->name, header->value);
-
- header = header->next;
+ headers = camel_medium_get_headers (CAMEL_MEDIUM (src_message));
+ len = camel_name_value_array_get_length (headers);
+ for (ii = 0; ii < len; ii++) {
+ const gchar *header_name = NULL, *header_value = NULL;
+
+ if (camel_name_value_array_get (headers, ii, &header_name, &header_value) &&
+ header_name &&
+ g_ascii_strncasecmp (header_name, "content-", 8) != 0) {
+ camel_medium_add_header (CAMEL_MEDIUM (new_message), header_name, header_value);
+ }
}
camel_medium_add_header (
@@ -2684,7 +2701,7 @@ e_mail_reader_save_messages (EMailReader *reader)
subject = camel_message_info_get_subject (info);
if (subject != NULL)
suggestion = g_strconcat (subject, ".mbox", NULL);
- camel_message_info_unref (info);
+ g_clear_object (&info);
}
if (suggestion == NULL) {
diff --git a/src/mail/e-mail-reader.c b/src/mail/e-mail-reader.c
index be23984..6ca3a50 100644
--- a/src/mail/e-mail-reader.c
+++ b/src/mail/e-mail-reader.c
@@ -206,8 +206,7 @@ action_mail_add_sender_cb (GtkAction *action,
g_object_unref (cia);
exit:
- if (info != NULL)
- camel_message_info_unref (info);
+ g_clear_object (&info);
g_ptr_array_unref (uids);
g_clear_object (&folder);
@@ -3052,7 +3051,7 @@ mail_reader_manage_followup_flag (EMailReader *reader,
g_object_unref (alert);
}
- camel_message_info_unref (info);
+ g_clear_object (&info);
if (!alert_added)
mail_reader_remove_followup_alert (reader);
@@ -4543,11 +4542,12 @@ e_mail_reader_check_state (EMailReader *reader)
if (folder != NULL) {
gchar *archive_folder;
+ guint32 folder_flags;
store = camel_folder_get_parent_store (folder);
- is_junk_folder =
- (folder->folder_flags & CAMEL_FOLDER_IS_JUNK) != 0;
- is_vtrash_folder = (store->flags & CAMEL_STORE_VTRASH) != 0 && (folder->folder_flags &
CAMEL_FOLDER_IS_TRASH) != 0;
+ folder_flags = camel_folder_get_flags (folder);
+ is_junk_folder = (folder_flags & CAMEL_FOLDER_IS_JUNK) != 0;
+ is_vtrash_folder = (camel_store_get_flags (store) & CAMEL_STORE_VTRASH) != 0 && (folder_flags
& CAMEL_FOLDER_IS_TRASH) != 0;
drafts_or_outbox =
em_utils_folder_is_drafts (registry, folder) ||
em_utils_folder_is_outbox (registry, folder);
@@ -4642,7 +4642,7 @@ e_mail_reader_check_state (EMailReader *reader)
has_notignore_thread = has_notignore_thread ||
!camel_message_info_get_user_flag (info, "ignore-thread");
- camel_message_info_unref (info);
+ g_clear_object (&info);
}
have_enabled_account =
diff --git a/src/mail/e-mail-remote-content.c b/src/mail/e-mail-remote-content.c
index f38d541..ea08f0d 100644
--- a/src/mail/e-mail-remote-content.c
+++ b/src/mail/e-mail-remote-content.c
@@ -21,6 +21,7 @@
#include <string.h>
#include <camel/camel.h>
+#include <sqlite3.h>
#include "e-mail-remote-content.h"
@@ -380,7 +381,7 @@ e_mail_remote_content_set_config_filename (EMailRemoteContent *content,
g_return_if_fail (config_filename != NULL);
g_return_if_fail (content->priv->db == NULL);
- content->priv->db = camel_db_open (config_filename, &error);
+ content->priv->db = camel_db_new (config_filename, &error);
if (error) {
g_warning ("%s: Failed to open '%s': %s", G_STRFUNC, config_filename, error->message);
@@ -444,8 +445,7 @@ mail_remote_content_finalize (GObject *object)
g_clear_error (&error);
}
- camel_db_close (content->priv->db);
- content->priv->db = NULL;
+ g_clear_object (&content->priv->db);
}
g_mutex_lock (&content->priv->recent_lock);
diff --git a/src/mail/e-mail-tag-editor.c b/src/mail/e-mail-tag-editor.c
index 2602241..73958de 100644
--- a/src/mail/e-mail-tag-editor.c
+++ b/src/mail/e-mail-tag-editor.c
@@ -117,75 +117,6 @@ mail_tag_editor_realize (GtkWidget *widget)
gtk_container_set_border_width (GTK_CONTAINER (action_area), 12);
}
-static CamelTag *
-mail_tag_editor_get_tag_list (EMailTagEditor *editor)
-{
- CamelTag *tag_list = NULL;
- time_t date;
- gchar *text = NULL;
- GtkWidget *entry;
-
- entry = gtk_bin_get_child (GTK_BIN (editor->priv->combo_entry));
- if (entry)
- text = g_strdup (gtk_entry_get_text (GTK_ENTRY (entry)));
- camel_tag_set (&tag_list, "follow-up", text);
- g_free (text);
-
- date = e_date_edit_get_time (editor->priv->target_date);
- if (date != (time_t) -1) {
- text = camel_header_format_date (date, 0);
- camel_tag_set (&tag_list, "due-by", text);
- g_free (text);
- } else
- camel_tag_set (&tag_list, "due-by", "");
-
- if (e_mail_tag_editor_get_completed (editor)) {
- text = camel_header_format_date (
- editor->priv->completed_date, 0);
- camel_tag_set (&tag_list, "completed-on", text);
- g_free (text);
- } else
- camel_tag_set (&tag_list, "completed-on", "");
-
- return tag_list;
-}
-
-static void
-mail_tag_editor_set_tag_list (EMailTagEditor *editor,
- CamelTag *tag_list)
-{
- GtkWidget *child;
- const gchar *text;
- time_t date;
-
- /* Extract the GtkEntry from the GtkComboBoxEntry. */
- child = gtk_bin_get_child (GTK_BIN (editor->priv->combo_entry));
-
- /* XXX This is kind of cheating. Since we only store the
- * translated tag there's no sure-fire way to determine
- * the corresponding combo box index (e.g. the tag may
- * have been set while running in a different locale). */
- text = camel_tag_get (&tag_list, "follow-up");
- if (text != NULL)
- gtk_entry_set_text (GTK_ENTRY (child), text);
-
- text = camel_tag_get (&tag_list, "due-by");
- if (text != NULL && *text != '\0') {
- date = camel_header_decode_date (text, NULL);
- e_date_edit_set_time (editor->priv->target_date, date);
- } else
- e_date_edit_set_time (editor->priv->target_date, (time_t) -1);
-
- text = camel_tag_get (&tag_list, "completed-on");
- if (text != NULL && *text != '\0') {
- date = camel_header_decode_date (text, NULL);
- if (date != (time_t) 0) {
- e_mail_tag_editor_set_completed (editor, TRUE);
- editor->priv->completed_date = date;
- }
- }
-}
-
static void
e_mail_tag_editor_class_init (EMailTagEditorClass *class)
{
@@ -201,9 +132,6 @@ e_mail_tag_editor_class_init (EMailTagEditorClass *class)
widget_class = GTK_WIDGET_CLASS (class);
widget_class->realize = mail_tag_editor_realize;
- class->get_tag_list = mail_tag_editor_get_tag_list;
- class->set_tag_list = mail_tag_editor_set_tag_list;
-
g_object_class_install_property (
object_class,
PROP_COMPLETED,
@@ -331,32 +259,79 @@ e_mail_tag_editor_set_completed (EMailTagEditor *editor,
g_object_notify (G_OBJECT (editor), "completed");
}
-CamelTag *
+CamelNameValueArray *
e_mail_tag_editor_get_tag_list (EMailTagEditor *editor)
{
- EMailTagEditorClass *class;
+ CamelNameValueArray *tag_list;
+ time_t date;
+ gchar *text = NULL;
+ GtkWidget *entry;
g_return_val_if_fail (E_IS_MAIL_TAG_EDITOR (editor), NULL);
- class = E_MAIL_TAG_EDITOR_GET_CLASS (editor);
- g_return_val_if_fail (class->get_tag_list != NULL, NULL);
+ tag_list = camel_name_value_array_new ();
+
+ entry = gtk_bin_get_child (GTK_BIN (editor->priv->combo_entry));
+ if (entry)
+ text = g_strdup (gtk_entry_get_text (GTK_ENTRY (entry)));
+ camel_name_value_array_set_named (tag_list, CAMEL_COMPARE_CASE_SENSITIVE, "follow-up", text);
+ g_free (text);
- return class->get_tag_list (editor);
+ date = e_date_edit_get_time (editor->priv->target_date);
+ if (date != (time_t) -1) {
+ text = camel_header_format_date (date, 0);
+ camel_name_value_array_set_named (tag_list, CAMEL_COMPARE_CASE_SENSITIVE, "due-by", text);
+ g_free (text);
+ } else
+ camel_name_value_array_set_named (tag_list, CAMEL_COMPARE_CASE_SENSITIVE, "due-by", "");
+
+ if (e_mail_tag_editor_get_completed (editor)) {
+ text = camel_header_format_date (editor->priv->completed_date, 0);
+ camel_name_value_array_set_named (tag_list, CAMEL_COMPARE_CASE_SENSITIVE, "completed-on",
text);
+ g_free (text);
+ } else
+ camel_name_value_array_set_named (tag_list, CAMEL_COMPARE_CASE_SENSITIVE, "completed-on", "");
+
+ return tag_list;
}
void
e_mail_tag_editor_set_tag_list (EMailTagEditor *editor,
- CamelTag *tag_list)
+ const CamelNameValueArray *tag_list)
{
- EMailTagEditorClass *class;
+ GtkWidget *child;
+ const gchar *text;
+ time_t date;
g_return_if_fail (E_IS_MAIL_TAG_EDITOR (editor));
g_return_if_fail (tag_list != NULL);
- class = E_MAIL_TAG_EDITOR_GET_CLASS (editor);
- g_return_if_fail (class->set_tag_list != NULL);
+ /* Extract the GtkEntry from the GtkComboBoxEntry. */
+ child = gtk_bin_get_child (GTK_BIN (editor->priv->combo_entry));
+
+ /* XXX This is kind of cheating. Since we only store the
+ * translated tag there's no sure-fire way to determine
+ * the corresponding combo box index (e.g. the tag may
+ * have been set while running in a different locale). */
+ text = camel_name_value_array_get_named (tag_list, CAMEL_COMPARE_CASE_SENSITIVE, "follow-up");
+ if (text != NULL)
+ gtk_entry_set_text (GTK_ENTRY (child), text);
+
+ text = camel_name_value_array_get_named (tag_list, CAMEL_COMPARE_CASE_SENSITIVE, "due-by");
+ if (text != NULL && *text != '\0') {
+ date = camel_header_decode_date (text, NULL);
+ e_date_edit_set_time (editor->priv->target_date, date);
+ } else
+ e_date_edit_set_time (editor->priv->target_date, (time_t) -1);
- class->set_tag_list (editor, tag_list);
+ text = camel_name_value_array_get_named (tag_list, CAMEL_COMPARE_CASE_SENSITIVE, "completed-on");
+ if (text != NULL && *text != '\0') {
+ date = camel_header_decode_date (text, NULL);
+ if (date != (time_t) 0) {
+ e_mail_tag_editor_set_completed (editor, TRUE);
+ editor->priv->completed_date = date;
+ }
+ }
}
void
diff --git a/src/mail/e-mail-tag-editor.h b/src/mail/e-mail-tag-editor.h
index b5c7af2..324c435 100644
--- a/src/mail/e-mail-tag-editor.h
+++ b/src/mail/e-mail-tag-editor.h
@@ -58,11 +58,6 @@ struct _EMailTagEditor {
struct _EMailTagEditorClass {
GtkDialogClass parent_class;
-
- /* virtual methods */
- CamelTag * (*get_tag_list) (EMailTagEditor *editor);
- void (*set_tag_list) (EMailTagEditor *editor,
- CamelTag *tags);
};
GType e_mail_tag_editor_get_type (void);
@@ -70,9 +65,10 @@ GtkWidget * e_mail_tag_editor_new (void);
gboolean e_mail_tag_editor_get_completed (EMailTagEditor *editor);
void e_mail_tag_editor_set_completed (EMailTagEditor *editor,
gboolean completed);
-CamelTag * e_mail_tag_editor_get_tag_list (EMailTagEditor *editor);
+CamelNameValueArray *
+ e_mail_tag_editor_get_tag_list (EMailTagEditor *editor);
void e_mail_tag_editor_set_tag_list (EMailTagEditor *editor,
- CamelTag *tag_list);
+ const CamelNameValueArray *tag_list);
void e_mail_tag_editor_add_message (EMailTagEditor *editor,
const gchar *from,
const gchar *subject);
diff --git a/src/mail/em-composer-utils.c b/src/mail/em-composer-utils.c
index 86c3eee..73deedf 100644
--- a/src/mail/em-composer-utils.c
+++ b/src/mail/em-composer-utils.c
@@ -1009,7 +1009,7 @@ composer_save_to_drafts_append_mail (AsyncContext *async_context,
composer_save_to_drafts_cleanup,
async_context);
- camel_message_info_unref (info);
+ g_clear_object (&info);
g_object_unref (drafts_folder);
}
@@ -1226,7 +1226,7 @@ em_utils_composer_save_to_outbox_cb (EMsgComposer *composer,
composer_save_to_outbox_completed,
async_context);
- camel_message_info_unref (info);
+ g_clear_object (&info);
}
typedef struct _PrintAsyncContext {
diff --git a/src/mail/em-folder-properties.c b/src/mail/em-folder-properties.c
index d267b05..1aae208 100644
--- a/src/mail/em-folder-properties.c
+++ b/src/mail/em-folder-properties.c
@@ -727,7 +727,7 @@ emfp_dialog_run (AsyncContext *context)
/* Get number of VISIBLE and DELETED messages, instead of TOTAL
* messages. VISIBLE+DELETED gives the correct count that matches
* the label below the Send & Receive button. */
- summary = context->folder->summary;
+ summary = camel_folder_get_folder_summary (context->folder);
context->total = camel_folder_summary_get_visible_count (summary);
context->unread = camel_folder_summary_get_unread_count (summary);
deleted = camel_folder_summary_get_deleted_count (summary);
@@ -739,7 +739,7 @@ emfp_dialog_run (AsyncContext *context)
/*
* Do the calculation only for those accounts that support VTRASHes
*/
- if (parent_store->flags & CAMEL_STORE_VTRASH) {
+ if (camel_store_get_flags (parent_store) & CAMEL_STORE_VTRASH) {
if (CAMEL_IS_VTRASH_FOLDER (context->folder))
context->total += deleted;
else if (!hide_deleted && deleted > 0)
@@ -749,9 +749,9 @@ emfp_dialog_run (AsyncContext *context)
/*
* If the folder is junk folder, get total number of mails.
*/
- if (parent_store->flags & CAMEL_STORE_VJUNK)
+ if (camel_store_get_flags (parent_store) & CAMEL_STORE_VJUNK)
context->total = camel_folder_summary_count (
- context->folder->summary);
+ camel_folder_get_folder_summary (context->folder));
name = camel_folder_get_display_name (context->folder);
diff --git a/src/mail/em-utils.c b/src/mail/em-utils.c
index 1b55f48..6d4c762 100644
--- a/src/mail/em-utils.c
+++ b/src/mail/em-utils.c
@@ -239,8 +239,8 @@ em_utils_flag_for_followup (EMailReader *reader,
EMailDisplay *display;
GtkWidget *editor;
GtkWindow *window;
- CamelTag *tags;
- gint i;
+ CamelNameValueArray *tags;
+ guint ii, tags_len;
g_return_if_fail (E_IS_MAIL_READER (reader));
g_return_if_fail (CAMEL_IS_FOLDER (folder));
@@ -251,10 +251,10 @@ em_utils_flag_for_followup (EMailReader *reader,
editor = e_mail_tag_editor_new ();
gtk_window_set_transient_for (GTK_WINDOW (editor), window);
- for (i = 0; i < uids->len; i++) {
+ for (ii = 0; ii < uids->len; ii++) {
CamelMessageInfo *info;
- info = camel_folder_get_message_info (folder, uids->pdata[i]);
+ info = camel_folder_get_message_info (folder, uids->pdata[ii]);
if (info == NULL)
continue;
@@ -264,7 +264,7 @@ em_utils_flag_for_followup (EMailReader *reader,
camel_message_info_get_from (info),
camel_message_info_get_subject (info));
- camel_message_info_unref (info);
+ g_clear_object (&info);
}
/* special-case... */
@@ -275,12 +275,13 @@ em_utils_flag_for_followup (EMailReader *reader,
message_uid = g_ptr_array_index (uids, 0);
info = camel_folder_get_message_info (folder, message_uid);
if (info) {
- tags = (CamelTag *) camel_message_info_get_user_tags (info);
+ tags = camel_message_info_dup_user_tags (info);
if (tags)
- e_mail_tag_editor_set_tag_list (
- E_MAIL_TAG_EDITOR (editor), tags);
- camel_message_info_unref (info);
+ e_mail_tag_editor_set_tag_list (E_MAIL_TAG_EDITOR (editor), tags);
+
+ camel_name_value_array_free (tags);
+ g_clear_object (&info);
}
}
@@ -291,25 +292,35 @@ em_utils_flag_for_followup (EMailReader *reader,
if (tags == NULL)
goto exit;
+ tags_len = camel_name_value_array_get_length (tags);
+
camel_folder_freeze (folder);
- for (i = 0; i < uids->len; i++) {
+ for (ii = 0; ii < uids->len; ii++) {
CamelMessageInfo *info;
- CamelTag *iter;
+ guint jj;
- info = camel_folder_get_message_info (folder, uids->pdata[i]);
+ info = camel_folder_get_message_info (folder, uids->pdata[ii]);
if (info == NULL)
continue;
- for (iter = tags; iter != NULL; iter = iter->next)
- camel_message_info_set_user_tag (
- info, iter->name, iter->value);
+ camel_message_info_freeze_notifications (info);
+
+ for (jj = 0; jj < tags_len; jj++) {
+ const gchar *name = NULL, *value = NULL;
+
+ if (!camel_name_value_array_get (tags, jj, &name, &value))
+ continue;
+
+ camel_message_info_set_user_tag (info, name, value);
+ }
- camel_message_info_unref (info);
+ camel_message_info_thaw_notifications (info);
+ g_clear_object (&info);
}
camel_folder_thaw (folder);
- camel_tag_list_free (&tags);
+ camel_name_value_array_free (tags);
display = e_mail_reader_get_mail_display (reader);
e_mail_display_reload (display);
@@ -346,7 +357,7 @@ em_utils_flag_for_followup_clear (GtkWindow *parent,
camel_message_info_set_user_tag (mi, "follow-up", NULL);
camel_message_info_set_user_tag (mi, "due-by", NULL);
camel_message_info_set_user_tag (mi, "completed-on", NULL);
- camel_message_info_unref (mi);
+ g_clear_object (&mi);
}
}
@@ -386,7 +397,7 @@ em_utils_flag_for_followup_completed (GtkWindow *parent,
tag = camel_message_info_get_user_tag (mi, "follow-up");
if (tag && tag[0])
camel_message_info_set_user_tag (mi, "completed-on", now);
- camel_message_info_unref (mi);
+ g_clear_object (&mi);
}
}
@@ -711,7 +722,7 @@ em_utils_selection_set_uidlist (GtkSelectionData *selection_data,
g_free (folder_uri);
}
- camel_message_info_unref (info);
+ g_clear_object (&info);
}
} else {
folder_uri = e_mail_folder_uri_from_folder (folder);
@@ -882,8 +893,7 @@ em_utils_build_export_basename (CamelFolder *folder,
basename = g_strdup_printf ("%s_%s%s", datetmp, subject, extension);
- if (info != NULL)
- camel_message_info_unref (info);
+ g_clear_object (&info);
return basename;
}
diff --git a/src/mail/importers/mail-importer.c b/src/mail/importers/mail-importer.c
index 0c02121..55a8873 100644
--- a/src/mail/importers/mail-importer.c
+++ b/src/mail/importers/mail-importer.c
@@ -134,7 +134,7 @@ import_mbox_add_message (CamelFolder *folder,
camel_folder_append_message_sync (
folder, msg, info, NULL,
cancellable, error);
- camel_message_info_unref (info);
+ g_clear_object (&info);
}
static void
@@ -357,7 +357,7 @@ import_kmail_folder (struct _import_mbox_msg *m,
camel_folder_append_message_sync (
folder, msg, info, NULL,
cancellable, error);
- camel_message_info_unref (info);
+ g_clear_object (&info);
g_object_unref (msg);
g_object_unref (mp);
} else {
diff --git a/src/mail/mail-autofilter.c b/src/mail/mail-autofilter.c
index 46e517a..c3eebf4 100644
--- a/src/mail/mail-autofilter.c
+++ b/src/mail/mail-autofilter.c
@@ -238,9 +238,13 @@ rule_from_message (EFilterRule *rule,
rule->grouping = E_FILTER_GROUP_ALL;
if (flags & AUTO_SUBJECT) {
- const gchar *subject = msg->subject ? msg->subject : "";
+ const gchar *subject;
gchar *namestr;
+ subject = camel_mime_message_get_subject (msg);
+ if (!subject)
+ subject = "";
+
rule_match_subject (context, rule, subject);
namestr = g_strdup_printf (_("Subject is %s"), strip_re (subject));
@@ -280,8 +284,7 @@ rule_from_message (EFilterRule *rule,
if (flags & AUTO_MLIST) {
gchar *name, *mlist;
- mlist = camel_header_raw_check_mailing_list (
- &((CamelMimePart *) msg)->headers);
+ mlist = camel_headers_dup_mailing_list (camel_medium_get_headers (CAMEL_MEDIUM (msg)));
if (mlist) {
rule_match_mlist (context, rule, mlist);
name = g_strdup_printf (_("%s mailing list"), mlist);
diff --git a/src/mail/message-list.c b/src/mail/message-list.c
index 7d65bef..d698e7f 100644
--- a/src/mail/message-list.c
+++ b/src/mail/message-list.c
@@ -520,8 +520,7 @@ regen_data_unref (RegenData *regen_data)
length = regen_data->summary->len;
for (ii = 0; ii < length; ii++)
- camel_message_info_unref (
- regen_data->summary->pdata[ii]);
+ g_clear_object (®en_data->summary->pdata[ii]);
g_ptr_array_free (regen_data->summary, TRUE);
}
@@ -1664,7 +1663,8 @@ add_all_labels_foreach (ETreeModel *etm,
CamelMessageInfo *msg_info;
const gchar *old_label;
gchar *new_label;
- const CamelFlag *flag;
+ const CamelNamedFlags *flags;
+ guint ii, len;
if (!etm)
msg_info = (CamelMessageInfo *) path;
@@ -1672,8 +1672,12 @@ add_all_labels_foreach (ETreeModel *etm,
msg_info = ((GNode *) path)->data;
g_return_val_if_fail (msg_info != NULL, FALSE);
- for (flag = camel_message_info_get_user_flags (msg_info); flag; flag = flag->next)
- add_label_if_known (ld, flag->name);
+ camel_message_info_property_lock (msg_info);
+ flags = camel_message_info_get_user_flags (msg_info);
+ len = camel_named_flags_get_length (flags);
+
+ for (ii = 0; ii < len; ii++)
+ add_label_if_known (ld, camel_named_flags_get (flags, ii));
old_label = camel_message_info_get_user_tag (msg_info, "label");
if (old_label != NULL) {
@@ -1684,6 +1688,8 @@ add_all_labels_foreach (ETreeModel *etm,
add_label_if_known (ld, new_label);
}
+ camel_message_info_property_unlock (msg_info);
+
return FALSE;
}
@@ -3170,6 +3176,7 @@ message_list_value_at (ETreeModel *tree_model,
{
MessageList *message_list;
CamelMessageInfo *msg_info;
+ gpointer result;
message_list = MESSAGE_LIST (tree_model);
@@ -3180,7 +3187,11 @@ message_list_value_at (ETreeModel *tree_model,
msg_info = ((GNode *) path)->data;
g_return_val_if_fail (msg_info != NULL, NULL);
- return ml_tree_value_at_ex (tree_model, path, col, msg_info, message_list);
+ camel_message_info_property_lock (msg_info);
+ result = ml_tree_value_at_ex (tree_model, path, col, msg_info, message_list);
+ camel_message_info_property_unlock (msg_info);
+
+ return result;
}
static gpointer
@@ -3786,8 +3797,7 @@ clear_info (gchar *key,
GNode *node,
MessageList *message_list)
{
- camel_message_info_unref (node->data);
- node->data = NULL;
+ g_clear_object (&node->data);
}
static void
@@ -3895,10 +3905,10 @@ folder_store_supports_vjunk_folder (CamelFolder *folder)
if (CAMEL_IS_VEE_FOLDER (folder))
return TRUE;
- if (store->flags & CAMEL_STORE_VJUNK)
+ if (camel_store_get_flags (store) & CAMEL_STORE_VJUNK)
return TRUE;
- if (store->flags & CAMEL_STORE_REAL_JUNK_FOLDER)
+ if (camel_store_get_flags (store) & CAMEL_STORE_REAL_JUNK_FOLDER)
return TRUE;
return FALSE;
@@ -3908,6 +3918,8 @@ static gboolean
message_list_get_hide_junk (MessageList *message_list,
CamelFolder *folder)
{
+ guint32 folder_flags;
+
if (folder == NULL)
return FALSE;
@@ -3917,10 +3929,12 @@ message_list_get_hide_junk (MessageList *message_list,
if (!folder_store_supports_vjunk_folder (folder))
return FALSE;
- if (folder->folder_flags & CAMEL_FOLDER_IS_JUNK)
+ folder_flags = camel_folder_get_flags (folder);
+
+ if (folder_flags & CAMEL_FOLDER_IS_JUNK)
return FALSE;
- if (folder->folder_flags & CAMEL_FOLDER_IS_TRASH)
+ if (folder_flags & CAMEL_FOLDER_IS_TRASH)
return FALSE;
if (CAMEL_IS_VEE_FOLDER (folder)) {
@@ -3949,8 +3963,8 @@ message_list_get_hide_deleted (MessageList *message_list,
g_return_val_if_fail (store != NULL, FALSE);
non_trash_folder =
- ((store->flags & CAMEL_STORE_VTRASH) == 0) ||
- ((folder->folder_flags & CAMEL_FOLDER_IS_TRASH) == 0);
+ ((camel_store_get_flags (store) & CAMEL_STORE_VTRASH) == 0) ||
+ ((camel_folder_get_flags (folder) & CAMEL_FOLDER_IS_TRASH) == 0);
if (non_trash_folder && CAMEL_IS_VEE_FOLDER (folder)) {
const gchar *expr = camel_vee_folder_get_expression (CAMEL_VEE_FOLDER (folder));
@@ -3970,7 +3984,7 @@ is_node_selectable (MessageList *message_list,
CamelFolder *folder;
gboolean is_junk_folder;
gboolean is_trash_folder;
- guint32 flags;
+ guint32 flags, folder_flags;
gboolean flag_junk;
gboolean flag_deleted;
gboolean hide_junk;
@@ -3984,12 +3998,11 @@ is_node_selectable (MessageList *message_list,
g_return_val_if_fail (folder != NULL, FALSE);
store_has_vjunk = folder_store_supports_vjunk_folder (folder);
+ folder_flags = camel_folder_get_flags (folder);
/* check folder type */
- is_junk_folder =
- store_has_vjunk &&
- (folder->folder_flags & CAMEL_FOLDER_IS_JUNK) != 0;
- is_trash_folder = folder->folder_flags & CAMEL_FOLDER_IS_TRASH;
+ is_junk_folder = store_has_vjunk && (folder_flags & CAMEL_FOLDER_IS_JUNK) != 0;
+ is_trash_folder = folder_flags & CAMEL_FOLDER_IS_TRASH;
hide_junk = message_list_get_hide_junk (message_list, folder);
hide_deleted = message_list_get_hide_deleted (message_list, folder);
@@ -4105,7 +4118,7 @@ ml_uid_nodemap_insert (MessageList *message_list,
flags = camel_message_info_get_flags (info);
date = camel_message_info_get_date_received (info);
- camel_message_info_ref (info);
+ g_object_ref (info);
g_hash_table_insert (message_list->uid_nodemap, (gpointer) uid, node);
/* Track the latest seen and unseen messages shown, used in
@@ -4153,7 +4166,7 @@ ml_uid_nodemap_remove (MessageList *message_list,
}
g_hash_table_remove (message_list->uid_nodemap, uid);
- camel_message_info_unref (info);
+ g_clear_object (&info);
g_object_unref (folder);
}
@@ -4551,8 +4564,8 @@ mail_folder_hide_by_flag (CamelFolder *folder,
else
camel_folder_change_info_change_uid (
newchanges, changes->uid_changed->pdata[i]);
- if (info)
- camel_message_info_unref (info);
+
+ g_clear_object (&info);
}
if (newchanges->uid_added->len > 0 || newchanges->uid_removed->len > 0) {
@@ -4751,11 +4764,11 @@ message_list_set_folder (MessageList *message_list,
store = camel_folder_get_parent_store (folder);
non_trash_folder =
- ((store->flags & CAMEL_STORE_VTRASH) == 0) ||
- ((folder->folder_flags & CAMEL_FOLDER_IS_TRASH) == 0);
+ ((camel_store_get_flags (store) & CAMEL_STORE_VTRASH) == 0) ||
+ ((camel_folder_get_flags (folder) & CAMEL_FOLDER_IS_TRASH) == 0);
non_junk_folder =
- ((store->flags & CAMEL_STORE_VJUNK) == 0) ||
- ((folder->folder_flags & CAMEL_FOLDER_IS_JUNK) == 0);
+ ((camel_store_get_flags (store) & CAMEL_STORE_VJUNK) == 0) ||
+ ((camel_folder_get_flags (folder) & CAMEL_FOLDER_IS_JUNK) == 0);
strikeout_col = -1;
strikeout_color_col = -1;
@@ -5124,7 +5137,7 @@ on_click (ETree *tree,
flags = camel_message_info_get_flags (info);
folder_is_trash =
- ((folder->folder_flags & CAMEL_FOLDER_IS_TRASH) != 0);
+ ((camel_folder_get_flags (folder) & CAMEL_FOLDER_IS_TRASH) != 0);
/* If a message was marked as deleted and the user flags it as
* important or unread in a non-Trash folder, then undelete the
@@ -5485,20 +5498,25 @@ cmp_array_uids (gconstpointer a,
struct sort_column_data *scol = g_ptr_array_index (sort_data->sort_columns, i);
if (md1->values->len <= i) {
+ camel_message_info_property_lock (md1->mi);
v1 = ml_tree_value_at_ex (
NULL, NULL,
scol->col->spec->compare_col,
md1->mi, sort_data->message_list);
+ camel_message_info_property_unlock (md1->mi);
g_ptr_array_add (md1->values, v1);
} else {
v1 = g_ptr_array_index (md1->values, i);
}
if (md2->values->len <= i) {
+ camel_message_info_property_lock (md2->mi);
v2 = ml_tree_value_at_ex (
NULL, NULL,
scol->col->spec->compare_col,
md2->mi, sort_data->message_list);
+ camel_message_info_property_unlock (md2->mi);
+
g_ptr_array_add (md2->values, v2);
} else {
v2 = g_ptr_array_index (md2->values, i);
@@ -5539,7 +5557,7 @@ free_message_info_data (gpointer uid,
g_ptr_array_free (data->values, TRUE);
}
- camel_message_info_unref (data->mi);
+ g_clear_object (&data->mi);
g_free (data);
}
@@ -5605,7 +5623,7 @@ ml_sort_uids_by_tree (MessageList *message_list,
g_ptr_array_add (sort_data.sort_columns, data);
}
- camel_folder_summary_prepare_fetch_all (folder->summary, NULL);
+ camel_folder_summary_prepare_fetch_all (camel_folder_get_folder_summary (folder), NULL);
for (i = 0;
i < uids->len
@@ -5640,7 +5658,7 @@ ml_sort_uids_by_tree (MessageList *message_list,
cmp_array_uids,
&sort_data);
- camel_folder_summary_unlock (folder->summary);
+ camel_folder_summary_unlock (camel_folder_get_folder_summary (folder));
/* FIXME Teach the hash table to destroy its own data. */
g_hash_table_foreach (
@@ -5715,7 +5733,7 @@ message_list_regen_tweak_search_results (MessageList *message_list,
search_results,
(gpointer) camel_pstring_strdup (uid));
- camel_message_info_unref (info);
+ g_clear_object (&info);
}
static void
@@ -5858,7 +5876,7 @@ message_list_regen_thread (GSimpleAsyncResult *simple,
camel_folder_sort_uids (folder, uids);
regen_data->summary = g_ptr_array_new ();
- camel_folder_summary_prepare_fetch_all (folder->summary, NULL);
+ camel_folder_summary_prepare_fetch_all (camel_folder_get_folder_summary (folder), NULL);
for (ii = 0; ii < uids->len; ii++) {
const gchar *uid;
diff --git a/src/modules/itip-formatter/itip-view.c b/src/modules/itip-formatter/itip-view.c
index f3b0661..0ede662 100644
--- a/src/modules/itip-formatter/itip-view.c
+++ b/src/modules/itip-formatter/itip-view.c
@@ -5790,7 +5790,7 @@ in_proper_folder (CamelFolder *folder)
));
} else {
/* cannot check for Inbox folder here */
- res = (folder->folder_flags & (CAMEL_FOLDER_IS_TRASH | CAMEL_FOLDER_IS_JUNK)) == 0 && (
+ res = (camel_folder_get_flags (folder) & (CAMEL_FOLDER_IS_TRASH | CAMEL_FOLDER_IS_JUNK)) == 0
&& (
(CAMEL_IS_VEE_FOLDER (folder)) || (
!em_utils_folder_is_sent (registry, folder) &&
!em_utils_folder_is_outbox (registry, folder) &&
diff --git a/src/modules/mail/e-mail-shell-backend.c b/src/modules/mail/e-mail-shell-backend.c
index 09e157e..9d69d28 100644
--- a/src/modules/mail/e-mail-shell-backend.c
+++ b/src/modules/mail/e-mail-shell-backend.c
@@ -159,7 +159,7 @@ mbox_fill_preview_cb (GObject *preview,
parser = e_mail_parser_new (CAMEL_SESSION (mail_session));
e_mail_parser_parse (
- parser, NULL, msg->message_id, msg,
+ parser, NULL, camel_mime_message_get_message_id (msg), msg,
message_parsed_cb, NULL, preview);
g_object_unref (mail_session);
diff --git a/src/modules/mail/e-mail-shell-view-actions.c b/src/modules/mail/e-mail-shell-view-actions.c
index 1f615f5..cb32b73 100644
--- a/src/modules/mail/e-mail-shell-view-actions.c
+++ b/src/modules/mail/e-mail-shell-view-actions.c
@@ -761,8 +761,8 @@ action_mail_folder_mark_all_as_read_cb (GtkAction *action,
folder = e_mail_reader_ref_folder (reader);
g_return_if_fail (folder != NULL);
- if (folder->summary != NULL &&
- camel_folder_summary_get_unread_count (folder->summary) == 0) {
+ if (camel_folder_get_folder_summary (folder) != NULL &&
+ camel_folder_summary_get_unread_count (camel_folder_get_folder_summary (folder)) == 0) {
g_object_unref (folder);
return;
}
diff --git a/src/modules/mail/e-mail-shell-view-private.c b/src/modules/mail/e-mail-shell-view-private.c
index e8bed96..a8b6cb9 100644
--- a/src/modules/mail/e-mail-shell-view-private.c
+++ b/src/modules/mail/e-mail-shell-view-private.c
@@ -886,6 +886,7 @@ e_mail_shell_view_update_sidebar (EMailShellView *mail_shell_view)
CamelStore *parent_store;
CamelFolder *folder;
CamelFolderInfoFlags flags = 0;
+ CamelFolderSummary *folder_summary;
MailFolderCache *folder_cache;
MessageList *message_list;
guint selected_count;
@@ -934,18 +935,18 @@ e_mail_shell_view_update_sidebar (EMailShellView *mail_shell_view)
folder_name = camel_folder_get_display_name (folder);
parent_store = camel_folder_get_parent_store (folder);
+ folder_summary = camel_folder_get_folder_summary (folder);
folder_cache = e_mail_session_get_folder_cache (
e_mail_backend_get_session (E_MAIL_BACKEND (shell_backend)));
mail_folder_cache_get_folder_info_flags (folder_cache, parent_store, folder_name, &flags);
is_inbox = (flags & CAMEL_FOLDER_TYPE_MASK) == CAMEL_FOLDER_TYPE_INBOX;
- num_deleted = camel_folder_summary_get_deleted_count (folder->summary);
- num_junked = camel_folder_summary_get_junk_count (folder->summary);
- num_junked_not_deleted =
- camel_folder_summary_get_junk_not_deleted_count (folder->summary);
- num_unread = camel_folder_summary_get_unread_count (folder->summary);
- num_visible = camel_folder_summary_get_visible_count (folder->summary);
+ num_deleted = camel_folder_summary_get_deleted_count (folder_summary);
+ num_junked = camel_folder_summary_get_junk_count (folder_summary);
+ num_junked_not_deleted = camel_folder_summary_get_junk_not_deleted_count (folder_summary);
+ num_unread = camel_folder_summary_get_unread_count (folder_summary);
+ num_visible = camel_folder_summary_get_visible_count (folder_summary);
buffer = g_string_sized_new (256);
message_list = MESSAGE_LIST (e_mail_reader_get_message_list (reader));
@@ -957,7 +958,7 @@ e_mail_shell_view_update_sidebar (EMailShellView *mail_shell_view)
selected_count), selected_count);
/* "Trash" folder (virtual or real) */
- if (folder->folder_flags & CAMEL_FOLDER_IS_TRASH) {
+ if (camel_folder_get_flags (folder) & CAMEL_FOLDER_IS_TRASH) {
if (CAMEL_IS_VTRASH_FOLDER (folder)) {
/* For a virtual Trash folder, count
* the messages marked for deletion. */
@@ -984,7 +985,7 @@ e_mail_shell_view_update_sidebar (EMailShellView *mail_shell_view)
}
/* "Junk" folder (virtual or real) */
- } else if (folder->folder_flags & CAMEL_FOLDER_IS_JUNK) {
+ } else if (camel_folder_get_flags (folder) & CAMEL_FOLDER_IS_JUNK) {
if (e_mail_reader_get_hide_deleted (reader)) {
/* Junk folder with deleted messages hidden. */
g_string_append_printf (
diff --git a/src/modules/mdn/evolution-mdn.c b/src/modules/mdn/evolution-mdn.c
index 155b9ec..44db3bf 100644
--- a/src/modules/mdn/evolution-mdn.c
+++ b/src/modules/mdn/evolution-mdn.c
@@ -80,9 +80,7 @@ G_DEFINE_DYNAMIC_TYPE (EMdn, e_mdn, E_TYPE_EXTENSION)
static void
mdn_context_free (MdnContext *context)
{
- if (context->info != NULL)
- camel_message_info_unref (context->info);
-
+ g_clear_object (&context->info);
g_object_unref (context->source);
g_object_unref (context->reader);
g_object_unref (context->folder);
@@ -421,7 +419,7 @@ mdn_notify_sender (ESource *identity_source,
NULL, (GAsyncReadyCallback) mdn_receipt_done,
g_object_ref (session));
- camel_message_info_unref (receipt_info);
+ g_clear_object (&receipt_info);
g_free (self_address);
g_free (message_date);
@@ -444,8 +442,7 @@ mdn_notify_action_cb (GtkAction *action,
MDN_SENDING_MODE_MANUAL);
/* Make sure the newly-added user flag gets saved. */
- camel_message_info_unref (context->info);
- context->info = NULL;
+ g_clear_object (&context->info);
}
static void
@@ -532,7 +529,7 @@ mdn_message_loaded_cb (EMailReader *reader,
context->reader = g_object_ref (reader);
context->folder = g_object_ref (folder);
context->message = g_object_ref (message);
- context->info = camel_message_info_ref (info);
+ context->info = g_object_ref (info);
context->notify_to = notify_to;
context->identity_address = identity_address;
@@ -567,9 +564,7 @@ mdn_message_loaded_cb (EMailReader *reader,
g_object_unref (source);
exit:
- if (info != NULL)
- camel_message_info_unref (info);
-
+ g_clear_object (&info);
g_clear_object (&folder);
g_free (identity_address);
g_free (notify_to);
@@ -629,9 +624,7 @@ mdn_message_seen_cb (EMailReader *reader,
g_object_unref (source);
exit:
- if (info != NULL)
- camel_message_info_unref (info);
-
+ g_clear_object (&info);
g_clear_object (&folder);
g_free (identity_address);
g_free (notify_to);
diff --git a/src/plugins/dbx-import/dbx-importer.c b/src/plugins/dbx-import/dbx-importer.c
index 0fe66dc..2c747b8 100644
--- a/src/plugins/dbx-import/dbx-importer.c
+++ b/src/plugins/dbx-import/dbx-importer.c
@@ -681,7 +681,7 @@ dbx_import_file (DbxImporter *m)
success = camel_folder_append_message_sync (
folder, msg, info, NULL,
cancellable, &m->base.error);
- camel_message_info_unref (info);
+ g_clear_object (&info);
g_object_unref (msg);
if (!success) {
diff --git a/src/plugins/mail-to-task/mail-to-task.c b/src/plugins/mail-to-task/mail-to-task.c
index 108b71b..9264797 100644
--- a/src/plugins/mail-to-task/mail-to-task.c
+++ b/src/plugins/mail-to-task/mail-to-task.c
@@ -108,13 +108,12 @@ set_attendees (ECalComponent *comp,
{
GSList *attendees = NULL, *to_free = NULL;
ECalComponentAttendee *ca;
- CamelInternetAddress *from = NULL, *to, *cc, *bcc, *arr[4];
+ CamelInternetAddress *from, *to, *cc, *bcc, *arr[4];
gint len, i, j;
- if (message->reply_to)
- from = message->reply_to;
- else if (message->from)
- from = message->from;
+ from = camel_mime_message_get_reply_to (message);
+ if (!from)
+ from = camel_mime_message_get_from (message);
to = camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_TO);
cc = camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_CC);
@@ -126,7 +125,7 @@ set_attendees (ECalComponent *comp,
if (!arr[j])
continue;
- len = CAMEL_ADDRESS (arr[j])->addresses->len;
+ len = camel_address_length (CAMEL_ADDRESS (arr[j]));
for (i = 0; i < len; i++) {
const gchar *name, *addr;
@@ -179,15 +178,14 @@ prepend_from (CamelMimeMessage *message,
{
gchar *res, *tmp, *addr = NULL;
const gchar *name = NULL, *eml = NULL;
- CamelInternetAddress *from = NULL;
+ CamelInternetAddress *from;
g_return_val_if_fail (message != NULL, NULL);
g_return_val_if_fail (text != NULL, NULL);
- if (message->reply_to)
- from = message->reply_to;
- else if (message->from)
- from = message->from;
+ from = camel_mime_message_get_reply_to (message);
+ if (!from)
+ from = camel_mime_message_get_from (message);
if (from && camel_internet_address_get (from, 0, &name, &eml))
addr = camel_internet_address_format_address (name, eml);
@@ -211,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;
@@ -246,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);
}
@@ -487,7 +487,7 @@ set_priority (ECalComponent *comp,
g_return_if_fail (comp != NULL);
g_return_if_fail (part != NULL);
- prio = camel_header_raw_find (& (part->headers), "X-Priority", NULL);
+ prio = camel_medium_get_header (CAMEL_MEDIUM (part), "X-Priority");
if (prio && atoi (prio) > 0) {
gint priority = 1;
diff --git a/src/plugins/pst-import/pst-importer.c b/src/plugins/pst-import/pst-importer.c
index fed8493..00d7376 100644
--- a/src/plugins/pst-import/pst-importer.c
+++ b/src/plugins/pst-import/pst-importer.c
@@ -1397,7 +1397,7 @@ pst_process_email (PstImporter *m,
/* FIXME Not passing a GCancellable or GError here. */
success = camel_folder_append_message_sync (
m->folder, msg, info, NULL, NULL, NULL);
- camel_message_info_unref (info);
+ g_clear_object (&info);
g_object_unref (msg);
/* FIXME Not passing a GCancellable or GError here. */
diff --git a/src/plugins/templates/e-templates-store.c b/src/plugins/templates/e-templates-store.c
index 40b092f..1f4017b 100644
--- a/src/plugins/templates/e-templates-store.c
+++ b/src/plugins/templates/e-templates-store.c
@@ -445,10 +445,10 @@ tmpl_folder_data_update_sync (TmplFolderData *tfd,
g_return_val_if_fail (CAMEL_IS_FOLDER (tfd->folder), FALSE);
if (!added_uids || !changed_uids || added_uids->len + changed_uids->len > 10)
- camel_folder_summary_prepare_fetch_all (tfd->folder->summary, NULL);
+ camel_folder_summary_prepare_fetch_all (camel_folder_get_folder_summary (tfd->folder), NULL);
if (!added_uids && !changed_uids) {
- all_uids = camel_folder_summary_get_array (tfd->folder->summary);
+ all_uids = camel_folder_summary_get_array (camel_folder_get_folder_summary (tfd->folder));
added_uids = all_uids;
}
@@ -457,7 +457,7 @@ tmpl_folder_data_update_sync (TmplFolderData *tfd,
for (ii = 0; added_uids && ii < added_uids->len; ii++) {
const gchar *uid = added_uids->pdata[ii];
- info = camel_folder_summary_get (tfd->folder->summary, uid);
+ info = camel_folder_summary_get (camel_folder_get_folder_summary (tfd->folder), uid);
if (info) {
if (!(camel_message_info_get_flags (info) & (CAMEL_MESSAGE_JUNK |
CAMEL_MESSAGE_DELETED))) {
/* Sometimes the 'add' notification can come after the 'change',
@@ -467,17 +467,17 @@ tmpl_folder_data_update_sync (TmplFolderData *tfd,
changed = tmpl_folder_data_remove_message (tfd, camel_message_info_get_uid
(info)) || changed;
}
- camel_message_info_unref (info);
+ g_clear_object (&info);
}
}
for (ii = 0; changed_uids && ii < changed_uids->len; ii++) {
const gchar *uid = changed_uids->pdata[ii];
- info = camel_folder_summary_get (tfd->folder->summary, uid);
+ info = camel_folder_summary_get (camel_folder_get_folder_summary (tfd->folder), uid);
if (info) {
changed = tmpl_folder_data_change_message (tfd, info) || changed;
- camel_message_info_unref (info);
+ g_clear_object (&info);
}
}
diff --git a/src/plugins/templates/templates.c b/src/plugins/templates/templates.c
index 6654bc0..1757b9c 100644
--- a/src/plugins/templates/templates.c
+++ b/src/plugins/templates/templates.c
@@ -657,7 +657,7 @@ static CamelMimePart *
fill_template (CamelMimeMessage *message,
CamelMimePart *template)
{
- struct _camel_header_raw *header;
+ const CamelNameValueArray *headers;
CamelContentType *ct;
CamelStream *stream;
CamelMimePart *return_part;
@@ -667,6 +667,7 @@ fill_template (CamelMimeMessage *message,
GString *template_body;
GByteArray *byte_array;
gint i;
+ guint jj, len;
gboolean message_html, template_html;
ct = camel_mime_part_get_content_type (template);
@@ -693,7 +694,7 @@ fill_template (CamelMimeMessage *message,
message_part = camel_multipart_get_part (multipart, i);
}
}
- } else
+ } else
message_part = CAMEL_MIME_PART (message);
/* Get content of the template */
@@ -705,17 +706,22 @@ fill_template (CamelMimeMessage *message,
g_object_unref (stream);
/* Replace all $ORIG[header_name] by respective values */
- header = CAMEL_MIME_PART (message)->headers;
- while (header) {
- if (g_ascii_strncasecmp (header->name, "content-", 8) != 0 &&
- g_ascii_strncasecmp (header->name, "to", 2) != 0 &&
- g_ascii_strncasecmp (header->name, "cc", 2) != 0 &&
- g_ascii_strncasecmp (header->name, "bcc", 3) != 0 &&
- g_ascii_strncasecmp (header->name, "from", 4) != 0 &&
- g_ascii_strncasecmp (header->name, "subject", 7) != 0)
- replace_template_variable (template_body, header->name, header->value);
-
- header = header->next;
+ headers = camel_medium_get_headers (CAMEL_MEDIUM (message));
+ len = camel_name_value_array_get_length (headers);
+ for (jj = 0; jj < len; jj++) {
+ const gchar *header_name = NULL, *header_value = NULL;
+
+ if (!camel_name_value_array_get (headers, jj, &header_name, &header_value) ||
+ !header_name)
+ continue;
+
+ if (g_ascii_strncasecmp (header_name, "content-", 8) != 0 &&
+ g_ascii_strcasecmp (header_name, "to") != 0 &&
+ g_ascii_strcasecmp (header_name, "cc") != 0 &&
+ g_ascii_strcasecmp (header_name, "bcc") != 0 &&
+ g_ascii_strcasecmp (header_name, "from") != 0 &&
+ g_ascii_strcasecmp (header_name, "subject") != 0)
+ replace_template_variable (template_body, header_name, header_value);
}
/* Now manually replace the *subject* header. The header->value for subject header could be
@@ -850,14 +856,15 @@ create_new_message_composer_created_cb (GObject *source_object,
CamelMimeMessage *template;
CamelMultipart *new_multipart;
CamelDataWrapper *dw;
- struct _camel_header_raw *header;
+ const CamelNameValueArray *headers;
+ CamelMimePart *template_part = NULL;
+ CamelFolder *folder;
EMailBackend *backend;
EMailSession *session;
const gchar *message_uid;
EMsgComposer *composer;
+ guint ii, len;
GError *error = NULL;
- CamelMimePart *template_part = NULL;
- CamelFolder *folder;
g_return_if_fail (context != NULL);
@@ -931,39 +938,45 @@ create_new_message_composer_created_cb (GObject *source_object,
/* Add the headers from the message we are replying to, so CC and that
* stuff is preserved. Also replace any $ORIG[header-name] modifiers ignoring
* 'content-*' headers */
- header = CAMEL_MIME_PART (message)->headers;
- while (header) {
- if (g_ascii_strncasecmp (header->name, "content-", 8) != 0 &&
- g_ascii_strcasecmp (header->name, "from") != 0) {
+ headers = camel_medium_dup_headers (CAMEL_MEDIUM (message));
+ len = camel_name_value_array_get_length (headers);
+ for (ii = 0; ii < len; ii++) {
+ const gchar *header_name = NULL, *header_value = NULL;
+
+ if (!camel_name_value_array_get (headers, ii, &header_name, &header_value) ||
+ !header_name)
+ continue;
+
+ if (g_ascii_strncasecmp (header_name, "content-", 8) != 0 &&
+ g_ascii_strcasecmp (header_name, "from") != 0) {
+ gchar *new_header_value = NULL;
/* Some special handling of the 'subject' header */
- if (g_ascii_strncasecmp (header->name, "subject", 7) == 0) {
+ if (g_ascii_strncasecmp (header_name, "subject", 7) == 0) {
GString *subject = g_string_new (camel_mime_message_get_subject (template));
+ guint jj;
/* Now replace all possible $ORIG[]s in the subject line by values from
original message */
- struct _camel_header_raw *m_header = CAMEL_MIME_PART (message)->headers;
- while (m_header) {
- if (g_ascii_strncasecmp (m_header->name, "content-", 8) != 0 &&
- g_ascii_strncasecmp (m_header->name, "subject", 7) !=0)
- replace_template_variable (subject, m_header->name,
m_header->value);
-
- m_header = m_header->next;
+ for (jj = 0; jj < len; jj++) {
+ const gchar *m_header_name = NULL, *m_header_value = NULL;
+
+ if (camel_name_value_array_get (headers, jj, &m_header_name,
&m_header_value) &&
+ m_header_name &&
+ g_ascii_strncasecmp (m_header_name, "content-", 8) != 0 &&
+ g_ascii_strcasecmp (m_header_name, "subject") != 0)
+ replace_template_variable (subject, m_header_name,
m_header_value);
}
/* Now replace $ORIG[subject] variable, handling possible base64 encryption */
replace_template_variable (
subject, "subject",
camel_mime_message_get_subject (message));
- header->value = g_strdup (subject->str);
- g_string_free (subject, TRUE);
+ new_header_value = g_string_free (subject, FALSE);
}
- camel_medium_add_header (
- CAMEL_MEDIUM (new),
- header->name,
- header->value);
- }
+ camel_medium_add_header (CAMEL_MEDIUM (new), header_name, new_header_value ?
new_header_value : header_value);
- header = header->next;
+ g_free (new_header_value);
+ }
}
/* Set the To: field to the same To: field of the message we are replying to. */
@@ -1185,7 +1198,7 @@ save_template_async_data_free (gpointer ptr)
g_clear_object (&sta->composer);
g_clear_object (&sta->session);
g_clear_object (&sta->message);
- camel_message_info_unref (sta->info);
+ g_clear_object (&sta->info);
g_free (sta->templates_folder_uri);
g_free (sta);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]