Commit FSCORE-183, tested by me but others test also.

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9777 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2008-10-01 17:31:59 +00:00
parent 282f070580
commit fb06cc2d01
5 changed files with 40 additions and 15 deletions

View File

@ -10,6 +10,7 @@
timeout ="10000" timeout ="10000"
inter-digit-timeout="2000" inter-digit-timeout="2000"
max-failures="3" max-failures="3"
max-timeouts="3"
digit-len="4"> digit-len="4">
<entry action="menu-exec-app" digits="1" param="bridge sofia/$${domain}/888@conference.freeswitch.org"/> <entry action="menu-exec-app" digits="1" param="bridge sofia/$${domain}/888@conference.freeswitch.org"/>
<entry action="menu-exec-app" digits="2" param="transfer 9996 XML default"/> <!-- FS echo --> <entry action="menu-exec-app" digits="2" param="transfer 9996 XML default"/> <!-- FS echo -->
@ -26,7 +27,8 @@
invalid-sound="ivr/ivr-that_was_an_invalid_entry.wav" invalid-sound="ivr/ivr-that_was_an_invalid_entry.wav"
exit-sound="voicemail/vm-goodbye.wav" exit-sound="voicemail/vm-goodbye.wav"
timeout="15000" timeout="15000"
max-failures="3"> max-failures="3"
max-timeouts="3">
<entry action="menu-top" digits="*"/> <entry action="menu-top" digits="*"/>
</menu> </menu>

View File

@ -92,7 +92,8 @@ SWITCH_DECLARE(void) consoleCleanLog(char *msg);
const char *exit_sound, const char *exit_sound,
const char *confirm_macro, const char *confirm_macro,
const char *confirm_key, const char *confirm_key,
int confirm_attempts, int inter_timeout, int digit_len, int timeout, int max_failures); int confirm_attempts, int inter_timeout, int digit_len,
int timeout, int max_failures, int max_timeouts);
virtual SWITCH_DECLARE_CONSTRUCTOR ~ IVRMenu(); virtual SWITCH_DECLARE_CONSTRUCTOR ~ IVRMenu();
SWITCH_DECLARE(void) bindAction(char *action, const char *arg, const char *bind); SWITCH_DECLARE(void) bindAction(char *action, const char *arg, const char *bind);
SWITCH_DECLARE(void) execute(CoreSession * session, const char *name); SWITCH_DECLARE(void) execute(CoreSession * session, const char *name);

View File

