dovecot-2.2: lib-storage: mailbox_attribute_set() now uses struc...

dovecot at dovecot.org dovecot at dovecot.org
Tue Mar 19 13:34:27 EET 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/2396eb0a3e3f
changeset: 16044:2396eb0a3e3f
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Mar 19 13:34:12 2013 +0200
description:
lib-storage: mailbox_attribute_set() now uses struct mail_attribute_value.
This allows settig the last_change value, as well as using streams and
setting other flags in future.

diffstat:

 src/doveadm/dsync/dsync-mailbox-import.c    |   7 ++++++-
 src/lib-imap-urlauth/imap-urlauth-backend.c |   4 +++-
 src/lib-storage/index/index-attribute.c     |   8 ++++----
 src/lib-storage/index/index-storage.h       |   4 ++--
 src/lib-storage/mail-storage-private.h      |   4 ++--
 src/lib-storage/mail-storage.c              |  11 ++++++++---
 src/lib-storage/mail-storage.h              |   4 ++--
 src/plugins/acl/acl-attributes.c            |  11 ++++++-----
 src/plugins/acl/acl-storage.h               |   4 ++--
 9 files changed, 35 insertions(+), 22 deletions(-)

diffs (177 lines):

diff -r 790bb5dfadc6 -r 2396eb0a3e3f src/doveadm/dsync/dsync-mailbox-import.c
--- a/src/doveadm/dsync/dsync-mailbox-import.c	Tue Mar 19 12:39:43 2013 +0200
+++ b/src/doveadm/dsync/dsync-mailbox-import.c	Tue Mar 19 13:34:12 2013 +0200
@@ -299,8 +299,13 @@
 		}
 	}
 	if (attr->value != NULL) {
+		struct mail_attribute_value value;
+
+		memset(&value, 0, sizeof(value));
+		value.value = attr->value;
+		value.last_change = attr->last_change;
 		ret = mailbox_attribute_set(importer->trans, attr->type,
-					    attr->key, attr->value);
+					    attr->key, &value);
 	} else {
 		ret = mailbox_attribute_unset(importer->trans, attr->type,
 					      attr->key);
diff -r 790bb5dfadc6 -r 2396eb0a3e3f src/lib-imap-urlauth/imap-urlauth-backend.c
--- a/src/lib-imap-urlauth/imap-urlauth-backend.c	Tue Mar 19 12:39:43 2013 +0200
+++ b/src/lib-imap-urlauth/imap-urlauth-backend.c	Tue Mar 19 13:34:12 2013 +0200
@@ -47,8 +47,10 @@
 		random_fill(mailbox_key_r, IMAP_URLAUTH_KEY_LEN);
 		mailbox_key_hex = binary_to_hex(mailbox_key_r,
 						IMAP_URLAUTH_KEY_LEN);
+		memset(&urlauth_key, 0, sizeof(urlauth_key));
+		urlauth_key.value = mailbox_key_hex;
 		ret = mailbox_attribute_set(trans, MAIL_ATTRIBUTE_TYPE_PRIVATE,
-					    IMAP_URLAUTH_KEY, mailbox_key_hex);
+					    IMAP_URLAUTH_KEY, &urlauth_key);
 		if (ret < 0)
 			return -1;
 		if (user->mail_debug) {
diff -r 790bb5dfadc6 -r 2396eb0a3e3f src/lib-storage/index/index-attribute.c
--- a/src/lib-storage/index/index-attribute.c	Tue Mar 19 12:39:43 2013 +0200
+++ b/src/lib-storage/index/index-attribute.c	Tue Mar 19 13:34:12 2013 +0200
@@ -173,8 +173,8 @@
 }
 
 int index_storage_attribute_set(struct mailbox_transaction_context *t,
-				enum mail_attribute_type type,
-				const char *key, const char *value)
+				enum mail_attribute_type type, const char *key,
+				const struct mail_attribute_value *value)
 {
 	struct dict_transaction_context *dtrans;
 	const char *mailbox_prefix;
@@ -195,8 +195,8 @@
 		const char *prefixed_key =
 			key_get_prefixed(type, mailbox_prefix, key);
 
-		if (value != NULL) {
-			dict_set(dtrans, prefixed_key, value);
+		if (value->value != NULL) {
+			dict_set(dtrans, prefixed_key, value->value);
 			mail_index_attribute_set(t->itrans, pvt, key);
 		} else {
 			dict_unset(dtrans, prefixed_key);
diff -r 790bb5dfadc6 -r 2396eb0a3e3f src/lib-storage/index/index-storage.h
--- a/src/lib-storage/index/index-storage.h	Tue Mar 19 12:39:43 2013 +0200
+++ b/src/lib-storage/index/index-storage.h	Tue Mar 19 13:34:12 2013 +0200
@@ -117,8 +117,8 @@
 			       struct mailbox_metadata *metadata_r);
 
 int index_storage_attribute_set(struct mailbox_transaction_context *t,
-				enum mail_attribute_type type,
-				const char *key, const char *value);
+				enum mail_attribute_type type, const char *key,
+				const struct mail_attribute_value *value);
 int index_storage_attribute_get(struct mailbox_transaction_context *t,
 				enum mail_attribute_type type, const char *key,
 				struct mail_attribute_value *value_r);
diff -r 790bb5dfadc6 -r 2396eb0a3e3f src/lib-storage/mail-storage-private.h
--- a/src/lib-storage/mail-storage-private.h	Tue Mar 19 12:39:43 2013 +0200
+++ b/src/lib-storage/mail-storage-private.h	Tue Mar 19 13:34:12 2013 +0200
@@ -154,8 +154,8 @@
 	int (*set_subscribed)(struct mailbox *box, bool set);
 
 	int (*attribute_set)(struct mailbox_transaction_context *t,
-			     enum mail_attribute_type type,
-			     const char *key, const char *value);
+			     enum mail_attribute_type type, const char *key,
+			     const struct mail_attribute_value *value);
 	int (*attribute_get)(struct mailbox_transaction_context *t,
 			     enum mail_attribute_type type, const char *key,
 			     struct mail_attribute_value *value_r);
