mailbox-list-maildir-iter.c revision d92f33f13830ba23d814342bf3ea8db721a15bb1
/* Copyright (C) 2002-2006 Timo Sirainen */
#include "lib.h"
#include "str.h"
#include "home-expand.h"
#include "imap-match.h"
#include "mailbox-tree.h"
#include "mailbox-list-subscriptions.h"
#include "mailbox-list-maildir.h"
#include <dirent.h>
struct maildir_list_iterate_context {
struct mailbox_list_iterate_context ctx;
struct mailbox_tree_context *tree_ctx;
struct mailbox_tree_iterate_context *tree_iter;
struct mailbox_info info;
};
static int
{
struct dirent *d;
const char *p, *mailbox_c;
enum mailbox_info_flags flags;
enum imap_match_result match;
struct mailbox_node *node;
bool created;
char hierarchy_sep;
int ret;
return -1;
}
return 0;
}
t_push();
if (fname[0] != hierarchy_sep)
continue;
/* skip . and .. */
if (fname[0] == '.' &&
continue;
/* make sure the pattern matches */
str_truncate(mailbox, 0);
continue;
/* check if this is an actual mailbox */
flags = 0;
mailbox_list_get_file_type(d), &flags);
if (ret < 0) {
t_pop();
return -1;
}
if (ret == 0)
continue;
if ((match & IMAP_MATCH_PARENT) != 0) {
/* get the name of the parent mailbox that matches */
t_push();
hierarchy_sep)) != NULL) {
break;
}
node = update_only ?
if (created) {
/* we haven't yet seen this mailbox,
but we might see it later */
}
if (!update_only)
}
t_pop();
} else {
node = update_only ?
if (created)
else
if (!update_only)
}
}
/* apply flags given by storage. we know the children
flags ourself, so ignore if any of them were set. */
/* Fix parent nodes' children states. also if we
happened to create any of the parents, we need to
mark them nonexistent. */
}
}
}
t_pop();
return -1;
}
/* make sure INBOX is there */
node = update_only ?
if (created)
if (!update_only)
}
/* see if INBOX exists. */
if (ret > 0) {
}
}
return 0;
}
struct mailbox_list_iterate_context *
enum mailbox_list_iter_flags flags)
{
struct maildir_list_iterate_context *ctx;
struct imap_match_glob *glob;
if ((flags & MAILBOX_LIST_ITER_SELECT_SUBSCRIBED) != 0) {
/* Listing only subscribed mailboxes.
Flags are set later if needed. */
}
}
if ((flags & MAILBOX_LIST_ITER_SELECT_SUBSCRIBED) == 0 ||
(flags & MAILBOX_LIST_ITER_RETURN_NO_FLAGS) == 0) {
bool update_only =
(flags & MAILBOX_LIST_ITER_SELECT_SUBSCRIBED) != 0;
}
}
if ((flags & MAILBOX_LIST_ITER_RETURN_SUBSCRIBED) != 0 &&
(flags & MAILBOX_LIST_ITER_SELECT_SUBSCRIBED) == 0) {
/* we're listing all mailboxes but we want to know
\Subscribed flags */
}
}
}
{
struct maildir_list_iterate_context *ctx =
(struct maildir_list_iterate_context *)_ctx;
return ret;
}
const struct mailbox_info *
{
struct maildir_list_iterate_context *ctx =
(struct maildir_list_iterate_context *)_ctx;
struct mailbox_node *node;
return NULL;
return NULL;
}