changeset 10273:4109e7f29735 HEAD

Added mail_storage_service_init_settings().
author Timo Sirainen <tss@iki.fi>
date Mon, 09 Nov 2009 13:42:16 -0500
parents 26e6636aa82e
children 409c782237d2
files src/lib-storage/mail-storage-service.c src/lib-storage/mail-storage-service.h
diffstat 2 files changed, 15 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/mail-storage-service.c	Mon Nov 09 13:41:38 2009 -0500
+++ b/src/lib-storage/mail-storage-service.c	Mon Nov 09 13:42:16 2009 -0500
@@ -57,9 +57,6 @@
 
 static struct module *modules = NULL;
 
-static void
-mail_storage_service_all_init_first(struct mail_storage_service_ctx *ctx);
-
 static void set_keyval(struct setting_parser_context *set_parser,
 		       const char *key, const char *value)
 {
@@ -501,8 +498,7 @@
 struct auth_master_connection *
 mail_storage_service_get_auth_conn(struct mail_storage_service_ctx *ctx)
 {
-	if (ctx->conn == NULL)
-		mail_storage_service_all_init_first(ctx);
+	i_assert(ctx->conn != NULL);
 	return ctx->conn;
 }
 
@@ -626,6 +622,8 @@
 {
 	const struct mail_storage_settings *mail_set;
 
+	i_assert(ctx->conn == NULL);
+
 	mail_set = mail_user_set_get_driver_settings(user_info, user_set,
 						MAIL_STORAGE_SET_DRIVER_NAME);
 	ctx->debug = mail_set->mail_debug;
@@ -813,8 +811,8 @@
 	pool_unref(&user->pool);
 }
 
-static void
-mail_storage_service_all_init_first(struct mail_storage_service_ctx *ctx)
+void mail_storage_service_init_settings(struct mail_storage_service_ctx *ctx,
+					const struct mail_storage_service_input *input)
 {
 	const struct setting_parser_info *user_info;
 	const struct mail_user_settings *user_set;
@@ -822,8 +820,11 @@
 	void **sets;
 	pool_t temp_pool;
 
+	if (ctx->conn != NULL)
+		return;
+
 	temp_pool = pool_alloconly_create("service all settings", 4096);
-	if (mail_storage_service_read_settings(ctx, NULL, temp_pool,
+	if (mail_storage_service_read_settings(ctx, input, temp_pool,
 					       &user_info, &error) < 0)
 		i_fatal("%s", error);
 	sets = settings_parser_get_list(ctx->service->set_parser);
@@ -838,8 +839,7 @@
 {
 	if (ctx->auth_list != NULL)
 		(void)auth_master_user_list_deinit(&ctx->auth_list);
-	if (ctx->conn == NULL)
-		mail_storage_service_all_init_first(ctx);
+	mail_storage_service_init_settings(ctx, NULL);
 
 	ctx->auth_list = auth_master_user_list_init(ctx->conn);
 	return auth_master_user_list_count(ctx->auth_list);
--- a/src/lib-storage/mail-storage-service.h	Mon Nov 09 13:41:38 2009 -0500
+++ b/src/lib-storage/mail-storage-service.h	Mon Nov 09 13:42:16 2009 -0500
@@ -46,6 +46,11 @@
 				       pool_t pool,
 				       const struct setting_parser_info **user_info_r,
 				       const char **error_r);
+/* Read settings and initialize context to use them. Do nothing if service is
+   already initialized. This is mainly necessary when calling _get_auth_conn()
+   or _all_init(). */
+void mail_storage_service_init_settings(struct mail_storage_service_ctx *ctx,
+					const struct mail_storage_service_input *input);
 /* Returns 1 if ok, 0 if user wasn't found, -1 if error. */
 int mail_storage_service_lookup(struct mail_storage_service_ctx *ctx,
 				const struct mail_storage_service_input *input,