ctx->ns_info.ns = ns;
ctx->ns_info.vname = p_strndup(ctx->pool, ns->prefix,
ns->prefix_len-1);
+ if (ns->special_use_mailboxes)
+ ctx->ns_info.flags |= MAILBOX_CHILD_SPECIALUSE;
if (strcasecmp(ctx->ns_info.vname, "INBOX") == 0) {
i_assert(!ctx->inbox_listed);
special_use_selection(struct mailbox_list_iterate_context *ctx,
const struct mailbox_info *info)
{
+ if ((ctx->flags & MAILBOX_LIST_ITER_SELECT_RECURSIVEMATCH) != 0 &&
+ (ctx->flags & MAILBOX_LIST_ITER_SELECT_SPECIALUSE) != 0) {
+ /* LIST (SPECIAL-USE RECURSIVEMATCH) used. for now we support
+ this only for namespace prefixes */
+ if ((info->flags & MAILBOX_CHILD_SPECIALUSE) != 0)
+ return TRUE;
+ }
return (ctx->flags & MAILBOX_LIST_ITER_SELECT_SPECIALUSE) == 0 ||
info->special_use != NULL;
}
i_free(ns);
}
+static bool
+namespace_has_special_use_mailboxes(struct mail_namespace_settings *ns_set)
+{
+ struct mailbox_settings *const *box_set;
+
+ if (!array_is_created(&ns_set->mailboxes))
+ return FALSE;
+
+ array_foreach(&ns_set->mailboxes, box_set) {
+ if ((*box_set)->special_use[0] != '\0')
+ return TRUE;
+ }
+ return FALSE;
+}
+
static int
namespace_add(struct mail_user *user,
struct mail_namespace_settings *ns_set,
ns->unexpanded_set = unexpanded_ns_set;
ns->mail_set = mail_set;
ns->prefix = i_strdup(ns_set->prefix);
+ ns->special_use_mailboxes = namespace_has_special_use_mailboxes(ns_set);
if (ns->type == MAIL_NAMESPACE_TYPE_SHARED &&
(strchr(ns->prefix, '%') != NULL ||
struct mail_namespace_settings *set, *unexpanded_set;
const struct mail_storage_settings *mail_set;
+ unsigned int special_use_mailboxes:1;
unsigned int destroyed:1;
};
MAILBOX_UNMARKED = 0x040,
MAILBOX_SUBSCRIBED = 0x080,
MAILBOX_CHILD_SUBSCRIBED = 0x100,
+ MAILBOX_CHILD_SPECIALUSE = 0x200,
/* Internally used by lib-storage */
MAILBOX_SELECT = 0x20000000,