]> 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 c5b4f1ca3090b35c051d71fce8ad60568a85ebd6..ecd05613b9ac158afb8b1c756fb0ccb5d66e5ff4 100644 (file)
@@ -858,7 +858,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 a296a8eb72fb7a0d5e12883a87023c72028ae5ff..a917b603338befeb281c65065f487b63f7ce383a 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 6cd590af981b4f491938f0b4bdada58894fd18d2..5dfbf60ef59508d3845615ea576f0389aac661eb 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;
 }
 
@@ -212,6 +221,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 61d9e92032719793be9e8799c840b801ad0bbdfd..23b1f348e864989021d2cfdaa61cedeeb4724be4 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): */