diff options
author | Paul J Stevens <paul@nfg.nl> | 2009-10-09 09:18:20 +0200 |
---|---|---|
committer | Paul J Stevens <paul@nfg.nl> | 2009-10-09 09:18:20 +0200 |
commit | cafea5c1d672e60d918b79ac8cfbdc94fd0ac3d0 (patch) | |
tree | e0b126ba43cf97aec5f8243cc495a9e591648374 | |
parent | 8dc32f423706f79bc6a9e9ed8121b09c973d13d7 (diff) |
fix UTC offset internal_date regression
-rw-r--r-- | check_dbmail_imapd.c | 12 | ||||
-rw-r--r-- | check_dbmail_message.c | 3 | ||||
-rw-r--r-- | dbmail-message.c | 9 |
3 files changed, 12 insertions, 12 deletions
diff --git a/check_dbmail_imapd.c b/check_dbmail_imapd.c index feb2bb46..5203dda6 100644 --- a/check_dbmail_imapd.c +++ b/check_dbmail_imapd.c @@ -379,9 +379,9 @@ START_TEST(test_imap_get_structure) message = dbmail_message_init_with_string(message, g_string_new(multipart_message)); result = imap_get_structure(GMIME_MESSAGE(message->content), 1); strncpy(expect,"((\"text\" \"html\" NIL NIL NIL \"7BIT\" 16 1 NIL (\"inline\" NIL) NIL NIL)" - "(\"text\" \"plain\" (\"charset\" \"us-ascii\" \"name\" \"testfile\") NIL NIL \"base64\" 432 7 NIL NIL NIL NIL)" + "(\"text\" \"plain\" (\"name\" \"testfile\" \"charset\" \"us-ascii\") NIL NIL \"base64\" 432 7 NIL NIL NIL NIL)" " \"mixed\" (\"boundary\" \"boundary\") NIL NIL NIL)",1024); - fail_unless(strncasecmp(result,expect,1024)==0, "imap_get_structure failed"); + fail_unless(strncasecmp(result,expect,1024)==0, "imap_get_structure failed\n[%s] != \n[%s]\n", result, expect); g_free(result); dbmail_message_free(message); @@ -969,13 +969,11 @@ START_TEST(test_dm_getguid) END_TEST /* this test will fail if you're not in the CET timezone */ -#define D(x,y) fail_unless(strncasecmp(date_sql2imap(x),y,IMAP_INTERNALDATE_LEN)==0,"date_sql2imap failed") +#define D(x,y) fail_unless(strncasecmp(date_sql2imap(x),y,IMAP_INTERNALDATE_LEN)==0,"date_sql2imap failed\n[%s] !=\n[%s]\n", date_sql2imap(x), y) START_TEST(test_date_sql2imap) { -// printf("[%s]\n", date_sql2imap("2005-05-03 14:10:06")); -// printf("[%s]\n", date_sql2imap("2005-01-03 14:10:06")); - D("2005-05-03 14:10:06","03-May-2005 14:10:06 +0200"); - D("2005-01-03 14:10:06","03-Jan-2005 14:10:06 +0100"); + D("2005-05-03 14:10:06","03-May-2005 14:10:06 +0000"); + D("2005-01-03 14:10:06","03-Jan-2005 14:10:06 +0000"); } END_TEST diff --git a/check_dbmail_message.c b/check_dbmail_message.c index 0ea30f8c..11599a81 100644 --- a/check_dbmail_message.c +++ b/check_dbmail_message.c @@ -239,7 +239,6 @@ START_TEST(test_dbmail_message_to_string) m = dbmail_message_new(); m = dbmail_message_init_with_string(m,s); result = dbmail_message_to_string(m); - printf("[%s]\n", result); fail_unless(strlen(result)==596,"test_dbmail_message_to_string failed. result size mismatch [%zd != 596]", strlen(result)); g_string_free(s,TRUE); g_free(result); @@ -251,7 +250,7 @@ START_TEST(test_dbmail_message_to_string) m = dbmail_message_new(); m = dbmail_message_retrieve(m, id, DBMAIL_MESSAGE_FILTER_FULL); result = dbmail_message_to_string(m); - printf("[%s]\n", result); + fail_unless(strlen(result)==596,"test_dbmail_message_to_string failed. result size mismatch [%zd != 596]", strlen(result)); dbmail_message_free(m); g_free(result); diff --git a/dbmail-message.c b/dbmail-message.c index bfaff026..7e34f73f 100644 --- a/dbmail-message.c +++ b/dbmail-message.c @@ -165,6 +165,7 @@ struct DbmailMessage * dbmail_message_new(void) { struct DbmailMessage *self = g_new0(struct DbmailMessage,1); + self->internal_date = time(NULL); self->envelope_recipient = g_string_new(""); /* provide quick case-insensitive header name searches */ @@ -501,8 +502,11 @@ u64_t dbmail_message_get_physid(const struct DbmailMessage *self) void dbmail_message_set_internal_date(struct DbmailMessage *self, char *internal_date) { - if (internal_date) + TRACE(TRACE_DEBUG,"[%s]", internal_date); + if (internal_date && strlen(internal_date)) self->internal_date = g_mime_utils_header_decode_date(internal_date, self->internal_date_gmtoff); + else + self->internal_date = time(NULL); } /* thisyear is a workaround for some broken gmime version. */ @@ -510,8 +514,7 @@ gchar * dbmail_message_get_internal_date(const struct DbmailMessage *self, int t { char *res; struct tm gmt; - if (! self->internal_date) - return NULL; + assert(self->internal_date); res = g_new0(char, TIMESTRING_SIZE+1); memset(&gmt,'\0', sizeof(struct tm)); |