dovecot-1.2: Added :MAILBOXDIR= to mail_location to specify the ...
dovecot at dovecot.org
dovecot at dovecot.org
Thu Mar 12 23:43:43 EET 2009
details: http://hg.dovecot.org/dovecot-1.2/rev/0e7e25da544c
changeset: 8816:0e7e25da544c
user: Timo Sirainen <tss at iki.fi>
date: Thu Mar 12 17:30:45 2009 -0400
description:
Added :MAILBOXDIR= to mail_location to specify the root dir for mailboxes.
diffstat:
5 files changed, 37 insertions(+), 11 deletions(-)
src/lib-storage/index/mbox/mbox-storage.c | 2 +-
src/lib-storage/list/mailbox-list-fs-iter.c | 8 +++++++-
src/lib-storage/list/mailbox-list-fs.c | 24 +++++++++++++++---------
src/lib-storage/mailbox-list.c | 11 +++++++++++
src/lib-storage/mailbox-list.h | 3 +++
diffs (137 lines):
diff -r 8785db70472f -r 0e7e25da544c src/lib-storage/index/mbox/mbox-storage.c
--- a/src/lib-storage/index/mbox/mbox-storage.c Thu Mar 12 15:22:51 2009 -0400
+++ b/src/lib-storage/index/mbox/mbox-storage.c Thu Mar 12 17:30:45 2009 -0400
@@ -858,7 +858,7 @@ static int mbox_list_iter_is_mailbox(str
}
if (strcmp(fname, MBOX_SUBSCRIPTION_FILE_NAME) == 0) {
root_dir = mailbox_list_get_path(storage->list, NULL,
- MAILBOX_LIST_PATH_TYPE_MAILBOX);
+ MAILBOX_LIST_PATH_TYPE_DIR);
if (strcmp(root_dir, dir) == 0) {
*flags |= MAILBOX_NOSELECT | MAILBOX_NOINFERIORS;
return 0;
diff -r 8785db70472f -r 0e7e25da544c src/lib-storage/list/mailbox-list-fs-iter.c
--- a/src/lib-storage/list/mailbox-list-fs-iter.c Thu Mar 12 15:22:51 2009 -0400
+++ b/src/lib-storage/list/mailbox-list-fs-iter.c Thu Mar 12 17:30:45 2009 -0400
@@ -282,7 +282,13 @@ fs_list_iter_init(struct mailbox_list *_
vpath = (flags & MAILBOX_LIST_ITER_VIRTUAL_NAMES) != 0 ?
_list->ns->prefix : "";
rootdir = list_get_rootdir(ctx, &vpath);
- path = mailbox_list_get_path(_list, rootdir, MAILBOX_LIST_PATH_TYPE_DIR);
+ if (rootdir == NULL) {
+ path = mailbox_list_get_path(_list, NULL,
+ MAILBOX_LIST_PATH_TYPE_MAILBOX);
+ } else {
+ path = mailbox_list_get_path(_list, rootdir,
+ MAILBOX_LIST_PATH_TYPE_DIR);
+ }
if ((ret = list_opendir(ctx, path, vpath, &dirp)) < 0)
return &ctx->ctx;
diff -r 8785db70472f -r 0e7e25da544c src/lib-storage/list/mailbox-list-fs.c
--- a/src/lib-storage/list/mailbox-list-fs.c Thu Mar 12 15:22:51 2009 -0400
+++ b/src/lib-storage/list/mailbox-list-fs.c Thu Mar 12 17:30:45 2009 -0400
@@ -145,8 +145,10 @@ fs_list_get_path(struct mailbox_list *_l
/* return root directories */
switch (type) {
case MAILBOX_LIST_PATH_TYPE_DIR:
+ return set->root_dir;
case MAILBOX_LIST_PATH_TYPE_MAILBOX:
- return set->root_dir;
+ return t_strconcat(set->root_dir, "/",
+ set->mailbox_dir_name, NULL);
case MAILBOX_LIST_PATH_TYPE_CONTROL:
return set->control_dir != NULL ?
set->control_dir : set->root_dir;
@@ -165,20 +167,22 @@ fs_list_get_path(struct mailbox_list *_l
switch (type) {
case MAILBOX_LIST_PATH_TYPE_DIR:
if (*set->maildir_name != '\0')
- return t_strdup_printf("%s/%s", set->root_dir, name);
+ return t_strdup_printf("%s/%s%s", set->root_dir,
+ set->mailbox_dir_name, name);
break;
case MAILBOX_LIST_PATH_TYPE_MAILBOX:
break;
case MAILBOX_LIST_PATH_TYPE_CONTROL:
if (set->control_dir != NULL)
- return t_strdup_printf("%s/%s", set->control_dir,
- name);
+ return t_strdup_printf("%s/%s%s", set->control_dir,
+ set->mailbox_dir_name, name);
break;
case MAILBOX_LIST_PATH_TYPE_INDEX:
if (set->index_dir != NULL) {
if (*set->index_dir == '\0')
return "";
- return t_strdup_printf("%s/%s", set->index_dir, name);
+ return t_strdup_printf("%s/%s%s", set->index_dir,
+ set->mailbox_dir_name, name);
}
break;
}
@@ -191,10 +195,12 @@ fs_list_get_path(struct mailbox_list *_l
type == MAILBOX_LIST_PATH_TYPE_DIR))
return set->inbox_path;
- if (*set->maildir_name == '\0')
- return t_strdup_printf("%s/%s", set->root_dir, name);
- else {
- return t_strdup_printf("%s/%s/%s", set->root_dir, name,
+ if (*set->maildir_name == '\0') {
+ return t_strdup_printf("%s/%s%s", set->root_dir,
+ set->mailbox_dir_name, name);
+ } else {
+ return t_strdup_printf("%s/%s%s/%s", set->root_dir,
+ set->mailbox_dir_name, name,
set->maildir_name);
}
}
diff -r 8785db70472f -r 0e7e25da544c src/lib-storage/mailbox-list.c
--- a/src/lib-storage/mailbox-list.c Thu Mar 12 15:22:51 2009 -0400
+++ b/src/lib-storage/mailbox-list.c Thu Mar 12 17:30:45 2009 -0400
@@ -166,6 +166,8 @@ int mailbox_list_settings_parse(const ch
dest = &set->subscription_fname;
else if (strcmp(key, "DIRNAME") == 0)
dest = &set->maildir_name;
+ else if (strcmp(key, "MAILBOXDIR") == 0)
+ dest = &set->mailbox_dir_name;
else {
*error_r = t_strdup_printf("Unknown setting: %s", key);
return -1;
@@ -180,6 +182,13 @@ int mailbox_list_settings_parse(const ch
if (set->index_dir != NULL && strcmp(set->index_dir, "MEMORY") == 0)
set->index_dir = "";
+
+ if (set->mailbox_dir_name == NULL)
+ set->mailbox_dir_name = "";
+ else if (set->mailbox_dir_name[strlen(set->mailbox_dir_name)-1] != '/') {
+ set->mailbox_dir_name =
+ t_strconcat(set->mailbox_dir_name, "/", NULL);
+ }
return 0;
}
@@ -212,6 +221,8 @@ void mailbox_list_init(struct mailbox_li
list->set.maildir_name =
(list->props & MAILBOX_LIST_PROP_NO_MAILDIR_NAME) != 0 ? "" :
p_strdup(list->pool, set->maildir_name);
+ list->set.mailbox_dir_name =
+ p_strdup(list->pool, set->mailbox_dir_name);
list->set.mail_storage_flags = set->mail_storage_flags;
list->set.lock_method = set->lock_method;
diff -r 8785db70472f -r 0e7e25da544c src/lib-storage/mailbox-list.h
--- a/src/lib-storage/mailbox-list.h Thu Mar 12 15:22:51 2009 -0400
+++ b/src/lib-storage/mailbox-list.h Thu Mar 12 17:30:45 2009 -0400
@@ -107,6 +107,9 @@ struct mailbox_list_settings {
If mailbox_name is "Maildir", you have a non-selectable mailbox
"mail" and a selectable mailbox "mail/foo". */
const char *maildir_name;
+ /* if set, store mailboxes under root_dir/mailbox_dir_name/.
+ this setting contains either "" or "dir/". */
+ const char *mailbox_dir_name;
/* If mailbox index is used, use these settings for it
(pointers, so they're set to NULL after init is finished): */
More information about the dovecot-cvs
mailing list