diff options
author | Paul J Stevens <paul@nfg.nl> | 2010-05-24 18:45:36 +0200 |
---|---|---|
committer | Paul J Stevens <paul@nfg.nl> | 2010-05-24 18:45:36 +0200 |
commit | 8d0ef2ad5dc097effafb07a4fd3cf2cd13bcd0a7 (patch) | |
tree | 16fc3ba13ceb8b203d23c048db76c6766dbc971e | |
parent | 093d508631d226379b4c1bbf18fd2dc670b76c5f (diff) |
various fixes (bug #797)
-rw-r--r-- | src/dbmail-imapsession.c | 74 | ||||
-rw-r--r-- | src/dbmail-message.c | 63 | ||||
-rw-r--r-- | src/dbmailtypes.h | 1 | ||||
-rw-r--r-- | src/dm_cache.c | 6 | ||||
-rw-r--r-- | src/dm_db.c | 56 | ||||
-rw-r--r-- | src/dm_db.h | 55 | ||||
-rw-r--r-- | src/dm_mailboxstate.c | 1 | ||||
-rw-r--r-- | test-scripts/testfetch.txt | 2 | ||||
-rw-r--r-- | test/check_dbmail_message.c | 30 |
9 files changed, 94 insertions, 194 deletions
diff --git a/src/dbmail-imapsession.c b/src/dbmail-imapsession.c index 57f178f9..8bd99f96 100644 --- a/src/dbmail-imapsession.c +++ b/src/dbmail-imapsession.c @@ -123,6 +123,8 @@ static u64_t dbmail_imap_session_message_load(ImapSession *self, int filter) { u64_t *physid = NULL; + TRACE(TRACE_DEBUG,"[%llu]", self->msg_idnr); + if (! (physid = g_tree_lookup(self->physids, &(self->msg_idnr)))) { u64_t *uid; physid = g_new0(u64_t,1); @@ -385,6 +387,7 @@ static int _imap_session_fetch_parse_octet_range(ImapSession *self) /* read the numbers */ token[strlen(token) - 1] = '\0'; token[delimpos] = '\0'; + self->fi->msgparse_needed=1; dbmail_imap_session_bodyfetch_set_octetstart(self, strtoll(&token[1], NULL, 10)); dbmail_imap_session_bodyfetch_set_octetcnt(self,strtoll(&token [delimpos + 1], NULL, 10)); @@ -463,6 +466,7 @@ int dbmail_imap_session_fetch_parse_args(ImapSession * self) if (! nexttoken || ! MATCH(nexttoken,"[")) { if (ispeek) return -2; /* error DONE */ + self->fi->msgparse_needed = 1; self->fi->getMIME_IMB_noextension = 1; /* just BODY specified */ } else { int res = 0; @@ -476,10 +480,13 @@ int dbmail_imap_session_fetch_parse_args(ImapSession * self) TRACE(TRACE_DEBUG,"[%p] token [%s], nexttoken [%s]", self, token, nexttoken); if (MATCH(token,"]")) { - if (ispeek) + if (ispeek) { + self->fi->msgparse_needed = 1; self->fi->getBodyTotalPeek = 1; - else + } else { + self->fi->msgparse_needed = 1; self->fi->getBodyTotal = 1; + } self->args_idx++; res = _imap_session_fetch_parse_octet_range(self); if (res == -2) @@ -534,8 +541,6 @@ int dbmail_imap_session_fetch_parse_args(ImapSession * self) else \ dbmail_imap_session_buff_printf(self, " ") - - #define QUERY_BATCHSIZE 2000 void _send_headers(ImapSession *self, const body_fetch_t *bodyfetch, gboolean not) @@ -903,7 +908,16 @@ static int _fetch_get_items(ImapSession *self, u64_t *uid) self->msg_idnr = *uid; self->fi->isfirstfetchout = 1; - + + TRACE(TRACE_DEBUG,"[%llu] [%d]", self->msg_idnr, self->fi->msgparse_needed); + if (self->fi->msgparse_needed) { + if (! (dbmail_imap_session_message_load(self, DBMAIL_MESSAGE_FILTER_FULL))) { + dbmail_imap_session_buff_clear(self); + dbmail_imap_session_buff_printf(self, "\r\n* BYE error loading message\r\n"); + return -1; + } + } + if (self->fi->getInternalDate) { SEND_SPACE; char *s =date_sql2imap(msginfo->internaldate); @@ -912,7 +926,8 @@ static int _fetch_get_items(ImapSession *self, u64_t *uid) } if (self->fi->getSize) { SEND_SPACE; - dbmail_imap_session_buff_printf(self, "RFC822.SIZE %llu", msginfo->rfcsize); + dbmail_imap_session_buff_printf(self, "RFC822.SIZE %llu", + self->cache?Cache_get_size(self->cache):msginfo->rfcsize); } if (self->fi->getFlags) { SEND_SPACE; @@ -927,14 +942,7 @@ static int _fetch_get_items(ImapSession *self, u64_t *uid) } if (self->fi->getMIME_IMB) { - SEND_SPACE; - - if (! (dbmail_imap_session_message_load(self, DBMAIL_MESSAGE_FILTER_FULL))) { - dbmail_imap_session_buff_clear(self); - dbmail_imap_session_buff_printf(self, "\r\n* BYE error fetching body structure\r\n"); - return -1; - } if ((s = imap_get_structure(GMIME_MESSAGE((self->message)->content), 1))==NULL) { dbmail_imap_session_buff_clear(self); dbmail_imap_session_buff_printf(self, "\r\n* BYE error fetching body structure\r\n"); @@ -945,15 +953,7 @@ static int _fetch_get_items(ImapSession *self, u64_t *uid) } if (self->fi->getMIME_IMB_noextension) { - SEND_SPACE; - - if (! (dbmail_imap_session_message_load(self, DBMAIL_MESSAGE_FILTER_FULL))) { - dbmail_imap_session_buff_clear(self); - dbmail_imap_session_buff_printf(self, "\r\n* BYE error fetching body\r\n"); - return -1; - } - if ((s = imap_get_structure(GMIME_MESSAGE((self->message)->content), 0))==NULL) { dbmail_imap_session_buff_clear(self); dbmail_imap_session_buff_printf(self, "\r\n* BYE error fetching body\r\n"); @@ -964,40 +964,21 @@ static int _fetch_get_items(ImapSession *self, u64_t *uid) } if (self->fi->getEnvelope) { - SEND_SPACE; - _fetch_envelopes(self); } if (self->fi->getRFC822 || self->fi->getRFC822Peek) { - SEND_SPACE; - - if (! (dbmail_imap_session_message_load(self, DBMAIL_MESSAGE_FILTER_FULL))) { - dbmail_imap_session_buff_clear(self); - dbmail_imap_session_buff_printf(self, "\r\n* BYE error fetching message\r\n"); - return -1; - } - - dbmail_imap_session_buff_printf(self, "RFC822 {%llu}\r\n", Cache_get_size(self->cache) ); send_data(self, Cache_get_memdump(self->cache), Cache_get_size(self->cache) ); - if (self->fi->getRFC822) self->fi->setseen = 1; } if (self->fi->getBodyTotal || self->fi->getBodyTotalPeek) { - SEND_SPACE; - - if (! (dbmail_imap_session_message_load(self, DBMAIL_MESSAGE_FILTER_FULL))) { - dbmail_imap_session_buff_clear(self); - dbmail_imap_session_buff_printf(self, "\r\n* BYE error fetching message\r\n"); - return -1; - } if (dbmail_imap_session_bodyfetch_get_last_octetcnt(self) == 0) { dbmail_imap_session_buff_printf(self, "BODY[] {%llu}\r\n", Cache_get_size(self->cache) ); send_data(self, Cache_get_memdump(self->cache), Cache_get_size(self->cache) ); @@ -1014,30 +995,22 @@ static int _fetch_get_items(ImapSession *self, u64_t *uid) dbmail_imap_session_bodyfetch_get_last_octetstart(self), actual_cnt); send_data(self, M, actual_cnt); } - if (self->fi->getBodyTotal) self->fi->setseen = 1; - } if (self->fi->getRFC822Header) { - SEND_SPACE; - tmpdumpsize = dbmail_imap_session_message_load(self,DBMAIL_MESSAGE_FILTER_HEAD); dbmail_imap_session_buff_printf(self, "RFC822.HEADER {%llu}\r\n", tmpdumpsize); send_data(self, Cache_get_tmpdump(self->cache), tmpdumpsize); } if (self->fi->getRFC822Text) { - SEND_SPACE; - - // FIXME tmpdumpsize = dbmail_imap_session_message_load(self,DBMAIL_MESSAGE_FILTER_BODY); dbmail_imap_session_buff_printf(self, "RFC822.TEXT {%llu}\r\n", tmpdumpsize); send_data(self, Cache_get_tmpdump(self->cache), tmpdumpsize); - self->fi->setseen = 1; } @@ -1087,7 +1060,6 @@ static int _fetch_get_items(ImapSession *self, u64_t *uid) return 0; } - static gboolean _do_fetch(u64_t *uid, gpointer UNUSED value, ImapSession *self) { /* go fetch the items */ @@ -1283,7 +1255,6 @@ int dbmail_imap_session_prompt(ImapSession * self, char * prompt) return 0; } - int dbmail_imap_session_mailbox_get_selectable(ImapSession * self, u64_t idnr) { /* check if mailbox is selectable */ @@ -1360,6 +1331,7 @@ static gboolean notify_expunge(ImapSession *self, u64_t *uid) return FALSE; } + static void mailbox_notify_expunge(ImapSession *self, MailboxState_T N) { u64_t *uid, *msn, exists; @@ -1736,7 +1708,6 @@ int dbmail_imap_session_mailbox_expunge(ImapSession *self) return 0; } - /***************************************************************************** * * @@ -1744,7 +1715,6 @@ int dbmail_imap_session_mailbox_expunge(ImapSession *self) * * ****************************************************************************/ - void dbmail_imap_session_bodyfetch_new(ImapSession *self) { diff --git a/src/dbmail-message.c b/src/dbmail-message.c index 0c7cfaf3..3cb5c6af 100644 --- a/src/dbmail-message.c +++ b/src/dbmail-message.c @@ -425,7 +425,6 @@ static DbmailMessage * _mime_retrieve(DbmailMessage *self) g_string_append_printf(m, "\n"); } - self = dbmail_message_init_with_string(self,m); dbmail_message_set_internal_date(self, internal_date); g_free(internal_date); @@ -449,21 +448,17 @@ static int store_body(GMimeObject *object, DbmailMessage *m) { int r; char *text = g_mime_object_get_body(object); - if (! text) - return 0; - + if (! text) return 0; r = store_blob(m, text, 0); g_free(text); return r; } - static gboolean store_mime_text(GMimeObject *object, DbmailMessage *m, gboolean skiphead) { g_return_val_if_fail(GMIME_IS_OBJECT(object), TRUE); if (! skiphead && store_head(object, m) < 0) return TRUE; if(store_body(object, m) < 0) return TRUE; - return FALSE; } @@ -640,6 +635,10 @@ void dbmail_message_free(DbmailMessage *self) g_object_unref(self->content); self->content = NULL; } + if (self->raw_content) { + g_free(self->raw_content); + self->raw_content = NULL; + } if (self->charset) { g_free(self->charset); self->charset = NULL; @@ -703,7 +702,6 @@ DbmailMessage * dbmail_message_init_with_string(DbmailMessage *self, const GStri parser = g_mime_parser_new_with_stream(stream); g_object_unref(stream); - TRACE(TRACE_DEBUG,"parse message"); if (strncmp(str->str, "From ", 5) == 0) { /* don't use gmime's from scanner since body lines may begin with 'From ' */ char *end; @@ -717,17 +715,17 @@ DbmailMessage * dbmail_message_init_with_string(DbmailMessage *self, const GStri if (content) { dbmail_message_set_class(self, DBMAIL_MESSAGE); self->content = content; + self->raw_content = dbmail_message_to_string(self); if (from) { - TRACE(TRACE_DEBUG,"from scan: %s", from); dbmail_message_set_internal_date(self, from); } g_object_unref(parser); } else { - TRACE(TRACE_DEBUG,"parse part"); content = GMIME_OBJECT(g_mime_parser_construct_part(parser)); if (content) { dbmail_message_set_class(self, DBMAIL_MESSAGE_PART); self->content = content; + self->raw_content = dbmail_message_to_string(self); g_object_unref(parser); } } @@ -775,7 +773,6 @@ static void _register_header(const char *header, const char *value, gpointer use assert(value); assert(m); - TRACE(TRACE_DEBUG,"%s: %s", header, value); if (! (hname = g_tree_lookup(m->header_name,header))) { g_tree_insert(m->header_name,(gpointer)header,(gpointer)header); hname = header; @@ -846,6 +843,9 @@ void dbmail_message_set_header(DbmailMessage *self, const char *header, const ch { g_mime_object_set_header(GMIME_OBJECT(self->content), header, value); if (self->headers) _map_headers(self); + if (self->raw_content) + g_free(self->raw_content); + self->raw_content = dbmail_message_to_string(self); } const gchar * dbmail_message_get_header(const DbmailMessage *self, const char *header) @@ -930,7 +930,9 @@ gchar * dbmail_message_hdrs_to_string(const DbmailMessage *self) size_t dbmail_message_get_size(const DbmailMessage *self, gboolean crlf) { char *s; size_t r; - s = dbmail_message_to_string(self); + + s = self->raw_content; + r = strlen(s); if (crlf) { @@ -944,8 +946,7 @@ size_t dbmail_message_get_size(const DbmailMessage *self, gboolean crlf) i++; } } - - g_free(s); + return r; } @@ -1075,13 +1076,31 @@ DbmailMessage * dbmail_message_retrieve(DbmailMessage *self, u64_t physid, int f * - -1 on error * - 1 on success */ +static int _update_message(DbmailMessage *self) +{ + u64_t size = (u64_t)dbmail_message_get_size(self,FALSE); + u64_t rfcsize = (u64_t)dbmail_message_get_size(self,TRUE); + + if (! db_update("UPDATE %sphysmessage SET messagesize = %llu, rfcsize = %llu WHERE id = %llu", + DBPFX, size, rfcsize, self->physid)) + return DM_EQUERY; + + if (! db_update("UPDATE %smessages SET status = %d WHERE message_idnr = %llu", + DBPFX, MESSAGE_STATUS_NEW, self->id)) + return DM_EQUERY; + + if (! dm_quota_user_inc(db_get_useridnr(self->id), size)) + return DM_EQUERY; + + return DM_SUCCESS; +} + + int dbmail_message_store(DbmailMessage *self) { u64_t user_idnr; char unique_id[UID_SIZE]; - int res = 0; - u64_t size, rfcsize; - int i=1, retry=10, delay=200; + int res = 0, i = 1, retry = 10, delay = 200; if (! auth_user_exists(DBMAIL_DELIVERY_USERNAME, &user_idnr)) { TRACE(TRACE_ERR, "unable to find user_idnr for user [%s]. Make sure this system user is in the database!", DBMAIL_DELIVERY_USERNAME); @@ -1097,16 +1116,13 @@ int dbmail_message_store(DbmailMessage *self) continue; } - if ((res = dm_message_store(self))) { - TRACE(TRACE_WARNING,"Failed to store mimeparts"); + if ((res = _update_message(self) < 0)) { usleep(delay*i); continue; } - size = (u64_t)dbmail_message_get_size(self,FALSE); - rfcsize = (u64_t)dbmail_message_get_size(self,TRUE); - - if (( res = db_update_message(self->id, unique_id, size, rfcsize)) < 0) { + if ((res = dm_message_store(self))) { + TRACE(TRACE_WARNING,"Failed to store mimeparts"); usleep(delay*i); continue; } @@ -1115,7 +1131,7 @@ int dbmail_message_store(DbmailMessage *self) if ((res = dbmail_message_cache_headers(self)) < 0) { usleep(delay*i); continue; - } + } /* ready */ break; @@ -1697,6 +1713,7 @@ DbmailMessage * dbmail_message_construct(DbmailMessage *self, // attach the message to the DbmailMessage struct self->content = (GMimeObject *)message; + self->raw_content = dbmail_message_to_string(self); // cleanup return self; diff --git a/src/dbmailtypes.h b/src/dbmailtypes.h index c932314d..3e14aa5f 100644 --- a/src/dbmailtypes.h +++ b/src/dbmailtypes.h @@ -141,6 +141,7 @@ typedef struct { GString *envelope_recipient; enum DBMAIL_MESSAGE_CLASS klass; GMimeObject *content; + gchar *raw_content; GRelation *headers; GHashTable *header_dict; GTree *header_name; diff --git a/src/dm_cache.c b/src/dm_cache.c index 6094c297..0c445580 100644 --- a/src/dm_cache.c +++ b/src/dm_cache.c @@ -118,16 +118,18 @@ u64_t Cache_update(T C, DbmailMessage *message, int filter) buf = dbmail_message_to_string(message); crlf = get_crlf_encoded(buf); + outcnt = Cache_set_dump(C,crlf,IMAP_CACHE_MEMDUMP); tmpcnt = Cache_set_dump(C,crlf,IMAP_CACHE_TMPDUMP); - g_free(buf); - g_free(crlf); assert(tmpcnt==outcnt); C->size = outcnt; C->id = message->id; + g_free(buf); + g_free(crlf); + } switch (filter) { diff --git a/src/dm_db.c b/src/dm_db.c index e1d27fef..f38e7569 100644 --- a/src/dm_db.c +++ b/src/dm_db.c @@ -1004,42 +1004,7 @@ u64_t db_get_useridnr(u64_t message_idnr) return user_idnr; } -static int db_physmessage_set_sizes(u64_t physmessage_id, u64_t message_size, u64_t rfc_size) -{ - return db_update("UPDATE %sphysmessage SET messagesize = %llu, rfcsize = %llu WHERE id = %llu", - DBPFX, message_size, rfc_size, physmessage_id); -} - -static int db_message_set_unique_id(u64_t message_idnr, const char *unique_id) -{ - return db_update("UPDATE %smessages SET unique_id = '%s', status = %d WHERE message_idnr = %llu", - DBPFX, unique_id, MESSAGE_STATUS_NEW, message_idnr); -} - -int db_update_message(u64_t message_idnr, const char *unique_id, u64_t message_size, u64_t rfc_size) -{ - assert(unique_id); - u64_t physmessage_id = 0; - - if (! db_message_set_unique_id(message_idnr, unique_id)) - return DM_EQUERY; - - /* update the fields in the physmessage table */ - if (db_get_physmessage_id(message_idnr, &physmessage_id)) - return DM_EQUERY; - - if (! db_physmessage_set_sizes(physmessage_id, message_size, rfc_size)) - return DM_EQUERY; - if (! dm_quota_user_inc(db_get_useridnr(message_idnr), message_size)) { - TRACE(TRACE_ERR, "error calculating quotum " - "used for user [%llu]. Database might be " - "inconsistent. Run dbmail-util.", - db_get_useridnr(message_idnr)); - return DM_EQUERY; - } - return DM_SUCCESS; -} int db_log_ip(const char *ip) { @@ -1509,20 +1474,6 @@ int db_delete_mailbox(u64_t mailbox_idnr, int only_empty, int update_curmail_siz return DM_SUCCESS; } -int db_send_message_lines(void *fstream, u64_t message_idnr, long lines, int no_end_dot) -{ - char *s; - size_t i; - - TRACE(TRACE_DEBUG, "sending [%ld] lines from message [%llu]", - lines, message_idnr); - if (! (s = db_get_message_lines(message_idnr, lines, no_end_dot))) - return -1; - i = fprintf((FILE *)fstream, "%s", s); - g_free(s); - return i; -} - char * db_get_message_lines(u64_t message_idnr, long lines, int no_end_dot) { DbmailMessage *msg; @@ -3375,13 +3326,6 @@ int db_mailbox_seq_update(u64_t mailbox_id) db_get_sql(SQL_IGNORE), DBPFX, mailbox_id); } -int db_message_mailbox_seq_update(u64_t message_id) -{ - return db_update("UPDATE %s %smailboxes SET seq=seq+1 WHERE mailbox_idnr=(" - "SELECT mailbox_idnr FROM %smessages WHERE message_idnr=%llu)", - db_get_sql(SQL_IGNORE), DBPFX, DBPFX, message_id); -} - int db_rehash_store(void) { GList *ids = NULL; diff --git a/src/dm_db.h b/src/dm_db.h index 6e65e25f..0f349b9f 100644 --- a/src/dm_db.h +++ b/src/dm_db.h @@ -31,9 +31,7 @@ #include "dbmail.h" #define DUMP_BUF_SIZE 1024 - #define ICHECK_RESULTSETSIZE 1000000 - #define MAX_EMAIL_SIZE 250 /* config types */ @@ -285,30 +283,6 @@ int dm_quota_rebuild_user(u64_t user_idnr); u64_t db_get_useridnr(u64_t message_idnr); /** - * \brief insert a physmessage with an internal date. - * \param internal_date the internal date in "YYYY-MM-DD HH:Mi:SS" - * \param physmessage_id will hold the id of the physmessage on return. Must - * hold a valid pointer on call. - * \return - * - -1 on failure - * - 1 on success - */ -int db_insert_physmessage_with_internal_date(timestring_t internal_date, u64_t * physmessage_id); - -/** - * \brief update unique_id, message_size and rfc_size of - * a message identified by message_idnr - * \param message_idnr - * \param unique_id unique id of message - * \param message_size size of message - * \param rfc_size - * \return - * - -1 on database error - * - 0 on success - */ -int db_update_message(u64_t message_idnr, const char *unique_id, u64_t message_size, u64_t rfc_size); - -/** * \brief log IP-address for POP/IMAP_BEFORE_SMTP. If the IP-address * is already logged, it's timestamp is renewed. * \param ip the ip (xxx.xxx.xxx.xxx) @@ -398,9 +372,6 @@ int db_update_rfcsize(GList *lost); int db_icheck_envelope(GList **lost); int db_set_envelope(GList *lost); - - -int db_setselectable(u64_t mailbox_idnr, int select_value); /** * \brief set status of a message * \param message_idnr @@ -433,22 +404,6 @@ int db_delete_message(u64_t message_idnr); int db_delete_mailbox(u64_t mailbox_idnr, int only_empty, int update_curmail_size); -/** - * \brief write lines of message to fstream. Always write full headers. - * \param fstream the stream to write to - * \param message_idnr idrn of message to write - * \param lines number of lines to write. If <PRE>lines == -2</PRE>, then - * the whole message (excluding the header) is written. - * \param no_end_dot if - * - 0 \b do write the final "." signalling - * the end of the message - * - otherwise do \b not write the final "." - * \return - * - 0 on failure - * - 1 on success - */ -int db_send_message_lines(void *fstream, u64_t message_idnr, long lines, int no_end_dot); - char * db_get_message_lines(u64_t message_idnr, long lines, int no_end_dot); /** @@ -615,14 +570,7 @@ int db_noinferiors(u64_t mailbox_idnr); */ int db_append_msg(const char *msgdata, u64_t mailbox_idnr, u64_t user_idnr, timestring_t internal_date, u64_t * msg_idnr); -/** - * \brief remove all messages from a mailbox - * \param mailbox_idnr - * \return - * - -1 on failure - * - 0 on success - */ -int db_removemsg(u64_t user_idnr, u64_t mailbox_idnr); + /** * \brief move all messages from one mailbox to another. * \param mailbox_to idnr of mailbox to move messages from. @@ -797,7 +745,6 @@ const char * db_get_sql(sql_fragment_t frag); char * db_returning(const char *s); int db_mailbox_seq_update(u64_t mailbox_id); -int db_message_mailbox_seq_update(u64_t message_id); int db_rehash_store(void); diff --git a/src/dm_mailboxstate.c b/src/dm_mailboxstate.c index 4b91fc7e..75b1e8c6 100644 --- a/src/dm_mailboxstate.c +++ b/src/dm_mailboxstate.c @@ -142,6 +142,7 @@ static T MailboxState_getMessageState(T M) if (! i) { // empty mailbox MailboxState_setMsginfo(M, msginfo); + db_commit_transaction(c); db_con_close(c); return M; } diff --git a/test-scripts/testfetch.txt b/test-scripts/testfetch.txt index cab549d9..107a058c 100644 --- a/test-scripts/testfetch.txt +++ b/test-scripts/testfetch.txt @@ -5,7 +5,7 @@ C00003 LIST "" "*" C00004 LSUB "" "*" C00005 SELECT INBOX C00006 fetch 1 (UID BODY.PEEK[HEADER]) -C00007 APPEND INBOX {10} +C00007 APPEND INBOX {11} From: paul C00008 UID FETCH 1:* (FLAGS RFC822.SIZE INTERNALDATE BODY.PEEK[HEADER.FIELDS (DATE FROM TO CC SUBJECT REFERENCES IN-REPLY-TO MESSAGE-ID MIME-VERSION CONTENT-TYPE X-MAILING-LIST X-LOOP LIST-ID LIST-POST MAILING-LIST ORIGINATOR X-LIST SENDER RETURN-PATH X-BEENTHERE)]) C00009 UID FETCH 1:* (BODY.PEEK[HEADER.FIELDS (References X-Ref X-Priority X-MSMail-Priority X-MSOESRec Newsgroups)] ENVELOPE RFC822.SIZE UID FLAGS INTERNALDATE) diff --git a/test/check_dbmail_message.c b/test/check_dbmail_message.c index c0699ee5..0834f020 100644 --- a/test/check_dbmail_message.c +++ b/test/check_dbmail_message.c @@ -192,13 +192,19 @@ START_TEST(test_dbmail_message_store) char *t, *e; //----------------------------------------- + m = message_init("From: paul\n"); + e = dbmail_message_to_string(m); + t = store_and_retrieve(m); + COMPARE(e,t); + g_free(e); + g_free(t); + //----------------------------------------- m = message_init(simple); e = dbmail_message_to_string(m); t = store_and_retrieve(m); COMPARE(e,t); g_free(e); g_free(t); - return; //----------------------------------------- m = message_init(rfc822); e = dbmail_message_to_string(m); @@ -375,7 +381,6 @@ START_TEST(test_dbmail_message_retrieve) { DbmailMessage *m, *n; GString *s; - char *expect, *t; u64_t physid; s = g_string_new(multipart_message); @@ -761,8 +766,8 @@ START_TEST(test_encoding) char *raw, *enc, *dec; raw = g_strdup( "Kristoffer Br�nemyr"); - enc = g_mime_utils_header_encode_phrase((unsigned char *)raw); - dec = g_mime_utils_header_decode_phrase((unsigned char *)enc); + enc = g_mime_utils_header_encode_phrase((char *)raw); + dec = g_mime_utils_header_decode_phrase((char *)enc); fail_unless(MATCH(raw,dec),"decode/encode failed"); g_free(raw); g_free(dec); @@ -773,6 +778,7 @@ END_TEST START_TEST(test_get_crlf_encoded_opt1) { char *in[] = { + "a\n", "a\nb\nc\n", "a\nb\r\nc\n", "a\nb\rc\n", @@ -780,6 +786,7 @@ START_TEST(test_get_crlf_encoded_opt1) NULL }; char *out[] = { + "a\r\n", "a\r\nb\r\nc\r\n", "a\r\nb\r\nc\r\n", "a\r\nb\rc\r\n", @@ -825,10 +832,9 @@ END_TEST START_TEST(test_dbmail_message_get_size) { DbmailMessage *m; - GString *s; - char *t, *r; size_t i, j; + /* */ m = dbmail_message_new(); m = dbmail_message_init_with_string(m, g_string_new(rfc822)); @@ -838,6 +844,18 @@ START_TEST(test_dbmail_message_get_size) fail_unless(j==289, "dbmail_message_get_size failed"); dbmail_message_free(m); + + /* */ + m = dbmail_message_new(); + m = dbmail_message_init_with_string(m, g_string_new("From: paul\n\n")); + + i = dbmail_message_get_size(m, FALSE); + fail_unless(i==12, "dbmail_message_get_size failed [%d]", i); + j = dbmail_message_get_size(m, TRUE); + fail_unless(j==14, "dbmail_message_get_size failed [%d]", j); + + dbmail_message_free(m); + } END_TEST |