mail-storage.c revision 5f352310311252d2da139beb208c21fcb8fdae89
02c335c23bf5fa225a467c19f2c063fb0dc7b8c3Timo Sirainen/* Copyright (c) 2002-2015 Dovecot authors, see the included COPYING file */
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarzextern struct mail_search_register *mail_search_register_imap;
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarzextern struct mail_search_register *mail_search_register_human;
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarzstruct mail_storage_module_register mail_storage_module_register = { 0 };
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarzstruct mail_module_register mail_module_register = { 0 };
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarzstruct mail_storage_mail_index_module mail_storage_mail_index_module =
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz MODULE_CONTEXT_INIT(&mail_index_module_register);
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M SlusarzARRAY_TYPE(mail_storage) mail_storage_classes;
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz mail_search_register_deinit(&mail_search_register_human);
2d7ad82a356217c7d763c7075aa3526129373bd8Timo Sirainen mail_search_register_deinit(&mail_search_register_imap);
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarzvoid mail_storage_class_register(struct mail_storage *storage_class)
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz i_assert(mail_storage_find_class(storage_class->name) == NULL);
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz /* append it after the list, so the autodetection order is correct */
2d7ad82a356217c7d763c7075aa3526129373bd8Timo Sirainen array_append(&mail_storage_classes, &storage_class, 1);
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarzvoid mail_storage_class_unregister(struct mail_storage *storage_class)
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz unsigned int i, count;
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz classes = array_get(&mail_storage_classes, &count);
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz for (i = 0; i < count; i++) {
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz array_delete(&mail_storage_classes, i, 1);
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarzstruct mail_storage *mail_storage_find_class(const char *name)
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz unsigned int i, count;
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz classes = array_get(&mail_storage_classes, &count);
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz for (i = 0; i < count; i++) {
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz if (strcasecmp(classes[i]->name, name) == 0)
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarzmail_storage_autodetect(const struct mail_namespace *ns,
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz unsigned int i, count;
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz classes = array_get(&mail_storage_classes, &count);
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz for (i = 0; i < count; i++) {
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarzmail_storage_set_autodetection(const char **data, const char **driver)
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz const char *p;
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz /* check if data is in driver:data format (eg. mbox:~/mail) */
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz /* no autodetection if the storage driver is given. */
static struct mail_storage *
const char *home;
return NULL;
return NULL;
return storage_class;
return storage_class;
return NULL;
const char **error_r)
} else if (!autocreate) {
bool autocreate;
int ret;
&root_dir)) {
if (ret == 0) {
error_r);
return FALSE;
return FALSE;
return FALSE;
return TRUE;
static struct mail_storage *
return storage;
return NULL;
const char **error_r)
error_r) < 0)
error_r);
T_BEGIN {
} T_END;
const char *str;
const char *fmt, ...)
const char *str;
const char *str;
const struct mail_storage_settings *
void *context)
return error;
const char *error_string;
return FALSE;
return FALSE;
return TRUE;
const struct mailbox_settings *
return NULL;
return *box_set;
return NULL;
T_BEGIN {
if (open_error != 0)
} T_END;
return box;
const char *vname;
&metadata) < 0) {
return box;
return box;
return TRUE;
const char *errstr;
MAILBOX_SET_AUTO_SUBSCRIBE) == 0) {
int ret;
return ret;
const char **error_r)
if (prev_sep) {
return FALSE;
if (prev_sep && i > 0) {
return FALSE;
return TRUE;
vname++;
const char *path;
&path) < 0)
return TRUE;
return FALSE;
const char *name)
NAMESPACE_FLAG_LIST_CHILDREN)) == 0)
return TRUE;
return FALSE;
case MAIL_ERROR_NOTFOUND:
int ret;
case MAIL_ERROR_NOTFOUND:
MAIL_STORAGE_CLASS_FLAG_OPEN_STREAMS) == 0) {
T_BEGIN {
} T_END;
} T_END;
if (ret < 0) {
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return TRUE;
const char *index_dir;
int ret;
&index_dir);
if (ret <= 0)
int ret;
return ret;
const char *name1;
return FALSE;
return TRUE;
bool directory)
int ret;
if (ret == 0)
return ret;
int ret;
return ret;
int ret;
if (ret < 0)
if (del)
if (ret < 0)
int ret;
return ret;
int ret;
return ret;
const char **error_r)
return TRUE;
return FALSE;
return FALSE;
return TRUE;
const char **error_r)
return FALSE;
return FALSE;
return FALSE;
return TRUE;
struct mail_namespace *
return FALSE;
i_unreached();
struct mailbox_sync_context *
T_BEGIN {
} T_END;
return ctx;
const char *errormsg;
int ret;
if (ret == 0)
return ret;
struct mail_search_context *
int ret;
return ret;
bool tryagain;
if (!tryagain)
return FALSE;
return TRUE;
return FALSE;
return TRUE;
int ret;
if (ret < 0)
return ret;
struct mailbox_transaction_context *
return trans;
int ret;
return ret;
int ret;
T_BEGIN {
} T_END;
return ret;
struct mailbox *
return t->box;
struct mail_save_context *
T_BEGIN {
} T_END;
return ctx;
const char *const *keywords_list;
const char *envelope)
unsigned int order)
int ret;
} else T_BEGIN {
} T_END;
if (ret < 0) {
int ret;
T_BEGIN {
} T_END;
return ret;
int ret;
T_BEGIN {
} T_END;
if (pvt_flags != 0)
t->save_count++;
return ret;
T_BEGIN {
} T_END;
struct mailbox_transaction_context *
int ret;
T_BEGIN {
} T_END;
if (ret == 0) {
if (pvt_flags != 0)
t->save_count++;
return ret;
const char **path_r)
int ret;
if (ret < 0) {
return ret;
int *fd_r)
int fd;
const char *root_dir;
int ret;
return ret;
&mail_dir) < 0)
unsigned int secs)
#ifndef MMAP_CONFLICTS_WRITE
return index_flags;
unsigned int secs;
const char *error;