aboutsummaryrefslogtreecommitdiffstats
path: root/mail/mail-format.c
diff options
context:
space:
mode:
author4 <NotZed@Ximian.com>2001-09-25 03:31:36 +0800
committerMichael Zucci <zucchi@src.gnome.org>2001-09-25 03:31:36 +0800
commit9a864d05fef7e45c251048bebaadbfd5e07d5ac7 (patch)
treeab3b028b70b28be23bd538988211037e3852db8c /mail/mail-format.c
parent450e955e76ca9174658c0bb94e99e4174df2fe48 (diff)
downloadgsoc2013-evolution-9a864d05fef7e45c251048bebaadbfd5e07d5ac7.tar
gsoc2013-evolution-9a864d05fef7e45c251048bebaadbfd5e07d5ac7.tar.gz
gsoc2013-evolution-9a864d05fef7e45c251048bebaadbfd5e07d5ac7.tar.bz2
gsoc2013-evolution-9a864d05fef7e45c251048bebaadbfd5e07d5ac7.tar.lz
gsoc2013-evolution-9a864d05fef7e45c251048bebaadbfd5e07d5ac7.tar.xz
gsoc2013-evolution-9a864d05fef7e45c251048bebaadbfd5e07d5ac7.tar.zst
gsoc2013-evolution-9a864d05fef7e45c251048bebaadbfd5e07d5ac7.zip
Removed unused variables.
2001-09-24 <NotZed@Ximian.com> * mail-local.c (mls_get_folder): Removed unused variables. * component-factory.c (storage_create_folder): Remove unused variable. * mail-format.c (write_default_header): Used to write a header that we know about/normally print. Use a static header table to index these. (write_header): removed. (default_header_index): Return the index of the default header. (write_headers): Changed the way it writes headers a bit. Use write_default_header or write_text_header directly. Also try and use the header charset as a fallback if the header can't be decoded using the locale charset. svn path=/trunk/; revision=13097
Diffstat (limited to 'mail/mail-format.c')
-rw-r--r--mail/mail-format.c101
1 files changed, 63 insertions, 38 deletions
diff --git a/mail/mail-format.c b/mail/mail-format.c
index 480a3fbcdc..b1e3f9b5d1 100644
--- a/mail/mail-format.c
+++ b/mail/mail-format.c
@@ -872,30 +872,53 @@ write_address (MailDisplay *md, const CamelInternetAddress *addr, const char *fi
mail_html_write (md->html, md->stream, "</td></tr>");
}
+/* order of these must match write_header code */
+static char *default_headers[] = {
+ "From", "Reply-To", "To", "Cc", "Subject", "Date",
+};
+
+/* return index of header in default_headers array */
+static int
+default_header_index(const char *name)
+{
+ int i;
+ for (i=0;i<sizeof(default_headers)/sizeof(default_headers[0]);i++)
+ if (!g_strcasecmp(name, default_headers[i]))
+ return i;
+
+ return -1;
+}
+
+/* index is index of header in default_headers array */
static void
-write_header (CamelMimeMessage *message, MailDisplay *md,
- const char *name, const char *value, int flags)
+write_default_header(CamelMimeMessage *message, MailDisplay *md, int index, int flags)
{
- if (!g_strcasecmp (name, "From")) {
- write_address (md, camel_mime_message_get_from (message),
- _("From"), flags | WRITE_BOLD);
- } else if (!g_strcasecmp (name, "Reply-To")) {
- write_address (md, camel_mime_message_get_reply_to (message),
- _("Reply-To"), flags);
- } else if (!g_strcasecmp (name, "To")) {
- write_address (md, camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_TO),
- _("To"), flags | WRITE_BOLD);
- } else if (!g_strcasecmp (name, "Cc")) {
+ switch(index) {
+ case 0:
+ write_address (md, camel_mime_message_get_from (message), _("From"), flags | WRITE_BOLD);
+ break;
+ case 1:
+ write_address (md, camel_mime_message_get_reply_to (message), _("Reply-To"), flags);
+ break;
+ case 2:
+ write_address(md, camel_mime_message_get_recipients(message, CAMEL_RECIPIENT_TYPE_TO),
+ _("To"), flags | WRITE_BOLD);
+ break;
+ case 3:
write_address (md, camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_CC),
_("Cc"), flags | WRITE_BOLD);
- } else if (!g_strcasecmp (name, "Subject")) {
+ break;
+ case 4:
write_text_header (_("Subject"), camel_mime_message_get_subject (message),
flags | WRITE_BOLD, md->html, md->stream);
- } else if (!g_strcasecmp (name, "Date")) {
+ break;
+ case 5:
write_date (message, flags | WRITE_BOLD, md->html, md->stream);
- } else
- write_text_header (name, value, flags, md->html, md->stream);
+ break;
+ default:
+ g_assert_not_reached();
+ }
}
#define COLOR_IS_LIGHT(r, g, b) ((r + g + b) > (128 * 3))
@@ -904,16 +927,10 @@ static void
write_headers (CamelMimeMessage *message, MailDisplay *md)
{
gboolean full = (md->display_style == MAIL_CONFIG_DISPLAY_FULL_HEADERS);
- CamelMediumHeader *headers, default_headers[] = {
- { "From", NULL }, { "Reply-To", NULL },
- { "To", NULL }, { "Cc" , NULL }, { "Subject", NULL },
- { "Date", NULL }
- };
char bgcolor[7], fontcolor[7];
GtkStyle *style = NULL;
- int i, len, flags;
- GArray *gheaders;
-
+ int i;
+
/* My favorite thing to do...much around with colors so we respect people's stupid themes */
style = gtk_widget_get_style (GTK_WIDGET (md->html));
if (style) {
@@ -958,23 +975,31 @@ write_headers (CamelMimeMessage *message, MailDisplay *md)
"<tr><td><table>\n", fontcolor, bgcolor);
if (full) {
- gheaders = camel_medium_get_headers (CAMEL_MEDIUM (message));
- headers = (CamelMediumHeader *)gheaders->data;
- len = gheaders->len;
- flags = WRITE_NOCOLUMNS;
+ struct _header_raw *header;
+ const char *charset;
+ CamelContentType *ct;
+ char *value;
+
+ ct = camel_mime_part_get_content_type(CAMEL_MIME_PART(message));
+ charset = header_content_type_param(ct, "charset");
+ charset = camel_charset_to_iconv(charset);
+
+ header = CAMEL_MIME_PART(message)->headers;
+ while (header) {
+ i = default_header_index(header->name);
+ if (i == -1) {
+ value = header_decode_string(header->value, charset);
+ write_text_header(header->name, value, WRITE_NOCOLUMNS, md->html, md->stream);
+ g_free(value);
+ } else
+ write_default_header(message, md, i, WRITE_NOCOLUMNS);
+ header = header->next;
+ }
} else {
- gheaders = NULL;
- headers = default_headers;
- len = sizeof (default_headers) / sizeof (default_headers[0]);
- flags = 0;
+ for (i=0;i<sizeof(default_headers)/sizeof(default_headers[0]);i++)
+ write_default_header(message, md, i, 0);
}
- for (i = 0; i < len; i++)
- write_header (message, md, headers[i].name, headers[i].value, flags);
-
- if (gheaders)
- camel_medium_free_headers (CAMEL_MEDIUM (message), gheaders);
-
mail_html_write (md->html, md->stream,
"</table></td></tr></table></td></tr></table></font></td>"
"<td><table width=10 cellpadding=0 cellspacing=0><tr><td></td></tr></table></td></tr>"