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