mail-storage-private.h revision 5fb3bff645380804c9db2510940c41db6b8fdb01
#ifndef __MAIL_STORAGE_PRIVATE_H
#define __MAIL_STORAGE_PRIVATE_H
#include "mail-storage.h"
/* Some error strings that should be used everywhere to avoid
permissions checks from revealing mailbox's existence */
#define MAIL_STORAGE_ERR_MAILBOX_NOT_FOUND "Mailbox doesn't exist: %s"
#define MAIL_STORAGE_ERR_NO_PERMISSION "Permission denied"
/* Called after mail storage has been created */
/* Called after mailbox has been opened */
struct mail_storage_vfuncs {
void (*class_init)(void);
void (*class_deinit)(void);
struct mail_storage *
enum mail_storage_flags flags,
struct mail_storage_callbacks *callbacks,
void *context);
const char *name);
const char *name);
const char *name,
enum mailbox_open_flags flags);
bool directory);
const char *newname);
enum mailbox_info_flags *flags,
enum mailbox_list_file_type type);
bool *syntax_error_r,
bool *temporary_error_r);
};
struct mail_storage {
const char *name;
bool mailbox_is_file;
struct mail_storage_vfuncs v;
/* private: */
char *error;
struct mailbox_list *list;
enum mail_storage_flags flags;
/* Module-specific contexts. See mail_storage_module_id. */
ARRAY_DEFINE(module_contexts, void);
/* IMAP: Give a BAD reply instead of NO */
unsigned int syntax_error:1;
/* Internal temporary error, as opposed to visible user errors like
"permission denied" or "out of disk space" */
unsigned int temporary_error:1;
};
struct mailbox_vfuncs {
struct mailbox_status *status);
struct mailbox_sync_context *
enum mailbox_sync_flags flags);
struct mailbox_sync_rec *sync_rec_r);
struct mailbox_status *status_r);
void *context);
struct mailbox_transaction_context *
enum mailbox_transaction_flags flags);
int (*transaction_commit)(struct mailbox_transaction_context *t,
enum mailbox_sync_flags flags);
void (*transaction_rollback)(struct mailbox_transaction_context *t);
struct mail_keywords *
(*keywords_create)(struct mailbox_transaction_context *t,
const char *const keywords[]);
void (*keywords_free)(struct mailbox_transaction_context *t,
struct mail_keywords *keywords);
struct mail *
(*mail_alloc)(struct mailbox_transaction_context *t,
struct mailbox_header_lookup_ctx *wanted_headers);
struct mailbox_header_lookup_ctx *
const char *const headers[]);
struct mail_search_context *
(*search_init)(struct mailbox_transaction_context *t,
const enum mail_sort_type *sort_program);
/* Internal search function which updates ctx->seq */
int (*save_init)(struct mailbox_transaction_context *t,
enum mail_flags flags,
struct mail_keywords *keywords,
struct mail_save_context **ctx_r);
};
struct mailbox {
char *name;
struct mail_storage *storage;
struct mailbox_vfuncs v;
/* private: */
/* Module-specific contexts. See mail_storage_module_id. */
ARRAY_DEFINE(module_contexts, void);
/* When FAST open flag is used, the mailbox isn't actually opened until
it's synced for the first time. */
unsigned int opened:1;
};
struct mail_vfuncs {
struct istream *
struct mailbox_header_lookup_ctx *headers);
struct message_size *hdr_size,
struct message_size *body_size);
enum mail_fetch_field field);
enum mail_flags flags);
struct mail_keywords *keywords);
};
struct mail_private {
struct mail_vfuncs v;
ARRAY_DEFINE(module_contexts, void);
};
struct mailbox_list_context {
struct mail_storage *storage;
enum mailbox_list_flags flags;
bool failed;
};
struct mailbox_transaction_context {
ARRAY_DEFINE(module_contexts, void);
};
struct mail_search_context {
struct mailbox_transaction_context *transaction;
char *charset;
struct mail_search_arg *args;
struct mail_search_sort_program *sort_program;
ARRAY_DEFINE(module_contexts, void);
};
struct mail_save_context {
struct mailbox_transaction_context *transaction;
};
struct mailbox_sync_context {
};
struct mailbox_header_lookup_ctx {
};
/* Modules should use do "my_id = mail_storage_module_id++" and
use objects' module_contexts[id] for their own purposes. */
extern unsigned int mail_storage_module_id;
/* Storage's module_id for mail_index. */
extern unsigned int mail_storage_mail_index_module_id;
#define MAIL_STORAGE_INDEX(index) \
*((void **)array_idx_modifiable( \
&(index)->mail_index_module_contexts, \
#define MAIL_STORAGE_VIEW(view) \
*((void **)array_idx_modifiable( \
#define MAIL_STORAGE_TRANSACTION(trans) \
*((void **)array_idx_modifiable( \
/* Set error message in storage. Critical errors are logged with i_error(),
but user sees only "internal error" message. */
bool *syntax_error_r);
enum mailbox_list_flags
enum mailbox_list_file_type type,
enum mailbox_info_flags *flags,
void *context);
#endif