# HG changeset patch # User Timo Sirainen # Date 1236893445 14400 # Node ID 0e7e25da544c6fc75635585c338d7421ed990824 # Parent 8785db70472f8de258264c9b30837bfb999185a1 Added :MAILBOXDIR= to mail_location to specify the root dir for mailboxes. 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 @@ } 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 @@ 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 @@ /* 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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): */