dovecot-2.0: lib-storage: Changed mailbox_list.iter_is_mailbox()...

dovecot at dovecot.org dovecot at dovecot.org
Mon Feb 15 02:09:17 EET 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/be5590207f20
changeset: 10715:be5590207f20
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Feb 15 02:03:42 2010 +0200
description:
lib-storage: Changed mailbox_list.iter_is_mailbox() API.

diffstat:

 src/lib-storage/index/cydir/cydir-storage.c       |   62 +-----
 src/lib-storage/index/dbox-common/dbox-storage.c  |   67 ------
 src/lib-storage/index/dbox-common/dbox-storage.h  |    5 -
 src/lib-storage/index/dbox-multi/mdbox-storage.c  |   24 +--
 src/lib-storage/index/dbox-single/sdbox-storage.c |   24 +--
 src/lib-storage/index/maildir/maildir-settings.c  |    2 -
 src/lib-storage/index/maildir/maildir-settings.h  |    1 -
 src/lib-storage/index/maildir/maildir-storage.c   |  284 ++++---------------------
 src/lib-storage/index/mbox/mbox-storage.c         |  114 +---------
 src/lib-storage/index/raw/raw-storage.c           |   50 +----
 src/lib-storage/list/Makefile.am                  |    1 +
 src/lib-storage/list/mailbox-list-delete.c        |    6 +-
 src/lib-storage/list/mailbox-list-fs-flags.c      |  208 ++++++++++++++++++
 src/lib-storage/list/mailbox-list-fs-iter.c       |   36 +-
 src/lib-storage/list/mailbox-list-fs.c            |   74 +++--
 src/lib-storage/list/mailbox-list-fs.h            |    6 +
 src/lib-storage/list/mailbox-list-maildir-iter.c  |  160 ++++++++++++--
 src/lib-storage/list/mailbox-list-maildir.c       |    4 +-
 src/lib-storage/list/mailbox-list-maildir.h       |    6 +
 src/lib-storage/mail-storage-settings.c           |    2 +
 src/lib-storage/mail-storage-settings.h           |    1 +
 src/lib-storage/mailbox-list-private.h            |   23 +-
 src/lib-storage/mailbox-list.c                    |   23 +-
 src/lib-storage/mailbox-list.h                    |    1 +
 src/plugins/virtual/virtual-storage.c             |   95 ++-----
 25 files changed, 542 insertions(+), 737 deletions(-)

diffs (truncated from 1844 to 300 lines):

diff -r 709351cde842 -r be5590207f20 src/lib-storage/index/cydir/cydir-storage.c
--- a/src/lib-storage/index/cydir/cydir-storage.c	Sun Feb 14 23:40:23 2010 +0200
+++ b/src/lib-storage/index/cydir/cydir-storage.c	Mon Feb 15 02:03:42 2010 +0200
@@ -116,66 +116,6 @@
 		index_mailbox_check_add(&mbox->box, mbox->box.path);
 }
 
