static void mailbox_list_index_update_info(struct mailbox_list_index_iterate_context *ctx) { struct mailbox_list_index_node *node = ctx->next_node; struct mailbox *box; p_clear(ctx->info_pool); str_truncate(ctx->path, ctx->parent_len); /* the root directory may have an empty name. in that case we'll still want to insert the separator, so check for non-NULL parent rather than non-empty path. */ if (node->parent != NULL) { str_append_c(ctx->path, mailbox_list_get_hierarchy_sep(ctx->ctx.list)); } str_append(ctx->path, node->name); ctx->info.vname = mailbox_list_get_vname(ctx->ctx.list, str_c(ctx->path)); ctx->info.flags = node->children != NULL ? MAILBOX_CHILDREN : MAILBOX_NOCHILDREN; if (strcmp(ctx->info.vname, "INBOX") != 0) { /* non-INBOX */ ctx->info.vname = p_strdup(ctx->info_pool, ctx->info.vname); } else if (!ctx->prefix_inbox_list) { /* listing INBOX itself */ ctx->info.vname = "INBOX"; if (mail_namespace_is_inbox_noinferiors(ctx->info.ns)) { ctx->info.flags &= ~(MAILBOX_CHILDREN|MAILBOX_NOCHILDREN); ctx->info.flags |= MAILBOX_NOINFERIORS; } } else { /* listing INBOX/INBOX */ ctx->info.vname = p_strconcat(ctx->info_pool, ctx->ctx.list->ns->prefix, "INBOX", NULL); ctx->info.flags |= MAILBOX_NONEXISTENT; } if ((node->flags & MAILBOX_LIST_INDEX_FLAG_NONEXISTENT) != 0) ctx->info.flags |= MAILBOX_NONEXISTENT; else if ((node->flags & MAILBOX_LIST_INDEX_FLAG_NOSELECT) != 0) ctx->info.flags |= MAILBOX_NOSELECT; if ((node->flags & MAILBOX_LIST_INDEX_FLAG_NOINFERIORS) != 0) ctx->info.flags |= MAILBOX_NOINFERIORS; if ((ctx->ctx.flags & (MAILBOX_LIST_ITER_SELECT_SUBSCRIBED | MAILBOX_LIST_ITER_RETURN_SUBSCRIBED)) != 0) { mailbox_list_set_subscription_flags(ctx->ctx.list, ctx->info.vname, &ctx->info.flags); } if ((ctx->ctx.flags & MAILBOX_LIST_ITER_RETURN_NO_FLAGS) == 0) { box = mailbox_alloc(ctx->ctx.list, ctx->info.vname, 0); mailbox_list_index_status_set_info_flags(box, node->uid, &ctx->info.flags); mailbox_free(&box); } }
static void mailbox_list_index_update_info(struct mailbox_list_index_iterate_context *ctx) { struct mailbox_list_index_node *node = ctx->next_node; struct mailbox *box; p_clear(ctx->info_pool); str_truncate(ctx->path, ctx->parent_len); if (str_len(ctx->path) > 0) { str_append_c(ctx->path, mailbox_list_get_hierarchy_sep(ctx->ctx.list)); } str_append(ctx->path, node->name); ctx->info.vname = mailbox_list_get_vname(ctx->ctx.list, str_c(ctx->path)); ctx->info.vname = p_strdup(ctx->info_pool, ctx->info.vname); ctx->info.flags = 0; if ((node->flags & MAILBOX_LIST_INDEX_FLAG_NONEXISTENT) != 0) ctx->info.flags |= MAILBOX_NONEXISTENT; else if ((node->flags & MAILBOX_LIST_INDEX_FLAG_NOSELECT) != 0) ctx->info.flags |= MAILBOX_NOSELECT; if ((node->flags & MAILBOX_LIST_INDEX_FLAG_NOINFERIORS) != 0) ctx->info.flags |= MAILBOX_NOINFERIORS; ctx->info.flags |= node->children != NULL ? MAILBOX_CHILDREN : MAILBOX_NOCHILDREN; if ((ctx->ctx.flags & (MAILBOX_LIST_ITER_SELECT_SUBSCRIBED | MAILBOX_LIST_ITER_RETURN_SUBSCRIBED)) != 0) { mailbox_list_set_subscription_flags(ctx->ctx.list, ctx->info.vname, &ctx->info.flags); } box = mailbox_alloc(ctx->ctx.list, ctx->info.vname, 0); mailbox_list_index_status_set_info_flags(box, node->uid, &ctx->info.flags); mailbox_free(&box); }