mail-storage-private.h revision 194603b35061fea1ee8d171a7104b6985c610966
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch/* Called after mail storage has been created */
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Boschextern void (*hook_mail_storage_created)(struct mail_storage *storage);
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch/* Called after mailbox has been opened */
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Boschextern void (*hook_mailbox_opened)(struct mailbox *box);
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch unsigned int id;
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch unsigned int id;
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch void (*class_init)(void);
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch int (*create)(struct mail_storage *storage, const char *data,
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch const char **error_r);
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch void (*destroy)(struct mail_storage *storage);
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch bool (*autodetect)(const char *data, enum mail_storage_flags flags);
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch struct mailbox *(*mailbox_open)(struct mail_storage *storage,
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch int (*mailbox_create)(struct mail_storage *storage, const char *name,
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch/* private: */
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch const char *user; /* name of user accessing the storage */
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch /* Module-specific contexts. See mail_storage_module_id. */
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch ARRAY_DEFINE(module_contexts, union mail_storage_module_context *);
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch bool (*allow_new_keywords)(struct mailbox *box);
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch void (*get_status)(struct mailbox *box, enum mailbox_status_items items,
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch /* Lookup sync extension record and figure out if it mailbox has
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch changed since. Returns 1 = yes, 0 = no, -1 = error. */
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch int (*list_index_has_changed)(struct mailbox *box,
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch /* Update the sync extension record. Returns 0 = ok, -1 = error. */
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch int (*list_index_update_sync)(struct mailbox *box,
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch bool (*sync_next)(struct mailbox_sync_context *ctx,
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch int (*sync_deinit)(struct mailbox_sync_context *ctx,
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch /* Called once for each expunge. Called one or more times for
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch flag/keyword changes. Once the sync is finished, called with
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch uid=0 and sync_type=0. */
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch void (*sync_notify)(struct mailbox *box, uint32_t uid,
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch int (*transaction_commit)(struct mailbox_transaction_context *t,
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch void (*transaction_rollback)(struct mailbox_transaction_context *t);
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch const char *const keywords[],
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch void (*keywords_free)(struct mail_keywords *keywords);
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch void (*get_uids)(struct mailbox *box, uint32_t uid1, uint32_t uid2,
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch (*mail_alloc)(struct mailbox_transaction_context *t,
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch struct mailbox_header_lookup_ctx *wanted_headers);
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch const char *const headers[]);
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch void (*header_lookup_deinit)(struct mailbox_header_lookup_ctx *ctx);
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch (*search_init)(struct mailbox_transaction_context *t,
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch const char *charset, struct mail_search_arg *args,
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch int (*search_deinit)(struct mail_search_context *ctx);
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch int (*search_next_nonblock)(struct mail_search_context *ctx,
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch /* Internal search function which updates ctx->seq */
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch int (*search_next_update_seq)(struct mail_search_context *ctx);
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch int (*save_init)(struct mailbox_transaction_context *t,
f091dd12d19df22e5403855f93dedee437bd7d87Stephan Bosch const char *from_envelope, struct istream *input,
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch int (*save_continue)(struct mail_save_context *ctx);
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch int (*save_finish)(struct mail_save_context *ctx);
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch void (*save_cancel)(struct mail_save_context *ctx);
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch int (*copy)(struct mailbox_transaction_context *t, struct mail *mail,
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch enum mail_flags flags, struct mail_keywords *keywords,
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch/* private: */
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch /* User's private flags if this is a shared mailbox */
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch /* mode and GID to use for newly created files/dirs */
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch /* Mailbox notification settings: */
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch /* Module-specific contexts. See mail_storage_module_id. */
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch ARRAY_DEFINE(module_contexts, union mailbox_module_context *);
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch /* When FAST open flag is used, the mailbox isn't actually opened until
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch it's synced for the first time. */
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch /* Mailbox was deleted while we had it open. */
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch void (*set_seq)(struct mail *mail, uint32_t seq);
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch bool (*set_uid)(struct mail *mail, uint32_t uid);
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch enum mail_flags (*get_flags)(struct mail *mail);
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch const char *const *(*get_keywords)(struct mail *mail);
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch int (*get_date)(struct mail *mail, time_t *date_r, int *timezone_r);
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch int (*get_received_date)(struct mail *mail, time_t *date_r);
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch int (*get_save_date)(struct mail *mail, time_t *date_r);
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch int (*get_virtual_size)(struct mail *mail, uoff_t *size_r);
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch int (*get_physical_size)(struct mail *mail, uoff_t *size_r);
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch int (*get_first_header)(struct mail *mail, const char *field,
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch int (*get_headers)(struct mail *mail, const char *field,
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch bool decode_to_utf8, const char *const **value_r);
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch int (*get_stream)(struct mail *mail, struct message_size *hdr_size,
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch int (*get_special)(struct mail *mail, enum mail_fetch_field field,
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch const char **value_r);
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch void (*update_flags)(struct mail *mail, enum modify_type modify_type,
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch void (*update_keywords)(struct mail *mail, enum modify_type modify_type,
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch void (*set_cache_corrupted)(struct mail *mail,
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch ARRAY_DEFINE(module_contexts, union mail_module_context *);
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch struct mailbox_transaction_context *transaction;
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch struct mail_search_sort_program *sort_program;
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch ARRAY_DEFINE(module_contexts, union mail_search_module_context *);
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch struct mailbox_transaction_context *transaction;
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch/* Modules should use do "my_id = mail_storage_module_id++" and
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch use objects' module_contexts[id] for their own purposes. */
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Boschextern struct mail_storage_module_register mail_storage_module_register;
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch/* Storage's module_id for mail_index. */
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Boschextern struct mail_module_register mail_module_register;
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch MODULE_CONTEXT(obj, mail_storage_mail_index_module)
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Boschextern MODULE_CONTEXT_DEFINE(mail_storage_mail_index_module,
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch/* Set error message in storage. Critical errors are logged with i_error(),
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Bosch but user sees only "internal error" message. */
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Boschvoid mail_storage_clear_error(struct mail_storage *storage);
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Boschvoid mail_storage_set_error(struct mail_storage *storage,
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Boschvoid mail_storage_set_critical(struct mail_storage *storage,
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Boschvoid mail_storage_set_internal_error(struct mail_storage *storage);
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Boschbool mail_storage_set_error_from_errno(struct mail_storage *storage);
56dd928c164ec5c0d1158a1760154b58c5f1f6e7Stephan Boschconst char *mail_storage_eacces_msg(const char *func, const char *path);