mail-storage-private.h revision d9fdacd5fb3e07997e5c389739d2054f0c8441d8
defb12ecd360df672ffb2f4dbf4d1218a0a9549cTimo Sirainen/* Some error strings that should be used everywhere to avoid
defb12ecd360df672ffb2f4dbf4d1218a0a9549cTimo Sirainen permissions checks from revealing mailbox's existence */
defb12ecd360df672ffb2f4dbf4d1218a0a9549cTimo Sirainen#define MAIL_STORAGE_ERR_MAILBOX_NOT_FOUND "Mailbox doesn't exist: %s"
defb12ecd360df672ffb2f4dbf4d1218a0a9549cTimo Sirainen#define MAIL_STORAGE_ERR_NO_PERMISSION "Permission denied"
5fb3bff645380804c9db2510940c41db6b8fdb01Timo Sirainen/* Called after mail storage has been created */
5fb3bff645380804c9db2510940c41db6b8fdb01Timo Sirainenextern void (*hook_mail_storage_created)(struct mail_storage *storage);
15b9759df8e4f6fb00c115353827a2aebbebfebcTimo Sirainen/* Called after mailbox has been opened */
15b9759df8e4f6fb00c115353827a2aebbebfebcTimo Sirainenextern void (*hook_mailbox_opened)(struct mailbox *box);
d6badc27cd6e8d3398877b6766cb0aaeef3a7800Timo Sirainen void (*class_init)(void);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen void (*destroy)(struct mail_storage *storage);
6ef7e31619edfaa17ed044b45861d106a86191efTimo Sirainen bool (*autodetect)(const char *data, enum mail_storage_flags flags);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen void (*set_callbacks)(struct mail_storage *storage,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen struct mailbox *(*mailbox_open)(struct mail_storage *storage,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen int (*mailbox_create)(struct mail_storage *storage, const char *name,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen int (*mailbox_delete)(struct mail_storage *storage, const char *name);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen int (*mailbox_rename)(struct mail_storage *storage, const char *oldname,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen const char *newname);
a27e065f1a1f91c7fbdf7c2ea1c387441af0cbb3Timo Sirainen int (*is_mailbox)(struct mail_storage *storage,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen const char *(*get_last_error)(struct mail_storage *storage,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen/* private: */
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainen /* Module-specific contexts. See mail_storage_module_id. */
ab0155cbec1286e1cd00a0e01d78e0f3ca34cea6Timo Sirainen /* IMAP: Give a BAD reply instead of NO */
ab0155cbec1286e1cd00a0e01d78e0f3ca34cea6Timo Sirainen /* Internal temporary error, as opposed to visible user errors like
ab0155cbec1286e1cd00a0e01d78e0f3ca34cea6Timo Sirainen "permission denied" or "out of disk space" */
6ef7e31619edfaa17ed044b45861d106a86191efTimo Sirainen bool (*allow_new_keywords)(struct mailbox *box);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen int (*get_status)(struct mailbox *box, enum mailbox_status_items items,
d756ebcfa96bd7cff02097c8f26df9df368b81b1Timo Sirainen int (*sync_next)(struct mailbox_sync_context *ctx,
d756ebcfa96bd7cff02097c8f26df9df368b81b1Timo Sirainen int (*sync_deinit)(struct mailbox_sync_context *ctx,
d756ebcfa96bd7cff02097c8f26df9df368b81b1Timo Sirainen void (*notify_changes)(struct mailbox *box, unsigned int min_interval,
b2c1349cf07410aefab0f5b17153af9e5cfcf48fTimo Sirainen int (*transaction_commit)(struct mailbox_transaction_context *t,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen void (*transaction_rollback)(struct mailbox_transaction_context *t);
16c89b1260c9d07c01c83a9219424d3727069b2eTimo Sirainen (*keywords_create)(struct mailbox_transaction_context *t,
16c89b1260c9d07c01c83a9219424d3727069b2eTimo Sirainen const char *const keywords[]);
faed8babca9914257f34fb2e603d74016d563b2dTimo Sirainen void (*keywords_free)(struct mailbox_transaction_context *t,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen int (*get_uids)(struct mailbox *box, uint32_t uid1, uint32_t uid2,
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainen (*mail_alloc)(struct mailbox_transaction_context *t,
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainen struct mailbox_header_lookup_ctx *wanted_headers);
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainen const char *const headers[]);
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainen void (*header_lookup_deinit)(struct mailbox_header_lookup_ctx *ctx);
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainen (*search_init)(struct mailbox_transaction_context *t,
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainen const char *charset, struct mail_search_arg *args,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen int (*search_deinit)(struct mail_search_context *ctx);
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainen int (*search_next)(struct mail_search_context *ctx, struct mail *mail);
a3ee5ce6ecc8e228ee69300fdd562d7ac8be89a7Timo Sirainen /* Internal search function which updates ctx->seq */
a3ee5ce6ecc8e228ee69300fdd562d7ac8be89a7Timo Sirainen int (*search_next_update_seq)(struct mail_search_context *ctx);
4981827cb5e32cf767b7b0e3070137e6b36f42afTimo Sirainen int (*save_init)(struct mailbox_transaction_context *t,
4981827cb5e32cf767b7b0e3070137e6b36f42afTimo Sirainen const char *from_envelope, struct istream *input,
a423d985ba7261661475811c22b21b80ec765a71Timo Sirainen int (*save_continue)(struct mail_save_context *ctx);
2ebeb22b9a8a8bb7fbe2f2e2908478a220792b87Timo Sirainen int (*save_finish)(struct mail_save_context *ctx);
a423d985ba7261661475811c22b21b80ec765a71Timo Sirainen void (*save_cancel)(struct mail_save_context *ctx);
345212e8f61ebf14ff4f80df26df9e655eb5121eTimo Sirainen int (*copy)(struct mailbox_transaction_context *t, struct mail *mail,
c13f3df87bc8ec1fb279fc0ffa6e8517f74dc07cTimo Sirainen enum mail_flags flags, struct mail_keywords *keywords,
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainen/* private: */
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainen /* Module-specific contexts. See mail_storage_module_id. */
5fb3bff645380804c9db2510940c41db6b8fdb01Timo Sirainen /* When FAST open flag is used, the mailbox isn't actually opened until
5fb3bff645380804c9db2510940c41db6b8fdb01Timo Sirainen it's synced for the first time. */
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainen int (*set_seq)(struct mail *mail, uint32_t seq);
a12399903f415a7e14c2816cffa2f7a09dcbb097Timo Sirainen int (*set_uid)(struct mail *mail, uint32_t uid);
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainen enum mail_flags (*get_flags)(struct mail *mail);
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainen const char *const *(*get_keywords)(struct mail *mail);
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainen const struct message_part *(*get_parts)(struct mail *mail);
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainen time_t (*get_date)(struct mail *mail, int *timezone);
90adcaa0a00eba29b7fbd50ca66be11c8d086d6aTimo Sirainen time_t (*get_received_date)(struct mail *mail);
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainen uoff_t (*get_virtual_size)(struct mail *mail);
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainen uoff_t (*get_physical_size)(struct mail *mail);
87460b08cb97b31cde640d4975a6aa2c1d0e7226Timo Sirainen const char *(*get_first_header)(struct mail *mail, const char *field);
87460b08cb97b31cde640d4975a6aa2c1d0e7226Timo Sirainen const char *const *(*get_headers)(struct mail *mail, const char *field);
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainen struct istream *(*get_stream)(struct mail *mail,
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainen int (*update_flags)(struct mail *mail, enum modify_type modify_type,
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainen int (*update_keywords)(struct mail *mail, enum modify_type modify_type,
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainen struct mailbox_transaction_context *transaction;
e63bdfedcf61e1a9ee21990140cbd0d0638da7e1Timo Sirainen struct mail_search_sort_program *sort_program;
fdc557286bc9f92c5f3bb49096ff6e2bcec0ea79Timo Sirainen struct mailbox_transaction_context *transaction;
d6badc27cd6e8d3398877b6766cb0aaeef3a7800Timo Sirainen/* Modules should use do "my_id = mail_storage_module_id++" and
d6badc27cd6e8d3398877b6766cb0aaeef3a7800Timo Sirainen use objects' module_contexts[id] for their own purposes. */
d6badc27cd6e8d3398877b6766cb0aaeef3a7800Timo Sirainenextern unsigned int mail_storage_module_id;
d6badc27cd6e8d3398877b6766cb0aaeef3a7800Timo Sirainen/* Storage's module_id for mail_index. */
d6badc27cd6e8d3398877b6766cb0aaeef3a7800Timo Sirainenextern unsigned int mail_storage_mail_index_module_id;
d6badc27cd6e8d3398877b6766cb0aaeef3a7800Timo Sirainen &(trans)->mail_index_transaction_module_contexts, \
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen/* Set error message in storage. Critical errors are logged with i_error(),
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen but user sees only "internal error" message. */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenvoid mail_storage_clear_error(struct mail_storage *storage);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenvoid mail_storage_set_error(struct mail_storage *storage,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenvoid mail_storage_set_syntax_error(struct mail_storage *storage,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenvoid mail_storage_set_critical(struct mail_storage *storage,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenvoid mail_storage_set_internal_error(struct mail_storage *storage);
b3b4f3875850099c9292ad74d08bb385c3988f8fTimo Sirainenconst char *mail_storage_class_get_last_error(struct mail_storage *storage,
a27e065f1a1f91c7fbdf7c2ea1c387441af0cbb3Timo Sirainenmail_storage_get_list_flags(enum mail_storage_flags storage_flags);
a27e065f1a1f91c7fbdf7c2ea1c387441af0cbb3Timo Sirainenint mailbox_storage_list_is_mailbox(const char *dir, const char *fname,