mail-storage-private.h revision ff7056842f14fd3b30a2d327dfab165b9d15dd30
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#ifndef __MAIL_STORAGE_PRIVATE_H
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#define __MAIL_STORAGE_PRIVATE_H
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#include "module-context.h"
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#include "file-lock.h"
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#include "mail-storage.h"
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#include "mail-index-private.h"
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/* Called after mail storage has been created */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncextern void (*hook_mail_storage_created)(struct mail_storage *storage);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/* Called after mailbox has been opened */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncextern void (*hook_mailbox_opened)(struct mailbox *box);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstruct mail_storage_module_register {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync unsigned int id;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync};
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstruct mail_module_register {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync unsigned int id;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync};
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstruct mail_storage_vfuncs {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync void (*class_init)(void);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync void (*class_deinit)(void);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync struct mail_storage *(*alloc)(void);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync int (*create)(struct mail_storage *storage, const char *data);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync void (*destroy)(struct mail_storage *storage);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync bool (*autodetect)(const char *data, enum mail_storage_flags flags);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync struct mailbox *(*mailbox_open)(struct mail_storage *storage,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync const char *name,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync struct istream *input,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync enum mailbox_open_flags flags);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync int (*mailbox_create)(struct mail_storage *storage, const char *name,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync bool directory);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync};
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncunion mail_storage_module_context {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync struct mail_storage_vfuncs super;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync struct mail_storage_module_register *reg;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync};
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstruct mail_storage {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync const char *name;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync bool mailbox_is_file;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync struct mail_storage_vfuncs v;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/* private: */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync pool_t pool;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync char *error_string;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync enum mail_error error;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync struct mail_namespace *ns;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync struct mailbox_list *list;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync const char *user; /* name of user accessing the storage */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync enum mail_storage_flags flags;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync enum file_lock_method lock_method;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync struct mail_storage_callbacks *callbacks;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync void *callback_context;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync /* Module-specific contexts. See mail_storage_module_id. */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ARRAY_DEFINE(module_contexts, union mail_storage_module_context *);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync};
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstruct mailbox_vfuncs {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync bool (*is_readonly)(struct mailbox *box);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync bool (*allow_new_keywords)(struct mailbox *box);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync int (*close)(struct mailbox *box);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync int (*get_status)(struct mailbox *box, enum mailbox_status_items items,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync struct mailbox_status *status);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync struct mailbox_sync_context *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync (*sync_init)(struct mailbox *box,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync enum mailbox_sync_flags flags);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync int (*sync_next)(struct mailbox_sync_context *ctx,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync struct mailbox_sync_rec *sync_rec_r);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync int (*sync_deinit)(struct mailbox_sync_context *ctx,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync enum mailbox_status_items status_items,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync struct mailbox_status *status_r);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync /* Called once for each expunge. Called one or more times for
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync flag/keyword changes. Once the sync is finished, called with
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync uid=0 and sync_type=0. */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync void (*sync_notify)(struct mailbox *box, uint32_t uid,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync enum mailbox_sync_type sync_type);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync void (*notify_changes)(struct mailbox *box);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync struct mailbox_transaction_context *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync (*transaction_begin)(struct mailbox *box,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync enum mailbox_transaction_flags flags);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync int (*transaction_commit)(struct mailbox_transaction_context *t,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync enum mailbox_sync_flags flags,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync uint32_t *first_saved_uid_r,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync uint32_t *last_saved_uid_r);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync void (*transaction_rollback)(struct mailbox_transaction_context *t);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync struct mail_keywords *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync (*keywords_create)(struct mailbox_transaction_context *t,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync const char *const keywords[]);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync void (*keywords_free)(struct mailbox_transaction_context *t,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync struct mail_keywords *keywords);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync int (*get_uids)(struct mailbox *box, uint32_t uid1, uint32_t uid2,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync uint32_t *seq1_r, uint32_t *seq2_r);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync struct mail *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync (*mail_alloc)(struct mailbox_transaction_context *t,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync enum mail_fetch_field wanted_fields,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync struct mailbox_header_lookup_ctx *wanted_headers);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync struct mailbox_header_lookup_ctx *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync (*header_lookup_init)(struct mailbox *box,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync const char *const headers[]);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync void (*header_lookup_deinit)(struct mailbox_header_lookup_ctx *ctx);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync struct mail_search_context *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync (*search_init)(struct mailbox_transaction_context *t,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync const char *charset, struct mail_search_arg *args,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync const enum mail_sort_type *sort_program);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync int (*search_deinit)(struct mail_search_context *ctx);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync int (*search_next_nonblock)(struct mail_search_context *ctx,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync struct mail *mail, bool *tryagain_r);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync /* Internal search function which updates ctx->seq */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync int (*search_next_update_seq)(struct mail_search_context *ctx);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync int (*save_init)(struct mailbox_transaction_context *t,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync enum mail_flags flags,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync struct mail_keywords *keywords,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync time_t received_date, int timezone_offset,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync const char *from_envelope, struct istream *input,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync struct mail *dest_mail,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync struct mail_save_context **ctx_r);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync int (*save_continue)(struct mail_save_context *ctx);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync int (*save_finish)(struct mail_save_context *ctx);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync void (*save_cancel)(struct mail_save_context *ctx);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync int (*copy)(struct mailbox_transaction_context *t, struct mail *mail,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync enum mail_flags flags, struct mail_keywords *keywords,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync struct mail *dest_mail);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync bool (*is_inconsistent)(struct mailbox *box);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync};
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncunion mailbox_module_context {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync struct mailbox_vfuncs super;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync struct mail_storage_module_register *reg;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync};
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstruct mailbox {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync char *name;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync struct mail_storage *storage;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync struct mailbox_vfuncs v;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/* private: */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync pool_t pool;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync unsigned int transaction_count;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync /* Mailbox notification settings: */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync unsigned int notify_min_interval;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync mailbox_notify_callback_t *notify_callback;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync void *notify_context;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync /* Module-specific contexts. See mail_storage_module_id. */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ARRAY_DEFINE(module_contexts, union mailbox_module_context *);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync /* When FAST open flag is used, the mailbox isn't actually opened until
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync it's synced for the first time. */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync unsigned int opened:1;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync};
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstruct mail_vfuncs {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync void (*free)(struct mail *mail);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync int (*set_seq)(struct mail *mail, uint32_t seq);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync int (*set_uid)(struct mail *mail, uint32_t uid);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync enum mail_flags (*get_flags)(struct mail *mail);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync const char *const *(*get_keywords)(struct mail *mail);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync const struct message_part *(*get_parts)(struct mail *mail);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync time_t (*get_date)(struct mail *mail, int *timezone);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync time_t (*get_received_date)(struct mail *mail);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync time_t (*get_save_date)(struct mail *mail);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync uoff_t (*get_virtual_size)(struct mail *mail);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync uoff_t (*get_physical_size)(struct mail *mail);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync const char *(*get_first_header)(struct mail *mail, const char *field);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync const char *const *(*get_headers)(struct mail *mail, const char *field);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync struct istream *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync (*get_header_stream)(struct mail *mail,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync struct mailbox_header_lookup_ctx *headers);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync struct istream *(*get_stream)(struct mail *mail,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync struct message_size *hdr_size,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync struct message_size *body_size);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync const char *(*get_special)(struct mail *mail,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync enum mail_fetch_field field);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync int (*update_flags)(struct mail *mail, enum modify_type modify_type,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync enum mail_flags flags);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync int (*update_keywords)(struct mail *mail, enum modify_type modify_type,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync struct mail_keywords *keywords);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync int (*expunge)(struct mail *mail);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync};
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncunion mail_module_context {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync struct mail_vfuncs super;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync struct mail_module_register *reg;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync};
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstruct mail_private {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync struct mail mail;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync struct mail_vfuncs v;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync pool_t pool;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ARRAY_DEFINE(module_contexts, union mail_module_context *);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync};
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstruct mailbox_list_context {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync struct mail_storage *storage;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync enum mailbox_list_flags flags;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync bool failed;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync};
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncunion mailbox_transaction_module_context {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync struct mail_storage_module_register *reg;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync};
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstruct mailbox_transaction_context {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync struct mailbox *box;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ARRAY_DEFINE(module_contexts,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync union mailbox_transaction_module_context *);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync};
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncunion mail_search_module_context {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync struct mail_storage_module_register *reg;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync};
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstruct mail_search_context {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync struct mailbox_transaction_context *transaction;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync char *charset;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync struct mail_search_arg *args;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync struct mail_search_sort_program *sort_program;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync uint32_t seq;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ARRAY_DEFINE(module_contexts, union mail_search_module_context *);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync};
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstruct mail_save_context {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync struct mailbox_transaction_context *transaction;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync struct mail *dest_mail;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync};
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstruct mailbox_sync_context {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync struct mailbox *box;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync};
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstruct mailbox_header_lookup_ctx {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync struct mailbox *box;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync};
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/* Modules should use do "my_id = mail_storage_module_id++" and
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync use objects' module_contexts[id] for their own purposes. */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncextern struct mail_storage_module_register mail_storage_module_register;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/* Storage's module_id for mail_index. */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncextern struct mail_module_register mail_module_register;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#define MAIL_STORAGE_CONTEXT(obj) \
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync MODULE_CONTEXT(obj, mail_storage_mail_index_module)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncextern MODULE_CONTEXT_DEFINE(mail_storage_mail_index_module,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync &mail_index_module_register);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/* Set error message in storage. Critical errors are logged with i_error(),
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync but user sees only "internal error" message. */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncvoid mail_storage_clear_error(struct mail_storage *storage);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncvoid mail_storage_set_error(struct mail_storage *storage,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync enum mail_error error, const char *string);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncvoid mail_storage_set_critical(struct mail_storage *storage,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync const char *fmt, ...) __attr_format__(2, 3);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncvoid mail_storage_set_internal_error(struct mail_storage *storage);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncbool mail_storage_set_error_from_errno(struct mail_storage *storage);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncenum mailbox_list_flags
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncmail_storage_get_list_flags(enum mail_storage_flags storage_flags);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#endif
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync