dovecot-2.2: imap: METADATA: Implemented mailbox and server comm...

dovecot at dovecot.org dovecot at dovecot.org
Mon Sep 7 22:31:30 UTC 2015


details:   http://hg.dovecot.org/dovecot-2.2/rev/793bf4ab439f
changeset: 19126:793bf4ab439f
user:      Stephan Bosch <stephan at rename-it.nl>
date:      Sat Apr 25 11:42:06 2015 +0200
description:
imap: METADATA: Implemented mailbox and server comment entries and the server admin entry.

diffstat:

 src/lib-storage/mail-storage-settings.c      |   11 ++-
 src/lib-storage/mail-storage-settings.h      |    3 +
 src/lib-storage/mailbox-attribute-internal.c |  100 +++++++++++++++++++++++++++
 src/lib-storage/mailbox-attribute-internal.h |    5 +
 4 files changed, 118 insertions(+), 1 deletions(-)

diffs (201 lines):

diff -r c4932f3f4acd -r 793bf4ab439f src/lib-storage/mail-storage-settings.c
--- a/src/lib-storage/mail-storage-settings.c	Sat Apr 25 11:42:06 2015 +0200
+++ b/src/lib-storage/mail-storage-settings.c	Sat Apr 25 11:42:06 2015 +0200
@@ -35,6 +35,8 @@
 	DEF(SET_STR, mail_cache_fields),
 	DEF(SET_STR, mail_always_cache_fields),
 	DEF(SET_STR, mail_never_cache_fields),
+	DEF(SET_STR, mail_server_comment),
+	DEF(SET_STR, mail_server_admin),
 	DEF(SET_UINT, mail_cache_min_mail_count),
 	DEF(SET_TIME, mailbox_idle_check_interval),
 	DEF(SET_UINT, mail_max_keyword_length),
@@ -73,6 +75,8 @@
 	.mail_cache_fields = "flags",
 	.mail_always_cache_fields = "",
 	.mail_never_cache_fields = "imap.envelope",
+	.mail_server_comment = "",
+	.mail_server_admin = "",
 	.mail_cache_min_mail_count = 0,
 	.mailbox_idle_check_interval = 30,
 	.mail_max_keyword_length = 50,
@@ -121,6 +125,7 @@
 	{ SET_ENUM, "auto", offsetof(struct mailbox_settings, autocreate), NULL } ,
 	DEF(SET_STR, special_use),
 	DEF(SET_STR, driver),
+	DEF(SET_STR, comment),
 
 	SETTING_DEFINE_LIST_END
 };
@@ -131,7 +136,8 @@
 		MAILBOX_SET_AUTO_CREATE":"
 		MAILBOX_SET_AUTO_SUBSCRIBE,
 	.special_use = "",
-	.driver = ""
+	.driver = "",
+	.comment = ""
 };
 
 const struct setting_parser_info mailbox_setting_parser_info = {
@@ -444,6 +450,9 @@
 		return FALSE;
 	}
 #endif
+
+	// FIXME: check set->mail_server_admin syntax (RFC 5464, Section 6.2.2)
+
 	return TRUE;
 }
 
diff -r c4932f3f4acd -r 793bf4ab439f src/lib-storage/mail-storage-settings.h
--- a/src/lib-storage/mail-storage-settings.h	Sat Apr 25 11:42:06 2015 +0200
+++ b/src/lib-storage/mail-storage-settings.h	Sat Apr 25 11:42:06 2015 +0200
@@ -20,6 +20,8 @@
 	const char *mail_cache_fields;
 	const char *mail_always_cache_fields;
 	const char *mail_never_cache_fields;
+	const char *mail_server_comment;
+	const char *mail_server_admin;
 	unsigned int mail_cache_min_mail_count;
 	unsigned int mailbox_idle_check_interval;
 	unsigned int mail_max_keyword_length;
@@ -78,6 +80,7 @@
 	const char *autocreate;
 	const char *special_use;
 	const char *driver;
+	const char *comment;
 };
 
 struct mail_user_settings {
diff -r c4932f3f4acd -r 793bf4ab439f src/lib-storage/mailbox-attribute-internal.c
--- a/src/lib-storage/mailbox-attribute-internal.c	Sat Apr 25 11:42:06 2015 +0200
+++ b/src/lib-storage/mailbox-attribute-internal.c	Sat Apr 25 11:42:06 2015 +0200
@@ -33,6 +33,93 @@
 	.get = mailbox_attribute_specialuse_get
 };
 
+/* /private/comment, /shared/comment (RFC 5464) */
+
+static int
+mailbox_attribute_comment_get(struct mailbox_transaction_context *t,
+	const char *key ATTR_UNUSED,
+	struct mail_attribute_value *value_r)
+{
+	const struct mailbox_settings *set = t->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_transaction_context *t,
+	const char *key ATTR_UNUSED,
+	struct mail_attribute_value *value_r)
+{
+	const struct mail_storage_settings *set = t->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_transaction_context *t,
+	const char *key ATTR_UNUSED,
+	struct mail_attribute_value *value_r)
+{
+	const struct mail_storage_settings *set = t->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
  */
@@ -45,4 +132,17 @@
 
 	/* /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);
 }
diff -r c4932f3f4acd -r 793bf4ab439f src/lib-storage/mailbox-attribute-internal.h
--- a/src/lib-storage/mailbox-attribute-internal.h	Sat Apr 25 11:42:06 2015 +0200
+++ b/src/lib-storage/mailbox-attribute-internal.h	Sat Apr 25 11:42:06 2015 +0200
@@ -1,8 +1,13 @@
 #ifndef MAILBOX_ATTRIBUTE_INTERNAL_H
 #define MAILBOX_ATTRIBUTE_INTERNAL_H
 
+/* RFC 5464, Section 3.2.1.2: Mailbox entries */
+#define MAILBOX_ATTRIBUTE_COMMENT "comment"
 /* RFC 6154, Section 4: IMAP METADATA Entry for Special-Use Attributes */
 #define MAILBOX_ATTRIBUTE_SPECIALUSE "specialuse"
+/* RFC 5464, Section 3.2.1.1: Server entries */
+#define MAIL_SERVER_ATTRIBUTE_COMMENT "comment"
+#define MAIL_SERVER_ATTRIBUTE_ADMIN "admin"
 
 void mailbox_attributes_internal_init(void);
 


More information about the dovecot-cvs mailing list