# HG changeset patch # User Timo Sirainen # Date 1302272774 -10800 # Node ID dafc2dcc1a64c458def93f739acdc2e5adb3be40 # Parent 18e87d50a10a7ab30c96e32d8340a0e6ca6f56b6 lib-storage: Added mail_namespaces_init_location() for creating a single namespace for user. diff -r 18e87d50a10a -r dafc2dcc1a64 src/lib-storage/mail-namespace.c --- a/src/lib-storage/mail-namespace.c Fri Apr 08 16:41:26 2011 +0300 +++ b/src/lib-storage/mail-namespace.c Fri Apr 08 17:26:14 2011 +0300 @@ -272,12 +272,10 @@ int mail_namespaces_init(struct mail_user *user, const char **error_r) { - const struct mail_storage_settings *mail_set, *unexpanded_mail_set; + const struct mail_storage_settings *mail_set; struct mail_namespace_settings *const *ns_set; struct mail_namespace_settings *const *unexpanded_ns_set; struct mail_namespace *namespaces, *ns, **ns_p; - struct mail_namespace_settings *inbox_set, *unexpanded_inbox_set; - const char *error, *driver, *location_source; unsigned int i, count, count2; i_assert(user->initialized); @@ -321,6 +319,19 @@ } /* no namespaces defined, create a default one */ + return mail_namespaces_init_location(user, NULL, error_r); +} + +int mail_namespaces_init_location(struct mail_user *user, const char *location, + const char **error_r) +{ + struct mail_namespace_settings *inbox_set, *unexpanded_inbox_set; + struct mail_namespace *ns; + const struct mail_storage_settings *mail_set, *unexpanded_mail_set; + const char *error, *driver, *location_source; + + i_assert(location == NULL || *location != '\0'); + ns = i_new(struct mail_namespace, 1); ns->refcount = 1; ns->type = NAMESPACE_PRIVATE; @@ -336,7 +347,11 @@ *unexpanded_inbox_set = *inbox_set; driver = NULL; - if (*mail_set->mail_location != '\0') { + mail_set = mail_user_set_get_storage_set(user); + if (location != NULL) { + inbox_set->location = p_strdup(user->pool, location); + location_source = "mail_location parameter"; + } else if (*mail_set->mail_location != '\0') { unexpanded_mail_set = mail_user_set_get_driver_settings( user->set_info, user->unexpanded_set, MAIL_STORAGE_SET_DRIVER_NAME); diff -r 18e87d50a10a -r dafc2dcc1a64 src/lib-storage/mail-namespace.h --- a/src/lib-storage/mail-namespace.h Fri Apr 08 16:41:26 2011 +0300 +++ b/src/lib-storage/mail-namespace.h Fri Apr 08 17:26:14 2011 +0300 @@ -74,6 +74,8 @@ }; int mail_namespaces_init(struct mail_user *user, const char **error_r); +int mail_namespaces_init_location(struct mail_user *user, const char *location, + const char **error_r); struct mail_namespace *mail_namespaces_init_empty(struct mail_user *user); /* Deinitialize all namespaces. mail_user_deinit() calls this automatically for user's namespaces. */