]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Add struct mail_namespace.user_set
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 14 Nov 2016 21:32:42 +0000 (22:32 +0100)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 18 Nov 2016 11:55:49 +0000 (13:55 +0200)
src/lib-storage/index/shared/shared-storage.c
src/lib-storage/mail-namespace.c
src/lib-storage/mail-namespace.h

index 8a4770325fc1c93988cb676f207b36c1c9e03af9..6a5cd6794a06afc9643a761b2910152b9d5e18ae 100644 (file)
@@ -290,6 +290,7 @@ int shared_storage_get_namespace(struct mail_namespace **_ns,
        new_ns->flags = (NAMESPACE_FLAG_SUBSCRIPTIONS & ns->flags) |
                NAMESPACE_FLAG_LIST_PREFIX | NAMESPACE_FLAG_HIDDEN |
                NAMESPACE_FLAG_AUTOCREATED | NAMESPACE_FLAG_INBOX_ANY;
+       new_ns->user_set = user->set;
        new_ns->mail_set = _storage->set;
        i_array_init(&new_ns->all_storages, 2);
 
index 0c3b088fe6d999013f07d8eae84c06d392f4860d..0455ef6d7211bb4868233dbf7b6e8307a18fe2f4 100644 (file)
@@ -83,6 +83,7 @@ namespace_has_special_use_mailboxes(struct mail_namespace_settings *ns_set)
 }
 
 int mail_namespace_alloc(struct mail_user *user,
+                        void *user_all_settings,
                         struct mail_namespace_settings *ns_set,
                         struct mail_namespace_settings *unexpanded_set,
                         struct mail_namespace **ns_r,
@@ -96,7 +97,9 @@ int mail_namespace_alloc(struct mail_user *user,
        ns->prefix = i_strdup(ns_set->prefix);
        ns->set = ns_set;
        ns->unexpanded_set = unexpanded_set;
-       ns->mail_set = mail_user_set_get_storage_set(user);
+       ns->user_set = user_all_settings;
+       ns->mail_set = mail_user_set_get_driver_settings(user->set_info,
+                               ns->user_set, MAIL_STORAGE_SET_DRIVER_NAME);
        i_array_init(&ns->all_storages, 2);
 
        if (strcmp(ns_set->type, "private") == 0) {
@@ -164,7 +167,8 @@ int mail_namespaces_init_add(struct mail_user *user,
                        ns_set->subscriptions ? "yes" : "no", ns_set->location);
        }
 
-       if ((ret = mail_namespace_alloc(user, ns_set, unexpanded_ns_set,
+       if ((ret = mail_namespace_alloc(user, user->set,
+                                       ns_set, unexpanded_ns_set,
                                        &ns, error_r)) < 0)
                return ret;
 
@@ -484,7 +488,8 @@ int mail_namespaces_init_location(struct mail_user *user, const char *location,
                                    inbox_set->location, NULL);
        }
 
-       if ((ret = mail_namespace_alloc(user, inbox_set, unexpanded_inbox_set,
+       if ((ret = mail_namespace_alloc(user, user->set,
+                                       inbox_set, unexpanded_inbox_set,
                                        &ns, error_r)) < 0)
                return ret;
 
@@ -520,6 +525,7 @@ struct mail_namespace *mail_namespaces_init_empty(struct mail_user *user)
        ns->prefix = i_strdup("");
        ns->flags = NAMESPACE_FLAG_INBOX_USER | NAMESPACE_FLAG_INBOX_ANY |
                NAMESPACE_FLAG_LIST_PREFIX | NAMESPACE_FLAG_SUBSCRIPTIONS;
+       ns->user_set = user->set;
        ns->mail_set = mail_user_set_get_storage_set(user);
        i_array_init(&ns->all_storages, 2);
        user->namespaces = ns;
index a516efd7b6032a44d702e8535e4050b7e300693b..d60e6d966abcbabc992014c1fe642ca2f135bde7 100644 (file)
@@ -70,6 +70,12 @@ struct mail_namespace {
        struct mail_storage *storage; /* default storage */
        ARRAY(struct mail_storage *) all_storages;
 
+       /* This may point to user->set, but it may also point to
+          namespace-specific settings. When accessing namespace-specific
+          settings it should be done through here instead of through the
+          mail_user. */
+       struct mail_user_settings *user_set;
+
        const struct mail_namespace_settings *set, *unexpanded_set;
        const struct mail_storage_settings *mail_set;
 
@@ -80,8 +86,15 @@ struct mail_namespace {
 
 /* Allocate a new namespace, and fill it based on the passed in settings.
    This is the most low-level namespace creation function. The storage isn't
-   initialized for the namespace. */
+   initialized for the namespace.
+
+   user_all_settings normally points to user->set. If you want to override
+   settings for the created namespace, you can duplicate the user's settings
+   and provide a pointer to it here. Note that the pointer must contain
+   ALL the settings, including the dynamic driver-specific settings, so it
+   needs to created via settings-parser API. */
 int mail_namespace_alloc(struct mail_user *user,
+                        void *user_all_settings,
                         struct mail_namespace_settings *ns_set,
                         struct mail_namespace_settings *unexpanded_set,
                         struct mail_namespace **ns_r,