Mercurial > dovecot > original-hg > dovecot-1.2
diff src/plugins/convert/convert-plugin.c @ 6976:7cedc391e6c5 HEAD
Convert only after namespaces are created. Convert mailboxes to INBOX
namespace.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sun, 09 Dec 2007 15:47:03 +0200 |
parents | baf570ca608b |
children | 7ed926ed7aa4 |
line wrap: on
line diff
--- a/src/plugins/convert/convert-plugin.c Sun Dec 09 15:01:14 2007 +0200 +++ b/src/plugins/convert/convert-plugin.c Sun Dec 09 15:47:03 2007 +0200 @@ -1,6 +1,7 @@ /* Copyright (c) 2006-2007 Dovecot authors, see the included COPYING file */ #include "lib.h" +#include "mail-namespace.h" #include "convert-storage.h" #include "convert-plugin.h" @@ -8,19 +9,19 @@ const char *convert_plugin_version = PACKAGE_VERSION; -void convert_plugin_init(void) +static void (*convert_next_hook_mail_namespaces_created) + (struct mail_namespace *namespaces); + +static void +convert_hook_mail_namespaces_created(struct mail_namespace *namespaces) { - const char *convert_mail, *mail, *str; + const char *convert_mail, *str; struct convert_settings set; convert_mail = getenv("CONVERT_MAIL"); if (convert_mail == NULL) return; - mail = getenv("MAIL"); - if (mail == NULL) - i_fatal("convert plugin: MAIL unset"); - memset(&set, 0, sizeof(set)); set.user = getenv("USER"); if (set.user == NULL) @@ -29,16 +30,26 @@ if (set.home == NULL) i_fatal("convert plugin: HOME unset"); - set.skip_broken_mailboxes = getenv("CONVERT_SKIP_BROKEN_MAILBOXES") != NULL; + set.skip_broken_mailboxes = + getenv("CONVERT_SKIP_BROKEN_MAILBOXES") != NULL; set.skip_dotdirs = getenv("CONVERT_SKIP_DOTDIRS") != NULL; str = getenv("CONVERT_ALT_HIERARCHY_CHAR"); set.alt_hierarchy_char = str != NULL && *str != '\0' ? *str : '_'; - if (convert_storage(convert_mail, mail, &set) < 0) - exit(FATAL_DEFAULT); + if (convert_storage(convert_mail, namespaces, &set) < 0) + i_fatal("Mailbox conversion failed, exiting"); +} + +void convert_plugin_init(void) +{ + convert_next_hook_mail_namespaces_created = + hook_mail_namespaces_created; + hook_mail_namespaces_created = convert_hook_mail_namespaces_created; } void convert_plugin_deinit(void) { + hook_mail_namespaces_created = + convert_next_hook_mail_namespaces_created; }