diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index 579e8c374a..f1f70f8170 100644 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -12325,70 +12325,6 @@ static int load_config(int reload) if ((val = ast_variable_retrieve(cfg, "general", "pollmailboxes"))) poll_mailboxes = ast_true(val); - if (ucfg) { - for (cat = ast_category_browse(ucfg, NULL); cat ; cat = ast_category_browse(ucfg, cat)) { - if (!strcasecmp(cat, "general")) { - continue; - } - if (!ast_true(ast_config_option(ucfg, cat, "hasvoicemail"))) - continue; - if ((current = find_or_create(userscontext, cat))) { - populate_defaults(current); - apply_options_full(current, ast_variable_browse(ucfg, cat)); - ast_copy_string(current->context, userscontext, sizeof(current->context)); - if (!ast_strlen_zero(current->password) && current->passwordlocation == OPT_PWLOC_VOICEMAILCONF) { - current->passwordlocation = OPT_PWLOC_USERSCONF; - } - - switch (current->passwordlocation) { - case OPT_PWLOC_SPOOLDIR: - snprintf(secretfn, sizeof(secretfn), "%s%s/%s/secret.conf", VM_SPOOL_DIR, current->context, current->mailbox); - read_password_from_file(secretfn, current->password, sizeof(current->password)); - } - } - } - ast_config_destroy(ucfg); - } - cat = ast_category_browse(cfg, NULL); - while (cat) { - if (strcasecmp(cat, "general")) { - var = ast_variable_browse(cfg, cat); - if (strcasecmp(cat, "zonemessages")) { - /* Process mailboxes in this context */ - while (var) { - append_mailbox(cat, var->name, var->value); - var = var->next; - } - } else { - /* Timezones in this context */ - while (var) { - struct vm_zone *z; - if ((z = ast_malloc(sizeof(*z)))) { - char *msg_format, *tzone; - msg_format = ast_strdupa(var->value); - tzone = strsep(&msg_format, "|,"); - if (msg_format) { - ast_copy_string(z->name, var->name, sizeof(z->name)); - ast_copy_string(z->timezone, tzone, sizeof(z->timezone)); - ast_copy_string(z->msg_format, msg_format, sizeof(z->msg_format)); - AST_LIST_LOCK(&zones); - AST_LIST_INSERT_HEAD(&zones, z, list); - AST_LIST_UNLOCK(&zones); - } else { - ast_log(AST_LOG_WARNING, "Invalid timezone definition at line %d\n", var->lineno); - ast_free(z); - } - } else { - AST_LIST_UNLOCK(&users); - ast_config_destroy(cfg); - return -1; - } - var = var->next; - } - } - } - cat = ast_category_browse(cfg, cat); - } memset(fromstring, 0, sizeof(fromstring)); memset(pagerfromstring, 0, sizeof(pagerfromstring)); strcpy(charset, "ISO-8859-1"); @@ -12451,6 +12387,75 @@ static int load_config(int reload) if ((val = ast_variable_retrieve(cfg, "general", "pagerbody"))) { pagerbody = ast_strdup(substitute_escapes(val)); } + + /* load mailboxes from users.conf */ + if (ucfg) { + for (cat = ast_category_browse(ucfg, NULL); cat ; cat = ast_category_browse(ucfg, cat)) { + if (!strcasecmp(cat, "general")) { + continue; + } + if (!ast_true(ast_config_option(ucfg, cat, "hasvoicemail"))) + continue; + if ((current = find_or_create(userscontext, cat))) { + populate_defaults(current); + apply_options_full(current, ast_variable_browse(ucfg, cat)); + ast_copy_string(current->context, userscontext, sizeof(current->context)); + if (!ast_strlen_zero(current->password) && current->passwordlocation == OPT_PWLOC_VOICEMAILCONF) { + current->passwordlocation = OPT_PWLOC_USERSCONF; + } + + switch (current->passwordlocation) { + case OPT_PWLOC_SPOOLDIR: + snprintf(secretfn, sizeof(secretfn), "%s%s/%s/secret.conf", VM_SPOOL_DIR, current->context, current->mailbox); + read_password_from_file(secretfn, current->password, sizeof(current->password)); + } + } + } + ast_config_destroy(ucfg); + } + + /* load mailboxes from voicemail.conf */ + cat = ast_category_browse(cfg, NULL); + while (cat) { + if (strcasecmp(cat, "general")) { + var = ast_variable_browse(cfg, cat); + if (strcasecmp(cat, "zonemessages")) { + /* Process mailboxes in this context */ + while (var) { + append_mailbox(cat, var->name, var->value); + var = var->next; + } + } else { + /* Timezones in this context */ + while (var) { + struct vm_zone *z; + if ((z = ast_malloc(sizeof(*z)))) { + char *msg_format, *tzone; + msg_format = ast_strdupa(var->value); + tzone = strsep(&msg_format, "|,"); + if (msg_format) { + ast_copy_string(z->name, var->name, sizeof(z->name)); + ast_copy_string(z->timezone, tzone, sizeof(z->timezone)); + ast_copy_string(z->msg_format, msg_format, sizeof(z->msg_format)); + AST_LIST_LOCK(&zones); + AST_LIST_INSERT_HEAD(&zones, z, list); + AST_LIST_UNLOCK(&zones); + } else { + ast_log(AST_LOG_WARNING, "Invalid timezone definition at line %d\n", var->lineno); + ast_free(z); + } + } else { + AST_LIST_UNLOCK(&users); + ast_config_destroy(cfg); + return -1; + } + var = var->next; + } + } + } + cat = ast_category_browse(cfg, cat); + } + AST_LIST_UNLOCK(&users); ast_config_destroy(cfg);