int fs_switch_ivr_collect_digits_callback(switch_core_session_t *session, switch_input_args_t *args, unsigned int timeout) { switch_status_t status; status = switch_ivr_collect_digits_callback(session, args, timeout); return status == SWITCH_STATUS_SUCCESS ? 1 : 0; }
switch_status_t ivre_playback(switch_core_session_t *session, ivre_data_t *loc, const char *macro_name, const char *data, switch_event_t *event, const char *lang, int timeout) { switch_status_t status = SWITCH_STATUS_SUCCESS; switch_channel_t *channel = switch_core_session_get_channel(session); if (switch_channel_ready(channel)) { switch_input_args_t args = { 0 }; args.input_callback = cb_on_dtmf; args.buf = loc; if (macro_name && loc->audio_stopped == SWITCH_FALSE && loc->result == RES_WAITFORMORE) { status = switch_ivr_phrase_macro_event(session, macro_name, data, event, lang, &args); } if (switch_channel_ready(channel) && (status == SWITCH_STATUS_SUCCESS || status == SWITCH_STATUS_BREAK) && timeout && loc->result == RES_WAITFORMORE) { loc->audio_stopped = SWITCH_TRUE; switch_ivr_collect_digits_callback(session, &args, timeout, 0); if (loc->result == RES_WAITFORMORE) { if (loc->potentialMatchCount == 1 && loc->completeMatch != NULL) { loc->result = RES_FOUND; } else { loc->result = RES_TIMEOUT; } } } } else { status = SWITCH_STATUS_BREAK; } return status; }
SWITCH_DECLARE(int) CoreSession::collectDigits(int digit_timeout, int abs_timeout) { this_check(-1); sanity_check(-1); begin_allow_threads(); switch_ivr_collect_digits_callback(session, ap, digit_timeout, abs_timeout); end_allow_threads(); return SWITCH_STATUS_SUCCESS; }
switch_status_t gather_name_digit(switch_core_session_t *session, dir_profile_t *profile, search_params_t *params) { switch_channel_t *channel = switch_core_session_get_channel(session); switch_status_t status = SWITCH_STATUS_SUCCESS; cbr_t cbr; int loop = 1; switch_input_args_t args = { 0 }; args.input_callback = on_dtmf; args.buf = &cbr; while (switch_channel_ready(channel) && loop) { char macro[255]; loop = 0; memset(&cbr, 0, sizeof(cbr)); cbr.profile = profile; params->timeout = 0; /* Gather the user Name */ switch_snprintf(macro, sizeof(macro), "%s:%c", (params->search_by == SEARCH_BY_LAST_NAME ? "last_name" : "first_name"), *profile->switch_order_key); switch_ivr_phrase_macro(session, DIR_INTRO, macro, NULL, &args); while (switch_channel_ready(channel)) { if (cbr.digit == *profile->terminator_key) { status = SWITCH_STATUS_BREAK; break; } if (cbr.digit == *profile->switch_order_key) { if (params->search_by == SEARCH_BY_LAST_NAME) { params->search_by = SEARCH_BY_FIRST_NAME; } else { params->search_by = SEARCH_BY_LAST_NAME; } loop = 1; break; } if (switch_ivr_collect_digits_callback(session, &args, profile->digit_timeout, 0) == SWITCH_STATUS_TIMEOUT) { params->timeout = 1; break; } } } switch_copy_string(params->digits, cbr.digits, 255); return status; }