forked from Mirrors/freeswitch
mod_voicemail: Add new vm_fsdb_pref_greeting_get
mod_voicemail_ivr: Added the new param for API vm_fsdb_pref_greeting_get WARNING, you must add it to the config or else module will complain of missing value... With the new API, it will now playback the greeting when setting it. Will need to figure out a better way to deal with api being added in the future... Add support to auto start new message playback and made it default in the config file. mod_voicemail_ivr phrases : make value = 0 as plural (0 messages). Don't tell the option for new message if no new message present. Changes a few default key to match more closely mod_voicemail key settings.
This commit is contained in:
parent
117609d2b3
commit
5542d040a2
|
@ -26,6 +26,7 @@
|
|||
<api name="msg_get" value="vm_fsdb_msg_get" />
|
||||
<api name="msg_forward" value="vm_fsdb_msg_forward" />
|
||||
<api name="pref_greeting_set" value="vm_fsdb_pref_greeting_set" />
|
||||
<api name="pref_greeting_get" value="vm_fsdb_pref_greeting_get" />
|
||||
<api name="pref_recname_set" value="vm_fsdb_pref_recname_set" />
|
||||
<api name="pref_password_set" value="vm_fsdb_pref_password_set" />
|
||||
</apis>
|
||||
|
@ -57,6 +58,9 @@
|
|||
</menu>
|
||||
|
||||
<menu name="std_main_menu">
|
||||
<settings>
|
||||
<param name="Action-On-New-Message" value="new_msg:std_navigator" />
|
||||
</settings>
|
||||
<phrases>
|
||||
<phrase name="msg_count" value="message_count@voicemail_ivr" />
|
||||
<phrase name="say_date" value="say_date_event@voicemail_ivr" />
|
||||
|
@ -89,9 +93,8 @@
|
|||
<key dtmf="4" action="prev_msg" />
|
||||
<key dtmf="7" action="delete_msg" variable="VM-Key-Main-Delete-File" /> <!-- Same key for undelete if it already deleted -->
|
||||
<key dtmf="8" action="menu:std_forward" variable="VM-Key-Main-Forward" />
|
||||
<key dtmf="3" action="save_msg" variable="VM-Key-Main-Save-File" />
|
||||
<key dtmf="2" action="callback" variable="VM-Key-Main-Callback" />
|
||||
<key dtmf="5" action="menu:std_preference" />
|
||||
<key dtmf="2" action="save_msg" variable="VM-Key-Main-Save-File" />
|
||||
<key dtmf="5" action="callback" variable="VM-Key-Main-Callback" />
|
||||
<key dtmf="#" action="return" /> <!-- TODO Might Conflict with future fast-forward -->
|
||||
</keys>
|
||||
</menu>
|
||||
|
@ -105,7 +108,7 @@
|
|||
<key dtmf="2" action="menu:std_select_greeting_slot" variable="VM-Key-Choose-Greeting" />
|
||||
<key dtmf="3" action="menu:std_record_name" variable="VM-Key-Record-Name" />
|
||||
<key dtmf="6" action="menu:std_set_password" variable="VM-Key-Change-Password" />
|
||||
<key dtmf="#" action="return" variable="VM-Key-Main-Menu" />
|
||||
<key dtmf="0" action="return" variable="VM-Key-Main-Menu" />
|
||||
</keys>
|
||||
</menu>
|
||||
|
||||
|
@ -117,7 +120,7 @@
|
|||
</phrases>
|
||||
<keys>
|
||||
<key dtmf="1" action="listen" variable="VM-Key-Listen-File" />
|
||||
<key dtmf="3" action="save" variable="VM-Key-Save-File" />
|
||||
<key dtmf="2" action="save" variable="VM-Key-Save-File" />
|
||||
<key dtmf="4" action="rerecord" variable="VM-Key-ReRecord-File" />
|
||||
<key dtmf="#" action="skip_instruction" />
|
||||
</keys>
|
||||
|
@ -132,7 +135,7 @@
|
|||
</phrases>
|
||||
<keys>
|
||||
<key dtmf="1" action="listen" variable="VM-Key-Listen-File" />
|
||||
<key dtmf="3" action="save" variable="VM-Key-Save-File" />
|
||||
<key dtmf="2" action="save" variable="VM-Key-Save-File" />
|
||||
<key dtmf="4" action="rerecord" variable="VM-Key-ReRecord-File" />
|
||||
<key dtmf="#" action="skip_instruction" />
|
||||
</keys>
|
||||
|
@ -146,7 +149,7 @@
|
|||
</phrases>
|
||||
<keys>
|
||||
<key dtmf="1" action="listen" variable="VM-Key-Listen-File" />
|
||||
<key dtmf="3" action="save" variable="VM-Key-Save-File" />
|
||||
<key dtmf="2" action="save" variable="VM-Key-Save-File" />
|
||||
<key dtmf="4" action="rerecord" variable="VM-Key-ReRecord-File" />
|
||||
<key dtmf="#" action="skip_instruction" />
|
||||
</keys>
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
</macro>
|
||||
|
||||
<macro name="plural_msg">
|
||||
<input pattern="^[01]:(.*):(.*)$" break_on_match="true">
|
||||
<input pattern="^[1]:(.*):(.*)$" break_on_match="true">
|
||||
<match>
|
||||
<action function="play-file" data="$1"/>
|
||||
</match>
|
||||
|
@ -111,10 +111,18 @@
|
|||
</macro>
|
||||
|
||||
<macro name="menu">
|
||||
<input>
|
||||
<match>
|
||||
<input field="${VM-Total-New-Messages}" pattern="^(0)$">
|
||||
<nomatch>
|
||||
<action function="phrase" phrase="press_key@voicemail_ivr" data="${VM-Key-Play-New-Messages}:voicemail/vm-listen_new.wav"/>
|
||||
</nomatch>
|
||||
</input>
|
||||
<input field="${VM-Total-Saved-Messages}" pattern="^(0)$">
|
||||
<nomatch>
|
||||
<action function="phrase" phrase="press_key@voicemail_ivr" data="${VM-Key-Play-Saved-Messages}:voicemail/vm-listen_saved.wav"/>
|
||||
</nomatch>
|
||||
</input>
|
||||
<input>
|
||||
<match>
|
||||
<action function="phrase" phrase="press_key@voicemail_ivr" data="${VM-Key-Config-Menu}:voicemail/vm-advanced.wav"/>
|
||||
<action function="phrase" phrase="press_key@voicemail_ivr" data="${VM-Key-Terminator}:voicemail/vm-to_exit.wav"/>
|
||||
</match>
|
||||
|
@ -264,6 +272,7 @@
|
|||
<macro name="greeting_selected">
|
||||
<input pattern="^(\d+)$">
|
||||
<match>
|
||||
<action function="play-file" data="${VM-Preference-Greeting-File-Path}"/>
|
||||
<action function="play-file" data="voicemail/vm-greeting.wav"/>
|
||||
<action function="say" data="$1" method="pronounced" type="items"/>
|
||||
<action function="play-file" data="voicemail/vm-selected.wav"/>
|
||||
|
|
|
@ -4975,6 +4975,78 @@ done:
|
|||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
#define VM_FSDB_PREF_GREETING_GET_USAGE "<format> <profile> <domain> <user> [slot]"
|
||||
SWITCH_STANDARD_API(vm_fsdb_pref_greeting_get_function)
|
||||
{
|
||||
int slot = -1;
|
||||
char *sql = NULL;
|
||||
char res[254] = "";
|
||||
|
||||
char *id = NULL, *domain = NULL, *profile_name = NULL;
|
||||
vm_profile_t *profile = NULL;
|
||||
|
||||
char *argv[6] = { 0 };
|
||||
char *mycmd = NULL;
|
||||
|
||||
switch_memory_pool_t *pool;
|
||||
|
||||
switch_core_new_memory_pool(&pool);
|
||||
|
||||
if (!zstr(cmd)) {
|
||||
mycmd = switch_core_strdup(pool, cmd);
|
||||
switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
|
||||
}
|
||||
|
||||
if (argv[1])
|
||||
profile_name = argv[1];
|
||||
if (argv[2])
|
||||
domain = argv[2];
|
||||
if (argv[3])
|
||||
id = argv[3];
|
||||
if (argv[4])
|
||||
slot = atoi(argv[4]);
|
||||
|
||||
if (!profile_name || !domain || !id) {
|
||||
stream->write_function(stream, "-ERR Missing Arguments\n");
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (!(profile = get_profile(profile_name))) {
|
||||
stream->write_function(stream, "-ERR Profile not found\n");
|
||||
goto done;
|
||||
}
|
||||
sql = switch_mprintf("select greeting_path from voicemail_prefs WHERE domain = '%q' AND username = '%q'", domain, id);
|
||||
|
||||
vm_execute_sql2str(profile, profile->mutex, sql, res, sizeof(res));
|
||||
|
||||
switch_safe_free(sql);
|
||||
|
||||
profile_rwunlock(profile);
|
||||
|
||||
/* TODO If no slot requested, returned currently selected and figure out the slot number from the file name.
|
||||
* IF slot provided, check if file exist, check if it currently selected */
|
||||
if (zstr(res)) {
|
||||
stream->write_function(stream, "-ERR No greeting found\n");
|
||||
} else {
|
||||
switch_event_t *my_params = NULL;
|
||||
char *ebuf = NULL;
|
||||
|
||||
switch_event_create(&my_params, SWITCH_EVENT_REQUEST_PARAMS);
|
||||
switch_event_add_header(my_params, SWITCH_STACK_BOTTOM, "VM-Preference-Greeting-File-Path", "%s", res);
|
||||
switch_event_add_header(my_params, SWITCH_STACK_BOTTOM, "VM-Preference-Greeting-Slot", "%s", "Not Implemented yet");
|
||||
switch_event_add_header(my_params, SWITCH_STACK_BOTTOM, "VM-Preference-Greeting-Selected", "%s", "True");
|
||||
switch_event_serialize_json(my_params, &ebuf);
|
||||
switch_event_destroy(&my_params);
|
||||
|
||||
stream->write_function(stream, "%s", ebuf);
|
||||
switch_safe_free(ebuf);
|
||||
|
||||
}
|
||||
done:
|
||||
switch_core_destroy_memory_pool(&pool);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
#define VM_FSDB_PREF_RECNAME_SET_USAGE "<profile> <domain> <user> <file-path>"
|
||||
SWITCH_STANDARD_API(vm_fsdb_pref_recname_set_function)
|
||||
{
|
||||
|
@ -5961,6 +6033,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_voicemail_load)
|
|||
|
||||
/* Preferences */
|
||||
SWITCH_ADD_API(commands_api_interface, "vm_fsdb_pref_greeting_set", "vm_fsdb_pref_greeting_set", vm_fsdb_pref_greeting_set_function, VM_FSDB_PREF_GREETING_SET_USAGE);
|
||||
SWITCH_ADD_API(commands_api_interface, "vm_fsdb_pref_greeting_get", "vm_fsdb_pref_greeting_get", vm_fsdb_pref_greeting_get_function, VM_FSDB_PREF_GREETING_GET_USAGE);
|
||||
SWITCH_ADD_API(commands_api_interface, "vm_fsdb_pref_recname_set", "vm_fsdb_pref_recname_set", vm_fsdb_pref_recname_set_function, VM_FSDB_PREF_RECNAME_SET_USAGE);
|
||||
SWITCH_ADD_API(commands_api_interface, "vm_fsdb_pref_password_set", "vm_fsdb_pref_password_set", vm_fsdb_pref_password_set_function, VM_FSDB_PREF_PASSWORD_SET_USAGE);
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ void menu_init(vmivr_profile_t *profile, vmivr_menu_t *menu) {
|
|||
if ((x_phrases = switch_xml_child(x_menu, "phrases"))) {
|
||||
switch_event_import_xml(switch_xml_child(x_phrases, "phrase"), "name", "value", &menu->event_phrases);
|
||||
}
|
||||
if ((x_settings = switch_xml_child(x_profile, "settings"))) {
|
||||
if ((x_settings = switch_xml_child(x_menu, "settings"))) {
|
||||
switch_event_import_xml(switch_xml_child(x_settings, "param"), "name", "value", &menu->event_settings);
|
||||
}
|
||||
|
||||
|
@ -114,6 +114,7 @@ void menu_instance_init(vmivr_menu_t *menu) {
|
|||
void menu_instance_free(vmivr_menu_t *menu) {
|
||||
if (menu->phrase_params) {
|
||||
switch_event_destroy(&menu->phrase_params);
|
||||
menu->phrase_params = NULL;
|
||||
}
|
||||
memset(&menu->ivre_d, 0, sizeof(menu->ivre_d));
|
||||
}
|
||||
|
@ -244,6 +245,8 @@ vmivr_profile_t *get_profile(switch_core_session_t *session, const char *profile
|
|||
profile->api_msg_forward = switch_core_session_strdup(session, val);
|
||||
else if (!strcasecmp(var, "pref_greeting_set") && !profile->api_pref_greeting_set)
|
||||
profile->api_pref_greeting_set = switch_core_session_strdup(session, val);
|
||||
else if (!strcasecmp(var, "pref_greeting_get") && !profile->api_pref_greeting_get)
|
||||
profile->api_pref_greeting_get = switch_core_session_strdup(session, val);
|
||||
else if (!strcasecmp(var, "pref_recname_set") && !profile->api_pref_recname_set)
|
||||
profile->api_pref_recname_set = switch_core_session_strdup(session, val);
|
||||
else if (!strcasecmp(var, "pref_password_set") && !profile->api_pref_password_set)
|
||||
|
@ -255,7 +258,7 @@ vmivr_profile_t *get_profile(switch_core_session_t *session, const char *profile
|
|||
total_options++;
|
||||
}
|
||||
}
|
||||
if (total_options - total_invalid_options != 12) {
|
||||
if (total_options - total_invalid_options != 13) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing api definition for profile '%s'\n", profile_name);
|
||||
profile = NULL;
|
||||
}
|
||||
|
|
|
@ -70,6 +70,7 @@ struct vmivr_profile {
|
|||
const char *api_msg_get;
|
||||
const char *api_msg_forward;
|
||||
const char *api_pref_greeting_set;
|
||||
const char *api_pref_greeting_get;
|
||||
const char *api_pref_recname_set;
|
||||
const char *api_pref_password_set;
|
||||
|
||||
|
|
|
@ -73,6 +73,7 @@ void vmivr_menu_main(switch_core_session_t *session, vmivr_profile_t *profile) {
|
|||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
vmivr_menu_t menu = { "std_main_menu" };
|
||||
int retry;
|
||||
switch_bool_t action_on_new_message_occured = SWITCH_FALSE;
|
||||
|
||||
/* Initialize Menu Configs */
|
||||
menu_init(profile, &menu);
|
||||
|
@ -84,6 +85,8 @@ void vmivr_menu_main(switch_core_session_t *session, vmivr_profile_t *profile) {
|
|||
|
||||
for (retry = menu.ivr_maximum_attempts; switch_channel_ready(channel) && retry > 0; retry--) {
|
||||
char *cmd = NULL;
|
||||
const char *action = NULL;
|
||||
const char *action_on_new_message = switch_event_get_header(menu.event_settings, "Action-On-New-Message");
|
||||
|
||||
menu_instance_init(&menu);
|
||||
|
||||
|
@ -93,17 +96,26 @@ void vmivr_menu_main(switch_core_session_t *session, vmivr_profile_t *profile) {
|
|||
|
||||
cmd = switch_core_session_sprintf(session, "json %s %s %s %s", profile->api_profile, profile->domain, profile->id, profile->folder_name);
|
||||
jsonapi2event(session, menu.phrase_params, profile->api_msg_count, cmd);
|
||||
//initial_count_played = SWITCH_TRUE;
|
||||
|
||||
ivre_playback(session, &menu.ivre_d, switch_event_get_header(menu.event_phrases, "msg_count"), NULL, menu.phrase_params, NULL, 0);
|
||||
|
||||
ivre_playback(session, &menu.ivre_d, switch_event_get_header(menu.event_phrases, "menu_options"), NULL, menu.phrase_params, NULL, menu.ivr_entry_timeout);
|
||||
if (atoi(switch_event_get_header(menu.phrase_params, "VM-Total-New-Messages")) > 0 && menu.ivre_d.result == RES_WAITFORMORE && !action_on_new_message_occured && action_on_new_message) {
|
||||
menu.ivre_d.result = RES_FOUND;
|
||||
action = action_on_new_message;
|
||||
action_on_new_message_occured = SWITCH_TRUE;
|
||||
|
||||
} else {
|
||||
ivre_playback(session, &menu.ivre_d, switch_event_get_header(menu.event_phrases, "menu_options"), NULL, menu.phrase_params, NULL, menu.ivr_entry_timeout);
|
||||
}
|
||||
|
||||
if (menu.ivre_d.result == RES_TIMEOUT) {
|
||||
ivre_playback_dtmf_buffered(session, switch_event_get_header(menu.event_phrases, "timeout"), NULL, NULL, NULL, 0);
|
||||
} else if (menu.ivre_d.result == RES_INVALID) {
|
||||
ivre_playback_dtmf_buffered(session, switch_event_get_header(menu.event_phrases, "invalid"), NULL, NULL, NULL, 0);
|
||||
} else if (menu.ivre_d.result == RES_FOUND) { /* Matching DTMF Key Pressed */
|
||||
const char *action = switch_event_get_header(menu.event_keys_dtmf, menu.ivre_d.dtmf_stored);
|
||||
if (!action) {
|
||||
action = switch_event_get_header(menu.event_keys_dtmf, menu.ivre_d.dtmf_stored);
|
||||
}
|
||||
|
||||
/* Reset the try count */
|
||||
retry = menu.ivr_maximum_attempts;
|
||||
|
@ -577,7 +589,19 @@ void vmivr_menu_select_greeting_slot(switch_core_session_t *session, vmivr_profi
|
|||
char * cmd = switch_core_session_sprintf(session, "%s %s %s %d", profile->api_profile, profile->domain, profile->id, gnum);
|
||||
if (vmivr_api_execute(session, profile->api_pref_greeting_set, cmd) == SWITCH_STATUS_SUCCESS) {
|
||||
char *str_num = switch_core_session_sprintf(session, "%d", gnum);
|
||||
ivre_playback_dtmf_buffered(session, switch_event_get_header(menu.event_phrases, "selected_slot"), str_num, NULL, NULL, 0);
|
||||
char *cmd = switch_core_session_sprintf(session, "json %s %s %s %d %s", profile->api_profile, profile->domain, profile->id);
|
||||
switch_event_t *phrases = jsonapi2event(session, NULL, profile->api_pref_greeting_get, cmd);
|
||||
|
||||
ivre_playback_dtmf_buffered(session, switch_event_get_header(menu.event_phrases, "selected_slot"), str_num, phrases, NULL, 0);
|
||||
|
||||
if (switch_true(switch_event_get_header(phrases, "VM-Message-Private-Local-Copy"))) {
|
||||
const char *file_path = switch_event_get_header(phrases, "VM-Preference-Greeting-File-Path");
|
||||
if (file_path && unlink(file_path) != 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Failed to delete temp file [%s]\n", file_path);
|
||||
}
|
||||
}
|
||||
|
||||
switch_event_destroy(&phrases);
|
||||
} else {
|
||||
ivre_playback_dtmf_buffered(session, switch_event_get_header(menu.event_phrases, "invalid_slot"), NULL, NULL, NULL, 0);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue