diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 09:51:24 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 09:51:24 +0000 |
commit | f7548d6d28c313cf80e6f3ef89aed16a19815df1 (patch) | |
tree | a3f6f2a3f247293bee59ecd28e8cd8ceb6ca064a /src/lib-storage/mailbox-attribute-internal.c | |
parent | Initial commit. (diff) | |
download | dovecot-f7548d6d28c313cf80e6f3ef89aed16a19815df1.tar.xz dovecot-f7548d6d28c313cf80e6f3ef89aed16a19815df1.zip |
Adding upstream version 1:2.3.19.1+dfsg1.upstream/1%2.3.19.1+dfsg1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/lib-storage/mailbox-attribute-internal.c')
-rw-r--r-- | src/lib-storage/mailbox-attribute-internal.c | 149 |
1 files changed, 149 insertions, 0 deletions
diff --git a/src/lib-storage/mailbox-attribute-internal.c b/src/lib-storage/mailbox-attribute-internal.c new file mode 100644 index 0000000..d5d0265 --- /dev/null +++ b/src/lib-storage/mailbox-attribute-internal.c @@ -0,0 +1,149 @@ +/* Copyright (c) 2003-2018 Dovecot authors, see the included COPYING file */ + +#include "lib.h" +#include "mail-storage-private.h" +#include "mailbox-attribute-internal.h" + +/* + * Internal mailbox attributes + */ + + /* /private/specialuse (RFC 6154) */ + +static int +mailbox_attribute_specialuse_get(struct mailbox *box, + const char *key ATTR_UNUSED, + struct mail_attribute_value *value_r) +{ + const struct mailbox_settings *set = box->set; + + if (set == NULL || *set->special_use == '\0') + return 0; + + value_r->value = set->special_use; + return 1; +} + +static struct mailbox_attribute_internal +iattr_mbox_prv_special_use = { + .type = MAIL_ATTRIBUTE_TYPE_PRIVATE, + .key = MAILBOX_ATTRIBUTE_SPECIALUSE, + .rank = MAIL_ATTRIBUTE_INTERNAL_RANK_AUTHORITY, + .flags = MAIL_ATTRIBUTE_INTERNAL_FLAG_VALIDATED, + + .get = mailbox_attribute_specialuse_get +}; + +/* /private/comment, /shared/comment (RFC 5464) */ + +static int +mailbox_attribute_comment_get(struct mailbox *box, + const char *key ATTR_UNUSED, + struct mail_attribute_value *value_r) +{ + const struct mailbox_settings *set = box->set; + + if (set == NULL || *set->comment == '\0') + return 0; + value_r->value = set->comment; + return 1; +} + +static struct mailbox_attribute_internal +iattr_mbox_prv_comment = { + .type = MAIL_ATTRIBUTE_TYPE_PRIVATE, + .key = MAILBOX_ATTRIBUTE_COMMENT, + .rank = MAIL_ATTRIBUTE_INTERNAL_RANK_DEFAULT, + + .get = mailbox_attribute_comment_get +}; + +static struct mailbox_attribute_internal +iattr_mbox_shd_comment = { + .type = MAIL_ATTRIBUTE_TYPE_SHARED, + .key = MAILBOX_ATTRIBUTE_COMMENT, + .rank = MAIL_ATTRIBUTE_INTERNAL_RANK_DEFAULT, + + .get = mailbox_attribute_comment_get +}; + +/* + * Internal server attributes + */ + +/* /shared/comment (RFC 5464) */ + +static int +server_attribute_comment_get(struct mailbox *box, + const char *key ATTR_UNUSED, + struct mail_attribute_value *value_r) +{ + const struct mail_storage_settings *set = box->storage->set; + + if (*set->mail_server_comment == '\0') + return 0; + value_r->value = set->mail_server_comment; + return 1; +} + +static struct mailbox_attribute_internal +iattr_serv_shd_comment = { + .type = MAIL_ATTRIBUTE_TYPE_SHARED, + .key = MAILBOX_ATTRIBUTE_PREFIX_DOVECOT_PVT_SERVER + MAIL_SERVER_ATTRIBUTE_COMMENT, + .rank = MAIL_ATTRIBUTE_INTERNAL_RANK_AUTHORITY, + + .get = server_attribute_comment_get +}; + +/* /shared/admin (RFC 5464) */ + +static int +server_attribute_admin_get(struct mailbox *box, + const char *key ATTR_UNUSED, + struct mail_attribute_value *value_r) +{ + const struct mail_storage_settings *set = box->storage->set; + + if (*set->mail_server_admin == '\0') + return 0; + value_r->value = set->mail_server_admin; + return 1; +} + +static struct mailbox_attribute_internal +iattr_serv_shd_admin = { + .type = MAIL_ATTRIBUTE_TYPE_SHARED, + .key = MAILBOX_ATTRIBUTE_PREFIX_DOVECOT_PVT_SERVER + MAIL_SERVER_ATTRIBUTE_ADMIN, + .rank = MAIL_ATTRIBUTE_INTERNAL_RANK_AUTHORITY, + + .get = server_attribute_admin_get +}; + +/* + * Registry + */ + +void mailbox_attributes_internal_init(void) +{ + /* + * Internal mailbox attributes + */ + + /* /private/specialuse (RFC 6154) */ + mailbox_attribute_register_internal(&iattr_mbox_prv_special_use); + /* /private/comment (RFC 5464) */ + mailbox_attribute_register_internal(&iattr_mbox_prv_comment); + /* /shared/comment (RFC 5464) */ + mailbox_attribute_register_internal(&iattr_mbox_shd_comment); + + /* + * internal server attributes + */ + + /* /shared/comment (RFC 5464) */ + mailbox_attribute_register_internal(&iattr_serv_shd_comment); + /* /shared/admin (RFC 5464) */ + mailbox_attribute_register_internal(&iattr_serv_shd_admin); +} |