]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Splitt off mailbox_settings_get_vname()
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 28 Aug 2024 01:39:28 +0000 (04:39 +0300)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Wed, 12 Feb 2025 10:34:14 +0000 (12:34 +0200)
src/lib-storage/list/mailbox-list-iter.c
src/lib-storage/mail-storage-settings.c
src/lib-storage/mail-storage-settings.h

index eea9115aef2d3b238b8425dd0c82c8d8119ae068..b472cd81e8fbe6971b39c774926e11f0ce94bd2a 100644 (file)
@@ -84,20 +84,15 @@ static const struct mailbox_settings *
 mailbox_settings_add_ns_prefix(pool_t pool, struct mail_namespace *ns,
                               const struct mailbox_settings *in_set)
 {
-       struct mailbox_settings *out_set;
+       const char *vname;
 
-       if (ns->prefix_len == 0 || strcasecmp(in_set->name, "INBOX") == 0)
+       vname = mailbox_settings_get_vname(pool, ns, in_set);
+       if (vname == in_set->name)
                return in_set;
 
-       out_set = p_new(pool, struct mailbox_settings, 1);
-       *out_set = *in_set;
-       if (*in_set->name == '\0') {
-               /* namespace prefix itself */
-               out_set->name = p_strndup(pool, ns->prefix, ns->prefix_len-1);
-       } else {
-               out_set->name =
-                       p_strconcat(pool, ns->prefix, in_set->name, NULL);
-       }
+       struct mailbox_settings *out_set =
+               p_memdup(pool, in_set, sizeof(*in_set));
+       out_set->name = vname;
        return out_set;
 }
 
index 8733ba5d6de5241443e4a9a7a277a0fafd44db7f..94ce15ce0faf7a04dd7145e1cae53bd74654facd 100644 (file)
@@ -1070,3 +1070,18 @@ void mail_storage_2nd_settings_reset(struct settings_instance *instance,
                }
        } T_END;
 }
+
+const char *
+mailbox_settings_get_vname(pool_t pool, const struct mail_namespace *ns,
+                          const struct mailbox_settings *set)
+{
+       if (ns->prefix_len == 0 || strcasecmp(set->name, "INBOX") == 0)
+               return set->name;
+
+       if (*set->name == '\0') {
+               /* namespace prefix itself */
+               return p_strndup(pool, ns->prefix, ns->prefix_len-1);
+       } else {
+               return p_strconcat(pool, ns->prefix, set->name, NULL);
+       }
+}
index c4dd5b79a0709a73691c3c980abe5699abe0b371..f4a1ba20c7028a1008a9d5d6bc9cef10b00a31a2 100644 (file)
@@ -209,6 +209,11 @@ bool mail_user_set_get_postmaster_smtp(const struct mail_user_settings *set,
 void mail_storage_2nd_settings_reset(struct settings_instance *instance,
                                     const char *key_prefix);
 
+/* Return mailbox_settings->name as vname (with namespace prefix). */
+const char *
+mailbox_settings_get_vname(pool_t pool, const struct mail_namespace *ns,
+                          const struct mailbox_settings *set);
+
 bool mail_user_settings_update_special_use(struct mail_user *user,
                                           const struct mail_storage_settings *set,
                                           const char **error_r);