]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Added :MAILBOXDIR= to mail_location to specify the root dir for mailboxes.
authorTimo Sirainen <tss@iki.fi>
Thu, 12 Mar 2009 21:30:45 +0000 (17:30 -0400)
committerTimo Sirainen <tss@iki.fi>
Thu, 12 Mar 2009 21:30:45 +0000 (17:30 -0400)
--HG--
branch : HEAD

src/lib-storage/index/mbox/mbox-storage.c
src/lib-storage/list/mailbox-list-fs-iter.c
src/lib-storage/list/mailbox-list-fs.c
src/lib-storage/mailbox-list.c
src/lib-storage/mailbox-list.h

index 416258898dc21be3d7473aa66c4a769091e4a4c6..5fc66e6487ba537b5760b82ab6db8a47f2a02d4c 100644 (file)
@@ -846,7 +846,7 @@ static int mbox_list_iter_is_mailbox(struct mailbox_list_iterate_context *ctx,
        }
        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;
index 5aa484a28c87151c57282450d4bdfbc4605e6f07..af40c10000411031df9f0bdcef98a1272c37242b 100644 (file)
@@ -282,7 +282,13 @@ fs_list_iter_init(struct mailbox_list *_list, const char *const *patterns,
        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;
 
index d4ae5015dbe95018e88fde62a767253343c67bd2..4d1f19f8e6709328037865a509634c46d272872a 100644 (file)
@@ -145,8 +145,10 @@ fs_list_get_path(struct mailbox_list *_list, const char *name,
                /* return root directories */
                switch (type) {
                case MAILBOX_LIST_PATH_TYPE_DIR:
-               case MAILBOX_LIST_PATH_TYPE_MAILBOX:
                        return set->root_dir;
+               case MAILBOX_LIST_PATH_TYPE_MAILBOX:
+                       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 *_list, const char *name,
        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 *_list, const char *name,
             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);
        }
 }
index 6bd7a2fdc2df4238c6c760bff7686b9e5d238a3a..d84ba3c8f11f5040fcb44d4a7e65f09f37a3763d 100644 (file)
@@ -166,6 +166,8 @@ int mailbox_list_settings_parse(const char *data,
                        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 char *data,
 
        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;
 }
 
@@ -211,6 +220,8 @@ void mailbox_list_init(struct mailbox_list *list, struct mail_namespace *ns,
        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;
index 118a7e3251329debd678bb0a777ba9a984a71050..d07cdb0545fb60270fd7f0e8c6512c5de85ee558 100644 (file)
@@ -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): */