dovecot-2.2: Replaced dict_init() with dict_init_full() in vario...

dovecot at dovecot.org dovecot at dovecot.org
Thu Aug 28 13:12:20 UTC 2014


details:   http://hg.dovecot.org/dovecot-2.2/rev/866bb1354e85
changeset: 17753:866bb1354e85
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Aug 28 22:10:25 2014 +0900
description:
Replaced dict_init() with dict_init_full() in various places.

diffstat:

 src/lib-storage/index/index-attribute.c    |  13 ++++++++-----
 src/plugins/last-login/last-login-plugin.c |   9 +++++++--
 src/plugins/quota/quota-dict.c             |  10 +++++++---
 src/plugins/quota/quota.c                  |  13 +++++++++----
 4 files changed, 31 insertions(+), 14 deletions(-)

diffs (106 lines):

diff -r 58c3676c116c -r 866bb1354e85 src/lib-storage/index/index-attribute.c
--- a/src/lib-storage/index/index-attribute.c	Thu Aug 28 21:57:34 2014 +0900
+++ b/src/lib-storage/index/index-attribute.c	Thu Aug 28 22:10:25 2014 +0900
@@ -82,6 +82,7 @@
 	struct mail_storage *storage = box->storage;
 	struct mail_namespace *ns;
 	struct mailbox_metadata metadata;
+	struct dict_settings set;
 	const char *error;
 
 	if (mailbox_get_metadata(box, MAILBOX_METADATA_GUID, &metadata) < 0)
@@ -118,11 +119,13 @@
 		return -1;
 	}
 
-	if (dict_init(storage->set->mail_attribute_dict,
-		      DICT_DATA_TYPE_STRING,
-		      storage->user->username,
-		      storage->user->set->base_dir,
-		      &storage->_shared_attr_dict, &error) < 0) {
+	memset(&set, 0, sizeof(set));
+	set.username = storage->user->username;
+	set.base_dir = storage->user->set->base_dir;
+	if (mail_user_get_home(storage->user, &set.home_dir) <= 0)
+		set.home_dir = NULL;
+	if (dict_init_full(storage->set->mail_attribute_dict, &set,
+			   &storage->_shared_attr_dict, &error) < 0) {
 		mail_storage_set_critical(storage,
 			"mail_attribute_dict: dict_init(%s) failed: %s",
 			storage->set->mail_attribute_dict, error);
diff -r 58c3676c116c -r 866bb1354e85 src/plugins/last-login/last-login-plugin.c
--- a/src/plugins/last-login/last-login-plugin.c	Thu Aug 28 21:57:34 2014 +0900
+++ b/src/plugins/last-login/last-login-plugin.c	Thu Aug 28 22:10:25 2014 +0900
@@ -61,6 +61,7 @@
 	struct mail_user_vfuncs *v = user->vlast;
 	struct last_login_user *luser;
 	struct dict *dict;
+	struct dict_settings set;
 	struct dict_transaction_context *trans;
 	const char *dict_value, *key_name, *error;
 
@@ -74,8 +75,12 @@
 	if (dict_value == NULL)
 		return;
 
-	if (dict_init(dict_value, DICT_DATA_TYPE_STRING, user->username,
-		      user->set->base_dir, &dict, &error) < 0) {
+	memset(&set, 0, sizeof(set));
+	set.username = user->username;
+	set.base_dir = user->set->base_dir;
+	if (mail_user_get_home(user, &set.home_dir) <= 0)
+		set.home_dir = NULL;
+	if (dict_init_full(dict_value, &set, &dict, &error) < 0) {
 		i_error("last_login_dict: dict_init(%s) failed: %s",
 			dict_value, error);
 		return;
diff -r 58c3676c116c -r 866bb1354e85 src/plugins/quota/quota-dict.c
--- a/src/plugins/quota/quota-dict.c	Thu Aug 28 21:57:34 2014 +0900
+++ b/src/plugins/quota/quota-dict.c	Thu Aug 28 22:10:25 2014 +0900
@@ -32,6 +32,7 @@
 			   const char **error_r)
 {
 	struct dict_quota_root *root = (struct dict_quota_root *)_root;
+	struct dict_settings set;
 	const char *username, *p, *error;
 
 	p = args == NULL ? NULL : strchr(args, ':');
@@ -78,9 +79,12 @@
 
 	/* FIXME: we should use 64bit integer as datatype instead but before
 	   it can actually be used don't bother */
-	if (dict_init(args, DICT_DATA_TYPE_STRING, username,
-		      _root->quota->user->set->base_dir, &root->dict,
-		      &error) < 0) {
+	memset(&set, 0, sizeof(set));
+	set.username = username;
+	set.base_dir = _root->quota->user->set->base_dir;
+	if (mail_user_get_home(_root->quota->user, &set.home_dir) <= 0)
+		set.home_dir = NULL;
+	if (dict_init_full(args, &set, &root->dict, &error) < 0) {
 		*error_r = t_strdup_printf("dict_init(%s) failed: %s", args, error);
 		return -1;
 	}
diff -r 58c3676c116c -r 866bb1354e85 src/plugins/quota/quota.c
--- a/src/plugins/quota/quota.c	Thu Aug 28 21:57:34 2014 +0900
+++ b/src/plugins/quota/quota.c	Thu Aug 28 22:10:25 2014 +0900
@@ -664,10 +664,15 @@
 	}
 
 	if (root->limit_set_dict == NULL) {
-		if (dict_init(root->set->limit_set, DICT_DATA_TYPE_STRING,
-			      root->quota->user->username,
-			      root->quota->user->set->base_dir,
-			      &root->limit_set_dict, error_r) < 0)
+		struct dict_settings set;
+
+		memset(&set, 0, sizeof(set));
+		set.username = root->quota->user->username;
+		set.base_dir = root->quota->user->set->base_dir;
+		if (mail_user_get_home(root->quota->user, &set.home_dir) <= 0)
+			set.home_dir = NULL;
+		if (dict_init_full(root->set->limit_set, &set,
+				   &root->limit_set_dict, error_r) < 0)
 			return -1;
 	}
 


More information about the dovecot-cvs mailing list