index-storage.h revision 54f9cedf212e30f690e8c7487374f2ea890494c6
#ifndef __INDEX_STORAGE_H
#define __INDEX_STORAGE_H
#include "file-dotlock.h"
#include "mail-storage-private.h"
#include "mail-index.h"
#include "index-mail.h"
/* Max. mmap()ed size for a message */
/* Block size when read()ing message. */
#define MAILBOX_FULL_SYNC_INTERVAL 5
enum mailbox_lock_notify_type {
/* Mailbox is locked, will abort in secs_left */
/* Mailbox lock looks stale, will override in secs_left */
};
struct index_autosync_file {
struct index_autosync_file *next;
char *path;
};
struct index_autosync_io {
struct index_autosync_io *next;
int fd;
};
struct index_storage {
struct mail_storage storage;
char *dir; /* root directory */
char *index_dir;
char *control_dir;
char *inbox_path; /* INBOX location */
char *temp_prefix; /* prefix for temporary files */
char *user; /* name of user accessing the storage */
struct mail_storage_callbacks *callbacks;
void *callback_context;
};
struct index_mailbox {
struct index_storage *storage;
char *path, *control_dir;
struct mail_index *index;
struct mail_index_view *view;
struct mail_cache *cache;
struct mail_cache_view *cache_view;
struct mail *mail_interface;
unsigned int last_recent_count;
struct timeout *autosync_to;
struct index_autosync_file *autosync_files;
struct index_autosync_io *autosync_ios;
unsigned int min_newmail_notify_interval;
/* mbox: */
int mbox_fd;
int mbox_lock_type;
unsigned int mbox_locks;
struct dotlock mbox_dotlock;
unsigned int mbox_lock_id;
/* maildir sync: */
struct maildir_uidlist *uidlist;
unsigned int private_flags_mask;
unsigned int readonly:1;
unsigned int keep_recent:1;
unsigned int sent_diskspace_warning:1;
unsigned int sent_readonly_flags_warning:1;
unsigned int autosync_pending:1;
unsigned int mail_read_mmaped:1;
unsigned int last_recent_count_initialized:1;
};
struct index_transaction_context {
struct index_mailbox *ibox;
struct mail_index_transaction *trans;
struct mail_cache_transaction_ctx *cache_trans;
};
unsigned int secs_left);
struct mail_index *
index_storage_alloc(const char *index_dir,
const char *mailbox_path, const char *prefix);
void index_storage_destroy_unrefed(void);
struct index_mailbox *
enum mailbox_open_flags flags);
enum mail_flags *flags,
const char *keywords[],
unsigned int keywords_count);
/* mailbox methods: */
struct mail_storage_callbacks *callbacks,
void *context);
enum mailbox_status_items items,
struct mailbox_status *status);
struct mail *
enum mail_fetch_field wanted_fields);
enum mail_sort_type *sort_program);
struct mail_search_context *
const enum mail_sort_type *sort_program,
const char *const wanted_headers[]);
struct mailbox_transaction_context *
int index_transaction_commit(struct mailbox_transaction_context *t);
void index_transaction_rollback(struct mailbox_transaction_context *t);
#endif