提交 372c160c authored 作者: Anthony Minessale's avatar Anthony Minessale

menu stuff: work in progress, look for bugs\!\!\!

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@3331 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 bfb6127d
......@@ -443,7 +443,6 @@ typedef struct switch_ivr_menu_action switch_ivr_menu_action_t;
*\param invalid_sound Optional pointer to a sound to play after invalid input.
*\param timeout A number of milliseconds to pause before looping.
*\param max_failures Maximum number of failures to withstand before hangingup This resets everytime you enter the menu.
*\param inlen The max len of the input (1 for 1 digit menu opts, 2 for 2 digit etc.)
*\param pool memory pool (NULL to create one)
*\return SWUTCH_STATUS_SUCCESS if the menu was created
*/
......@@ -453,9 +452,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_init(switch_ivr_menu_t **new,
char *greeting_sound,
char *short_greeting_sound,
char *invalid_sound,
char *tts_engine,
char *tts_voice,
int timeout,
int max_failures,
int inlen,
switch_memory_pool_t *pool);
/*!
......
......@@ -81,6 +81,65 @@ static void xml_function(switch_core_session_t *session, char *data)
}
static void ivr_application_function(switch_core_session_t *session, char *data)
{
switch_channel_t *channel = switch_core_session_get_channel(session);
char *params = switch_core_session_strdup(session,data);
if (channel != NULL && params != NULL) {
switch_ivr_menu_t *menu = NULL, *sub_menu = NULL;
switch_status_t status;
// answer the channel if need be
switch_channel_answer(channel);
status = switch_ivr_menu_init(&menu,
NULL,
"main",
"please enter some numbers so i can figure out if I have any bugs or not",
"enter some numbers",
"I have no idea what that is",
"cepstral",
"david",
15000, 10, NULL);
status = switch_ivr_menu_init(&sub_menu,
menu,
"sub",
"/ram/congrats.wav",
"/ram/extension.wav",
"/ram/invalid.wav",
NULL,
NULL,
15000, 10, NULL);
if (status == SWITCH_STATUS_SUCCESS) {
// build the menu
switch_ivr_menu_bind_action(menu, SWITCH_IVR_ACTION_PLAYSOUND, "/ram/swimp.raw", "1");
switch_ivr_menu_bind_action(menu, SWITCH_IVR_ACTION_PLAYSOUND, "/ram/congrats.wav", "2");
switch_ivr_menu_bind_action(menu, SWITCH_IVR_ACTION_EXECMENU, "sub", "3");
//switch_ivr_menu_bind_action(menu, SWITCH_IVR_ACTION_PLAYSOUND, "/usr/local/freeswitch/sounds/3.wav", "3");
switch_ivr_menu_bind_action(sub_menu, SWITCH_IVR_ACTION_PLAYSOUND, "/ram/swimp.raw", "1");
switch_ivr_menu_bind_action(sub_menu, SWITCH_IVR_ACTION_BACK, NULL, "2");
// start the menu
status = switch_ivr_menu_execute(session, menu, "main", NULL);
// cleaup the menu
switch_ivr_menu_free_stack(menu);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "unable to build menu %s\n",params);
}
switch_ivr_play_file(session, NULL,"/ram/goodbye.wav",NULL,NULL,NULL,0);
}
}
static void dirtest_function(switch_core_session_t *session, char *data)
{
char *var, *val;
......@@ -354,11 +413,19 @@ static const switch_state_handler_table_t state_handlers = {
};
static const switch_application_interface_t ivr_application_interface = {
/*.interface_name */ "ivrmenu",
/*.application_function */ ivr_application_function,
NULL, NULL, NULL,
/*.next*/ NULL
};
static const switch_application_interface_t xml_application_interface = {
/*.interface_name */ "xml",
/*.application_function */ xml_function,
NULL, NULL, NULL,
/*.next*/ NULL
/*.next*/ &ivr_application_interface
};
static const switch_application_interface_t disast_application_interface = {
......
差异被折叠。
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论