mailbox-list-subscriptions.c revision e3677df81bc31e3ce3188f71f3833f9bbda5fc0b
/* Copyright (c) 2002-2013 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "ioloop.h"
#include "array.h"
#include "unichar.h"
#include "imap-match.h"
#include "subscription-file.h"
#include "mailbox-tree.h"
#include "mailbox-list-private.h"
#include "mailbox-list-subscriptions.h"
struct mailbox_list_iterate_context ctx;
struct mailbox_tree_context *tree;
struct mailbox_tree_iterate_context *iter;
struct mailbox_info info;
};
static int
struct mailbox_list *src_list,
const char *name)
{
struct mailbox_node *node;
unsigned int len;
bool created;
/* default_ns is whatever namespace we're currently listing.
if we have e.g. prefix="" and prefix=pub/ namespaces with
pub/ namespace having subscriptions=no, we want to:
1) when listing "" namespace we want to skip over any names
that begin with pub/. */
else {
}
if (ns->prefix_len > 0)
return 0;
/* prefix="" namespace=no : catching this is basically the
same as not finding any namespace. */
}
/* 2) when listing pub/ namespace, skip over entries that don't
begin with pub/. */
return 0;
/* When listing shared namespace's subscriptions, we need to
autocreate all the visible child namespaces. their subscriptions
are listed later. */
/* we'll need to get the namespace autocreated.
one easy way is to just ask to join a reference and
pattern */
}
/* When listing pub/ namespace, skip over the namespace
prefix in the name. the rest of the name is storage_name. */
ns = default_ns;
} else {
/* "pub" entry - this shouldn't be possible normally, because
it should be saved as "pub/", but handle it anyway */
}
/* entry ends with hierarchy separator, remove it.
this exists mainly for backwards compatibility with old
Dovecot versions and non-Dovecot software that added them */
}
/* we'll only get into trouble if we show this */
return -1;
} else {
if (!uni_utf8_str_is_valid(vname))
return -1;
}
return 0;
}
struct mailbox_list *dest_list)
{
struct subsfile_list_context *subsfile_ctx;
enum mailbox_list_path_type type;
char sep;
int ret;
/* src_list is subscriptions=yes, dest_list is subscriptions=no
(or the same as src_list) */
}
/* no subscriptions */
dest_list->subscriptions_mtime = 0;
return 0;
}
path);
return -1;
}
/* we're up to date */
return 0;
}
T_BEGIN {
} T_END;
if (ret < 0) {
i_warning("Subscriptions file %s: "
"Removing invalid entry: %s",
}
} T_END;
if (subsfile_list_deinit(&subsfile_ctx) < 0) {
return -1;
}
return 0;
}
const char *vname,
enum mailbox_info_flags *flags)
{
struct mailbox_node *node;
/* the only reason why node might have a child is if one of
them is subscribed */
}
}
struct mailbox_tree_context *tree,
bool default_nonexistent)
{
struct mailbox_tree_iterate_context *iter;
struct mailbox_node *node;
const char *name;
if (default_nonexistent)
}
struct mailbox_list_iterate_context *
const char *const *patterns,
enum mailbox_list_iter_flags flags)
{
/* the tree usually has only those entries we want to iterate through,
but there are also non-matching root entries (e.g. "LSUB foo/%" will
include the "foo"), which we'll drop with MAILBOX_MATCHED. */
}
const struct mailbox_info *
{
(struct subscriptions_mailbox_list_iterate_context *)_ctx;
struct mailbox_node *node;
enum mailbox_info_flags subs_flags;
int ret;
return NULL;
/* don't care about flags, just return it */
}
/* broken entry in subscriptions file */
MAILBOX_NOCHILDREN)) == 0) {
if (ret < 0)
else if (ret == 0)
else
}
}
{
(struct subscriptions_mailbox_list_iterate_context *)_ctx;
return ret;
}