-static int cydir_list_iter_is_mailbox(struct mailbox_list_iterate_context *ctx
-				      			ATTR_UNUSED,
-				      const char *dir, const char *fname,
-				      const char *mailbox_name ATTR_UNUSED,
-				      enum mailbox_list_file_type type,
-				      enum mailbox_info_flags *flags)
-{
-	const char *mail_path;
-	struct stat st;
-	int ret = 1;
-
-	/* try to avoid stat() with these checks */
-	if (type != MAILBOX_LIST_FILE_TYPE_DIR &&
-	    type != MAILBOX_LIST_FILE_TYPE_SYMLINK &&
-	    type != MAILBOX_LIST_FILE_TYPE_UNKNOWN) {
-		/* it's a file */
-		*flags |= MAILBOX_NOSELECT | MAILBOX_NOINFERIORS;
-		return 0;
-	}
-
-	/* need to stat() then */
-	mail_path = t_strconcat(dir, "/", fname, NULL);
-	if (stat(mail_path, &st) == 0) {
-		if (!S_ISDIR(st.st_mode)) {
-			/* non-directory */
-			*flags |= MAILBOX_NOSELECT | MAILBOX_NOINFERIORS;
-			ret = 0;
-		} else if (st.st_nlink == 2) {
-			/* no subdirectories */
-			*flags |= MAILBOX_NOCHILDREN;
-		} else if (*ctx->list->set.maildir_name != '\0') {
-			/* non-default configuration: we have one directory
-			   containing the mailboxes. if there are 3 links,
-			   either this is a selectable mailbox without children
-			   or non-selectable mailbox with children */
-			if (st.st_nlink > 3)
-				*flags |= MAILBOX_CHILDREN;
-		} else {
-			/* default configuration: all subdirectories are
-			   child mailboxes. */
-			if (st.st_nlink > 2)
-				*flags |= MAILBOX_CHILDREN;
-		}
-	} else if (errno == ENOENT) {
-		/* doesn't exist - probably a non-existing subscribed mailbox */
-		*flags |= MAILBOX_NONEXISTENT;
-	} else {
-		/* non-selectable. probably either access denied, or symlink
-		   destination not found. don't bother logging errors. */
-		*flags |= MAILBOX_NOSELECT;
-	}
-	return ret;
-}
-
-static void cydir_storage_add_list(struct mail_storage *storage ATTR_UNUSED,
-				   struct mailbox_list *list)
-{
-	list->v.iter_is_mailbox = cydir_list_iter_is_mailbox;
-}
-
 struct mail_storage cydir_storage = {
 	.name = CYDIR_STORAGE_NAME,
 	.class_flags = 0,
@@ -185,7 +125,7 @@
 		cydir_storage_alloc,
 		NULL,
 		NULL,
-		cydir_storage_add_list,
+		NULL,
 		cydir_storage_get_list_settings,
 		NULL,
 		cydir_mailbox_alloc,
diff -r 709351cde842 -r be5590207f20 src/lib-storage/index/dbox-common/dbox-storage.c
--- a/src/lib-storage/index/dbox-common/dbox-storage.c	Sun Feb 14 23:40:23 2010 +0200
+++ b/src/lib-storage/index/dbox-common/dbox-storage.c	Mon Feb 15 02:03:42 2010 +0200
@@ -139,70 +139,3 @@
 		return -1;
 	return 0;
 }
-
-int dbox_list_iter_is_mailbox(struct mailbox_list_iterate_context *ctx ATTR_UNUSED,
-			      const char *dir, const char *fname,
-			      const char *mailbox_name ATTR_UNUSED,
-			      enum mailbox_list_file_type type,
-			      enum mailbox_info_flags *flags)
-{
-	const char *path, *maildir_path;
-	struct stat st, st2;
-	int ret = 1;
-
-	/* try to avoid stat() with these checks */
-	if (type != MAILBOX_LIST_FILE_TYPE_DIR &&
-	    type != MAILBOX_LIST_FILE_TYPE_SYMLINK &&
-	    type != MAILBOX_LIST_FILE_TYPE_UNKNOWN) {
-		/* it's a file */
-		*flags |= MAILBOX_NOSELECT | MAILBOX_NOINFERIORS;
-		return 0;
-	}
-
-	/* need to stat() then */
-	path = t_strconcat(dir, "/", fname, NULL);
-	if (stat(path, &st) == 0) {
-		if (!S_ISDIR(st.st_mode)) {
-			/* non-directory */
-			*flags |= MAILBOX_NOSELECT | MAILBOX_NOINFERIORS;
-			ret = 0;
-		} else if (st.st_nlink == 2) {
-			/* no subdirectories */
-			*flags |= MAILBOX_NOCHILDREN;
-		} else if (*ctx->list->set.maildir_name != '\0') {
-			/* default configuration: we have one directory
-			   containing the mailboxes. if there are 3 links,
-			   either this is a selectable mailbox without children
-			   or non-selectable mailbox with children */
-			if (st.st_nlink > 3)
-				*flags |= MAILBOX_CHILDREN;
-		} else {
-			/* non-default configuration: all subdirectories are
-			   child mailboxes. */
-			if (st.st_nlink > 2)
-				*flags |= MAILBOX_CHILDREN;
-		}
-	} else if (errno == ENOENT) {
-		/* doesn't exist - probably a non-existing subscribed mailbox */
-		*flags |= MAILBOX_NONEXISTENT;
-	} else {
-		/* non-selectable. probably either access denied, or symlink
-		   destination not found. don't bother logging errors. */
-		*flags |= MAILBOX_NOSELECT;
-	}
-	if ((*flags & (MAILBOX_NOSELECT | MAILBOX_NONEXISTENT)) == 0) {
-		/* make sure it's a selectable mailbox */
-		maildir_path = t_strconcat(path, "/",
-					   ctx->list->set.maildir_name, NULL);
-		if (stat(maildir_path, &st2) < 0 || !S_ISDIR(st2.st_mode))
-			*flags |= MAILBOX_NOSELECT;
-		if (st.st_nlink == 3 && *ctx->list->set.maildir_name != '\0') {
-			/* now we know what link count 3 means. */
-			if ((*flags & MAILBOX_NOSELECT) != 0)
-				*flags |= MAILBOX_CHILDREN;
-			else
-				*flags |= MAILBOX_NOCHILDREN;
-		}
-	}
-	return ret;
-}
diff -r 709351cde842 -r be5590207f20 src/lib-storage/index/dbox-common/dbox-storage.h
--- a/src/lib-storage/index/dbox-common/dbox-storage.h	Sun Feb 14 23:40:23 2010 +0200
+++ b/src/lib-storage/index/dbox-common/dbox-storage.h	Mon Feb 15 02:03:42 2010 +0200
@@ -49,10 +49,5 @@
 int dbox_mailbox_open(struct mailbox *box);
 int dbox_mailbox_create(struct mailbox *box,
 			const struct mailbox_update *update, bool directory);
