mail-storage-private.h revision f81f4bc282cd1944cec187bae89c0701a416ed2a
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen/* Called after mail storage has been created */
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainenextern void (*hook_mail_storage_created)(struct mail_storage *storage);
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen/* Called after mailbox has been opened */
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainenextern void (*hook_mailbox_opened)(struct mailbox *box);
b3254619187a08d0ecbdfaf4d251468158287c40Timo Sirainen unsigned int id;
b3254619187a08d0ecbdfaf4d251468158287c40Timo Sirainen unsigned int id;
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen void (*class_init)(void);
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen int (*create)(struct mail_storage *storage, const char *data);
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen void (*destroy)(struct mail_storage *storage);
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen bool (*autodetect)(const char *data, enum mail_storage_flags flags);
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen struct mailbox *(*mailbox_open)(struct mail_storage *storage,
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen int (*mailbox_create)(struct mail_storage *storage, const char *name,
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen const char *(*get_last_error)(struct mail_storage *storage,
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen/* private: */
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen const char *user; /* name of user accessing the storage */
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen /* Module-specific contexts. See mail_storage_module_id. */
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen ARRAY_DEFINE(module_contexts, union mail_storage_module_context *);
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen /* IMAP: Give a BAD reply instead of NO */
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen /* Internal temporary error, as opposed to visible user errors like
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen "permission denied" or "out of disk space" */
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen bool (*allow_new_keywords)(struct mailbox *box);
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen int (*get_status)(struct mailbox *box, enum mailbox_status_items items,
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen int (*sync_next)(struct mailbox_sync_context *ctx,
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen int (*sync_deinit)(struct mailbox_sync_context *ctx,
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen int (*transaction_commit)(struct mailbox_transaction_context *t,
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen void (*transaction_rollback)(struct mailbox_transaction_context *t);
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen (*keywords_create)(struct mailbox_transaction_context *t,
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen const char *const keywords[]);
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen void (*keywords_free)(struct mailbox_transaction_context *t,
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen int (*get_uids)(struct mailbox *box, uint32_t uid1, uint32_t uid2,
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen (*mail_alloc)(struct mailbox_transaction_context *t,
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen struct mailbox_header_lookup_ctx *wanted_headers);
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen const char *const headers[]);
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen void (*header_lookup_deinit)(struct mailbox_header_lookup_ctx *ctx);
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen (*search_init)(struct mailbox_transaction_context *t,
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen const char *charset, struct mail_search_arg *args,
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen int (*search_deinit)(struct mail_search_context *ctx);
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen int (*search_next_nonblock)(struct mail_search_context *ctx,
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen /* Internal search function which updates ctx->seq */
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen int (*search_next_update_seq)(struct mail_search_context *ctx);
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen int (*save_init)(struct mailbox_transaction_context *t,
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen const char *from_envelope, struct istream *input,
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen int (*save_continue)(struct mail_save_context *ctx);
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen int (*save_finish)(struct mail_save_context *ctx);
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen void (*save_cancel)(struct mail_save_context *ctx);
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen int (*copy)(struct mailbox_transaction_context *t, struct mail *mail,
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen enum mail_flags flags, struct mail_keywords *keywords,
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen/* private: */
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen /* Mailbox notification settings: */
b3254619187a08d0ecbdfaf4d251468158287c40Timo Sirainen /* Module-specific contexts. See mail_storage_module_id. */
b3254619187a08d0ecbdfaf4d251468158287c40Timo Sirainen ARRAY_DEFINE(module_contexts, union mailbox_module_context *);
cbd6cad82e1c9ad60869ad71ae6c42e1af8b10a8Timo Sirainen /* When FAST open flag is used, the mailbox isn't actually opened until
cbd6cad82e1c9ad60869ad71ae6c42e1af8b10a8Timo Sirainen it's synced for the first time. */
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen int (*set_seq)(struct mail *mail, uint32_t seq);
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen int (*set_uid)(struct mail *mail, uint32_t uid);
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen enum mail_flags (*get_flags)(struct mail *mail);
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen const char *const *(*get_keywords)(struct mail *mail);
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen const struct message_part *(*get_parts)(struct mail *mail);
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen time_t (*get_date)(struct mail *mail, int *timezone);
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen time_t (*get_received_date)(struct mail *mail);
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen uoff_t (*get_virtual_size)(struct mail *mail);
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen uoff_t (*get_physical_size)(struct mail *mail);
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen const char *(*get_first_header)(struct mail *mail, const char *field);
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen const char *const *(*get_headers)(struct mail *mail, const char *field);
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen struct istream *(*get_stream)(struct mail *mail,
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen int (*update_flags)(struct mail *mail, enum modify_type modify_type,
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen int (*update_keywords)(struct mail *mail, enum modify_type modify_type,
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen ARRAY_DEFINE(module_contexts, union mail_module_context *);
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen struct mailbox_transaction_context *transaction;
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen struct mail_search_sort_program *sort_program;
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen ARRAY_DEFINE(module_contexts, union mail_search_module_context *);
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen struct mailbox_transaction_context *transaction;
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen/* Modules should use do "my_id = mail_storage_module_id++" and
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen use objects' module_contexts[id] for their own purposes. */
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainenextern struct mail_storage_module_register mail_storage_module_register;
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen/* Storage's module_id for mail_index. */
3d7590a656f4f746b2adc6e00fa607eba5d2412dTimo Sirainenextern struct mail_module_register mail_module_register;
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen MODULE_CONTEXT(obj, mail_storage_mail_index_module)
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainenextern MODULE_CONTEXT_DEFINE(mail_storage_mail_index_module,
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen/* Set error message in storage. Critical errors are logged with i_error(),
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainen but user sees only "internal error" message. */
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainenvoid mail_storage_clear_error(struct mail_storage *storage);
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainenvoid mail_storage_set_error(struct mail_storage *storage,
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainenvoid mail_storage_set_syntax_error(struct mail_storage *storage,
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainenvoid mail_storage_set_critical(struct mail_storage *storage,
fb15bb48cf8be41cd94738c868b64608b4fda1adTimo Sirainenvoid mail_storage_set_internal_error(struct mail_storage *storage);