mail-storage.c revision 874766f940cb44291e40f5c138eaf175d524a350
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen/* Copyright (c) 2002-2010 Dovecot authors, see the included COPYING file */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenextern struct mail_search_register *mail_search_register_imap;
1175f27441385a7011629f295f42708f9a3a4ffcTimo Sirainenextern struct mail_search_register *mail_search_register_human;
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenstruct mail_storage_module_register mail_storage_module_register = { 0 };
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenstruct mail_module_register mail_module_register = { 0 };
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenstruct mail_storage_mail_index_module mail_storage_mail_index_module =
1175f27441385a7011629f295f42708f9a3a4ffcTimo Sirainen MODULE_CONTEXT_INIT(&mail_index_module_register);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen mail_search_register_deinit(&mail_search_register_human);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen mail_search_register_deinit(&mail_search_register_imap);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenvoid mail_storage_class_register(struct mail_storage *storage_class)
56f45b3f3ae20e5c933701f4657dda5ef1916855Timo Sirainen i_assert(mail_storage_find_class(storage_class->name) == NULL);
56f45b3f3ae20e5c933701f4657dda5ef1916855Timo Sirainen /* append it after the list, so the autodetection order is correct */
e06c0b65c16ccce69bbee009ead14d7d3d17a256Timo Sirainen array_append(&mail_storage_classes, &storage_class, 1);
e06c0b65c16ccce69bbee009ead14d7d3d17a256Timo Sirainenvoid mail_storage_class_unregister(struct mail_storage *storage_class)
e06c0b65c16ccce69bbee009ead14d7d3d17a256Timo Sirainen unsigned int i, count;
a928e7efabb1672b1476e597106d4b4b81ac6f3cTimo Sirainen classes = array_get(&mail_storage_classes, &count);
e06c0b65c16ccce69bbee009ead14d7d3d17a256Timo Sirainen for (i = 0; i < count; i++) {
5a07b37a9df398b5189c14872a600384208ab74bTimo Sirainenstruct mail_storage *mail_storage_find_class(const char *name)
7797aa2479e99aeb71057b7a2584b2cb72e4d3f8Timo Sirainen unsigned int i, count;
5a07b37a9df398b5189c14872a600384208ab74bTimo Sirainen classes = array_get(&mail_storage_classes, &count);
5a07b37a9df398b5189c14872a600384208ab74bTimo Sirainen for (i = 0; i < count; i++) {
1175f27441385a7011629f295f42708f9a3a4ffcTimo Sirainenmail_storage_autodetect(const struct mail_namespace *ns,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen unsigned int i, count;
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen classes = array_get(&mail_storage_classes, &count);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen for (i = 0; i < count; i++) {
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenmail_storage_set_autodetection(const char **data, const char **driver)
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen const char *p;
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen /* check if data is in driver:data format (eg. mbox:~/mail) */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen while (i_isalnum(*p)) p++;
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen /* no autodetection if the storage driver is given. */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenmail_storage_get_class(struct mail_namespace *ns, const char *driver,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen enum mail_storage_flags flags, const char **error_r)
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen storage_class = mail_storage_find_class(driver);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen if (list_set->root_dir == NULL || *list_set->root_dir == '\0') {
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen /* no root directory given. is this allowed? */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen (flags & MAIL_STORAGE_FLAG_NO_AUTODETECTION) == 0) {
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen /* autodetection should take care of this */
return NULL;
return storage_class;
return storage_class;
return NULL;
const char **error_r)
} else if (!autocreate) {
bool autocreate;
int ret;
if (ret != 0)
return ret;
static struct mail_storage *
MAIL_STORAGE_CLASS_FLAG_UNIQUE_ROOT) == 0 ||
return storage;
return NULL;
error_r) < 0)
error_r);
T_BEGIN {
} T_END;
const char *fmt, ...)
const char *str;
const struct mail_storage_settings *
void *context)
const char *error_string;
return FALSE;
return FALSE;
return TRUE;
T_BEGIN {
} T_END;
return box;
int ret;
MAIL_STORAGE_CLASS_FLAG_OPEN_STREAMS) == 0) {
T_BEGIN {
} T_END;
} T_END;
if (ret < 0) {
bool directory)
int ret;
if (ret < 0)
if (del)
return FALSE;
return FALSE;
return FALSE;
return TRUE;
int ret;
return ret;
return TRUE;
return FALSE;
return FALSE;
return TRUE;
bool rename_children)
struct mail_namespace *
return FALSE;
struct mailbox_sync_context *
T_BEGIN {
} T_END;
return ctx;
const char *errormsg;
int ret;
return ret;
struct mail_keywords *
const char *const keywords[])
i_unreached();
return kw;
struct mail_keywords *
const char **error_r)
return FALSE;
bool only_with_msgs)
struct mailbox_header_lookup_ctx *
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 *
return ctx;
const char *const *keywords_list;
const char *envelope)
int ret;
if (ret < 0) {
int ret;
return ret;
struct mailbox_transaction_context *
int ret;
return ret;
int *fd_r)
int fd;
unsigned int secs)