aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-mime-message.c
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2003-03-21 00:43:29 +0800
committerDan Winship <danw@src.gnome.org>2003-03-21 00:43:29 +0800
commitbecf944b42e72175079e9b975ab631e9adc91b43 (patch)
treeafaa5e3960f576cc653e6d095fc5420dcdf12664 /camel/camel-mime-message.c
parent1bef6b2b8cd335f167deb690160c8fb9d4f06dd0 (diff)
downloadgsoc2013-evolution-becf944b42e72175079e9b975ab631e9adc91b43.tar
gsoc2013-evolution-becf944b42e72175079e9b975ab631e9adc91b43.tar.gz
gsoc2013-evolution-becf944b42e72175079e9b975ab631e9adc91b43.tar.bz2
gsoc2013-evolution-becf944b42e72175079e9b975ab631e9adc91b43.tar.lz
gsoc2013-evolution-becf944b42e72175079e9b975ab631e9adc91b43.tar.xz
gsoc2013-evolution-becf944b42e72175079e9b975ab631e9adc91b43.tar.zst
gsoc2013-evolution-becf944b42e72175079e9b975ab631e9adc91b43.zip
Handle raw 8-bit From data "correctly". (The same way we handle
raw 8-bit Subject data.) * camel-mime-utils.c (header_decode_mailbox): Take a charset arg and pass it to header_decode_string. (header_decode_address): Take a charset arg and pass it to header_decode_mailbox. (header_mailbox_decode): Likewise. (header_address_decode): Take a charset arg and pass it to header_decode_address. * camel-folder-summary.c (summary_format_address): Take a charset arg and pass to header_address_decode. (message_info_new, camel_message_info_new_from_header): Pass charset to summary_format_address * camel-internet-address.c (internet_decode): Update for header_address_decode change. (Unfortunately we don't have a charset to pass here.) * camel-mime-message.c (camel_mime_message_build_mbox_from): Move this here from camel-mbox-summary since the same functionality is needed by evolution-mail too (and update for header_address_decode change) * providers/local/camel-mbox-summary.c (camel_mbox_summary_build_from): Moved to CamelMimeMessage svn path=/trunk/; revision=20430
Diffstat (limited to 'camel/camel-mime-message.c')
-rw-r--r--camel/camel-mime-message.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/camel/camel-mime-message.c b/camel/camel-mime-message.c
index aa15eeec5f..5108670104 100644
--- a/camel/camel-mime-message.c
+++ b/camel/camel-mime-message.c
@@ -901,3 +901,68 @@ camel_mime_message_get_part_by_content_id (CamelMimeMessage *message, const char
return check.part;
}
+
+static char *tz_months[] = {
+ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
+ "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
+};
+
+static char *tz_days[] = {
+ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
+};
+
+char *
+camel_mime_message_build_mbox_from (CamelMimeMessage *message)
+{
+ struct _header_raw *header = ((CamelMimePart *)message)->headers;
+ GString *out = g_string_new("From ");
+ char *ret;
+ const char *tmp;
+ time_t thetime;
+ int offset;
+ struct tm tm;
+
+ tmp = header_raw_find (&header, "Sender", NULL);
+ if (tmp == NULL)
+ tmp = header_raw_find (&header, "From", NULL);
+ if (tmp != NULL) {
+ struct _header_address *addr = header_address_decode (tmp, NULL);
+
+ tmp = NULL;
+ if (addr) {
+ if (addr->type == HEADER_ADDRESS_NAME) {
+ g_string_append (out, addr->v.addr);
+ tmp = "";
+ }
+ header_address_unref (addr);
+ }
+ }
+
+ if (tmp == NULL)
+ g_string_append (out, "unknown@nodomain.now.au");
+
+ /* try use the received header to get the date */
+ tmp = header_raw_find (&header, "Received", NULL);
+ if (tmp) {
+ tmp = strrchr(tmp, ';');
+ if (tmp)
+ tmp++;
+ }
+
+ /* if there isn't one, try the Date field */
+ if (tmp == NULL)
+ tmp = header_raw_find (&header, "Date", NULL);
+
+ thetime = header_decode_date (tmp, &offset);
+ thetime += ((offset / 100) * (60 * 60)) + (offset % 100) * 60;
+ gmtime_r (&thetime, &tm);
+ g_string_append_printf (out, " %s %s %2d %02d:%02d:%02d %4d\n",
+ tz_days[tm.tm_wday], tz_months[tm.tm_mon],
+ tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec,
+ tm.tm_year + 1900);
+
+ ret = out->str;
+ g_string_free (out, FALSE);
+
+ return ret;
+}