mail-storage-private.h revision 73b50eecfc31750a312e2f940023f522eb07178c
#ifndef __MAIL_STORAGE_PRIVATE_H
#define __MAIL_STORAGE_PRIVATE_H
#include "module-context.h"
#include "file-lock.h"
#include "mail-storage.h"
#include "mail-index-private.h"
/* Called after mail storage has been created */
/* Called after mailbox has been opened */
struct mail_storage_module_register {
unsigned int id;
};
struct mail_module_register {
unsigned int id;
};
struct mail_storage_vfuncs {
void (*class_init)(void);
void (*class_deinit)(void);
struct mail_storage *(*alloc)(void);
const char **error_r);
const char *name,
enum mailbox_open_flags flags);
bool directory);
};
union mail_storage_module_context {
struct mail_storage_vfuncs super;
struct mail_storage_module_register *reg;
};
struct mail_storage {
const char *name;
bool mailbox_is_file;
struct mail_storage_vfuncs v;
/* private: */
char *error_string;
enum mail_error error;
struct mail_namespace *ns;
struct mailbox_list *list;
const char *user; /* name of user accessing the storage */
enum mail_storage_flags flags;
enum file_lock_method lock_method;
struct mail_storage_callbacks *callbacks;
void *callback_context;
/* Module-specific contexts. See mail_storage_module_id. */
};
struct mailbox_vfuncs {
struct mailbox_status *status_r);
/* Lookup sync extension record and figure out if it mailbox has
changed since. Returns 1 = yes, 0 = no, -1 = error. */
struct mail_index_view *list_view,
/* Update the sync extension record. Returns 0 = ok, -1 = error. */
struct mail_index_transaction *trans,
struct mailbox_sync_context *
enum mailbox_sync_flags flags);
struct mailbox_sync_rec *sync_rec_r);
struct mailbox_status *status_r);
/* Called once for each expunge. Called one or more times for
uid=0 and sync_type=0. */
enum mailbox_sync_type sync_type);
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);
};
union mailbox_module_context {
struct mailbox_vfuncs super;
struct mail_storage_module_register *reg;
};
struct mailbox {
char *name;
struct mail_storage *storage;
struct mailbox_vfuncs v;
/* private: */
unsigned int transaction_count;
/* User's private flags if this is a shared mailbox */
enum mail_flags private_flags_mask;
/* Mailbox notification settings: */
unsigned int notify_min_interval;
void *notify_context;
/* Module-specific contexts. See mail_storage_module_id. */
/* 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 {
bool decode_to_utf8);
bool decode_to_utf8);
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);
};
union mail_module_context {
struct mail_vfuncs super;
struct mail_module_register *reg;
};
struct mail_private {
struct mail_vfuncs v;
};
struct mailbox_list_context {
struct mail_storage *storage;
enum mailbox_list_flags flags;
bool failed;
};
struct mail_storage_module_register *reg;
};
struct mailbox_transaction_context {
union mailbox_transaction_module_context *);
};
union mail_search_module_context {
struct mail_storage_module_register *reg;
};
struct mail_search_context {
struct mailbox_transaction_context *transaction;
char *charset;
struct mail_search_arg *args;
struct mail_search_sort_program *sort_program;
};
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 struct mail_storage_module_register mail_storage_module_register;
/* Storage's module_id for mail_index. */
extern struct mail_module_register mail_module_register;
#define MAIL_STORAGE_CONTEXT(obj) \
/* Set error message in storage. Critical errors are logged with i_error(),
but user sees only "internal error" message. */
enum mailbox_list_flags
#endif