[dovecot-cvs] dovecot/src/lib-storage/index/maildir maildir-list.c,
1.31, 1.32 maildir-storage.c, 1.81, 1.82 maildir-storage.h,
1.25, 1.26
cras at dovecot.org
cras at dovecot.org
Fri Jul 23 00:20:03 EEST 2004
Update of /home/cvs/dovecot/src/lib-storage/index/maildir
In directory talvi:/tmp/cvs-serv11339/lib-storage/index/maildir
Modified Files:
maildir-list.c maildir-storage.c maildir-storage.h
Log Message:
Moved namespace and hierarchy separator handling to imap-specific code. LIST
now shows non-hidden namespaces in the LIST reply.
Index: maildir-list.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/maildir/maildir-list.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- maildir-list.c 15 Jun 2004 03:20:12 -0000 1.31
+++ maildir-list.c 22 Jul 2004 21:20:01 -0000 1.32
@@ -70,13 +70,6 @@
return FALSE;
}
- /* INBOX exists always */
- if (imap_match(glob, "INBOX") > 0 && !update_only) {
- node = mailbox_tree_get(ctx->tree_ctx, "INBOX", NULL);
- node->flags |= MAILBOX_FLAG_MATCHED | MAILBOX_NOCHILDREN;
- node->flags &= ~(MAILBOX_PLACEHOLDER | MAILBOX_NONEXISTENT);
- }
-
stat_dirs = getenv("MAILDIR_STAT_DIRS") != NULL;
mailbox = t_str_new(PATH_MAX);
@@ -139,9 +132,6 @@
match != IMAP_MATCH_PARENT)
continue;
- if (strcasecmp(fname, "INBOX") == 0)
- continue; /* ignore inboxes */
-
if (match == IMAP_MATCH_PARENT) {
t_push();
while ((p = strrchr(mailbox_c,
@@ -219,9 +209,8 @@
node = mailbox_tree_get(ctx->tree_ctx, name, NULL);
node->flags = MAILBOX_FLAG_MATCHED;
if ((ctx->flags & MAILBOX_LIST_FAST_FLAGS) == 0) {
- if (strcasecmp(name, "INBOX") != 0)
- node->flags |= MAILBOX_NONEXISTENT;
- node->flags |= MAILBOX_NOCHILDREN;
+ node->flags |= MAILBOX_NONEXISTENT |
+ MAILBOX_NOCHILDREN;
}
break;
case IMAP_MATCH_PARENT:
@@ -249,7 +238,8 @@
struct mailbox_list_context *
maildir_mailbox_list_init(struct mail_storage *storage,
- const char *mask, enum mailbox_list_flags flags)
+ const char *ref, const char *mask,
+ enum mailbox_list_flags flags)
{
struct index_storage *istorage = (struct index_storage *)storage;
struct maildir_list_context *ctx;
@@ -266,29 +256,32 @@
ctx->flags = flags;
ctx->tree_ctx = mailbox_tree_init(MAILDIR_FS_SEP);
- if (storage->hierarchy_sep != MAILDIR_FS_SEP &&
- strchr(mask, MAILDIR_FS_SEP) != NULL) {
- /* this will never match, return nothing */
- return &ctx->mailbox_ctx;
+ if (*ref != '\0') {
+ /* join reference + mask */
+ if (*mask == MAILDIR_FS_SEP &&
+ ref[strlen(ref)-1] == MAILDIR_FS_SEP) {
+ /* A. .B -> A.B */
+ mask++;
+ } else if (*mask != MAILDIR_FS_SEP &&
+ ref[strlen(ref)-1] != MAILDIR_FS_SEP) {
+ /* A B -> A.B */
+ mask = t_strconcat(ref, MAILDIR_FS_SEP_S, mask, NULL);
+ } else {
+ mask = t_strconcat(ref, mask, NULL);
+ }
}
- mask = maildir_fix_mailbox_name(istorage, mask, FALSE);
glob = imap_match_init(pool, mask, TRUE, MAILDIR_FS_SEP);
ctx->dir = istorage->dir;
- ctx->prefix = storage->namespace == NULL ? "" :
- maildir_fix_mailbox_name(istorage, storage->namespace, FALSE);
+ ctx->prefix = "";
if ((flags & MAILBOX_LIST_SUBSCRIBED) != 0) {
- if (!maildir_fill_subscribed(ctx, glob)) {
- mailbox_tree_deinit(ctx->tree_ctx);
- pool_unref(pool);
- return NULL;
- }
+ if (!maildir_fill_subscribed(ctx, glob))
+ return &ctx->mailbox_ctx;
} else if (full_filesystem_access && (p = strrchr(mask, '/')) != NULL) {
dir = t_strdup_until(mask, p);
- ctx->prefix = t_strconcat(ctx->prefix,
- t_strdup_until(mask, p+1), NULL);
+ ctx->prefix = p_strdup_until(pool, mask, p+1);
if (*mask != '/' && *mask != '~')
dir = t_strconcat(istorage->dir, "/", dir, NULL);
@@ -298,14 +291,10 @@
if ((flags & MAILBOX_LIST_SUBSCRIBED) == 0 ||
(ctx->flags & MAILBOX_LIST_FAST_FLAGS) == 0) {
int update_only = (flags & MAILBOX_LIST_SUBSCRIBED) != 0;
- if (!maildir_fill_readdir(ctx, glob, update_only)) {
- mailbox_tree_deinit(ctx->tree_ctx);
- pool_unref(pool);
- return NULL;
- }
+ if (!maildir_fill_readdir(ctx, glob, update_only))
+ return &ctx->mailbox_ctx;
}
- ctx->prefix = p_strdup(pool, ctx->prefix);
ctx->node_path = str_new(pool, 256);
ctx->root = mailbox_tree_get(ctx->tree_ctx, NULL, NULL);
ctx->mailbox_ctx.storage = storage;
Index: maildir-storage.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/maildir/maildir-storage.c,v
retrieving revision 1.81
retrieving revision 1.82
diff -u -d -r1.81 -r1.82
--- maildir-storage.c 18 Jul 2004 02:25:07 -0000 1.81
+++ maildir-storage.c 22 Jul 2004 21:20:01 -0000 1.82
@@ -30,8 +30,7 @@
static int verify_inbox(struct index_storage *storage);
static struct mail_storage *
-maildir_create(const char *data, const char *user,
- const char *namespace, char hierarchy_sep)
+maildir_create(const char *data, const char *user)
{
struct index_storage *storage;
const char *root_dir, *inbox_dir, *index_dir, *control_dir;
@@ -91,10 +90,6 @@
storage = i_new(struct index_storage, 1);
storage->storage = maildir_storage;
- if (hierarchy_sep != '\0')
- storage->storage.hierarchy_sep = hierarchy_sep;
- storage->storage.namespace = i_strdup(namespace);
-
/* the default ".temp.xxx" prefix would be treated as directory */
storage->temp_prefix =
i_strconcat("temp.", my_hostname, ".", my_pid, ".", NULL);
@@ -184,48 +179,6 @@
MAILDIR_FS_SEP_S, p+1, NULL);
}
-const char *maildir_fix_mailbox_name(struct index_storage *storage,
- const char *name, int remove_namespace)
-{
- char *dup, *p, sep;
- size_t len;
-
- if (strncasecmp(name, "INBOX", 5) == 0 &&
- (name[5] == '\0' || name[5] == storage->storage.hierarchy_sep)) {
- /* use same case with all INBOX folders or we'll get
- into trouble */
- name = t_strconcat("INBOX", name+5, NULL);
- if (name[5] == '\0') {
- /* don't check namespace with INBOX */
- return name;
- }
- }
-
- if (storage->storage.namespace != NULL && remove_namespace) {
- len = strlen(storage->storage.namespace);
- if (strncmp(storage->storage.namespace, name, len) != 0) {
- i_panic("maildir: expecting namespace '%s' in name "
- "'%s'", storage->storage.namespace, name);
- }
- name += len;
- }
-
- if (full_filesystem_access && (*name == '/' || *name == '~'))
- return name;
-
- sep = storage->storage.hierarchy_sep;
- if (sep == MAILDIR_FS_SEP)
- return name;
-
- dup = t_strdup_noconst(name);
- for (p = dup; *p != '\0'; p++) {
- if (*p == sep)
- *p = MAILDIR_FS_SEP;
- }
-
- return dup;
-}
-
const char *maildir_get_path(struct index_storage *storage, const char *name)
{
if (full_filesystem_access && (*name == '/' || *name == '~'))
@@ -455,7 +408,6 @@
mail_storage_clear_error(_storage);
- name = maildir_fix_mailbox_name(storage, name, TRUE);
if (strcmp(name, "INBOX") == 0) {
if (verify_inbox(storage) < 0)
return NULL;
@@ -496,7 +448,6 @@
mail_storage_clear_error(_storage);
- name = maildir_fix_mailbox_name(storage, name, TRUE);
if (!maildir_is_valid_create_name(name)) {
mail_storage_set_error(_storage, "Invalid mailbox name");
return -1;
@@ -524,7 +475,6 @@
mail_storage_clear_error(_storage);
- name = maildir_fix_mailbox_name(storage, name, TRUE);
if (strcmp(name, "INBOX") == 0) {
mail_storage_set_error(_storage, "INBOX can't be deleted.");
return -1;
@@ -620,29 +570,23 @@
{
struct mailbox_list_context *ctx;
struct mailbox_list *list;
- const char *oldpath, *newpath, *new_listname, *mask;
+ const char *oldpath, *newpath, *new_listname;
size_t oldnamelen;
int ret;
ret = 0;
oldnamelen = strlen(oldname);
- mask = t_strdup_printf("%s%s%c*", storage->storage.namespace != NULL ?
- storage->storage.namespace : "", oldname,
- storage->storage.hierarchy_sep);
- ctx = maildir_mailbox_list_init(&storage->storage, mask,
+ ctx = maildir_mailbox_list_init(&storage->storage, oldname, "*",
MAILBOX_LIST_FAST_FLAGS);
while ((list = maildir_mailbox_list_next(ctx)) != NULL) {
- const char *list_name;
-
t_push();
- list_name = maildir_fix_mailbox_name(storage, list->name, TRUE);
- i_assert(oldnamelen <= strlen(list_name));
+ i_assert(oldnamelen <= strlen(list->name));
new_listname = t_strconcat(newname,
- list_name + oldnamelen, NULL);
- oldpath = maildir_get_path(storage, list_name);
+ list->name + oldnamelen, NULL);
+ oldpath = maildir_get_path(storage, list->name);
newpath = maildir_get_path(storage, new_listname);
/* FIXME: it's possible to merge two folders if either one of
@@ -665,7 +609,7 @@
break;
}
- (void)rename_indexes(storage, list_name, new_listname);
+ (void)rename_indexes(storage, list->name, new_listname);
t_pop();
}
@@ -683,9 +627,6 @@
mail_storage_clear_error(_storage);
- oldname = maildir_fix_mailbox_name(storage, oldname, TRUE);
- newname = maildir_fix_mailbox_name(storage, newname, TRUE);
-
if (!maildir_is_valid_existing_name(oldname) ||
!maildir_is_valid_create_name(newname)) {
mail_storage_set_error(_storage, "Invalid mailbox name");
@@ -741,7 +682,6 @@
storage->control_dir : storage->dir,
"/" SUBSCRIPTION_FILE_NAME, NULL);
- name = maildir_fix_mailbox_name(storage, name, FALSE);
return subsfile_set_subscribed(_storage, path, storage->temp_prefix,
name, set);
}
@@ -756,7 +696,6 @@
mail_storage_clear_error(_storage);
- name = maildir_fix_mailbox_name(storage, name, TRUE);
if (!maildir_is_valid_existing_name(name)) {
*status = MAILBOX_NAME_INVALID;
return 0;
@@ -821,9 +760,8 @@
struct mail_storage maildir_storage = {
"maildir", /* name */
- NULL, /* namespace */
- '.', /* default hierarchy separator */
+ '.', /* hierarchy separator */
maildir_create,
maildir_free,
Index: maildir-storage.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/maildir/maildir-storage.h,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- maildir-storage.h 12 Jul 2004 11:35:51 -0000 1.25
+++ maildir-storage.h 22 Jul 2004 21:20:01 -0000 1.26
@@ -33,7 +33,8 @@
struct mailbox_list_context *
maildir_mailbox_list_init(struct mail_storage *storage,
- const char *mask, enum mailbox_list_flags flags);
+ const char *ref, const char *mask,
+ enum mailbox_list_flags flags);
int maildir_mailbox_list_deinit(struct mailbox_list_context *ctx);
struct mailbox_list *
maildir_mailbox_list_next(struct mailbox_list_context *ctx);
@@ -60,8 +61,6 @@
int maildir_copy_commit(struct maildir_copy_context *ctx);
void maildir_copy_rollback(struct maildir_copy_context *ctx);
-const char *maildir_fix_mailbox_name(struct index_storage *storage,
- const char *name, int remove_namespace);
const char *maildir_get_path(struct index_storage *storage, const char *name);
int maildir_sync_last_commit(struct index_mailbox *ibox);
More information about the dovecot-cvs
mailing list