dovecot-1.1: Added :MAILBOXDIR= to mail_location to specify the ...
dovecot at dovecot.org
dovecot at dovecot.org
Thu Mar 12 23:43:39 EET 2009
details: http://hg.dovecot.org/dovecot-1.1/rev/c560fbd69ee4
changeset: 8190:c560fbd69ee4
user: Timo Sirainen <tss at iki.fi>
date: Thu Mar 12 17:39:58 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 0822dfb36f3b -r c560fbd69ee4 src/lib-storage/index/mbox/mbox-storage.c
--- a/src/lib-storage/index/mbox/mbox-storage.c Wed Mar 11 17:21:57 2009 -0400
+++ b/src/lib-storage/index/mbox/mbox-storage.c Thu Mar 12 17:39:58 2009 -0400
@@ -833,7 +833,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 0822dfb36f3b -r c560fbd69ee4 src/lib-storage/list/mailbox-list-fs-iter.c
--- a/src/lib-storage/list/mailbox-list-fs-iter.c Wed Mar 11 17:21:57 2009 -0400
+++ b/src/lib-storage/list/mailbox-list-fs-iter.c Thu Mar 12 17:39:58 2009 -0400
@@ -281,7 +281,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 0822dfb36f3b -r c560fbd69ee4 src/lib-storage/list/mailbox-list-fs.c
--- a/src/lib-storage/list/mailbox-list-fs.c Wed Mar 11 17:21:57 2009 -0400
+++ b/src/lib-storage/list/mailbox-list-fs.c Thu Mar 12 17:39:58 2009 -0400
@@ -148,8 +148,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;
@@ -172,20 +174,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;
}
@@ -198,10 +202,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 0822dfb36f3b -r c560fbd69ee4 src/lib-storage/mailbox-list.c
--- a/src/lib-storage/mailbox-list.c Wed Mar 11 17:21:57 2009 -0400
+++ b/src/lib-storage/mailbox-list.c Thu Mar 12 17:39:58 2009 -0400
@@ -151,6 +151,8 @@ int mailbox_list_settings_parse(const ch
set->subscription_fname = fix_path(value);
else if (strcmp(key, "DIRNAME") == 0)
set->maildir_name = value;
+ else if (strcmp(key, "MAILBOXDIR") == 0)
+ set->mailbox_dir_name = value;
else {
*error_r = t_strdup_printf("Unknown setting: %s", key);
return -1;
@@ -159,6 +161,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;
}
@@ -188,6 +197,8 @@ void mailbox_list_init(struct mailbox_li
list->set.subscription_fname =
p_strdup(list->pool, set->subscription_fname);
list->set.maildir_name = 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 0822dfb36f3b -r c560fbd69ee4 src/lib-storage/mailbox-list.h
--- a/src/lib-storage/mailbox-list.h Wed Mar 11 17:21:57 2009 -0400
+++ b/src/lib-storage/mailbox-list.h Thu Mar 12 17:39:58 2009 -0400
@@ -102,6 +102,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