From fb34ff9ade7a497b31647da7cd899d457ed12e55 Mon Sep 17 00:00:00 2001 From: Brian West Date: Wed, 24 Jul 2013 18:40:31 -0500 Subject: [PATCH] adding transfer-sound to ivr menu so you can specifiy a sound file to pay when a transfer takes place --- src/include/switch_cpp.h | 1 + src/include/switch_ivr.h | 2 ++ src/switch_cpp.cpp | 3 ++- src/switch_ivr_menu.c | 12 ++++++++++++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/include/switch_cpp.h b/src/include/switch_cpp.h index 43aa6c0bef..bccf71a3a1 100644 --- a/src/include/switch_cpp.h +++ b/src/include/switch_cpp.h @@ -90,6 +90,7 @@ SWITCH_DECLARE(bool) email(char *to, char *from, char *headers = NULL, char *bod const char *short_greeting_sound, const char *invalid_sound, const char *exit_sound, + const char *transfer_sound, const char *confirm_macro, const char *confirm_key, const char *tts_engine, diff --git a/src/include/switch_ivr.h b/src/include/switch_ivr.h index 74f9a8e738..c0ba440c99 100644 --- a/src/include/switch_ivr.h +++ b/src/include/switch_ivr.h @@ -787,6 +787,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_set_terminator(sw *\param short_greeting_sound Optional pointer to a shorter main sound for subsequent loops. *\param invalid_sound Optional pointer to a sound to play after invalid input. *\param exit_sound Optional pointer to a sound to play upon exiting the menu. + *\param transfer_sound Optional pointer to a sound to play upon transfer away from the menu. *\param confirm_macro phrase macro name to confirm input *\param confirm_key the dtmf key required for positive confirmation *\param tts_engine the tts engine to use for this menu @@ -807,6 +808,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_init(switch_ivr_menu_t ** new_me const char *short_greeting_sound, const char *invalid_sound, const char *exit_sound, + const char *transfer_sound, const char *confirm_macro, const char *confirm_key, const char *tts_engine, diff --git a/src/switch_cpp.cpp b/src/switch_cpp.cpp index e8a8a1513e..f7f6a4a5b8 100644 --- a/src/switch_cpp.cpp +++ b/src/switch_cpp.cpp @@ -161,6 +161,7 @@ SWITCH_DECLARE_CONSTRUCTOR IVRMenu::IVRMenu(IVRMenu *main, const char *short_greeting_sound, const char *invalid_sound, const char *exit_sound, + const char *transfer_sound, const char *confirm_macro, const char *confirm_key, const char *tts_engine, @@ -180,7 +181,7 @@ SWITCH_DECLARE_CONSTRUCTOR IVRMenu::IVRMenu(IVRMenu *main, } switch_ivr_menu_init(&menu, main ? main->menu : NULL, name, greeting_sound, short_greeting_sound, invalid_sound, - exit_sound, confirm_macro, confirm_key, tts_engine, tts_voice, confirm_attempts, inter_timeout, + exit_sound, transfer_sound, confirm_macro, confirm_key, tts_engine, tts_voice, confirm_attempts, inter_timeout, digit_len, timeout, max_failures, max_timeouts, pool); diff --git a/src/switch_ivr_menu.c b/src/switch_ivr_menu.c index 639ff58f29..e3dfa5c848 100644 --- a/src/switch_ivr_menu.c +++ b/src/switch_ivr_menu.c @@ -40,6 +40,7 @@ struct switch_ivr_menu { char *short_greeting_sound; char *invalid_sound; char *exit_sound; + char *transfer_sound; char *buf; char *ptr; char *confirm_macro; @@ -105,6 +106,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_init(switch_ivr_menu_t ** new_me const char *short_greeting_sound, const char *invalid_sound, const char *exit_sound, + const char *transfer_sound, const char *confirm_macro, const char *confirm_key, const char *tts_engine, @@ -158,6 +160,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_init(switch_ivr_menu_t ** new_me menu->invalid_sound = switch_core_strdup(menu->pool, invalid_sound); } + if (!zstr(transfer_sound)) { + menu->transfer_sound = switch_core_strdup(menu->pool, transfer_sound); + } + if (!zstr(exit_sound)) { menu->exit_sound = switch_core_strdup(menu->pool, exit_sound); } @@ -588,6 +594,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_execute(switch_core_session_t *s } if ((application_interface = switch_loadable_module_get_application_interface(app_name))) { + if (!zstr(menu->transfer_sound) && !strcmp(app_name, "transfer")) { + status = play_and_collect(session, menu, menu->transfer_sound, 0); + } + switch_core_session_exec(session, application_interface, app_arg); UNPROTECT_INTERFACE(application_interface); status = SWITCH_STATUS_SUCCESS; @@ -822,6 +832,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_stack_xml_build(switch_ivr_menu_ const char *greet_short = switch_xml_attr(xml_menu, "greet-short"); /* if the attr doesn't exist, return NULL */ const char *invalid_sound = switch_xml_attr(xml_menu, "invalid-sound"); /* if the attr doesn't exist, return NULL */ const char *exit_sound = switch_xml_attr(xml_menu, "exit-sound"); /* if the attr doesn't exist, return NULL */ + const char *transfer_sound = switch_xml_attr(xml_menu, "transfer-sound"); /* if the attr doesn't exist, return NULL */ const char *timeout = switch_xml_attr_soft(xml_menu, "timeout"); /* if the attr doesn't exist, return "" */ const char *max_failures = switch_xml_attr_soft(xml_menu, "max-failures"); /* if the attr doesn't exist, return "" */ const char *max_timeouts = switch_xml_attr_soft(xml_menu, "max-timeouts"); @@ -853,6 +864,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_stack_xml_build(switch_ivr_menu_ greet_short, invalid_sound, exit_sound, + transfer_sound, confirm_macro, confirm_key, tts_engine,