dovecot-2.2: quota: Added "hidden" option to hide the quota root...

dovecot at dovecot.org dovecot at dovecot.org
Mon Dec 1 20:12:19 UTC 2014


details:   http://hg.dovecot.org/dovecot-2.2/rev/831f7e40546d
changeset: 18119:831f7e40546d
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Dec 01 12:11:54 2014 -0800
description:
quota: Added "hidden" option to hide the quota root from IMAP GETQUOTAROOT command.

diffstat:

 src/plugins/imap-quota/imap-quota-plugin.c |  2 ++
 src/plugins/quota/quota-dict.c             |  5 +++++
 src/plugins/quota/quota-fs.c               |  2 ++
 src/plugins/quota/quota-maildir.c          |  2 ++
 src/plugins/quota/quota-private.h          |  2 ++
 src/plugins/quota/quota.c                  |  7 +++++++
 src/plugins/quota/quota.h                  |  3 +++
 7 files changed, 23 insertions(+), 0 deletions(-)

diffs (100 lines):

diff -r 67b46a7f4ed2 -r 831f7e40546d src/plugins/imap-quota/imap-quota-plugin.c
--- a/src/plugins/imap-quota/imap-quota-plugin.c	Fri Nov 28 10:57:43 2014 +0200
+++ b/src/plugins/imap-quota/imap-quota-plugin.c	Mon Dec 01 12:11:54 2014 -0800
@@ -105,6 +105,8 @@
 
 	iter = quota_root_iter_init(box);
 	while ((root = quota_root_iter_next(iter)) != NULL) {
+		if (quota_root_is_hidden(root))
+			continue;
 		str_append_c(quotaroot_reply, ' ');
 		name = imap_quota_root_get_name(client->user, ns->owner, root);
 		imap_append_astring(quotaroot_reply, name);
diff -r 67b46a7f4ed2 -r 831f7e40546d src/plugins/quota/quota-dict.c
--- a/src/plugins/quota/quota-dict.c	Fri Nov 28 10:57:43 2014 +0200
+++ b/src/plugins/quota/quota-dict.c	Mon Dec 01 12:11:54 2014 -0800
@@ -52,6 +52,11 @@
 			args += 12;
 			continue;
 		}
+		if (strncmp(args, "hidden:", 7) == 0) {
+			_root->hidden = TRUE;
+			args += 7;
+			continue;
+		}
 		if (strncmp(args, "ignoreunlimited:", 16) == 0) {
 			_root->disable_unlimited_tracking = TRUE;
 			args += 16;
diff -r 67b46a7f4ed2 -r 831f7e40546d src/plugins/quota/quota-fs.c
--- a/src/plugins/quota/quota-fs.c	Fri Nov 28 10:57:43 2014 +0200
+++ b/src/plugins/quota/quota-fs.c	Mon Dec 01 12:11:54 2014 -0800
@@ -113,6 +113,8 @@
 			root->inode_per_mail = TRUE;
 		else if (strcmp(*tmp, "noenforcing") == 0)
 			_root->no_enforcing = TRUE;
+		else if (strcmp(*tmp, "hidden") == 0)
+			_root->hidden = TRUE;
 		else if (strncmp(*tmp, "mount=", 6) == 0) {
 			i_free(root->storage_mount_path);
 			root->storage_mount_path = i_strdup(*tmp + 6);
diff -r 67b46a7f4ed2 -r 831f7e40546d src/plugins/quota/quota-maildir.c
--- a/src/plugins/quota/quota-maildir.c	Fri Nov 28 10:57:43 2014 +0200
+++ b/src/plugins/quota/quota-maildir.c	Mon Dec 01 12:11:54 2014 -0800
@@ -772,6 +772,8 @@
 	for (tmp = t_strsplit(args, ":"); *tmp != NULL; tmp++) {
 		if (strcmp(*tmp, "noenforcing") == 0)
 			_root->no_enforcing = TRUE;
+		else if (strcmp(*tmp, "hidden") == 0)
+			_root->hidden = TRUE;
 		else if (strcmp(*tmp, "ignoreunlimited") == 0)
 			_root->disable_unlimited_tracking = TRUE;
 		else if (strncmp(*tmp, "ns=", 3) == 0)
diff -r 67b46a7f4ed2 -r 831f7e40546d src/plugins/quota/quota-private.h
--- a/src/plugins/quota/quota-private.h	Fri Nov 28 10:57:43 2014 +0200
+++ b/src/plugins/quota/quota-private.h	Mon Dec 01 12:11:54 2014 -0800
@@ -134,6 +134,8 @@
 	unsigned int disable_unlimited_tracking:1;
 	/* Set while quota is being recalculated to avoid recursion. */
 	unsigned int recounting:1;
+	/* Quota root is hidden (to e.g. IMAP GETQUOTAROOT) */
+	unsigned int hidden:1;
 };
 
 struct quota_transaction_context {
diff -r 67b46a7f4ed2 -r 831f7e40546d src/plugins/quota/quota.c
--- a/src/plugins/quota/quota.c	Fri Nov 28 10:57:43 2014 +0200
+++ b/src/plugins/quota/quota.c	Mon Dec 01 12:11:54 2014 -0800
@@ -305,6 +305,8 @@
 		for (; *tmp != NULL; tmp++) {
 			if (strcmp(*tmp, "noenforcing") == 0)
 				root->no_enforcing = TRUE;
+			else if (strcmp(*tmp, "hidden") == 0)
+				root->hidden = TRUE;
 			else if (strcmp(*tmp, "ignoreunlimited") == 0)
 				root->disable_unlimited_tracking = TRUE;
 			else
@@ -635,6 +637,11 @@
 	return root->backend.v.get_resources(root);
 }
 
+bool quota_root_is_hidden(struct quota_root *root)
+{
+	return root->hidden;
+}
+
 int quota_get_resource(struct quota_root *root, const char *mailbox_name,
 		       const char *name, uint64_t *value_r, uint64_t *limit_r)
 {
diff -r 67b46a7f4ed2 -r 831f7e40546d src/plugins/quota/quota.h
--- a/src/plugins/quota/quota.h	Fri Nov 28 10:57:43 2014 +0200
+++ b/src/plugins/quota/quota.h	Mon Dec 01 12:11:54 2014 -0800
@@ -49,6 +49,9 @@
 const char *quota_root_get_name(struct quota_root *root);
 /* Return a list of all resources set for the quota root. */
 const char *const *quota_root_get_resources(struct quota_root *root);
+/* Returns TRUE if quota root is marked as hidden (so it shouldn't be visible
+   to users via IMAP GETQUOTAROOT command). */
+bool quota_root_is_hidden(struct quota_root *root);
 
 /* Returns 1 if quota value was found, 0 if not, -1 if error. */
 int quota_get_resource(struct quota_root *root, const char *mailbox_name,


More information about the dovecot-cvs mailing list