mail-storage.h revision 162677af0091c924cb7266e23978e342982f7d05
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amoretypedef enum {
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amoretypedef enum {
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amoretypedef enum {
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amoretypedef enum {
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amoretypedef struct _MailStorageCallbacks MailStorageCallbacks;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amoretypedef struct _MailFetchBodyData MailFetchBodyData;
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amoretypedef void (*MailboxFunc)(MailStorage *storage, const char *name,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore/* All methods returning int return either TRUE or FALSE. */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore /* Create new instance */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MailStorage *(*create)(const char *data, const char *user);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore /* Free this instance */
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 /* Set storage callback functions to use. */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore MailStorageCallbacks *callbacks, void *context);
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 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 /* 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 /* 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 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 /* 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 /* 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 /* Exactly like find_mailboxes(), but list only subscribed mailboxes. */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore int (*find_subscribed)(MailStorage *storage, const char *mask,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore /* Returns mailbox name status */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore int (*get_mailbox_name_status)(MailStorage *storage, const char *name,
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/* private: */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore char *user; /* name of user accessing the storage */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore unsigned int syntax_error:1; /* Give a BAD reply instead of NO */
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 /* Gets the mailbox status information. */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore int (*get_status)(Mailbox *box, MailboxStatusItems items,
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 /* Expunge all mails with \Deleted flag. If notify is TRUE, call
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore expunge callbacks. Also always does full syncing. */
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 /* Copy mails to another mailbox. */
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 /* 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 /* 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 int (*save)(Mailbox *box, MailFlags flags, const char *custom_flags[],
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/* private: */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore /* may be allocated from data stack */
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 /* 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 custom_flags_count, void *context);
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore /* EXISTS, RECENT */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore void (*new_messages)(Mailbox *mailbox, unsigned int messages_count,
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore /* FLAGS, PERMANENTFLAGS */
49ef7e0638c8b771d8a136eae78b1c0f99acc8e0Garrett D'Amore void (*new_custom_flags)(Mailbox *mailbox, const char *custom_flags[],
struct _MailFetchBodyData {
void mail_storage_register_all(void);
const char *user);