-int dbox_list_iter_is_mailbox(struct mailbox_list_iterate_context *ctx,
-			      const char *dir, const char *fname,
-			      const char *mailbox_name,
-			      enum mailbox_list_file_type type,
-			      enum mailbox_info_flags *flags);
 
 #endif
diff -r 709351cde842 -r be5590207f20 src/lib-storage/index/dbox-multi/mdbox-storage.c
--- a/src/lib-storage/index/dbox-multi/mdbox-storage.c	Sun Feb 14 23:40:23 2010 +0200
+++ b/src/lib-storage/index/dbox-multi/mdbox-storage.c	Mon Feb 15 02:03:42 2010 +0200
@@ -14,20 +14,10 @@
 #include "mdbox-storage-rebuild.h"
 #include "mdbox-storage.h"
 
-#define MDBOX_LIST_CONTEXT(obj) \
-	MODULE_CONTEXT(obj, mdbox_mailbox_list_module)
-
-struct mdbox_mailbox_list {
-	union mailbox_list_module_context module_ctx;
-};
-
 extern struct mail_storage mdbox_storage;
 extern struct mailbox mdbox_mailbox;
 extern struct dbox_storage_vfuncs mdbox_dbox_storage_vfuncs;
 
-static MODULE_CONTEXT_DEFINE_INIT(mdbox_mailbox_list_module,
-				  &mailbox_list_module_register);
-
 static struct mail_storage *mdbox_storage_alloc(void)
 {
 	struct mdbox_storage *storage;
@@ -313,18 +303,6 @@
 	return index_storage_mailbox_delete(box);
 }
 
