[Freeswitch-svn] [commit] r3444 - freeswitch/branches/knhor/trunk/src/mod/applications/mod_conference
Freeswitch SVN
knhor at freeswitch.org
Thu Nov 23 11:03:37 EST 2006
Author: knhor
Date: Thu Nov 23 11:03:37 2006
New Revision: 3444
Modified:
freeswitch/branches/knhor/trunk/src/mod/applications/mod_conference/mod_conference.c
Log:
flesh out the menu function callback for caller control
Modified: freeswitch/branches/knhor/trunk/src/mod/applications/mod_conference/mod_conference.c
==============================================================================
--- freeswitch/branches/knhor/trunk/src/mod/applications/mod_conference/mod_conference.c (original)
+++ freeswitch/branches/knhor/trunk/src/mod/applications/mod_conference/mod_conference.c Thu Nov 23 11:03:37 2006
@@ -938,7 +938,7 @@
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "conference_loop_fn_menu handler '%s'\n",menu_ctx->name);
if (menu_ctx->menu_stack != NULL && menu_ctx->xml_ctx != NULL) {
- switch_ivr_menu_execute(member->session,menu_ctx->menu_stack,menu_ctx->name,NULL);
+ switch_ivr_menu_execute(member->session,menu_ctx->menu_stack,menu_ctx->name,member);
} else {
if(menu_ctx->menu_stack == NULL)
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "conference_loop_fn_menu handler NULL menu_stack\n");
@@ -3222,12 +3222,53 @@
/*.chat_interface */ &conference_chat_interface
};
+static struct caller_control_fn_table {
+ char *key;
+ char *digits;
+ caller_control_t action;
+ void (*handler)(conference_member_t *, void *);
+} ccfntbl[] = {
+ {"mute", "0", CALLER_CONTROL_MUTE, conference_loop_fn_mute_toggle},
+ {"deaf mute", "*", CALLER_CONTROL_DEAF_MUTE, conference_loop_fn_deafmute_toggle},
+ {"energy up", "9", CALLER_CONTROL_ENERGY_UP, conference_loop_fn_energy_up},
+ {"energy equ", "8", CALLER_CONTROL_ENERGY_EQU_CONF, conference_loop_fn_energy_equ_conf},
+ {"energy dn", "7", CALLER_CONTROL_ENERGEY_DN, conference_loop_fn_energy_dn},
+ {"vol talk up", "3", CALLER_CONTROL_VOL_TALK_UP, conference_loop_fn_volume_talk_up},
+ {"vol talk zero", "2", CALLER_CONTROL_VOL_TALK_ZERO, conference_loop_fn_volume_talk_zero},
+ {"vol talk dn", "1", CALLER_CONTROL_VOL_TALK_DN, conference_loop_fn_volume_talk_dn},
+ {"vol listen up", "6", CALLER_CONTROL_VOL_LISTEN_UP, conference_loop_fn_volume_listen_up},
+ {"vol listen zero", "5", CALLER_CONTROL_VOL_LISTEN_ZERO, conference_loop_fn_volume_listen_zero},
+ {"vol listen dn", "4", CALLER_CONTROL_VOL_LISTEN_DN, conference_loop_fn_volume_listen_dn},
+ {"hangup", "#", CALLER_CONTROL_HANGUP, conference_loop_fn_hangup},
+ {"menu", NULL, CALLER_CONTROL_MENU, conference_loop_fn_menu},
+};
+#define CCFNTBL_QTY (sizeof(ccfntbl)/sizeof(ccfntbl[0]))
+
static switch_ivr_action_t conference_caller_control_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, "caller control menu action '%s'\n",param);
+ if (!switch_strlen_zero(param)) {
+ if (obj != NULL) {
+ int i,found;
+
+ for(i=0,found=0; !found && i<CCFNTBL_QTY; i++) {
+ found = (ccfntbl[i].action != CALLER_CONTROL_MENU && strcasecmp(ccfntbl[i].key,param) == 0);
+ if (found) {
+ if (obj != NULL) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "invoking caller control menu action '%s'\n",param);
+ ccfntbl[i].handler((conference_member_t *)obj,NULL);
+ }
+ }
+ }
+ if (!found) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "unknown caller control menu action '%s'\n",param);
+ }
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "unable to invoke caller control menu action '%s', NULL member!\n",param);
+ }
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "NULL or empty param!\n");
}
return action;
@@ -3252,10 +3293,12 @@
status = switch_ivr_menu_stack_xml_init(&(*ctx)->xml_ctx, conference->pool);
if (status == SWITCH_STATUS_SUCCESS) {
(*ctx)->name = switch_core_strdup(conference->pool,menu_name);
+
// add our xml menu handler to the xml stack parser
status = switch_ivr_menu_stack_xml_add_custom((*ctx)->xml_ctx, "control", &conference_caller_control_menu_handler);
if (status != SWITCH_STATUS_SUCCESS)
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "unable to add custom xml handler\n");
+
// parse the xml stack to build the menu stack
status = switch_ivr_menu_stack_xml_build((*ctx)->xml_ctx, &(*ctx)->menu_stack, xml_menus, xml_menu, conference->timer_name);
if (status != SWITCH_STATUS_SUCCESS)
@@ -3503,28 +3546,6 @@
// try to build caller control if the set has been specified and != "none"
if (xml_controls != NULL && controls_set != NULL && strcasecmp(controls_set,"none") != 0) {
- struct default_caller_control_table {
- char *key;
- char *digits;
- caller_control_t action;
- void (*handler)(conference_member_t *, void *);
- } dcctbl[] = {
- {"mute", "0", CALLER_CONTROL_MUTE, conference_loop_fn_mute_toggle},
- {"deaf mute", "*", CALLER_CONTROL_DEAF_MUTE, conference_loop_fn_deafmute_toggle},
- {"energy up", "9", CALLER_CONTROL_ENERGY_UP, conference_loop_fn_energy_up},
- {"energy equ", "8", CALLER_CONTROL_ENERGY_EQU_CONF, conference_loop_fn_energy_equ_conf},
- {"energy dn", "7", CALLER_CONTROL_ENERGEY_DN, conference_loop_fn_energy_dn},
- {"vol talk up", "3", CALLER_CONTROL_VOL_TALK_UP, conference_loop_fn_volume_talk_up},
- {"vol talk zero", "2", CALLER_CONTROL_VOL_TALK_ZERO, conference_loop_fn_volume_talk_zero},
- {"vol talk dn", "1", CALLER_CONTROL_VOL_TALK_DN, conference_loop_fn_volume_talk_dn},
- {"vol listen up", "6", CALLER_CONTROL_VOL_LISTEN_UP, conference_loop_fn_volume_listen_up},
- {"vol listen zero", "5", CALLER_CONTROL_VOL_LISTEN_ZERO, conference_loop_fn_volume_listen_zero},
- {"vol listen dn", "4", CALLER_CONTROL_VOL_LISTEN_DN, conference_loop_fn_volume_listen_dn},
- {"hangup", "#", CALLER_CONTROL_HANGUP, conference_loop_fn_hangup},
- {"menu", NULL, CALLER_CONTROL_MENU, conference_loop_fn_menu},
- };
- int dcctbl_qty = (sizeof(dcctbl)/sizeof(dcctbl[0]));
-
if(switch_ivr_digit_stream_parser_new(conference->pool,&conference->dtmf_parser) == SWITCH_STATUS_SUCCESS) {
// map in the default control handler strings if specified
@@ -3532,23 +3553,23 @@
int i;
caller_control_action_t *action;
- for(i=0,status=SWITCH_STATUS_SUCCESS; status == SWITCH_STATUS_SUCCESS && i<dcctbl_qty; i++) {
- switch(dcctbl[i].action)
+ for(i=0,status=SWITCH_STATUS_SUCCESS; status == SWITCH_STATUS_SUCCESS && i<CCFNTBL_QTY; i++) {
+ switch(ccfntbl[i].action)
{
case CALLER_CONTROL_MENU:
// default caller control, has no menu specification
break;
default:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Installing default caller control action '%s' bound to '%s'.\n",
- dcctbl[i].key,
- dcctbl[i].digits);
+ ccfntbl[i].key,
+ ccfntbl[i].digits);
action = (caller_control_action_t *)switch_core_alloc(conference->pool,sizeof(caller_control_action_t));
if (action != NULL) {
- action->handler = dcctbl[i].handler;
+ action->handler = ccfntbl[i].handler;
action->data = NULL;
- status = switch_ivr_digit_stream_parser_set_event(conference->dtmf_parser,dcctbl[i].digits,action);
+ status = switch_ivr_digit_stream_parser_set_event(conference->dtmf_parser,ccfntbl[i].digits,action);
} else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "unable to alloc memory for caller control binding '%s' to '%s'\n",dcctbl[i].key,dcctbl[i].digits);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "unable to alloc memory for caller control binding '%s' to '%s'\n",ccfntbl[i].key,ccfntbl[i].digits);
status = SWITCH_STATUS_MEMERR;
}
break;
@@ -3567,11 +3588,11 @@
// scan through all of the valid actions, and if found,
// set the new caller control action digit string, then
// stop scanning the table, and go to the next xml kvp.
- for(i=0,status=SWITCH_STATUS_NOOP; i<dcctbl_qty && status == SWITCH_STATUS_NOOP; i++) {
+ for(i=0,status=SWITCH_STATUS_NOOP; i<CCFNTBL_QTY && status == SWITCH_STATUS_NOOP; i++) {
caller_control_menu_ctx_t *menu_ctx = NULL;
- if(strcasecmp(dcctbl[i].key,key) == 0) {
- switch(dcctbl[i].action)
+ if(strcasecmp(ccfntbl[i].key,key) == 0) {
+ switch(ccfntbl[i].action)
{
case CALLER_CONTROL_MENU:
{
@@ -3588,11 +3609,11 @@
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Installing caller control action '%s' bound to '%s'.\n",key,val);
action = (caller_control_action_t *)switch_core_alloc(conference->pool,sizeof(caller_control_action_t));
if (action != NULL) {
- action->handler = dcctbl[i].handler;
+ action->handler = ccfntbl[i].handler;
action->data = (void *)menu_ctx;
status = switch_ivr_digit_stream_parser_set_event(conference->dtmf_parser,val,action);
} else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "unable to alloc memory for caller control binding '%s' to '%s'\n",dcctbl[i].key,dcctbl[i].digits);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "unable to alloc memory for caller control binding '%s' to '%s'\n",ccfntbl[i].key,ccfntbl[i].digits);
status = SWITCH_STATUS_MEMERR;
}
break;
More information about the Freeswitch-svn
mailing list