Browse files

Merge branch 'master' of git.dbmail.eu:/var/git/paul/dbmail

  • Loading branch information...
2 parents a53bddc + 55a96e7 commit fe49337689b56b82289b5739617822de6ff6568e @pjstevns committed Mar 2, 2012
Showing with 46 additions and 41 deletions.
  1. +1 −1 src/dbmail-mailbox.c
  2. +3 −1 src/dm_memblock.c
  3. +23 −23 src/imapcommands.c
  4. +14 −13 test-scripts/testfetch.imap
  5. +2 −2 test-scripts/testimap.py
  6. +3 −1 test-scripts/testimap.sh
View
2 src/dbmail-mailbox.c
@@ -1384,7 +1384,7 @@ static GTree * mailbox_search(DbmailMailbox *self, search_key_t *s)
old = s->found;
s->found = invert;
g_tree_destroy(old);
-
+ g_list_free(g_list_first(uids));
}
CATCH(SQLException)
View
4 src/dm_memblock.c
@@ -28,6 +28,7 @@
#include <assert.h>
#include <string.h>
#include <unistd.h>
+
#include "dm_memblock.h"
#define T Mem_T
@@ -82,7 +83,8 @@ void Mem_close(T *M)
*/
int Mem_write(T M, const void *data, int size)
{
-
+ guint remove = M->data->len - M->pos;
+ if (remove > 0) M->data = g_byte_array_remove_range(M->data, M->pos, remove);
M->data = g_byte_array_append(M->data, (const guint8 *)data, (guint)size);
return size;
}
View
46 src/imapcommands.c
@@ -1534,8 +1534,10 @@ int _dm_imapsession_get_ids(ImapSession *self, const char *set)
self->ids = dbmail_mailbox_get_set(self->mailbox, set, self->use_uid);
- if ( (!self->ids) || (g_tree_nnodes(self->ids)==0) )
+ if ( (! self->use_uid) && ((!self->ids) || (g_tree_nnodes(self->ids)==0)) ) {
+ dbmail_imap_session_buff_printf(self, "%s BAD invalid sequence\r\n", self->tag);
return DM_EGENERAL;
+ }
return DM_SUCCESS;
}
@@ -1576,18 +1578,15 @@ static void _ic_fetch_enter(dm_thread_data *D)
self->args_idx++;
} while (state > 0);
- result = DM_SUCCESS;
+ dbmail_imap_session_mailbox_status(self, FALSE);
- if (g_tree_nnodes(MailboxState_getIds(self->mailbox->mbstate)) > 0) {
- if (_dm_imapsession_get_ids(self, self->args[setidx]) == DM_SUCCESS) {
- self->ids_list = g_tree_keys(self->ids);
- result = dbmail_imap_session_fetch_get_items(self);
- }
+ if ((result = _dm_imapsession_get_ids(self, self->args[setidx])) == DM_SUCCESS) {
+ self->ids_list = g_tree_keys(self->ids);
+ result = dbmail_imap_session_fetch_get_items(self);
}
dbmail_imap_session_fetch_free(self);
dbmail_imap_session_args_free(self, FALSE);
- dbmail_imap_session_mailbox_status(self, FALSE);
if (result) {
D->status = result;
@@ -1787,8 +1786,6 @@ static void _ic_store_enter(dm_thread_data *D)
the right to store the flags */
self->cmd = cmd;
-
- result = DM_SUCCESS;
if ( update ) {
char *flags = MailboxState_flags(self->mailbox->mbstate);
@@ -1797,14 +1794,12 @@ static void _ic_store_enter(dm_thread_data *D)
g_free(flags);
}
- if (g_tree_nnodes(MailboxState_getIds(self->mailbox->mbstate)) > 0) {
- if ((result = _dm_imapsession_get_ids(self, self->args[k])) == DM_SUCCESS)
- g_tree_foreach(self->ids, (GTraverseFunc) _do_store, D);
- else
- dbmail_imap_session_buff_printf(self, "%s NO STORE failed: Sequence invalid.\r\n", self->tag);
- }
-
- db_mailbox_seq_update(MailboxState_getId(self->mailbox->mbstate));
+ if ((result = _dm_imapsession_get_ids(self, self->args[k])) == DM_SUCCESS) {
+ g_tree_foreach(self->ids, (GTraverseFunc) _do_store, D);
+ if (self->ids) {
+ db_mailbox_seq_update(MailboxState_getId(self->mailbox->mbstate));
+ }
+ }
g_list_destroy(cmd->keywords);
g_free(cmd);
@@ -1881,14 +1876,19 @@ static void _ic_copy_enter(dm_thread_data *D)
cmd->mailbox_id = destmboxid;
self->cmd = cmd;
- if (g_tree_nnodes(MailboxState_getIds(self->mailbox->mbstate)) > 0) {
- if ((_dm_imapsession_get_ids(self, self->args[self->args_idx]) == DM_SUCCESS))
- g_tree_foreach(self->ids, (GTraverseFunc) _do_copy, self);
- }
+ if ((result = _dm_imapsession_get_ids(self, self->args[self->args_idx])) == DM_SUCCESS) {
+ g_tree_foreach(self->ids, (GTraverseFunc) _do_copy, self);
+ if (self->ids)
+ db_mailbox_seq_update(destmboxid);
+ }
+
g_free(self->cmd);
self->cmd = NULL;
- db_mailbox_seq_update(destmboxid);
+ if (result) {
+ D->status = result;
+ SESSION_RETURN;
+ }
if (MailboxState_getId(self->mailbox->mbstate) == destmboxid)
dbmail_imap_session_mailbox_status(self, TRUE);
View
27 test-scripts/testfetch.imap
@@ -1,14 +1,15 @@
-C00000 CAPABILITY
-C00001 LOGIN testuser1 test
-C00002 NAMESPACE
-C00003 LIST "" "*"
-C00004 LSUB "" "*"
-C00005 SELECT INBOX
-C00006 fetch 1 (UID BODY.PEEK[HEADER])
-C00007 APPEND INBOX {11}
+x CAPABILITY
+x LOGIN testuser1 test
+x NAMESPACE
+x LIST "" "*"
+x LSUB "" "*"
+x SELECT INBOX
+x fetch 1 (UID BODY.PEEK[HEADER])
+x 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)
-C0000A UID FETCH 1:* (BODY.PEEK[HEADER.FIELDS (Subject)] BODY.PEEK[HEADER.FIELDS (Message-Id)] ENVELOPE RFC822.SIZE UID FLAGS INTERNALDATE)
-C0000B UID FETCH 1:* (UID RFC822.SIZE BODY.PEEK[])
-C0000C LOGOUT
+x 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)])
+x UID FETCH 1:* (BODY.PEEK[HEADER.FIELDS (References X-Ref X-Priority X-MSMail-Priority X-MSOESRec Newsgroups)] ENVELOPE RFC822.SIZE UID FLAGS INTERNALDATE)
+x UID FETCH 1:* (BODY.PEEK[HEADER.FIELDS (Subject)] BODY.PEEK[HEADER.FIELDS (Message-Id)] ENVELOPE RFC822.SIZE UID FLAGS INTERNALDATE)
+x UID FETCH 1:* (UID RFC822.SIZE BODY.PEEK[])
+x FETCH 1 RFC822.TEXT
+x LOGOUT
View
4 test-scripts/testimap.py
@@ -350,8 +350,8 @@ def testFetch(self):
self.assertEquals(self.o.fetch("1:*", "(Flags)")[0], 'OK')
# bogus ranges
- self.assertEquals(self.o.fetch("-10:10", "(Flags)")[0], 'OK')
- self.assertEquals(self.o.fetch("10:-10", "(Flags)")[0], 'OK')
+ self.failUnlessRaises(Exception, self.o.fetch, "-10:10", "(Flags)")
+ self.failUnlessRaises(Exception, self.o.fetch, "10:-10", "(Flags)")
def testGetacl(self):
"""
View
4 test-scripts/testimap.sh
@@ -1,6 +1,8 @@
#!/bin/sh
-for f in *.imap; do
+_dir=`dirname $0`
+
+for f in ${_dir}/*.imap; do
cat $f | nc localhost 10143
done

0 comments on commit fe49337

Please sign in to comment.