static void (*autocreate_next_hook_mail_namespaces_created)
(struct mail_namespace *ns);
-static void autocreate_mailboxes(struct mail_storage *storage)
+static void autocreate_mailboxes(struct mail_namespace *namespaces)
{
+ struct mail_namespace *ns;
char env_name[20];
- const char *env;
+ const char *name;
unsigned int i;
i = 1;
- env = getenv("AUTOCREATE");
- while (env != NULL) {
- (void)mail_storage_mailbox_create(storage, env, FALSE);
+ name = getenv("AUTOCREATE");
+ while (name != NULL) {
+ ns = mail_namespace_find(namespaces, &name);
+ if (ns != NULL) {
+ (void)mail_storage_mailbox_create(ns->storage,
+ name, FALSE);
+ }
+
i_snprintf(env_name, sizeof(env_name), "AUTOCREATE%d", ++i);
- env = getenv(env_name);
+ name = getenv(env_name);
}
}
-static void autosubscribe_mailboxes(struct mailbox_list *list)
+static void autosubscribe_mailboxes(struct mail_namespace *namespaces)
{
+ struct mail_namespace *ns;
char env_name[20];
- const char *env;
+ const char *name;
unsigned int i;
i = 1;
- env = getenv("AUTOSUBSCRIBE");
- while (env != NULL) {
- (void)mailbox_list_set_subscribed(list, env, TRUE);
+ name = getenv("AUTOSUBSCRIBE");
+ while (name != NULL) {
+ ns = mail_namespace_find(namespaces, &name);
+ if (ns != NULL)
+ (void)mailbox_list_set_subscribed(ns->list, name, TRUE);
+
i_snprintf(env_name, sizeof(env_name), "AUTOSUBSCRIBE%d", ++i);
- env = getenv(env_name);
+ name = getenv(env_name);
}
}
-static void autocreate_mail_namespaces_created(struct mail_namespace *ns)
+static void
+autocreate_mail_namespaces_created(struct mail_namespace *namespaces)
{
if (autocreate_next_hook_mail_namespaces_created != NULL)
- autocreate_next_hook_mail_namespaces_created(ns);
+ autocreate_next_hook_mail_namespaces_created(namespaces);
- for (; ns != NULL; ns = ns->next) {
- if (ns->type == NAMESPACE_PRIVATE) {
- autocreate_mailboxes(ns->storage);
- autosubscribe_mailboxes(ns->list);
- break;
- }
- }
+ autocreate_mailboxes(namespaces);
+ autosubscribe_mailboxes(namespaces);
}
void autocreate_plugin_init(void)