@ -680,7 +680,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_set_terminator(sw
const char *confirm_macro, const char *confirm_macro,
const char *confirm_key, const char *confirm_key,
int confirm_attempts, int confirm_attempts,
int inter_timeout, int digit_len, int timeout, int max_failures, switch_memory_pool_t *pool); int inter_timeout, int digit_len, int timeout, int max_failures,
int max_timeouts, switch_memory_pool_t *pool);
/*! /*!
*\brief switch_ivr_menu_bind_action: Bind a keystroke to an action. *\brief switch_ivr_menu_bind_action: Bind a keystroke to an action.

View File

@ -112,7 +112,8 @@ SWITCH_DECLARE_CONSTRUCTOR IVRMenu::IVRMenu(IVRMenu *main,
int inter_timeout, int inter_timeout,
int digit_len, int digit_len,
int timeout, int timeout,
int max_failures) int max_failures,
int max_timeouts)
{ {
menu = NULL; menu = NULL;
switch_core_new_memory_pool(&pool); switch_core_new_memory_pool(&pool);
@ -122,7 +123,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, switch_ivr_menu_init(&menu, main ? main->menu : NULL, name, greeting_sound, short_greeting_sound, invalid_sound,
exit_sound, confirm_macro, confirm_key, confirm_attempts, inter_timeout, digit_len, timeout, max_failures, pool); exit_sound, confirm_macro, confirm_key, confirm_attempts, inter_timeout, digit_len, timeout, max_failures, max_timeouts, pool);
} }

View File

@ -47,6 +47,7 @@ struct switch_ivr_menu {
int confirm_attempts; int confirm_attempts;
int digit_len; int digit_len;
int max_failures; int max_failures;
int max_timeouts;
int timeout; int timeout;
int inter_timeout; int inter_timeout;
switch_size_t inlen; switch_size_t inlen;
@ -102,6 +103,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_init(switch_ivr_menu_t ** new_me
int inter_timeout, int inter_timeout,
int digit_len, int digit_len,
int timeout, int max_failures, int timeout, int max_failures,
int max_timeouts,
switch_memory_pool_t *pool) switch_memory_pool_t *pool)
{ {
switch_ivr_menu_t *menu; switch_ivr_menu_t *menu;
@ -167,6 +169,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_init(switch_ivr_menu_t ** new_me
menu->max_failures = max_failures; menu->max_failures = max_failures;
menu->max_timeouts = max_timeouts;
menu->timeout = timeout; menu->timeout = timeout;
menu->inter_timeout = inter_timeout; menu->inter_timeout = inter_timeout;
@ -345,7 +349,7 @@ static switch_status_t play_and_collect(switch_core_session_t *session, switch_i
SWITCH_DECLARE(switch_status_t) switch_ivr_menu_execute(switch_core_session_t *session, switch_ivr_menu_t * stack, char *name, void *obj) SWITCH_DECLARE(switch_status_t) switch_ivr_menu_execute(switch_core_session_t *session, switch_ivr_menu_t * stack, char *name, void *obj)
{ {
int reps = 0, errs = 0, match = 0, running = 1; int reps = 0, errs = 0, timeouts = 0, match = 0, running = 1;
char *greeting_sound = NULL, *aptr = NULL; char *greeting_sound = NULL, *aptr = NULL;
char arg[512]; char arg[512];
switch_ivr_action_t todo = SWITCH_IVR_ACTION_DIE; switch_ivr_action_t todo = SWITCH_IVR_ACTION_DIE;
@ -372,11 +376,22 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_execute(switch_core_session_t *s
} }
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Executing IVR menu %s\n", menu->name); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Executing IVR menu %s\n", menu->name);
switch_channel_set_variable(channel, "ivr_menu_status", "success");
for (reps = 0; (running && status == SWITCH_STATUS_SUCCESS && errs < menu->max_failures); reps++) { for (reps = 0; running && status == SWITCH_STATUS_SUCCESS; reps++) {
if (!switch_channel_ready(channel)) { if (!switch_channel_ready(channel)) {
break; break;
} }
if (errs == menu->max_failures) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Maximum failures\n");
switch_channel_set_variable(channel, "ivr_menu_status", "failure");
break;
}
if (timeouts == menu->max_timeouts) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Maximum timeouts\n");
switch_channel_set_variable(channel, "ivr_menu_status", "timeout");
break;
}
if (reps > 0 && menu->short_greeting_sound) { if (reps > 0 && menu->short_greeting_sound) {
greeting_sound = menu->short_greeting_sound; greeting_sound = menu->short_greeting_sound;
@ -390,7 +405,11 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_execute(switch_core_session_t *s
memset(arg, 0, sizeof(arg)); memset(arg, 0, sizeof(arg));
memset(menu->buf, 0, menu->inlen + 1); memset(menu->buf, 0, menu->inlen + 1);
status = play_and_collect(session, menu, greeting_sound, menu->inlen);
if (play_and_collect(session, menu, greeting_sound, menu->inlen) == SWITCH_STATUS_TIMEOUT && *menu->buf == '\0') {
timeouts++;
continue;
}
if (*menu->buf != '\0') { if (*menu->buf != '\0') {
@ -494,17 +513,12 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_execute(switch_core_session_t *s
if (*menu->buf) { if (*menu->buf) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "IVR menu '%s' caught invalid input '%s'\n", menu->name, menu->buf); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "IVR menu '%s' caught invalid input '%s'\n", menu->name, menu->buf);
if (menu->invalid_sound) { if (menu->invalid_sound) {
status = play_and_collect(session, menu, menu->invalid_sound, 0); play_and_collect(session, menu, menu->invalid_sound, 0);
} }
} else { } else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "IVR menu '%s' no input detected\n", menu->name); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "IVR menu '%s' no input detected\n", menu->name);
} }
errs++; errs++;
if (status == SWITCH_STATUS_TIMEOUT) {
status = SWITCH_STATUS_SUCCESS;
}
if (status == SWITCH_STATUS_SUCCESS) { if (status == SWITCH_STATUS_SUCCESS) {
status = switch_ivr_sleep(session, 1000, NULL); status = switch_ivr_sleep(session, 1000, NULL);
} }
@ -693,6 +707,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_stack_xml_build(switch_ivr_menu_
const char *exit_sound = switch_xml_attr(xml_menu, "exit-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 *timeout = switch_xml_attr_soft(xml_menu, "timeout"); /* if the attr doesn't exist, return "" */ 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_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");
const char *confirm_macro= switch_xml_attr(xml_menu, "confirm-macro"); const char *confirm_macro= switch_xml_attr(xml_menu, "confirm-macro");
const char *confirm_key= switch_xml_attr(xml_menu, "confirm-key"); const char *confirm_key= switch_xml_attr(xml_menu, "confirm-key");
const char *confirm_attempts = switch_xml_attr_soft(xml_menu, "confirm-attempts"); const char *confirm_attempts = switch_xml_attr_soft(xml_menu, "confirm-attempts");
@ -701,6 +716,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_stack_xml_build(switch_ivr_menu_
switch_ivr_menu_t *menu = NULL; switch_ivr_menu_t *menu = NULL;
if (switch_strlen_zero(max_timeouts)) {
max_timeouts = max_failures;
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "building menu '%s'\n", menu_name); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "building menu '%s'\n", menu_name);
status = switch_ivr_menu_init(&menu, status = switch_ivr_menu_init(&menu,
@ -716,7 +735,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_stack_xml_build(switch_ivr_menu_
atoi(inter_timeout), atoi(inter_timeout),
atoi(digit_len), atoi(digit_len),
atoi(timeout), atoi(timeout),
atoi(max_failures), strlen(max_failures)? atoi(max_failures): 1,
strlen(max_timeouts)? atoi(max_timeouts): 1,
xml_menu_ctx->pool); xml_menu_ctx->pool);
/* set the menu_stack for the caller */ /* set the menu_stack for the caller */
if (status == SWITCH_STATUS_SUCCESS && *menu_stack == NULL) { if (status == SWITCH_STATUS_SUCCESS && *menu_stack == NULL) {