]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imap: Implemented /private/specialuse METADATA entry for SPECIAL-USE capability.
authorStephan Bosch <stephan@rename-it.nl>
Sat, 25 Apr 2015 09:42:06 +0000 (11:42 +0200)
committerStephan Bosch <stephan@rename-it.nl>
Sat, 25 Apr 2015 09:42:06 +0000 (11:42 +0200)
src/lib-storage/Makefile.am
src/lib-storage/mailbox-attribute-internal.c [new file with mode: 0644]
src/lib-storage/mailbox-attribute-internal.h [new file with mode: 0644]
src/lib-storage/mailbox-attribute.c

index 822a053808b2a912f92425fb92fda64498f4d152..5492b9914ce9456427e2c957c5a6e46495243d08 100644 (file)
@@ -45,6 +45,7 @@ libstorage_la_SOURCES = \
        mail-thread.c \
        mail-user.c \
        mailbox-attribute.c \
+       mailbox-attribute-internal.c \
        mailbox-get.c \
        mailbox-guid-cache.c \
        mailbox-header.c \
@@ -75,6 +76,7 @@ headers = \
        mail-storage-settings.h \
        mail-user.h \
        mailbox-attribute.h \
+       mailbox-attribute-internal.h \
        mailbox-attribute-private.h \
        mailbox-guid-cache.h \
        mailbox-list.h \
diff --git a/src/lib-storage/mailbox-attribute-internal.c b/src/lib-storage/mailbox-attribute-internal.c
new file mode 100644 (file)
index 0000000..6c87b4b
--- /dev/null
@@ -0,0 +1,48 @@
+/* Copyright (c) 2003-2015 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_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->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,
+
+       .get = mailbox_attribute_specialuse_get
+};
+
+/*
+ * Registry
+ */
+
+void mailbox_attributes_internal_init(void)
+{
+       /*
+        * Internal mailbox attributes
+        */
+
+       /* /private/specialuse (RFC 6154) */
+       mailbox_attribute_register_internal(&iattr_mbox_prv_special_use);
+}
diff --git a/src/lib-storage/mailbox-attribute-internal.h b/src/lib-storage/mailbox-attribute-internal.h
new file mode 100644 (file)
index 0000000..888780b
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef MAILBOX_ATTRIBUTE_INTERNAL_H
+#define MAILBOX_ATTRIBUTE_INTERNAL_H
+
+/* RFC 6154, Section 4: IMAP METADATA Entry for Special-Use Attributes */
+#define MAILBOX_ATTRIBUTE_SPECIALUSE "specialuse"
+
+void mailbox_attributes_internal_init(void);
+
+#endif
index 9e4edd04c5ff86edf2cd9703d8a45d36484b5d6f..ba94e4711c3923458c7b70583e9c5c0401a3ac62 100644 (file)
@@ -6,6 +6,7 @@
 #include "istream.h"
 #include "mail-storage-private.h"
 #include "bsearch-insert-pos.h"
+#include "mailbox-attribute-internal.h"
 
 static ARRAY(struct mailbox_attribute_internal) mailbox_internal_attributes;
 static pool_t mailbox_attribute_pool;
@@ -15,6 +16,9 @@ void mailbox_attributes_init(void)
        mailbox_attribute_pool =
                pool_alloconly_create("mailbox attributes", 2048);
        i_array_init(&mailbox_internal_attributes, 32);
+
+       /* internal mailbox attributes */
+       mailbox_attributes_internal_init();
 }
 
 void mailbox_attributes_deinit(void)