Mercurial > dovecot > core-2.2
changeset 18119:831f7e40546d
quota: Added "hidden" option to hide the quota root from IMAP GETQUOTAROOT command.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 01 Dec 2014 12:11:54 -0800 |
parents | 67b46a7f4ed2 |
children | 096d233acb7d |
files | src/plugins/imap-quota/imap-quota-plugin.c src/plugins/quota/quota-dict.c src/plugins/quota/quota-fs.c src/plugins/quota/quota-maildir.c src/plugins/quota/quota-private.h src/plugins/quota/quota.c src/plugins/quota/quota.h |
diffstat | 7 files changed, 23 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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);
--- 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;
--- 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);
--- 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)
--- 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 {
--- 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) {
--- 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,