Mercurial > dovecot > core-2.2
changeset 15741:03a0af22100d
lib-storage: Changed mailbox_attribute_get() to return a struct for value.
This allows returning flags for the values in future. Mainly readonly-flag
for internal attributes and when restricted by ACL plugin.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Tue, 05 Feb 2013 03:53:40 +0200 |
parents | 397253f15f36 |
children | 28db20f9c0cf |
files | src/lib-imap-urlauth/imap-urlauth-backend.c src/lib-storage/index/index-attribute.c src/lib-storage/index/index-storage.h src/lib-storage/mail-storage-private.h src/lib-storage/mail-storage.c src/lib-storage/mail-storage.h |
diffstat | 6 files changed, 22 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-imap-urlauth/imap-urlauth-backend.c Tue Feb 05 03:37:47 2013 +0200 +++ b/src/lib-imap-urlauth/imap-urlauth-backend.c Tue Feb 05 03:53:40 2013 +0200 @@ -18,6 +18,7 @@ enum mail_error *error_code_r) { struct mail_user *user = mail_storage_get_user(mailbox_get_storage(box)); + struct mail_attribute_value urlauth_key; const char *mailbox_key_hex = NULL; buffer_t key_buf; int ret; @@ -26,7 +27,7 @@ *error_code_r = MAIL_ERROR_TEMP; ret = mailbox_attribute_get(box, MAIL_ATTRIBUTE_TYPE_PRIVATE, - IMAP_URLAUTH_KEY, &mailbox_key_hex); + IMAP_URLAUTH_KEY, &urlauth_key); if (ret < 0) return -1; @@ -55,6 +56,7 @@ /* read existing key */ buffer_create_from_data(&key_buf, mailbox_key_r, IMAP_URLAUTH_KEY_LEN); + mailbox_key_hex = urlauth_key.value; if (strlen(mailbox_key_hex) != 2*IMAP_URLAUTH_KEY_LEN || hex_to_binary(mailbox_key_hex, &key_buf) < 0 || key_buf.used != IMAP_URLAUTH_KEY_LEN) {
--- a/src/lib-storage/index/index-attribute.c Tue Feb 05 03:37:47 2013 +0200 +++ b/src/lib-storage/index/index-attribute.c Tue Feb 05 03:53:40 2013 +0200 @@ -174,24 +174,25 @@ } int index_storage_attribute_get(struct mailbox *box, - enum mail_attribute_type type, - const char *key, const char **value_r) + enum mail_attribute_type type, const char *key, + struct mail_attribute_value *value_r) { struct dict *dict; const char *mailbox_prefix; int ret; + memset(value_r, 0, sizeof(*value_r)); + if (index_storage_get_dict(box, type, &dict, &mailbox_prefix) < 0) return -1; ret = dict_lookup(dict, pool_datastack_create(), - key_get_prefixed(type, mailbox_prefix, key), value_r); + key_get_prefixed(type, mailbox_prefix, key), + &value_r->value); if (ret < 0) { mail_storage_set_internal_error(box->storage); return -1; } - if (ret == 0) - *value_r = NULL; return ret; }
--- a/src/lib-storage/index/index-storage.h Tue Feb 05 03:37:47 2013 +0200 +++ b/src/lib-storage/index/index-storage.h Tue Feb 05 03:53:40 2013 +0200 @@ -120,8 +120,8 @@ enum mail_attribute_type type, const char *key, const char *value); int index_storage_attribute_get(struct mailbox *box, - enum mail_attribute_type type, - const char *key, const char **value_r); + enum mail_attribute_type type, const char *key, + struct mail_attribute_value *value_r); struct mailbox_attribute_iter * index_storage_attribute_iter_init(struct mailbox *box, enum mail_attribute_type type,
--- a/src/lib-storage/mail-storage-private.h Tue Feb 05 03:37:47 2013 +0200 +++ b/src/lib-storage/mail-storage-private.h Tue Feb 05 03:53:40 2013 +0200 @@ -154,7 +154,7 @@ int (*attribute_set)(struct mailbox *box, enum mail_attribute_type type, const char *key, const char *value); int (*attribute_get)(struct mailbox *box, enum mail_attribute_type type, - const char *key, const char **value_r); + const char *key, struct mail_attribute_value *value_r); struct mailbox_attribute_iter * (*attribute_iter_init)(struct mailbox *box, enum mail_attribute_type type,
--- a/src/lib-storage/mail-storage.c Tue Feb 05 03:37:47 2013 +0200 +++ b/src/lib-storage/mail-storage.c Tue Feb 05 03:53:40 2013 +0200 @@ -1515,7 +1515,7 @@ } int mailbox_attribute_get(struct mailbox *box, enum mail_attribute_type type, - const char *key, const char **value_r) + const char *key, struct mail_attribute_value *value_r) { return box->v.attribute_get(box, type, key, value_r); }
--- a/src/lib-storage/mail-storage.h Tue Feb 05 03:37:47 2013 +0200 +++ b/src/lib-storage/mail-storage.h Tue Feb 05 03:53:40 2013 +0200 @@ -203,6 +203,14 @@ MAIL_ATTRIBUTE_TYPE_PRIVATE, MAIL_ATTRIBUTE_TYPE_SHARED }; +enum mail_attribute_value_flags { + MAIL_ATTRIBUTE_VALUE_FLAG_READONLY = 0x01 +}; + +struct mail_attribute_value { + const char *value; + enum mail_attribute_value_flags flags; +}; struct message_part; struct mail_namespace; @@ -527,7 +535,7 @@ /* Returns value for mailbox attribute key. Returns 1 if value was returned, 0 if value wasn't found (set to NULL), -1 if error */ int mailbox_attribute_get(struct mailbox *box, enum mail_attribute_type type, - const char *key, const char **value_r); + const char *key, struct mail_attribute_value *value_r); /* Iterate through mailbox attributes of the given type. The prefix can be used to restrict what attributes are returned. */