diff -r 790bb5dfadc6 -r 2396eb0a3e3f src/lib-storage/mail-storage.c
--- a/src/lib-storage/mail-storage.c	Tue Mar 19 12:39:43 2013 +0200
+++ b/src/lib-storage/mail-storage.c	Tue Mar 19 13:34:12 2013 +0200
@@ -1522,16 +1522,21 @@
 }
 
 int mailbox_attribute_set(struct mailbox_transaction_context *t,
-			  enum mail_attribute_type type,
-			  const char *key, const char *value)
+			  enum mail_attribute_type type, const char *key,
+			  const struct mail_attribute_value *value)
 {
+	i_assert(value->value != NULL);
+
 	return t->box->v.attribute_set(t, type, key, value);
 }
 
 int mailbox_attribute_unset(struct mailbox_transaction_context *t,
 			    enum mail_attribute_type type, const char *key)
 {
-	return t->box->v.attribute_set(t, type, key, NULL);
+	struct mail_attribute_value value;
+
+	memset(&value, 0, sizeof(value));
+	return t->box->v.attribute_set(t, type, key, &value);
 }
 
 int mailbox_attribute_get(struct mailbox_transaction_context *t,
diff -r 790bb5dfadc6 -r 2396eb0a3e3f src/lib-storage/mail-storage.h
--- a/src/lib-storage/mail-storage.h	Tue Mar 19 12:39:43 2013 +0200
+++ b/src/lib-storage/mail-storage.h	Tue Mar 19 13:34:12 2013 +0200
@@ -553,8 +553,8 @@
    IMAP METADATA, so for Dovecot-specific keys use
    MAILBOX_ATTRIBUTE_PREFIX_DOVECOT. */
 int mailbox_attribute_set(struct mailbox_transaction_context *t,
-			  enum mail_attribute_type type,
-			  const char *key, const char *value);
+			  enum mail_attribute_type type, const char *key,
+			  const struct mail_attribute_value *value);
 /* Delete mailbox attribute key. */
 int mailbox_attribute_unset(struct mailbox_transaction_context *t,
 			    enum mail_attribute_type type, const char *key);
diff -r 790bb5dfadc6 -r 2396eb0a3e3f src/plugins/acl/acl-attributes.c
--- a/src/plugins/acl/acl-attributes.c	Tue Mar 19 12:39:43 2013 +0200
+++ b/src/plugins/acl/acl-attributes.c	Tue Mar 19 13:34:12 2013 +0200
@@ -17,8 +17,9 @@
 	bool failed;
 };
 
-static int acl_attribute_update_acl(struct mailbox_transaction_context *t,
-				    const char *key, const char *value)
+static int
+acl_attribute_update_acl(struct mailbox_transaction_context *t, const char *key,
+			 const struct mail_attribute_value *value)
 {
 	const char *id, *const *rights, *error;
 	struct acl_rights_update update;
@@ -38,7 +39,7 @@
 	update.modify_mode = ACL_MODIFY_MODE_REPLACE;
 	update.neg_modify_mode = ACL_MODIFY_MODE_REPLACE;
 	id = key + strlen(MAILBOX_ATTRIBUTE_PREFIX_ACL);
-	rights = value == NULL ? NULL : t_strsplit(value, " ");
+	rights = value->value == NULL ? NULL : t_strsplit(value->value, " ");
 	if (acl_rights_update_import(&update, id, rights, &error) < 0) {
 		mail_storage_set_error(t->box->storage, MAIL_ERROR_PARAMS, error);
 		return -1;
@@ -125,8 +126,8 @@
 }
 
 int acl_attribute_set(struct mailbox_transaction_context *t,
-		      enum mail_attribute_type type,
-		      const char *key, const char *value)
+		      enum mail_attribute_type type, const char *key,
+		      const struct mail_attribute_value *value)
 {
 	struct acl_mailbox *abox = ACL_CONTEXT(t->box);
 
diff -r 790bb5dfadc6 -r 2396eb0a3e3f src/plugins/acl/acl-storage.h
--- a/src/plugins/acl/acl-storage.h	Tue Mar 19 12:39:43 2013 +0200
+++ b/src/plugins/acl/acl-storage.h	Tue Mar 19 13:34:12 2013 +0200
@@ -32,8 +32,8 @@
 			   const struct acl_rights_update *update);
 
 int acl_attribute_set(struct mailbox_transaction_context *t,
-		      enum mail_attribute_type type,
-		      const char *key, const char *value);
+		      enum mail_attribute_type type, const char *key,
+		      const struct mail_attribute_value *value);
 int acl_attribute_get(struct mailbox_transaction_context *t,
 		      enum mail_attribute_type type, const char *key,
 		      struct mail_attribute_value *value_r);


More information about the dovecot-cvs mailing list