From a6c90763ec058317613174b418534cc07d7119e7 Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Tue, 11 Feb 2014 17:40:58 +0000 Subject: [PATCH] Add voicemail parameter storage-dir-shared If this is set to true (default false) we assume the storage-dir is shared, organized by realm/domain, with uses other than voicemail, so we adopt a directory structure of: //voicemail/ --- .../mod_voicemail/mod_voicemail.c | 28 +++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/src/mod/applications/mod_voicemail/mod_voicemail.c b/src/mod/applications/mod_voicemail/mod_voicemail.c index b3ed3e5bd2..75e34fecfa 100644 --- a/src/mod/applications/mod_voicemail/mod_voicemail.c +++ b/src/mod/applications/mod_voicemail/mod_voicemail.c @@ -155,6 +155,7 @@ struct vm_profile { char *vmain_ext; char *tone_spec; char *storage_dir; + switch_bool_t storage_dir_shared; char *callback_dialplan; char *callback_context; char *email_body; @@ -629,6 +630,8 @@ vm_profile_t *profile_set_config(vm_profile_t *profile) &profile->tone_spec, "%(1000, 0, 640)", &profile->config_str_pool, NULL, NULL); SWITCH_CONFIG_SET_ITEM(profile->config[i++], "storage-dir", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, &profile->storage_dir, "", &profile->config_str_pool, NULL, NULL); + SWITCH_CONFIG_SET_ITEM(profile->config[i++], "storage-dir-shared", SWITCH_CONFIG_BOOL, CONFIG_RELOADABLE, + &profile->storage_dir_shared, SWITCH_FALSE, NULL, NULL, NULL); SWITCH_CONFIG_SET_ITEM(profile->config[i++], "callback-dialplan", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, &profile->callback_dialplan, "XML", &profile->config_str_pool, NULL, NULL); SWITCH_CONFIG_SET_ITEM(profile->config[i++], "callback-context", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, @@ -2608,9 +2611,16 @@ static void voicemail_check_main(switch_core_session_t *session, vm_profile_t *p } else if (!zstr(storage_dir)) { dir_path = switch_core_session_sprintf(session, "%s%s%s", storage_dir, SWITCH_PATH_SEPARATOR, myid); } else if (!zstr(profile->storage_dir)) { - dir_path = - switch_core_session_sprintf(session, "%s%s%s%s%s", profile->storage_dir, SWITCH_PATH_SEPARATOR, domain_name, - SWITCH_PATH_SEPARATOR, myid); + if (profile->storage_dir_shared) { + dir_path = + switch_core_session_sprintf(session, "%s%s%s%s%s%s%s", profile->storage_dir, SWITCH_PATH_SEPARATOR, domain_name, + SWITCH_PATH_SEPARATOR, "voicemail", + SWITCH_PATH_SEPARATOR, myid); + } else { + dir_path = + switch_core_session_sprintf(session, "%s%s%s%s%s", profile->storage_dir, SWITCH_PATH_SEPARATOR, domain_name, + SWITCH_PATH_SEPARATOR, myid); + } } else { dir_path = switch_core_session_sprintf(session, "%s%svoicemail%s%s%s%s%s%s", SWITCH_GLOBAL_dirs.storage_dir, SWITCH_PATH_SEPARATOR, @@ -2811,7 +2821,11 @@ static switch_status_t deliver_vm(vm_profile_t *profile, } else if (!zstr(storage_dir)) { dir_path = switch_mprintf("%s%s%s", storage_dir, SWITCH_PATH_SEPARATOR, myid); } else if (!zstr(profile->storage_dir)) { - dir_path = switch_mprintf("%s%s%s%s%s", profile->storage_dir, SWITCH_PATH_SEPARATOR, domain_name, SWITCH_PATH_SEPARATOR, myid); + if (profile->storage_dir_shared) { + dir_path = switch_mprintf("%s%s%s%s%s%s%s", profile->storage_dir, SWITCH_PATH_SEPARATOR, domain_name, SWITCH_PATH_SEPARATOR, "voicemail", SWITCH_PATH_SEPARATOR, myid); + } else { + dir_path = switch_mprintf("%s%s%s%s%s", profile->storage_dir, SWITCH_PATH_SEPARATOR, domain_name, SWITCH_PATH_SEPARATOR, myid); + } } else { dir_path = switch_mprintf("%s%svoicemail%s%s%s%s%s%s", SWITCH_GLOBAL_dirs.storage_dir, SWITCH_PATH_SEPARATOR, @@ -3481,7 +3495,11 @@ static switch_status_t voicemail_leave_main(switch_core_session_t *session, vm_p } else if (!zstr(storage_dir)) { dir_path = switch_core_session_sprintf(session, "%s%s%s", storage_dir, SWITCH_PATH_SEPARATOR, id); } else if (!zstr(profile->storage_dir)) { - dir_path = switch_core_session_sprintf(session, "%s%s%s%s%s", profile->storage_dir, SWITCH_PATH_SEPARATOR, domain_name, SWITCH_PATH_SEPARATOR, id); + if (profile->storage_dir_shared) { + dir_path = switch_core_session_sprintf(session, "%s%s%s%s%s%s%s", profile->storage_dir, SWITCH_PATH_SEPARATOR, domain_name, SWITCH_PATH_SEPARATOR, "voicemail", SWITCH_PATH_SEPARATOR, id); + } else { + dir_path = switch_core_session_sprintf(session, "%s%s%s%s%s", profile->storage_dir, SWITCH_PATH_SEPARATOR, domain_name, SWITCH_PATH_SEPARATOR, id); + } } else { dir_path = switch_core_session_sprintf(session, "%s%svoicemail%s%s%s%s%s%s", SWITCH_GLOBAL_dirs.storage_dir, SWITCH_PATH_SEPARATOR,