Index: apps/app_voicemail.c =================================================================== --- apps/app_voicemail.c (revision 306864) +++ apps/app_voicemail.c (working copy) @@ -1614,7 +1614,7 @@ ast_build_string(&t, &left, "/%s", imapflags); /* End with username */ -#if 1 +#if 0 ast_build_string(&t, &left, "/user=%s}", vms->imapuser); #else ast_build_string(&t, &left, "/user=%s/novalidate-cert}", vms->imapuser); @@ -4182,6 +4182,7 @@ { #ifdef IMAP_STORAGE int newmsgs, oldmsgs; + char *imapseparator; #endif struct vm_state *vms = NULL; char txtfile[PATH_MAX], tmptxtfile[PATH_MAX]; @@ -4261,10 +4262,12 @@ #ifndef IMAP_STORAGE create_dirpath(dir, sizeof(dir), vmu->context, ext, "INBOX"); #else - snprintf(dir, sizeof(dir), "%simap", VM_SPOOL_DIR); - if (mkdir(dir, VOICEMAIL_DIR_MODE) && errno != EEXIST) { - ast_log(LOG_WARNING, "mkdir '%s' failed: %s\n", dir, strerror(errno)); + snprintf(VM_SPOOL_DIR, sizeof(VM_SPOOL_DIR), "%s/voicemail/imap", ast_config_AST_SPOOL_DIR); + if (mkdir(VM_SPOOL_DIR, VOICEMAIL_DIR_MODE) && errno != EEXIST) { + ast_log(LOG_WARNING, "mkdir '%s' failed: %s\n", VM_SPOOL_DIR, strerror(errno)); } + imapseparator = strrchr(VM_SPOOL_DIR, '/'); + *(imapseparator + 1) = '\0'; /* keep trailing slash */ #endif create_dirpath(tmpdir, sizeof(tmpdir), vmu->context, ext, "tmp"); @@ -5236,10 +5239,14 @@ /* Back up the original file, so we can retry the prepend */ if (already_recorded) { ast_filecopy(backup, msgfile, NULL); +#ifndef IMAP_STORAGE /* IMAP stores message length in body of email */ copy(textfile, backup_textfile); +#endif } else { ast_filecopy(msgfile, backup, NULL); +#ifndef IMAP_STORAGE copy(textfile, backup_textfile); +#endif } already_recorded = 1; @@ -9194,6 +9201,9 @@ int res; char *adsi_loaded = ast_module_helper("", "res_adsi", 0, 0, 0, 0); char *smdi_loaded = ast_module_helper("", "res_smdi", 0, 0, 0, 0); +#ifdef IMAP_STORAGE + char *imapseparator; +#endif free(adsi_loaded); free(smdi_loaded); @@ -9227,7 +9237,17 @@ ast_cli_register_multiple(cli_voicemail, sizeof(cli_voicemail) / sizeof(struct ast_cli_entry)); /* compute the location of the voicemail spool directory */ + /* TODO - IMAP_STORAGE path should really stay as voicemail/imap/ to keep things fully separated */ +#ifdef IMAP_STORAGE + snprintf(VM_SPOOL_DIR, sizeof(VM_SPOOL_DIR), "%s/voicemail/imap", ast_config_AST_SPOOL_DIR); + if (mkdir(VM_SPOOL_DIR, VOICEMAIL_DIR_MODE) && errno != EEXIST) { + ast_log(LOG_WARNING, "mkdir '%s' failed: %s\n", VM_SPOOL_DIR, strerror(errno)); + } + imapseparator = strrchr(VM_SPOOL_DIR, '/'); + *(imapseparator + 1) = '\0'; /* keep trailing slash */ +#else snprintf(VM_SPOOL_DIR, sizeof(VM_SPOOL_DIR), "%s/voicemail/", ast_config_AST_SPOOL_DIR); +#endif ast_install_vm_functions(has_voicemail, inboxcount, messagecount);