mailbox-list-maildir-iter.c revision a720aa23fb1f835f7e1a1c139fd949fe1fc119c5
/* Copyright (c) 2002-2010 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "str.h"
#include "ioloop.h"
#include "unlink-directory.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;
const char *dir;
char prefix_char;
struct mailbox_tree_context *tree_ctx;
struct mailbox_tree_iterate_context *tree_iter;
struct mailbox_info info;
};
{
/* Fix parent nodes' children states. also if we happened to create any
of the parents, we need to mark them nonexistent. */
}
}
static void
{
struct mailbox_node *node;
const char *p, *mailbox_c;
char hierarchy_sep;
bool created;
unsigned int prefix_len;
} else {
prefix_len = 0;
}
continue;
/* don't return matches to namespace prefix itself */
continue;
}
node = update_only ?
if (created) {
/* we haven't yet seen this mailbox,
but we might see it later */
}
if (!update_only)
}
}
}
{
struct mailbox_node *node;
const char *p, *mailbox_c;
char hierarchy_sep;
else
/* mark the first existing parent as containing children */
break;
}
}
}
static int
struct imap_match_glob *glob,
bool update_only)
{
struct mailbox_node *node;
enum mailbox_info_flags flags;
enum imap_match_result match;
bool created;
int ret;
/* always show INBOX */
/* INBOX doesn't exist, since it wasn't listed */
update_only = TRUE;
} else {
/* INBOX is in Maildir root. show it only if it has already
been created */
if (ret < 0)
return -1;
if (ret == 0)
update_only = TRUE;
}
node = update_only ?
if (created)
if (!update_only)
}
return 0;
}
static bool
enum mailbox_list_file_type *type_r,
enum mailbox_info_flags *flags)
{
const char *path;
/* just deleted? */
*flags |= MAILBOX_NONEXISTENT;
} else {
*flags |= MAILBOX_NOSELECT;
}
return FALSE;
}
return TRUE;
} else {
*flags |= MAILBOX_NONEXISTENT;
else
*flags |= MAILBOX_NOSELECT;
return FALSE;
}
}
enum mailbox_list_file_type type,
enum mailbox_info_flags *flags_r)
{
*flags_r = 0;
switch (type) {
break;
/* need to check with stat() to be sure */
/* just assume it's a valid mailbox */
return 1;
}
return 0;
break;
}
switch (type) {
*flags_r |= MAILBOX_NOSELECT;
return 0;
}
break;
*flags_r |= MAILBOX_NOSELECT;
return 0;
}
break;
*flags_r |= MAILBOX_NOSELECT;
return 0;
i_unreached();
}
*flags_r |= MAILBOX_SELECT;
return 1;
}
const char *fname)
{
const char *path;
return FALSE;
/* this directory is in the middle of being deleted, or the process
trying to delete it had died. delete it ourself if it's been there
longer than one hour. */
return TRUE;
}
static int
{
struct dirent *d;
const char *mailbox_name;
enum mailbox_info_flags flags;
enum imap_match_result match;
struct mailbox_node *node;
bool created, virtual_names;
int ret;
return -1;
}
return 0;
}
else {
continue;
}
/* skip . and .. */
if (fname[0] == '.' &&
continue;
if (!virtual_names) {
str_truncate(mailbox, 0);
} else {
}
/* make sure the pattern matches */
continue;
/* check if this is an actual mailbox */
continue;
T_BEGIN {
} T_END;
if (ret <= 0) {
if (ret < 0)
return -1;
continue;
}
/* we know the children flags ourself, so ignore if any of
them were set. */
flags &= ~(MAILBOX_NOINFERIORS |
if ((match & IMAP_MATCH_PARENT) != 0) {
T_BEGIN {
} T_END;
} else {
node = update_only ?
mailbox_name) :
mailbox_name, &created);
if (created)
else
if (!update_only)
} else {
}
}
}
return -1;
}
return 0;
else {
/* make sure INBOX is listed */
}
}
struct mailbox_list_iterate_context *
enum mailbox_list_iter_flags flags)
{
struct maildir_list_iterate_context *ctx;
struct imap_match_glob *glob;
char sep;
int ret;
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;
T_BEGIN {
} T_END;
if (ret < 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;
}