The non-virtual listing code would have already crashed with assert.
{
const enum mailbox_list_iter_flags iter_flags =
MAILBOX_LIST_ITER_RAW_LIST |
- MAILBOX_LIST_ITER_VIRTUAL_NAMES |
MAILBOX_LIST_ITER_NO_AUTO_INBOX |
MAILBOX_LIST_ITER_RETURN_NO_FLAGS;
struct doveadm_mail_list_iter *iter;
{
const enum mailbox_list_iter_flags iter_flags =
MAILBOX_LIST_ITER_RAW_LIST |
- MAILBOX_LIST_ITER_VIRTUAL_NAMES |
MAILBOX_LIST_ITER_NO_AUTO_INBOX |
MAILBOX_LIST_ITER_RETURN_NO_FLAGS;
struct doveadm_mail_list_iter *iter;
{
struct fetch_cmd_context *ctx = (struct fetch_cmd_context *)_ctx;
const enum mailbox_list_iter_flags iter_flags =
- MAILBOX_LIST_ITER_VIRTUAL_NAMES |
MAILBOX_LIST_ITER_NO_AUTO_INBOX |
MAILBOX_LIST_ITER_RETURN_NO_FLAGS;
struct doveadm_mail_list_iter *iter;
struct doveadm_mail_list_iter *iter;
ARRAY_TYPE(const_string) patterns;
- i_assert((iter_flags & MAILBOX_LIST_ITER_VIRTUAL_NAMES) != 0);
-
iter = i_new(struct doveadm_mail_list_iter, 1);
iter->search_args = search_args;
{
struct status_cmd_context *ctx = (struct status_cmd_context *)_ctx;
enum mailbox_list_iter_flags iter_flags =
- MAILBOX_LIST_ITER_VIRTUAL_NAMES |
MAILBOX_LIST_ITER_RAW_LIST |
MAILBOX_LIST_ITER_NO_AUTO_INBOX |
MAILBOX_LIST_ITER_RETURN_NO_FLAGS;
struct list_cmd_context *ctx = (struct list_cmd_context *)_ctx;
enum mailbox_list_iter_flags iter_flags =
MAILBOX_LIST_ITER_RAW_LIST |
- MAILBOX_LIST_ITER_VIRTUAL_NAMES |
MAILBOX_LIST_ITER_NO_AUTO_INBOX |
MAILBOX_LIST_ITER_RETURN_NO_FLAGS;
struct doveadm_mail_list_iter *iter;
{
const enum mailbox_list_iter_flags iter_flags =
MAILBOX_LIST_ITER_RAW_LIST |
- MAILBOX_LIST_ITER_VIRTUAL_NAMES |
MAILBOX_LIST_ITER_NO_AUTO_INBOX |
MAILBOX_LIST_ITER_RETURN_NO_FLAGS;
struct doveadm_mail_list_iter *iter;
(struct local_dsync_worker *)_worker;
struct local_dsync_worker_mailbox_iter *iter;
enum mailbox_list_iter_flags list_flags =
- MAILBOX_LIST_ITER_VIRTUAL_NAMES |
MAILBOX_LIST_ITER_SKIP_ALIASES |
MAILBOX_LIST_ITER_NO_AUTO_INBOX;
static const char *patterns[] = { "*", NULL };
(struct local_dsync_worker *)_worker;
struct local_dsync_worker_subs_iter *iter;
enum mailbox_list_iter_flags list_flags =
- MAILBOX_LIST_ITER_VIRTUAL_NAMES |
MAILBOX_LIST_ITER_SKIP_ALIASES |
MAILBOX_LIST_ITER_SELECT_SUBSCRIBED;
static const char *patterns[] = { "*", NULL };
/* find the INBOX flags */
ns = mail_namespace_find_inbox(ctx->cmd->client->user->namespaces);
- list_iter = mailbox_list_iter_init(ns->list, "INBOX",
- MAILBOX_LIST_ITER_VIRTUAL_NAMES);
+ list_iter = mailbox_list_iter_init(ns->list, "INBOX", 0);
info = mailbox_list_iter_next(list_iter);
if (info != NULL) {
i_assert(strcasecmp(info->name, "INBOX") == 0);
static bool list_namespace_has_children(struct cmd_list_context *ctx)
{
enum mailbox_list_iter_flags list_flags =
- MAILBOX_LIST_ITER_RETURN_NO_FLAGS |
- MAILBOX_LIST_ITER_VIRTUAL_NAMES;
+ MAILBOX_LIST_ITER_RETURN_NO_FLAGS;
struct mailbox_list_iterate_context *list_iter;
const struct mailbox_info *info;
bool ret = FALSE;
args += 2;
}
- ctx->list_flags |= MAILBOX_LIST_ITER_VIRTUAL_NAMES;
if (lsub) {
/* LSUB - we don't care about flags */
ctx->list_flags |= MAILBOX_LIST_ITER_SELECT_SUBSCRIBED |
ctx->default_list = ns->list;
iter = mailbox_list_iter_init(ns->list, "*",
- MAILBOX_LIST_ITER_VIRTUAL_NAMES |
MAILBOX_LIST_ITER_RAW_LIST |
MAILBOX_LIST_ITER_RETURN_NO_FLAGS);
while ((info = mailbox_list_iter_next(iter)) != NULL) {
prefix matches without the trailing separator */
i_assert(ns->prefix_len > 0);
ctx->info.name = t_strndup(ns->prefix, ns->prefix_len - 1);
- if ((_ctx->flags & MAILBOX_LIST_ITER_VIRTUAL_NAMES) == 0)
- ctx->info.name += ctx->info.ns->prefix_len;
if (imap_match(ctx->glob, ctx->info.name) == IMAP_MATCH_YES) {
ctx->cur_ns = ns->next;
return &ctx->info;
ctx->ctx.flags = flags;
ctx->info_pool = pool_alloconly_create("fs list", 1024);
ctx->next = fs_list_next;
- ctx->sep = (flags & MAILBOX_LIST_ITER_VIRTUAL_NAMES) != 0 ?
- _list->ns->sep : _list->ns->real_sep;
+ ctx->sep = _list->ns->sep;
ctx->info.ns = _list->ns;
prefix_len = strlen(_list->ns->prefix);
for (; *patterns != NULL; patterns++) {
/* check that we're not trying to do any "../../" lists */
test_pattern = *patterns;
- if ((flags & MAILBOX_LIST_ITER_VIRTUAL_NAMES) != 0) {
- /* skip namespace prefix if possible. this allows using
- e.g. ~/mail/ prefix and have it pass the pattern
- validation. */
- if (strncmp(test_pattern, _list->ns->prefix,
- prefix_len) == 0)
- test_pattern += prefix_len;
- }
+ /* skip namespace prefix if possible. this allows using
+ e.g. ~/mail/ prefix and have it pass the pattern
+ validation. */
+ if (strncmp(test_pattern, _list->ns->prefix, prefix_len) == 0)
+ test_pattern += prefix_len;
if (mailbox_list_is_valid_pattern(_list, test_pattern)) {
if (strcasecmp(*patterns, "INBOX") == 0) {
ctx->inbox_match = TRUE;
return &ctx->ctx;
}
- vpath = (flags & MAILBOX_LIST_ITER_VIRTUAL_NAMES) != 0 ?
- _list->ns->prefix : "";
+ vpath = _list->ns->prefix;
rootdir = list_get_rootdir(ctx, &vpath);
if (rootdir == NULL) {
path = mailbox_list_get_path(_list, NULL,
&storage_name);
if (ns == NULL) {
ns = ctx->info.ns;
- if ((ctx->ctx.flags & MAILBOX_LIST_ITER_VIRTUAL_NAMES) != 0)
- storage_name = mail_namespace_get_storage_name(ns, storage_name);
- else
- storage_name = ctx->info.name;
+ storage_name = mail_namespace_get_storage_name(ns, storage_name);
}
/* if name ends with hierarchy separator, drop the separator */
struct mail_namespace *ns = ctx->ctx.list->ns;
struct mailbox_node *node;
const char *p, *mailbox_c;
- char hierarchy_sep;
bool created;
- unsigned int prefix_len;
-
- if ((ctx->ctx.flags & MAILBOX_LIST_ITER_VIRTUAL_NAMES) != 0) {
- hierarchy_sep = ns->sep;
- prefix_len = ns->prefix_len;
- } else {
- hierarchy_sep = ns->real_sep;
- prefix_len = 0;
- }
mailbox_c = str_c(mailbox);
- while ((p = strrchr(mailbox_c, hierarchy_sep)) != NULL) {
+ while ((p = strrchr(mailbox_c, ns->sep)) != NULL) {
str_truncate(mailbox, (size_t) (p-mailbox_c));
mailbox_c = str_c(mailbox);
if (imap_match(glob, mailbox_c) != IMAP_MATCH_YES)
continue;
- if (prefix_len > 0 && str_len(mailbox) == prefix_len-1 &&
- strncmp(mailbox_c, ns->prefix, prefix_len - 1) == 0 &&
- mailbox_c[prefix_len-1] == hierarchy_sep) {
+ if (ns->prefix_len > 0 && str_len(mailbox) == ns->prefix_len-1 &&
+ strncmp(mailbox_c, ns->prefix, ns->prefix_len - 1) == 0 &&
+ mailbox_c[ns->prefix_len-1] == ns->sep) {
/* don't return matches to namespace prefix itself */
continue;
}
const char *p, *mailbox_c;
char hierarchy_sep;
- if ((ctx->ctx.flags & MAILBOX_LIST_ITER_VIRTUAL_NAMES) != 0)
- hierarchy_sep = ctx->ctx.list->ns->sep;
- else
- hierarchy_sep = ctx->ctx.list->ns->real_sep;
+ hierarchy_sep = ctx->ctx.list->ns->sep;
/* mark the first existing parent as containing children */
mailbox_c = str_c(mailbox);
enum mailbox_info_flags flags;
enum imap_match_result match;
struct mailbox_node *node;
- bool created, virtual_names;
+ bool created;
struct stat st;
int ret;
return 0;
}
- virtual_names = (ctx->ctx.flags & MAILBOX_LIST_ITER_VIRTUAL_NAMES) != 0;
-
mailbox = t_str_new(MAILBOX_LIST_NAME_MAX_LENGTH);
while ((d = readdir(dirp)) != NULL) {
const char *fname = d->d_name;
(fname[1] == '\0' || (fname[1] == '.' && fname[2] == '\0')))
continue;
- if (!virtual_names) {
- str_truncate(mailbox, 0);
- str_append(mailbox, mailbox_name);
- mailbox_name = str_c(mailbox);
- } else {
- mailbox_name = mail_namespace_get_vname(ns, mailbox,
- mailbox_name);
- }
+ mailbox_name = mail_namespace_get_vname(ns, mailbox,
+ mailbox_name);
/* make sure the pattern matches */
match = imap_match(glob, mailbox_name);
struct mailbox_node *node;
iter = mailbox_list_iter_init(ns->list, "*",
- MAILBOX_LIST_ITER_VIRTUAL_NAMES |
MAILBOX_LIST_ITER_RETURN_CHILDREN);
while ((info = mailbox_list_iter_next(iter)) != NULL) {
node = mailbox_tree_lookup(ctx->tree_ctx, info->name);
{
struct maildir_list_iterate_context *ctx;
struct imap_match_glob *glob;
- char sep;
pool_t pool;
int ret;
- sep = (flags & MAILBOX_LIST_ITER_VIRTUAL_NAMES) != 0 ?
- _list->ns->sep : _list->ns->real_sep;
-
pool = pool_alloconly_create("maildir_list", 1024);
ctx = p_new(pool, struct maildir_list_iterate_context, 1);
ctx->ctx.list = _list;
ctx->ctx.flags = flags;
ctx->pool = pool;
- ctx->tree_ctx = mailbox_tree_init(sep);
+ ctx->tree_ctx = mailbox_tree_init(_list->ns->sep);
ctx->info.ns = _list->ns;
ctx->prefix_char = strcmp(_list->name, MAILBOX_LIST_NAME_IMAPDIR) == 0 ?
'\0' : _list->hierarchy_sep;
- glob = imap_match_init_multiple(pool, patterns, TRUE, sep);
+ glob = imap_match_init_multiple(pool, patterns, TRUE, _list->ns->sep);
ctx->dir = _list->set.root_dir;
pattern = t_strdup_printf("%s%c*", old_vname, oldlist->ns->sep);
iter = mailbox_list_iter_init(oldlist, pattern,
- MAILBOX_LIST_ITER_VIRTUAL_NAMES |
MAILBOX_LIST_ITER_RETURN_NO_FLAGS |
MAILBOX_LIST_ITER_RAW_LIST);
while ((info = mailbox_list_iter_next(iter)) != NULL) {
{
i_assert(*patterns != NULL);
- /* we'll want to remove MAILBOX_LIST_ITER_VIRTUAL_NAMES flag completely.
- this assert will be here until it's sure that there are no more
- non-virtual users and it can be safely removed. (and if there are,
- this assert can still be easily removed) */
- i_assert((flags & MAILBOX_LIST_ITER_VIRTUAL_NAMES) != 0);
return list->v.iter_init(list, patterns, flags);
}
if (!ns_match_simple(ctx, ns))
return FALSE;
- if ((ctx->ctx.flags & MAILBOX_LIST_ITER_VIRTUAL_NAMES) != 0) {
- /* filter out namespaces whose prefix doesn't match.
- this same code handles both with and without
- STAR_WITHIN_NS, so the "without" case is slower than
- necessary, but this shouldn't matter much */
- T_BEGIN {
- for (i = 0; ctx->patterns_ns_match[i] != NULL; i++) {
- if (ns_match_inbox(ns, ctx->patterns_ns_match[i]))
- break;
- if (ns_match_next(ctx, ns,
- ctx->patterns_ns_match[i]))
- break;
- }
- } T_END;
+ /* filter out namespaces whose prefix doesn't match. this same code
+ handles both with and without STAR_WITHIN_NS, so the "without" case
+ is slower than necessary, but this shouldn't matter much */
+ T_BEGIN {
+ for (i = 0; ctx->patterns_ns_match[i] != NULL; i++) {
+ if (ns_match_inbox(ns, ctx->patterns_ns_match[i]))
+ break;
+ if (ns_match_next(ctx, ns, ctx->patterns_ns_match[i]))
+ break;
+ }
+ } T_END;
- if (ctx->patterns_ns_match[i] == NULL)
- return FALSE;
- }
- return ns;
+ return ctx->patterns_ns_match[i] != NULL;
}
static struct mail_namespace *
i_assert(namespaces != NULL);
- i_assert((flags & MAILBOX_LIST_ITER_STAR_WITHIN_NS) == 0 ||
- (flags & MAILBOX_LIST_ITER_VIRTUAL_NAMES) != 0);
-
pool = pool_alloconly_create("mailbox list namespaces", 1024);
ctx = p_new(pool, struct ns_list_iterate_context, 1);
ctx->pool = pool;
enum mailbox_list_iter_flags {
/* Ignore index file and ACLs (used by ACL plugin internally) */
MAILBOX_LIST_ITER_RAW_LIST = 0x000001,
- /* Use virtual mailbox names (virtual separators and namespace
- prefixes) for patterns and for returned mailbox names. */
- MAILBOX_LIST_ITER_VIRTUAL_NAMES = 0x000002,
/* Don't list INBOX unless it actually exists */
MAILBOX_LIST_ITER_NO_AUTO_INBOX = 0x000004,
match beyond namespace boundary (e.g. "foo*" or "*o" doesn't match
"foo." namespace's mailboxes, but "*.*" does). also '%' can't match
namespace prefixes, if there exists a parent namespace whose children
- it matches. VIRTUAL_NAMES must be set when using this flag. */
+ it matches. */
MAILBOX_LIST_ITER_STAR_WITHIN_NS = 0x000010,
/* List only subscribed mailboxes */
backend->rebuilding_acllist = TRUE;
iter = mailbox_list_iter_init(list, "*",
- MAILBOX_LIST_ITER_VIRTUAL_NAMES |
MAILBOX_LIST_ITER_RAW_LIST |
MAILBOX_LIST_ITER_RETURN_NO_FLAGS);
while ((info = mailbox_list_iter_next(iter)) != NULL) {
return;
/* no LOOKUP right by default, we can optimize this */
- if ((ctx->ctx.flags & MAILBOX_LIST_ITER_VIRTUAL_NAMES) != 0)
- vname = t_str_new(256);
-
+ vname = t_str_new(256);
memset(&update_ctx, 0, sizeof(update_ctx));
update_ctx.iter_ctx = &ctx->ctx;
update_ctx.glob =
ctx->ctx.flags = flags;
inboxcase = (list->ns->flags & NAMESPACE_FLAG_INBOX_USER) != 0;
- ctx->sep = (ctx->ctx.flags & MAILBOX_LIST_ITER_VIRTUAL_NAMES) != 0 ?
- list->ns->sep : list->ns->real_sep;
+ ctx->sep = list->ns->sep;
ctx->glob = imap_match_init_multiple(default_pool, patterns,
inboxcase, ctx->sep);
/* see if all patterns have only a single '*' and it's at the end.
struct mail_namespace *ns = ctx->list->ns;
unsigned int len;
- if ((ctx->flags & MAILBOX_LIST_ITER_VIRTUAL_NAMES) != 0)
- name = mail_namespace_get_storage_name(ns, name);
-
+ name = mail_namespace_get_storage_name(ns, name);
len = strlen(name);
if (name[len-1] == ns->real_sep) {
/* name ends with separator. this can happen if doing e.g.
{
struct mailbox_list_iterate_context *iter;
const struct mailbox_info *info;
- enum mailbox_list_iter_flags flags;
string_t *pattern;
const char *prefix;
unsigned int i, prefix_len;
prefix = str_c(pattern);
prefix_len = str_len(pattern) - 1;
- flags = (ctx->ctx.flags & MAILBOX_LIST_ITER_VIRTUAL_NAMES) |
- MAILBOX_LIST_ITER_RETURN_NO_FLAGS;
- iter = mailbox_list_iter_init(ctx->ctx.list, str_c(pattern), flags);
+ iter = mailbox_list_iter_init(ctx->ctx.list, str_c(pattern),
+ MAILBOX_LIST_ITER_RETURN_NO_FLAGS);
while ((info = mailbox_list_iter_next(iter)) != NULL) {
if (only_nonpatterns &&
imap_match(ctx->glob, info->name) == IMAP_MATCH_YES) {
/* check if there are any mailboxes really visible to us */
iter = mailbox_list_iter_init(new_ns->list, "*",
- MAILBOX_LIST_ITER_VIRTUAL_NAMES |
MAILBOX_LIST_ITER_RETURN_NO_FLAGS);
while ((info = mailbox_list_iter_next(iter)) != NULL)
break;
struct mailbox_list_iterate_context *ctx;
const char **escaped_patterns;
unsigned int i;
- bool vname;
/* this is kind of kludgy. In ACL code we want to convert patterns,
in maildir renaming code we don't. so for now just use the _RAW_LIST
flag.. */
if ((flags & MAILBOX_LIST_ITER_RAW_LIST) == 0) {
- vname = (flags & MAILBOX_LIST_ITER_VIRTUAL_NAMES) != 0;
escaped_patterns = t_new(const char *,
str_array_length(patterns) + 1);
for (i = 0; patterns[i] != NULL; i++) {
escaped_patterns[i] =
- list_escape(list->ns, patterns[i], vname);
+ list_escape(list->ns, patterns[i], TRUE);
}
patterns = escaped_patterns;
}
ctx->list->ns->real_sep = ctx->list->hierarchy_sep;
info = mlist->module_ctx.super.iter_next(ctx);
ctx->list->ns->real_sep = ctx->list->ns->sep;
- if (info == NULL || (ctx->flags & MAILBOX_LIST_ITER_VIRTUAL_NAMES) == 0)
+ if (info == NULL)
return info;
ns = (ctx->flags & MAILBOX_LIST_ITER_SELECT_SUBSCRIBED) == 0 ?
int ret = 0;
ctx = mailbox_list_iter_init(ns->list, "*",
- MAILBOX_LIST_ITER_VIRTUAL_NAMES |
MAILBOX_LIST_ITER_RETURN_NO_FLAGS);
while ((info = mailbox_list_iter_next(ctx)) != NULL) {
if ((info->flags & (MAILBOX_NONEXISTENT |
ctx->path = str_new(default_pool, 512);
ctx->list = list;
ctx->iter = mailbox_list_iter_init(list, "*",
- MAILBOX_LIST_ITER_VIRTUAL_NAMES |
MAILBOX_LIST_ITER_RETURN_NO_FLAGS);
return ctx;
}
const enum namespace_type iter_ns_types =
NAMESPACE_PRIVATE | NAMESPACE_SHARED | NAMESPACE_PUBLIC;
const enum mailbox_list_iter_flags iter_flags =
- MAILBOX_LIST_ITER_VIRTUAL_NAMES |
MAILBOX_LIST_ITER_RETURN_NO_FLAGS;
struct mail_user *user = ctx->mbox->storage->storage.user;
ARRAY_TYPE(virtual_backend_box) wildcard_boxes, neg_boxes;