]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
mailbox_list_iter_update() was always setting subscribed flags to processed
authorTimo Sirainen <tss@iki.fi>
Sun, 4 May 2008 20:44:56 +0000 (23:44 +0300)
committerTimo Sirainen <tss@iki.fi>
Sun, 4 May 2008 20:44:56 +0000 (23:44 +0300)
nodes. Changed the API so the flags can be specified.

--HG--
branch : HEAD

src/lib-storage/list/mailbox-list-subscriptions.c
src/lib-storage/mailbox-list-private.h
src/lib-storage/mailbox-list.c

index a7ce5033a9224fe55e9023f9ed72afccd957217e..edc3027da30375c38907a3175affe1e33c1799d6 100644 (file)
@@ -13,10 +13,10 @@ mailbox_list_subscriptions_fill_real(struct mailbox_list_iterate_context *ctx,
                                     bool update_only)
 {
        struct mail_namespace *ns = ctx->list->ns;
+       struct mailbox_list_iter_update_context update_ctx;
        struct subsfile_list_context *subsfile_ctx;
        const char *path, *name;
        string_t *vname;
-       bool match_parents;
 
        vname = t_str_new(256);
        path = t_strconcat(ctx->list->set.control_dir != NULL ?
@@ -25,13 +25,19 @@ mailbox_list_subscriptions_fill_real(struct mailbox_list_iterate_context *ctx,
                           "/", ctx->list->set.subscription_fname, NULL);
        subsfile_ctx = subsfile_list_init(ctx->list, path);
 
-       match_parents =
+       memset(&update_ctx, 0, sizeof(update_ctx));
+       update_ctx.iter_ctx = ctx;
+       update_ctx.tree_ctx = tree_ctx;
+       update_ctx.glob = glob;
+       update_ctx.leaf_flags = MAILBOX_SUBSCRIBED;
+       update_ctx.parent_flags = MAILBOX_CHILD_SUBSCRIBED;
+       update_ctx.update_only = update_only;
+       update_ctx.match_parents =
                (ctx->flags & MAILBOX_LIST_ITER_SELECT_RECURSIVEMATCH) != 0;
 
        while ((name = subsfile_list_next(subsfile_ctx)) != NULL) {
                name = mail_namespace_get_vname(ns, vname, name);
-               mailbox_list_iter_update(ctx, tree_ctx, glob, update_only,
-                                        match_parents, name);
+               mailbox_list_iter_update(&update_ctx, name);
        }
        return subsfile_list_deinit(subsfile_ctx);
 }
index 9544b856002024d9e7cc48481ab42bf7c6f944d2..20464d7703b691fb5f1a4cec5bd3f64b43848a2c 100644 (file)
@@ -93,6 +93,17 @@ struct mailbox_list_iterate_context {
        bool failed;
 };
 
+struct mailbox_list_iter_update_context {
+       struct mailbox_list_iterate_context *iter_ctx;
+       struct mailbox_tree_context *tree_ctx;
+                             
+       struct imap_match_glob *glob;
+       enum mailbox_info_flags leaf_flags, parent_flags;
+
+       unsigned int update_only:1;
+       unsigned int match_parents:1;
+};
+
 /* Modules should use do "my_id = mailbox_list_module_id++" and
    use objects' module_contexts[id] for their own purposes. */
 extern struct mailbox_list_module_register mailbox_list_module_register;
@@ -110,10 +121,8 @@ int mailbox_list_settings_parse(const char *data,
 int mailbox_list_delete_index_control(struct mailbox_list *list,
                                      const char *name);
 
-void mailbox_list_iter_update(struct mailbox_list_iterate_context *ctx,
-                             struct mailbox_tree_context *tree_ctx,
-                             struct imap_match_glob *glob, bool update_only,
-                             bool match_parents, const char *name);
+void mailbox_list_iter_update(struct mailbox_list_iter_update_context *ctx,
+                             const char *name);
 
 bool mailbox_list_name_is_too_large(const char *name, char sep);
 enum mailbox_list_file_type mailbox_list_get_file_type(const struct dirent *d);
index 699411594254b707119d8ada67a7fc6b6ffe8f6c..860f9e60288d44ce4a8696177c530a01318db6fc 100644 (file)
@@ -474,38 +474,36 @@ static void node_fix_parents(struct mailbox_node *node)
 }
 
 static void
-mailbox_list_iter_update_real(struct mailbox_list_iterate_context *ctx,
-                             struct mailbox_tree_context *tree_ctx,
-                             struct imap_match_glob *glob, bool update_only,
-                             bool match_parents, const char *name)
+mailbox_list_iter_update_real(struct mailbox_list_iter_update_context *ctx,
+                             const char *name)
 {
-       struct mail_namespace *ns = ctx->list->ns;
+       struct mail_namespace *ns = ctx->iter_ctx->list->ns;
        struct mailbox_node *node;
-       enum mailbox_info_flags create_flags, always_flags;
+       enum mailbox_info_flags create_flags = 0, always_flags;
        enum imap_match_result match;
        const char *p;
        bool created, add_matched;
 
-       create_flags = (update_only ||
-                       (ctx->flags & MAILBOX_LIST_ITER_RETURN_NO_FLAGS) == 0) ?
-               (MAILBOX_NONEXISTENT | MAILBOX_NOCHILDREN) : 0;
-       always_flags = MAILBOX_SUBSCRIBED;
+       if (ctx->update_only ||
+           (ctx->iter_ctx->flags & MAILBOX_LIST_ITER_RETURN_NO_FLAGS) == 0)
+               create_flags = MAILBOX_NONEXISTENT | MAILBOX_NOCHILDREN;
+       always_flags = ctx->leaf_flags;
        add_matched = TRUE;
 
        for (;;) {
                created = FALSE;
-               match = imap_match(glob, name);
+               match = imap_match(ctx->glob, name);
                if (match == IMAP_MATCH_YES) {
-                       node = update_only ?
-                               mailbox_tree_lookup(tree_ctx, name) :
-                               mailbox_tree_get(tree_ctx, name, &created);
+                       node = ctx->update_only ?
+                               mailbox_tree_lookup(ctx->tree_ctx, name) :
+                               mailbox_tree_get(ctx->tree_ctx, name, &created);
                        if (created) {
                                node->flags = create_flags;
                                if (create_flags != 0)
                                        node_fix_parents(node);
                        }
                        if (node != NULL) {
-                               if (!update_only && add_matched)
+                               if (!ctx->update_only && add_matched)
                                        node->flags |= MAILBOX_MATCHED;
                                node->flags |= always_flags;
                        }
@@ -521,7 +519,7 @@ mailbox_list_iter_update_real(struct mailbox_list_iterate_context *ctx,
                           return the parent mailbox. */
                }
 
-               if (!match_parents)
+               if (!ctx->match_parents)
                        break;
 
                /* see if parent matches */
@@ -531,18 +529,15 @@ mailbox_list_iter_update_real(struct mailbox_list_iterate_context *ctx,
 
                name = t_strdup_until(name, p);
                create_flags &= ~MAILBOX_NOCHILDREN;
-               always_flags = MAILBOX_CHILDREN | MAILBOX_CHILD_SUBSCRIBED;
+               always_flags = MAILBOX_CHILDREN | ctx->parent_flags;
        }
 }
 
-void mailbox_list_iter_update(struct mailbox_list_iterate_context *ctx,
-                             struct mailbox_tree_context *tree_ctx,
-                             struct imap_match_glob *glob, bool update_only,
-                             bool match_parents, const char *name)
+void mailbox_list_iter_update(struct mailbox_list_iter_update_context *ctx,
+                             const char *name)
 {
        T_BEGIN {
-               mailbox_list_iter_update_real(ctx, tree_ctx, glob, update_only,
-                                             match_parents, name);
+               mailbox_list_iter_update_real(ctx, name);
        } T_END;
 }