diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2013-06-07 02:08:21 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2013-06-07 02:08:21 +0800 |
commit | 863fee647958686bce10a0e0a499b78e72d64a41 (patch) | |
tree | da32ced8b069a0c214c83168cae26cc89f1f4725 /em-format | |
parent | 312d230cd2493ddfb2581d1ed90e688e6d099fb9 (diff) | |
download | gsoc2013-evolution-863fee647958686bce10a0e0a499b78e72d64a41.tar gsoc2013-evolution-863fee647958686bce10a0e0a499b78e72d64a41.tar.gz gsoc2013-evolution-863fee647958686bce10a0e0a499b78e72d64a41.tar.bz2 gsoc2013-evolution-863fee647958686bce10a0e0a499b78e72d64a41.tar.lz gsoc2013-evolution-863fee647958686bce10a0e0a499b78e72d64a41.tar.xz gsoc2013-evolution-863fee647958686bce10a0e0a499b78e72d64a41.tar.zst gsoc2013-evolution-863fee647958686bce10a0e0a499b78e72d64a41.zip |
e_mail_formatter_format_header: Split the header param.
Split the _camel_header_raw struct parameter into separate "header_name"
and "header_value" string parameters, which is all the function actually
needs to work.
Diffstat (limited to 'em-format')
-rw-r--r-- | em-format/e-mail-formatter-headers.c | 18 | ||||
-rw-r--r-- | em-format/e-mail-formatter-print-headers.c | 32 | ||||
-rw-r--r-- | em-format/e-mail-formatter-utils.c | 24 | ||||
-rw-r--r-- | em-format/e-mail-formatter-utils.h | 3 |
4 files changed, 41 insertions, 36 deletions
diff --git a/em-format/e-mail-formatter-headers.c b/em-format/e-mail-formatter-headers.c index 9e43bb24e1..3cd5fa553d 100644 --- a/em-format/e-mail-formatter-headers.c +++ b/em-format/e-mail-formatter-headers.c @@ -342,7 +342,9 @@ format_full_headers (EMailFormatter *formatter, header = ((CamelMimePart *) part)->headers; while (header != NULL) { e_mail_formatter_format_header ( - formatter, buffer, header, + formatter, buffer, + header->name, + header->value, E_MAIL_FORMATTER_HEADER_FLAG_NOCOLUMNS, charset); header = header->next; } @@ -372,7 +374,7 @@ format_full_headers (EMailFormatter *formatter, !g_ascii_strcasecmp (header->name, "User-Agent") || !g_ascii_strcasecmp (header->name, "X-Newsreader") || !g_ascii_strcasecmp (header->name, "X-MimeOLE"))) { - struct _camel_header_raw xmailer, *use_header = NULL; + struct _camel_header_raw *use_header = NULL; if (!g_ascii_strcasecmp (header->name, "X-MimeOLE")) { for (use_header = header->next; use_header; use_header = use_header->next) { @@ -385,16 +387,16 @@ format_full_headers (EMailFormatter *formatter, } } - if (!use_header) + if (use_header == NULL) use_header = header; - xmailer.name = (gchar *) "X-Evolution-Mailer"; - xmailer.value = use_header->value; mailer_shown = TRUE; e_mail_formatter_format_header ( formatter, buffer, - &xmailer, h->flags, charset); + "X-Evolution-Mailer", + use_header->value, + h->flags, charset); } else if (!face_decoded && face && !g_ascii_strcasecmp (header->name, "Face")) { gchar *cp = header->value; @@ -413,7 +415,9 @@ format_full_headers (EMailFormatter *formatter, } else if (!g_ascii_strcasecmp (header->name, h->name) && !face) { e_mail_formatter_format_header ( formatter, buffer, - header, h->flags, charset); + header->name, + header->value, + h->flags, charset); } header = header->next; diff --git a/em-format/e-mail-formatter-print-headers.c b/em-format/e-mail-formatter-print-headers.c index 8a11e0f8d3..3eb188525b 100644 --- a/em-format/e-mail-formatter-print-headers.c +++ b/em-format/e-mail-formatter-print-headers.c @@ -55,7 +55,6 @@ emfpe_headers_format (EMailFormatterExtension *extension, CamelStream *stream, GCancellable *cancellable) { - struct _camel_header_raw raw_header; GString *str, *tmp; gchar *subject; const gchar *buf; @@ -83,16 +82,16 @@ emfpe_headers_format (EMailFormatterExtension *extension, headers_queue = e_mail_formatter_dup_headers (formatter); for (link = headers_queue->head; link != NULL; link = g_list_next (link)) { EMailFormatterHeader *header = link->data; - raw_header.name = header->name; /* Skip 'Subject' header, it's already displayed. */ if (g_ascii_strncasecmp (header->name, "Subject", 7) == 0) continue; if (header->value && *header->value) { - raw_header.value = header->value; e_mail_formatter_format_header ( - formatter, str, &raw_header, + formatter, str, + header->name, + header->value, header->flags | E_MAIL_FORMATTER_HEADER_FLAG_NOLINKS, "UTF-8"); } else { @@ -103,17 +102,15 @@ emfpe_headers_format (EMailFormatterExtension *extension, header_value = camel_medium_get_header ( CAMEL_MEDIUM (message), header->name); - raw_header.value = g_strdup (header_value); - if (raw_header.value && *raw_header.value) { + if (header_value != NULL && *header_value != '\0') { e_mail_formatter_format_header ( - formatter, str, &raw_header, + formatter, str, + header->name, + header_value, header->flags | E_MAIL_FORMATTER_HEADER_FLAG_NOLINKS, "UTF-8"); } - - if (raw_header.value) - g_free (raw_header.value); } } @@ -124,7 +121,6 @@ emfpe_headers_format (EMailFormatterExtension *extension, part_id_prefix = g_strndup (part_id, g_strrstr (part_id, ".") - part_id); /* Add encryption/signature header */ - raw_header.name = _("Security"); tmp = g_string_new (""); e_mail_part_list_queue_parts (context->part_list, NULL, &queue); @@ -167,9 +163,9 @@ emfpe_headers_format (EMailFormatterExtension *extension, } if (tmp->len > 0) { - raw_header.value = tmp->str; e_mail_formatter_format_header ( - formatter, str, &raw_header, + formatter, str, + _("Security"), tmp->str, E_MAIL_FORMATTER_HEADER_FLAG_BOLD | E_MAIL_FORMATTER_HEADER_FLAG_NOLINKS, "UTF-8"); } @@ -197,13 +193,15 @@ emfpe_headers_format (EMailFormatterExtension *extension, } if (attachments_count > 0) { - raw_header.name = _("Attachments"); - raw_header.value = g_strdup_printf ("%d", attachments_count); + gchar *header_value; + + header_value = g_strdup_printf ("%d", attachments_count); e_mail_formatter_format_header ( - formatter, str, &raw_header, + formatter, str, + _("Attachments"), header_value, E_MAIL_FORMATTER_HEADER_FLAG_BOLD | E_MAIL_FORMATTER_HEADER_FLAG_NOLINKS, "UTF-8"); - g_free (raw_header.value); + g_free (header_value); } while (!g_queue_is_empty (&queue)) diff --git a/em-format/e-mail-formatter-utils.c b/em-format/e-mail-formatter-utils.c index 409e2c6314..f3f6f24a20 100644 --- a/em-format/e-mail-formatter-utils.c +++ b/em-format/e-mail-formatter-utils.c @@ -273,7 +273,8 @@ e_mail_formatter_canon_header_name (gchar *name) void e_mail_formatter_format_header (EMailFormatter *formatter, GString *buffer, - struct _camel_header_raw *header, + const gchar *header_name, + const gchar *header_value, guint32 flags, const gchar *charset) { @@ -285,10 +286,11 @@ e_mail_formatter_format_header (EMailFormatter *formatter, g_return_if_fail (E_IS_MAIL_FORMATTER (formatter)); g_return_if_fail (buffer != NULL); - g_return_if_fail (header != NULL); + g_return_if_fail (header_name != NULL); + g_return_if_fail (header_value != NULL); - name = g_alloca (strlen (header->name) + 1); - strcpy (name, header->name); + name = g_alloca (strlen (header_name) + 1); + strcpy (name, header_name); e_mail_formatter_canon_header_name (name); for (i = 0; addrspec_hdrs[i]; i++) { @@ -310,7 +312,7 @@ e_mail_formatter_format_header (EMailFormatter *formatter, if (charset == NULL) charset = e_mail_formatter_dup_default_charset (formatter); - buf = camel_header_unfold (header->value); + buf = camel_header_unfold (header_value); addrs = camel_header_address_decode (buf, charset); if (addrs == NULL) { g_free (charset); @@ -342,7 +344,7 @@ e_mail_formatter_format_header (EMailFormatter *formatter, flags |= E_MAIL_FORMATTER_HEADER_FLAG_BOLD; } else if (g_str_equal (name, "Subject")) { - buf = camel_header_unfold (header->value); + buf = camel_header_unfold (header_value); txt = value = camel_header_decode_string (buf, charset); g_free (buf); @@ -351,7 +353,7 @@ e_mail_formatter_format_header (EMailFormatter *formatter, } else if (g_str_equal (name, "X-evolution-mailer")) { /* pseudo-header */ label = _("Mailer"); - txt = value = camel_header_format_ctext (header->value, charset); + txt = value = camel_header_format_ctext (header_value, charset); flags |= E_MAIL_FORMATTER_HEADER_FLAG_BOLD; } else if (g_str_equal (name, "Date") || g_str_equal (name, "Resent-Date")) { @@ -364,7 +366,7 @@ e_mail_formatter_format_header (EMailFormatter *formatter, hide_real_date = !e_mail_formatter_get_show_real_date (formatter); - txt = header->value; + txt = header_value; while (*txt == ' ' || *txt == '\t') txt++; @@ -413,7 +415,7 @@ e_mail_formatter_format_header (EMailFormatter *formatter, struct _camel_header_newsgroup *ng, *scan; GString *html; - buf = camel_header_unfold (header->value); + buf = camel_header_unfold (header_value); if (!(ng = camel_header_newsgroups_decode (buf))) { g_free (buf); @@ -447,11 +449,11 @@ e_mail_formatter_format_header (EMailFormatter *formatter, } else if (g_str_equal (name, "Received") || g_str_has_prefix (name, "X-")) { /* don't unfold Received nor extension headers */ - txt = value = camel_header_decode_string (header->value, charset); + txt = value = camel_header_decode_string (header_value, charset); } else { /* don't unfold Received nor extension headers */ - buf = camel_header_unfold (header->value); + buf = camel_header_unfold (header_value); txt = value = camel_header_decode_string (buf, charset); g_free (buf); } diff --git a/em-format/e-mail-formatter-utils.h b/em-format/e-mail-formatter-utils.h index f24ee6f5b2..0312d545e0 100644 --- a/em-format/e-mail-formatter-utils.h +++ b/em-format/e-mail-formatter-utils.h @@ -26,7 +26,8 @@ G_BEGIN_DECLS void e_mail_formatter_format_header (EMailFormatter *formatter, GString *buffer, - struct _camel_header_raw *header, + const gchar *header_name, + const gchar *header_value, guint32 flags, const gchar *charset); |