[evolution/wip/camel-more-gobject] Bug 773787 - Replace CamelHeaderRaw by CamelNameValueArray
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/wip/camel-more-gobject] Bug 773787 - Replace CamelHeaderRaw by CamelNameValueArray
- Date: Fri, 4 Nov 2016 12:13:11 +0000 (UTC)
commit 2564e4a34102c78385fad81b2f5bf35498bd306f
Author: Milan Crha <mcrha redhat com>
Date: Fri Nov 4 13:13:13 2016 +0100
Bug 773787 - Replace CamelHeaderRaw by CamelNameValueArray
src/composer/e-msg-composer.c | 65 +++++++++------------
src/em-format/e-mail-formatter-headers.c | 71 +++++++++++++----------
src/em-format/e-mail-part-headers.c | 11 +---
src/libemail-engine/e-mail-folder-utils.c | 9 +--
src/libemail-engine/e-mail-session-utils.c | 28 +++++----
src/libemail-engine/e-mail-session.c | 4 +-
src/libemail-engine/mail-ops.c | 19 ++++--
src/libemail-engine/mail-tools.c | 62 ++++++++++++++-------
src/libemail-engine/mail-tools.h | 17 ++++--
src/mail/e-mail-reader-utils.c | 21 ++++---
src/mail/e-mail-tag-editor.c | 16 +++---
src/mail/mail-autofilter.c | 3 +-
src/plugins/mail-to-task/mail-to-task.c | 2 +-
src/plugins/templates/templates.c | 85 ++++++++++++++++------------
14 files changed, 229 insertions(+), 184 deletions(-)
---
diff --git a/src/composer/e-msg-composer.c b/src/composer/e-msg-composer.c
index 01a9e71..ca526aa 100644
--- a/src/composer/e-msg-composer.c
+++ b/src/composer/e-msg-composer.c
@@ -278,22 +278,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)
@@ -1516,7 +1500,7 @@ composer_build_message_finish (EMsgComposer *composer,
CAMEL_IS_MIME_PART (context->top_level_part)) {
CamelDataWrapper *content;
CamelMedium *imedium, *omedium;
- CamelNameValueArray *headers;
+ const CamelNameValueArray *headers;
imedium = CAMEL_MEDIUM (context->top_level_part);
omedium = CAMEL_MEDIUM (context->message);
@@ -1525,7 +1509,7 @@ composer_build_message_finish (EMsgComposer *composer,
camel_medium_set_content (omedium, content);
camel_data_wrapper_set_encoding (CAMEL_DATA_WRAPPER (omedium),
camel_data_wrapper_get_encoding (CAMEL_DATA_WRAPPER (imedium)));
- headers = camel_medium_dup_headers (imedium);
+ headers = camel_medium_get_headers (imedium);
if (headers) {
gint ii, length;
length = camel_name_value_array_get_length (headers);
@@ -1537,8 +1521,6 @@ composer_build_message_finish (EMsgComposer *composer,
if (camel_name_value_array_get (headers, ii, &header_name,
&header_value))
camel_medium_set_header (omedium, header_name, header_value);
}
-
- camel_name_value_array_free (headers);
}
} else {
camel_medium_set_content (
@@ -3542,7 +3524,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;
@@ -3550,23 +3532,27 @@ e_msg_composer_setup_with_message (EMsgComposer *composer,
EHTMLEditor *editor;
EContentEditor *cnt_editor;
GtkToggleAction *action;
- struct _camel_header_raw *xev;
gchar *identity_uid;
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);
@@ -3770,8 +3756,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 (
@@ -3787,19 +3772,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/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-part-headers.c b/src/em-format/e-mail-part-headers.c
index fd53d79..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;
- CamelNameValueArray *headers;
+ const CamelNameValueArray *headers;
gint default_position = 0;
guint ii, length = 0;
@@ -78,10 +78,8 @@ mail_part_headers_build_print_model (EMailPartHeaders *part)
G_TYPE_STRING); /* HEADER_VALUE */
message = e_mail_part_list_get_message (part_list);
- headers = camel_medium_dup_headers (CAMEL_MEDIUM (message));
-
- if (headers != NULL)
- length = camel_name_value_array_get_length (headers);
+ headers = camel_medium_get_headers (CAMEL_MEDIUM (message));
+ length = camel_name_value_array_get_length (headers);
for (ii = 0; ii < length; ii++) {
GtkTreeIter iter;
@@ -126,9 +124,6 @@ mail_part_headers_build_print_model (EMailPartHeaders *part)
-1);
}
- if (headers != NULL)
- camel_name_value_array_free (headers);
-
g_object_unref (part_list);
/* Stash the print model internally. */
diff --git a/src/libemail-engine/e-mail-folder-utils.c b/src/libemail-engine/e-mail-folder-utils.c
index 5f96387..a1ba050 100644
--- a/src/libemail-engine/e-mail-folder-utils.c
+++ b/src/libemail-engine/e-mail-folder-utils.c
@@ -1370,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);
diff --git a/src/libemail-engine/e-mail-session-utils.c b/src/libemail-engine/e-mail-session-utils.c
index 71b72cb..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;
@@ -77,8 +77,7 @@ async_context_free (AsyncContext *context)
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 (
@@ -633,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) {
@@ -803,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));
@@ -819,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);
}
@@ -880,7 +883,8 @@ e_mail_session_send_to (EMailSession *session,
/* Miscellaneous preparations. */
- info = camel_message_info_new_from_header (NULL, CAMEL_MIME_PART (message)->headers);
+ 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);
@@ -896,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 5cb61cc..40b1e83 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;
@@ -1446,8 +1445,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 ();
diff --git a/src/libemail-engine/mail-ops.c b/src/libemail-engine/mail-ops.c
index e690bc3..9d99d3f 100644
--- a/src/libemail-engine/mail-ops.c
+++ b/src/libemail-engine/mail-ops.c
@@ -585,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;
@@ -621,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 ();
@@ -689,13 +690,17 @@ mail_send_message (struct _send_queue_msg *m,
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) {
@@ -713,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 (
@@ -891,7 +896,7 @@ exit:
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);
}
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/mail/e-mail-reader-utils.c b/src/mail/e-mail-reader-utils.c
index 891d728..654c5b4 100644
--- a/src/mail/e-mail-reader-utils.c
+++ b/src/mail/e-mail-reader-utils.c
@@ -2410,7 +2410,8 @@ e_mail_reader_reply_to_message (EMailReader *reader,
CamelFolder *folder;
EMailReplyStyle reply_style;
EWebView *web_view;
- struct _camel_header_raw *header;
+ const CamelNameValueArray *headers;
+ guint ii, len;
const gchar *uid;
gchar *selection = NULL;
gint length;
@@ -2524,14 +2525,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 (
diff --git a/src/mail/e-mail-tag-editor.c b/src/mail/e-mail-tag-editor.c
index da38b3f..73958de 100644
--- a/src/mail/e-mail-tag-editor.c
+++ b/src/mail/e-mail-tag-editor.c
@@ -274,23 +274,23 @@ e_mail_tag_editor_get_tag_list (EMailTagEditor *editor)
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, TRUE, "follow-up", text);
+ camel_name_value_array_set_named (tag_list, CAMEL_COMPARE_CASE_SENSITIVE, "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_name_value_array_set_named (tag_list, TRUE, "due-by", text);
+ 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, TRUE, "due-by", "");
+ 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, TRUE, "completed-on", text);
+ 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, TRUE, "completed-on", "");
+ camel_name_value_array_set_named (tag_list, CAMEL_COMPARE_CASE_SENSITIVE, "completed-on", "");
return tag_list;
}
@@ -313,18 +313,18 @@ e_mail_tag_editor_set_tag_list (EMailTagEditor *editor,
* 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, TRUE, "follow-up");
+ 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, TRUE, "due-by");
+ 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);
- text = camel_name_value_array_get_named (tag_list, TRUE, "completed-on");
+ 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) {
diff --git a/src/mail/mail-autofilter.c b/src/mail/mail-autofilter.c
index 36344fd..c3eebf4 100644
--- a/src/mail/mail-autofilter.c
+++ b/src/mail/mail-autofilter.c
@@ -284,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/plugins/mail-to-task/mail-to-task.c b/src/plugins/mail-to-task/mail-to-task.c
index 0b334ed..a852029 100644
--- a/src/plugins/mail-to-task/mail-to-task.c
+++ b/src/plugins/mail-to-task/mail-to-task.c
@@ -470,7 +470,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/templates/templates.c b/src/plugins/templates/templates.c
index 4a20077..cca85ae 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. */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]