mail-storage.h revision 162677af0091c924cb7266e23978e342982f7d05
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore#ifndef __MAIL_STORAGE_H
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore#define __MAIL_STORAGE_H
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore#include "imap-util.h"
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore#include "imap-parser.h"
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amoretypedef enum {
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MAILBOX_NOSELECT = 0x01,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MAILBOX_CHILDREN = 0x02,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MAILBOX_NOCHILDREN = 0x04,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MAILBOX_NOINFERIORS = 0x08,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MAILBOX_MARKED = 0x10,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MAILBOX_UNMARKED = 0x20,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MAILBOX_READONLY = 0x40
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore} MailboxFlags;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amoretypedef enum {
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore STATUS_MESSAGES = 0x01,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore STATUS_RECENT = 0x02,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore STATUS_UIDNEXT = 0x04,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore STATUS_UIDVALIDITY = 0x08,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore STATUS_UNSEEN = 0x10,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore STATUS_FIRST_UNSEEN_SEQ = 0x20,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore STATUS_CUSTOM_FLAGS = 0x40
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore} MailboxStatusItems;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amoretypedef enum {
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MAILBOX_NAME_EXISTS,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MAILBOX_NAME_VALID,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MAILBOX_NAME_INVALID
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore} MailboxNameStatus;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amoretypedef enum {
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MODIFY_ADD,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MODIFY_REMOVE,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MODIFY_REPLACE
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore} ModifyType;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amoretypedef struct _MailStorage MailStorage;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amoretypedef struct _Mailbox Mailbox;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amoretypedef struct _MailboxStatus MailboxStatus;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amoretypedef struct _MailStorageCallbacks MailStorageCallbacks;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amoretypedef struct _MailFetchData MailFetchData;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amoretypedef struct _MailFetchBodyData MailFetchBodyData;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amoretypedef struct _MailSearchArg MailSearchArg;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amoretypedef enum _MailSortType MailSortType;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amoretypedef void (*MailboxFunc)(MailStorage *storage, const char *name,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MailboxFlags flags, void *context);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore/* All methods returning int return either TRUE or FALSE. */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amorestruct _MailStorage {
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore char *name;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore char hierarchy_sep;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore /* Create new instance */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MailStorage *(*create)(const char *data, const char *user);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore /* Free this instance */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore void (*free)(MailStorage *storage);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore /* Returns TRUE if this storage would accept the given data
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore as a valid parameter to create(). */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore int (*autodetect)(const char *data);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore /* Set storage callback functions to use. */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore void (*set_callbacks)(MailStorage *storage,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MailStorageCallbacks *callbacks, void *context);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore /* Open a mailbox. If readonly is TRUE, mailbox must not be
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore modified in any way even when it's asked. If fast is TRUE,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore any extra time consuming operations shouldn't be performed
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore (eg. when opening mailbox just for STATUS).
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore Note that append and copy may open the selected mailbox again
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore with possibly different readonly-state. */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore Mailbox *(*open_mailbox)(MailStorage *storage, const char *name,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore int readonly, int fast);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore /* name is allowed to contain multiple new hierarchy levels */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore int (*create_mailbox)(MailStorage *storage, const char *name);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore int (*delete_mailbox)(MailStorage *storage, const char *name);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore /* If the name has inferior hierarchical names, then the inferior
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore hierarchical names MUST also be renamed (ie. foo -> bar renames
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore also foo/bar -> bar/bar).
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore If oldname is case-insensitively "INBOX", the mails are moved
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore into new folder but the INBOX folder must not be deleted. */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore int (*rename_mailbox)(MailStorage *storage, const char *oldname,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore const char *newname);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore /* Execute specified function for all mailboxes matching given
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore mask. The mask is in RFC2060 LIST format. */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore int (*find_mailboxes)(MailStorage *storage, const char *mask,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MailboxFunc func, void *context);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore /* Subscribe/unsubscribe mailbox. There should be no error when
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore subscribing to already subscribed mailbox. Subscribing to
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore unexisting mailboxes is optional. */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore int (*set_subscribed)(MailStorage *storage, const char *name, int set);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore /* Exactly like find_mailboxes(), but list only subscribed mailboxes. */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore int (*find_subscribed)(MailStorage *storage, const char *mask,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MailboxFunc func, void *context);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore /* Returns mailbox name status */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore int (*get_mailbox_name_status)(MailStorage *storage, const char *name,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MailboxNameStatus *status);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore /* Returns the error message of last occured error. */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore const char *(*get_last_error)(MailStorage *storage, int *syntax_error);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore/* private: */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore char *dir; /* root directory */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore char *inbox_file; /* INBOX file for mbox */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore char *index_dir;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore char *user; /* name of user accessing the storage */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore char *error;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MailStorageCallbacks *callbacks;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore void *callback_context;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore unsigned int syntax_error:1; /* Give a BAD reply instead of NO */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore};
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amorestruct _Mailbox {
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore char *name;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MailStorage *storage;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore /* Close the box. Returns FALSE if some cleanup errors occured, but
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore the mailbox was closed anyway. */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore int (*close)(Mailbox *box);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore /* Gets the mailbox status information. */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore int (*get_status)(Mailbox *box, MailboxStatusItems items,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MailboxStatus *status);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore /* Synchronize the mailbox. If sync_expunges is FALSE, everything
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore but expunges are synced. */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore int (*sync)(Mailbox *box, int sync_expunges);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore /* Expunge all mails with \Deleted flag. If notify is TRUE, call
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore expunge callbacks. Also always does full syncing. */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore int (*expunge)(Mailbox *box, int notify);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore /* Update mail flags, calling update_flags callbacks. */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore int (*update_flags)(Mailbox *box, const char *messageset, int uidset,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MailFlags flags, const char *custom_flags[],
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore ModifyType modify_type, int notify, int *all_found);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore /* Copy mails to another mailbox. */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore int (*copy)(Mailbox *box, Mailbox *destbox,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore const char *messageset, int uidset);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore /* Fetch wanted mail data. The results are written into output stream
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore in RFC2060 FETCH format. */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore int (*fetch)(Mailbox *box, MailFetchData *fetch_data,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore OStream *output, int *all_found);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore /* Search wanted mail data. args contains the search criteria.
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore Results are written into output stream in RFC2060 SEARCH format.
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore If charset is NULL, the given search strings are matched without
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore any conversion. */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore int (*search)(Mailbox *box, const char *charset, MailSearchArg *args,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MailSortType *sorting, OStream *output, int uid_result);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore /* Save a new mail into mailbox. timezone_offset specifies the
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore timezone in minutes which internal_date was originally given
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore with. */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore int (*save)(Mailbox *box, MailFlags flags, const char *custom_flags[],
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore time_t internal_date, int timezone_offset,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore IStream *data, uoff_t data_size);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore /* Returns TRUE if mailbox is now in inconsistent state, meaning that
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore the message IDs etc. may have changed - only way to recover this
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore would be to fully close the mailbox and reopen it. With IMAP
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore connection this would mean a forced disconnection since we can't
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore do forced CLOSE. */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore int (*is_inconsistency_error)(Mailbox *box);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore/* public: */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore unsigned int readonly:1;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore unsigned int allow_custom_flags:1;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore/* private: */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore unsigned int inconsistent:1;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore};
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amorestruct _MailboxStatus {
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore unsigned int messages;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore unsigned int recent;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore unsigned int unseen;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore unsigned int uidvalidity;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore unsigned int uidnext;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore unsigned int first_unseen_seq;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore unsigned int diskspace_full:1;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore /* may be allocated from data stack */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore unsigned int custom_flags_count;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore const char **custom_flags;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore};
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amorestruct _MailStorageCallbacks {
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore /* Alert: Not enough disk space */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore void (*alert_no_diskspace)(Mailbox *mailbox, void *context);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore /* "* OK <text>" */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore void (*notify_ok)(Mailbox *mailbox, const char *text, void *context);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore /* "* NO <text>" */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore void (*notify_no)(Mailbox *mailbox, const char *text, void *context);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore /* EXPUNGE */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore void (*expunge)(Mailbox *mailbox, unsigned int seq, void *context);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore /* FETCH FLAGS */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore void (*update_flags)(Mailbox *mailbox, unsigned int seq,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore unsigned int uid, MailFlags flags,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore const char *custom_flags[],
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore unsigned int custom_flags_count, void *context);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore /* EXISTS, RECENT */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore void (*new_messages)(Mailbox *mailbox, unsigned int messages_count,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore unsigned int recent_count, void *context);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore /* FLAGS, PERMANENTFLAGS */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore void (*new_custom_flags)(Mailbox *mailbox, const char *custom_flags[],
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore unsigned int custom_flags_count,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore void *context);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore};
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amorestruct _MailFetchData {
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore const char *messageset;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore unsigned int uidset:1;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore unsigned int body:1;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore unsigned int bodystructure:1;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore unsigned int envelope:1;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore unsigned int flags:1;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore unsigned int internaldate:1;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore unsigned int rfc822:1;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore unsigned int rfc822_header:1;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore unsigned int rfc822_size:1;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore unsigned int rfc822_text:1;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore unsigned int uid:1;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MailFetchBodyData *body_sections;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore};
struct _MailFetchBodyData {
MailFetchBodyData *next;
const char *section; /* NOTE: always uppercased */
uoff_t skip, max_size; /* if you don't want max_size,
set it to (uoff_t)-1 */
unsigned int skip_set:1;
unsigned int peek:1;
};
/* register all mail storages */
void mail_storage_register_all(void);
/* Register mail storage class with given name - all methods that are NULL
are set to default methods */
void mail_storage_class_register(MailStorage *storage_class);
void mail_storage_class_unregister(MailStorage *storage_class);
/* Create a new instance of registered mail storage class with given
storage-specific data. If data is NULL, it tries to use defaults.
May return NULL if anything fails. */
MailStorage *mail_storage_create(const char *name, const char *data,
const char *user);
void mail_storage_destroy(MailStorage *storage);
MailStorage *mail_storage_create_default(const char *user);
MailStorage *mail_storage_create_with_data(const char *data, const char *user);
/* Set error message in storage. Critical errors are logged with i_error(),
but user sees only "internal error" message. */
void mail_storage_clear_error(MailStorage *storage);
void mail_storage_set_error(MailStorage *storage, const char *fmt, ...)
__attr_format__(2, 3);
void mail_storage_set_syntax_error(MailStorage *storage, const char *fmt, ...)
__attr_format__(2, 3);
void mail_storage_set_critical(MailStorage *storage, const char *fmt, ...)
__attr_format__(2, 3);
void mail_storage_set_internal_error(MailStorage *storage);
const char *mail_storage_get_last_error(MailStorage *storage, int *syntax);
int mail_storage_is_inconsistency_error(Mailbox *box);
#endif