mail-storage.h revision 62da0b5f36c26088e524b0bd062eb0772607aadd
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen/* Maximum size for sort program, 2x for reverse + END */
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen MAIL_SORT_REVERSE = 0x0001, /* reverse the next type */
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen MAIL_SORT_END = 0x0000 /* ends sort program */
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen /* specials: */
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen/* All methods returning int return either TRUE or FALSE. */
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen /* Create new instance. If namespace is non-NULL, all mailbox names
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen are expected to begin with it. hierarchy_sep overrides the default
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen separator if it's not '\0'. */
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen struct mail_storage *(*create)(const char *data, const char *user,
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen /* Free this instance */
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen /* Returns TRUE if this storage would accept the given data
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen as a valid parameter to create(). */
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen /* Set storage callback functions to use. */
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen void (*set_callbacks)(struct mail_storage *storage,
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen /* Open a mailbox. If readonly is TRUE, mailbox must not be
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen modified in any way even when it's asked. If fast is TRUE,
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen any extra time consuming operations shouldn't be performed
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen (eg. when opening mailbox just for STATUS).
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen Note that append and copy may open the selected mailbox again
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen with possibly different readonly-state. */
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen struct mailbox *(*open_mailbox)(struct mail_storage *storage,
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen /* name is allowed to contain multiple new hierarchy levels.
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen If only_hierarchy is TRUE, the mailbox itself isn't created, just
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen the hierarchy structure (if needed). */
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen int (*create_mailbox)(struct mail_storage *storage, const char *name,
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen /* Only the specified mailbox is deleted, ie. folders under the
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen specified mailbox must not be deleted. */
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen int (*delete_mailbox)(struct mail_storage *storage, const char *name);
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen /* If the name has inferior hierarchical names, then the inferior
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen hierarchical names MUST also be renamed (ie. foo -> bar renames
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen also foo/bar -> bar/bar). newname may contain multiple new
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen If oldname is case-insensitively "INBOX", the mails are moved
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen into new folder but the INBOX folder must not be deleted. */
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen int (*rename_mailbox)(struct mail_storage *storage, const char *oldname,
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen const char *newname);
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen /* Initialize new mailbox list request. mask may contain '%' and '*'
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen wildcards as defined in RFC2060. Matching against "INBOX" is
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen case-insensitive, but anything else is not. */
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen (*list_mailbox_init)(struct mail_storage *storage,
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen /* Deinitialize mailbox list request. Returns FALSE if some error
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen occured while listing. */
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen int (*list_mailbox_deinit)(struct mailbox_list_context *ctx);
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen /* Get next mailbox. Returns the mailbox name */
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen (*list_mailbox_next)(struct mailbox_list_context *ctx);
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen /* Subscribe/unsubscribe mailbox. There should be no error when
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen subscribing to already subscribed mailbox. Subscribing to
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen unexisting mailboxes is optional. */
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen int (*set_subscribed)(struct mail_storage *storage,
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen /* Returns mailbox name status */
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen int (*get_mailbox_name_status)(struct mail_storage *storage,
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen /* Returns the error message of last occured error. */
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen const char *(*get_last_error)(struct mail_storage *storage,
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen/* private: */
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen char *user; /* name of user accessing the storage */
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen unsigned int syntax_error:1; /* Give a BAD reply instead of NO */
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen /* Returns TRUE if mailbox is read-only. */
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen /* Returns TRUE if mailbox supports adding custom flags. */
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen int (*allow_new_custom_flags)(struct mailbox *box);
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen /* Close the box. Returns FALSE if some cleanup errors occured, but
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen the mailbox was closed anyway. */
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen /* Explicitly lock the mailbox. If not used, all the methods below
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen use the minimum locking requirements. This allows you to for
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen example use the update_flags() method in struct mail. The mailbox
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen stays locked until you unlock it. Note that if you call a method
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen which wants more locks than you've given here, the call will fail
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen (to avoid deadlocks). */
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen int (*lock)(struct mailbox *box, enum mailbox_lock_type lock_type);
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen /* Gets the mailbox status information. */
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen int (*get_status)(struct mailbox *box, enum mailbox_status_items items,
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen /* Synchronize the mailbox. */
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen int (*sync)(struct mailbox *box, enum mail_sync_flags flags);
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen /* Synchronize mailbox in background. It's done until this function is
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen called with sync_type = MAILBOX_SYNC_NONE */
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen void (*auto_sync)(struct mailbox *box, enum mailbox_sync_type sync_type,
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen /* Initialize new fetch request. wanted_fields isn't required, but it
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen can be used for optimizations. update_flags must be set to TRUE, if
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen you want to call mail->update_flags() */
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen const char *const *wanted_headers,
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen /* Deinitialize fetch request. all_found is set to TRUE if all of the
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen fetched messages were found (ie. not just deleted). */
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen int (*fetch_deinit)(struct mail_fetch_context *ctx, int *all_found);
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen /* Fetch the next message. Returned mail object can be used until
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen the next call to fetch_next() or fetch_deinit(). */
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen struct mail *(*fetch_next)(struct mail_fetch_context *ctx);
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen /* Simplified fetching for a single UID or sequence. Must be called
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen between fetch_init() .. fetch_deinit() or
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen search_init() .. search_deinit() */
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen struct mail *(*fetch_uid)(struct mailbox *box, unsigned int uid,
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen struct mail *(*fetch_seq)(struct mailbox *box, unsigned int seq,
01435c38e7d671d5a892c4b802cfb204881cd454Timo Sirainen /* Modify sort_program to specify a sort program acceptable for
struct mail_search_context *
const char *const wanted_headers[]);
int transaction);
struct mail_expunge_context *
int expunge_all);
struct mail {
unsigned int seq;
unsigned int uid;
const char *const minimum_fields[]);
struct mailbox_list {
const char *name;
struct mailbox_status {
unsigned int messages;
unsigned int recent;
unsigned int unseen;
unsigned int uidvalidity;
unsigned int uidnext;
unsigned int first_unseen_seq;
unsigned int custom_flags_count;
const char **custom_flags;
struct mail_storage_callbacks {
void *context);
void *context);
void *context);
void *context);
unsigned int messages_count,
const char *custom_flags[],
unsigned int custom_flags_count,
void *context);
extern int full_filesystem_access;
void mail_storage_init(void);
void mail_storage_deinit(void);
void mail_storage_register_all(void);
struct mail_storage *
struct mail_storage *
struct mail_storage *
int *syntax);