]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: mail_storage_vfuncs.autodetect() - Change API to return root_path and...
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 15 Nov 2023 21:20:15 +0000 (23:20 +0200)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Wed, 12 Feb 2025 10:34:11 +0000 (12:34 +0200)
This will be necessary once mailbox_list_settings is removed.

src/lib-storage/index/dbox-multi/mdbox-storage.c
src/lib-storage/index/dbox-single/sdbox-storage.c
src/lib-storage/index/maildir/maildir-storage.c
src/lib-storage/index/mbox/mbox-storage.c
src/lib-storage/mail-storage-private.h
src/lib-storage/mail-storage.c

index ca367c5335f07aca6ec76d43b706eb3964774bfa..e5850d3d8e96f8ba60cc027ce8c3312b3d723cbe 100644 (file)
@@ -118,7 +118,9 @@ mdbox_storage_find_root_dir(const struct mail_namespace *ns)
 static bool
 mdbox_storage_autodetect(const struct mail_namespace *ns,
                         struct mailbox_list_settings *set,
-                        const struct mail_storage_settings *mail_set ATTR_UNUSED)
+                        const struct mail_storage_settings *mail_set ATTR_UNUSED,
+                        const char **root_path_r,
+                        const char **inbox_path_r ATTR_UNUSED)
 {
        struct event *event = ns->user->event;
        struct stat st;
@@ -146,7 +148,7 @@ mdbox_storage_autodetect(const struct mail_namespace *ns,
                return FALSE;
        }
 
-       set->root_dir = root_dir;
+       *root_path_r = root_dir;
        return TRUE;
 }
 
index c8d23fb0c04515e0741a724e15666a91b32f4080..7597889c87d1722232df0629c44495a1f69c0413 100644 (file)
@@ -80,7 +80,9 @@ sdbox_storage_find_root_dir(const struct mail_namespace *ns)
 static bool
 sdbox_storage_autodetect(const struct mail_namespace *ns,
                         struct mailbox_list_settings *set,
-                        const struct mail_storage_settings *mail_set ATTR_UNUSED)
+                        const struct mail_storage_settings *mail_set ATTR_UNUSED,
+                        const char **root_path_r,
+                        const char **inbox_path_r ATTR_UNUSED)
 {
        struct event *event = ns->user->event;
        struct stat st;
@@ -110,7 +112,7 @@ sdbox_storage_autodetect(const struct mail_namespace *ns,
                return FALSE;
        }
 
-       set->root_dir = root_dir;
+       *root_path_r = root_dir;
        return TRUE;
 }
 
index 73db6f3f84b6b911608a930bdf9d44a3fdb6e37d..f2f8635859b2556f4c2df55e7e95a95256a4f9be 100644 (file)
@@ -134,7 +134,9 @@ maildir_storage_find_root_dir(const struct mail_namespace *ns)
 static bool
 maildir_storage_autodetect(const struct mail_namespace *ns,
                           struct mailbox_list_settings *set,
-                          const struct mail_storage_settings *mail_set ATTR_UNUSED)
+                          const struct mail_storage_settings *mail_set ATTR_UNUSED,
+                          const char **root_path_r,
+                          const char **inbox_path_r ATTR_UNUSED)
 {
        struct event *event = ns->user->event;
        struct stat st;
@@ -161,7 +163,7 @@ maildir_storage_autodetect(const struct mail_namespace *ns,
                return FALSE;
        }
 
-       set->root_dir = root_dir;
+       *root_path_r = root_dir;
        return TRUE;
 }
 
index ed572f132bda5b29fca0fb338eb36faf49882a0e..f3afc45842b0410c65bb2d860b92e58daebe56d7 100644 (file)
@@ -329,7 +329,8 @@ mbox_storage_find_inbox_file(struct mail_user *user, struct event *event)
 static bool
 mbox_storage_autodetect(const struct mail_namespace *ns,
                        struct mailbox_list_settings *set,
-                       const struct mail_storage_settings *mail_set ATTR_UNUSED)
+                       const struct mail_storage_settings *mail_set ATTR_UNUSED,
+                       const char **root_path_r, const char **inbox_path_r)
 {
        struct event *event = ns->user->event;
        const char *root_dir, *inbox_path;
@@ -356,8 +357,8 @@ mbox_storage_autodetect(const struct mail_namespace *ns,
        if (inbox_path == NULL) {
                inbox_path = mbox_storage_find_inbox_file(ns->user, event);
        }
-       set->root_dir = root_dir;
-       set->inbox_path = inbox_path;
+       *root_path_r = root_dir;
+       *inbox_path_r = inbox_path;
        return TRUE;
 }
 
index 69af3b547ef9a955d4cedf4ba5606aa2fb4dbfb5..41dfe67e13027494b1f6ee98b163d71959ba3309 100644 (file)
@@ -61,9 +61,13 @@ struct mail_storage_vfuncs {
        void (*get_list_settings)(const struct mail_namespace *ns,
                                  struct mailbox_list_settings *set,
                                  const struct mail_storage_settings *mail_set);
+       /* Returns TRUE if mailbox path could be autodetected. root_path_r
+          must be returned in that case. inbox_path_r is NULL already when
+          calling, and means the default INBOX path is used. */
        bool (*autodetect)(const struct mail_namespace *ns,
                           struct mailbox_list_settings *set,
-                          const struct mail_storage_settings *mail_set);
+                          const struct mail_storage_settings *mail_set,
+                          const char **root_path_r, const char **inbox_path_r);
 
        struct mailbox *(*mailbox_alloc)(struct mail_storage *storage,
                                         struct mailbox_list *list,
index c01d83b5964282c54d66caccdd75c8b89b5d4e75..1965e53fe6bf2b78a547c6b04a5b31ed015b8d91 100644 (file)
@@ -144,13 +144,19 @@ mail_storage_autodetect(const struct mail_namespace *ns,
                        const struct mail_storage_settings *mail_set)
 {
        struct mail_storage *const *classes;
+       const char *root_path, *inbox_path = NULL;
        unsigned int i, count;
 
        classes = array_get(&mail_storage_classes, &count);
        for (i = 0; i < count; i++) {
                if (classes[i]->v.autodetect != NULL) {
-                       if (classes[i]->v.autodetect(ns, set, mail_set))
+                       if (classes[i]->v.autodetect(ns, set, mail_set,
+                                                    &root_path, &inbox_path)) {
+                               set->root_dir = root_path;
+                               if (inbox_path != NULL)
+                                       set->inbox_path = inbox_path;
                                return classes[i];
+                       }
                }
        }
        return NULL;