-static void dbox_storage_add_list(struct mail_storage *storage ATTR_UNUSED,
-				  struct mailbox_list *list)
-{
-	struct mdbox_mailbox_list *mlist;
-
-	mlist = p_new(list->pool, struct mdbox_mailbox_list, 1);
-	mlist->module_ctx.super = list->v;
-	list->v.iter_is_mailbox = dbox_list_iter_is_mailbox;
-
-	MODULE_CONTEXT_SET(list, mdbox_mailbox_list_module, mlist);
-}
-
 struct mail_storage mdbox_storage = {
 	.name = MDBOX_STORAGE_NAME,
 	.class_flags = MAIL_STORAGE_CLASS_FLAG_UNIQUE_ROOT,
@@ -334,7 +312,7 @@
 		mdbox_storage_alloc,
 		mdbox_storage_create,
 		mdbox_storage_destroy,
-		dbox_storage_add_list,
+		NULL,
 		dbox_storage_get_list_settings,
 		NULL,
 		mdbox_mailbox_alloc,
diff -r 709351cde842 -r be5590207f20 src/lib-storage/index/dbox-single/sdbox-storage.c
--- a/src/lib-storage/index/dbox-single/sdbox-storage.c	Sun Feb 14 23:40:23 2010 +0200
+++ b/src/lib-storage/index/dbox-single/sdbox-storage.c	Mon Feb 15 02:03:42 2010 +0200
@@ -8,20 +8,10 @@
 #include "sdbox-sync.h"
 #include "sdbox-storage.h"
 
-#define SDBOX_LIST_CONTEXT(obj) \
-	MODULE_CONTEXT(obj, sdbox_mailbox_list_module)
-
-struct sdbox_mailbox_list {
-	union mailbox_list_module_context module_ctx;
-};
-
 extern struct mail_storage dbox_storage;
 extern struct mailbox sdbox_mailbox;
 extern struct dbox_storage_vfuncs sdbox_dbox_storage_vfuncs;
 
-static MODULE_CONTEXT_DEFINE_INIT(sdbox_mailbox_list_module,
-				  &mailbox_list_module_register);
-
 static struct mail_storage *sdbox_storage_alloc(void)
 {
 	struct sdbox_storage *storage;
@@ -203,18 +193,6 @@
 	return sdbox_write_index_header(box, update);
 }
 
-static void sdbox_storage_add_list(struct mail_storage *storage ATTR_UNUSED,
-				   struct mailbox_list *list)
-{
-	struct sdbox_mailbox_list *mlist;
-
-	mlist = p_new(list->pool, struct sdbox_mailbox_list, 1);
-	mlist->module_ctx.super = list->v;
-	list->v.iter_is_mailbox = dbox_list_iter_is_mailbox;
-
-	MODULE_CONTEXT_SET(list, sdbox_mailbox_list_module, mlist);
-}
-
 struct mail_storage dbox_storage = {
 	.name = SDBOX_STORAGE_NAME,
 	.class_flags = 0,
@@ -224,7 +202,7 @@
 		sdbox_storage_alloc,
 		NULL,
 		NULL,
-		sdbox_storage_add_list,
+		NULL,
 		dbox_storage_get_list_settings,
 		NULL,
 		sdbox_mailbox_alloc,
diff -r 709351cde842 -r be5590207f20 src/lib-storage/index/maildir/maildir-settings.c
--- a/src/lib-storage/index/maildir/maildir-settings.c	Sun Feb 14 23:40:23 2010 +0200
+++ b/src/lib-storage/index/maildir/maildir-settings.c	Mon Feb 15 02:03:42 2010 +0200
@@ -12,7 +12,6 @@
 	{ type, #name, offsetof(struct maildir_settings, name), NULL }
 
 static const struct setting_define maildir_setting_defines[] = {
-	DEF(SET_BOOL, maildir_stat_dirs),
 	DEF(SET_BOOL, maildir_copy_with_hardlinks),
 	DEF(SET_BOOL, maildir_copy_preserve_filename),
 	DEF(SET_BOOL, maildir_very_dirty_syncs),
@@ -21,7 +20,6 @@
 };
 
 static const struct maildir_settings maildir_default_settings = {
-	.maildir_stat_dirs = FALSE,
 	.maildir_copy_with_hardlinks = TRUE,
 	.maildir_copy_preserve_filename = FALSE,
 	.maildir_very_dirty_syncs = FALSE
diff -r 709351cde842 -r be5590207f20 src/lib-storage/index/maildir/maildir-settings.h
--- a/src/lib-storage/index/maildir/maildir-settings.h	Sun Feb 14 23:40:23 2010 +0200
+++ b/src/lib-storage/index/maildir/maildir-settings.h	Mon Feb 15 02:03:42 2010 +0200
@@ -2,7 +2,6 @@
 #define MAILDIR_SETTINGS_H
 
 struct maildir_settings {
-	bool maildir_stat_dirs;
 	bool maildir_copy_with_hardlinks;
 	bool maildir_copy_preserve_filename;


More information about the dovecot-cvs mailing list