Implement `remove' method for mailboxes.
* include/mailutils/mailbox.h (mu_mailbox_remove): New function. * include/mailutils/stream.h: Add some comments. * include/mailutils/sys/amd.h (_amd_data)<remove>: New method. (amd_remove_dir): New function. * include/mailutils/sys/mailbox.h (_mu_mailbox)<_remove>: New method. * libmailutils/amd.c (amd_remove_mbox): New function. (amd_init_mailbox): Initialize the _remove method. (amd_remove_dir): New function. * libmailutils/errors (MU_ERR_MBX_REMOVED) (MU_ERR_NOT_OPEN, MU_ERR_OPEN): New error codes. * libmailutils/mailbox.c: Keep state of the mailbox (open vs. not open, removed). Check it before doing anything on it. (_MU_MAILBOX_OPEN, _MU_MAILBOX_REMOVED, _MU_MAILBOX_MASK): New defines. (mu_mailbox_open): Set _MU_MAILBOX_OPEN if the operation succeeds. (mu_mailbox_close): Clear _MU_MAILBOX_OPEN if the operation succeeds. Refuse to run if the mailbox was not opened. (mu_mailbox_remove): New function. (all functions): return MU_ERR_MBX_NULL if the mbox argument is NULL. Check mailbox state on entry and proceed accordingly. * libproto/maildir/mbox.c: Implement _remove method. (maildir_remove): New function. (_mailbox_maildir_init): Initialize amd->_remove. * libproto/mbox/mbox.c: Implement _remove method. (mbox_remove): New function. (_mailbox_mbox_init): Initialize amd->_remove. * libproto/mh/mbox.c: Implement _remove method. (mh_remove): New function. (_mailbox_mh_init): Initialize amd->_remove. * libmailutils/tests/mbdel.c: New file. * libmailutils/tests/.gitignore: Add mbdel. * libmailutils/tests/Makefile.am (noinst_PROGRAMS): Likewise. (LDADD): List all mailbox formats. * imap4d/delete.c (imap4d_delete): Use mu_mailbox_remove to delete the folder. Fall back to remove() if it does not appear to be a mailbox.
Showing
15 changed files
with
323 additions
and
52 deletions
libmailutils/tests/mbdel.c
0 → 100644
-
Please register or sign in to post a comment