Author: knhor Date: Wed Nov 22 20:29:46 2006 New Revision: 3438 Modified: freeswitch/branches/knhor/trunk/src/mod/applications/mod_ivr/mod_ivr.c Log: update for new xml api. add ifdef for custom callback handlers Modified: freeswitch/branches/knhor/trunk/src/mod/applications/mod_ivr/mod_ivr.c ============================================================================== --- freeswitch/branches/knhor/trunk/src/mod/applications/mod_ivr/mod_ivr.c (original) +++ freeswitch/branches/knhor/trunk/src/mod/applications/mod_ivr/mod_ivr.c Wed Nov 22 20:29:46 2006 @@ -60,6 +60,19 @@ /*.chat_interface */ NULL }; +#ifdef _TEST_CALLBACK_ +static switch_ivr_action_t menu_handler(switch_ivr_menu_t *menu, char *param, char *buf, size_t buflen, void *obj) +{ + switch_ivr_action_t action = SWITCH_IVR_ACTION_NOOP; + + if (param != NULL) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "menu_handler '%s'\n",param); + } + + return action; +} +#endif + static void ivr_application_function(switch_core_session_t *session, char *data) { switch_channel_t *channel = switch_core_session_get_channel(session); @@ -76,12 +89,19 @@ // if the menu was found if (xml_menu != NULL) { + switch_ivr_menu_xml_ctx_t *xml_ctx = NULL; switch_ivr_menu_t *menu_stack = NULL; // build a menu tree and execute it - if (switch_ivr_build_xml_menu_stack(&menu_stack,xml_menus,xml_menu,NULL) == SWITCH_STATUS_SUCCESS) { + if (switch_ivr_menu_stack_xml_init(&xml_ctx,NULL) == SWITCH_STATUS_SUCCESS +#ifdef _TEST_CALLBACK_ + && switch_ivr_menu_stack_xml_add_custom(xml_ctx, "custom", &menu_handler) == SWITCH_STATUS_SUCCESS +#endif + && switch_ivr_menu_stack_xml_build(xml_ctx,&menu_stack,xml_menus,xml_menu,NULL) == SWITCH_STATUS_SUCCESS) + { switch_channel_answer(channel); switch_ivr_menu_execute(session,menu_stack,params,NULL); + switch_ivr_menu_stack_free(menu_stack); } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to create menu '%s'\n", params); }