FS-9319 [mod_dptools] Support "both" in clear_digit_action

Add support for "both" as target parameter to clear_digit_action.
CDA previously only supported target values of:

	"", "self" or "peer"

CDA Behaviour now corresponds with documentation.

For example, the follow will work as expected:

	<action application="clear_digit_action" data="all,both"/>

FS-9319 #resolve
This commit is contained in:
Andy Newlands 2016-11-08 12:49:06 +00:00
parent 732b6e75fe
commit 6e8508f2a0
1 changed files with 14 additions and 3 deletions

View File

@ -286,7 +286,7 @@ SWITCH_STANDARD_APP(clear_digit_action_function)
switch_ivr_dmachine_t *dmachine; switch_ivr_dmachine_t *dmachine;
char *realm = NULL; char *realm = NULL;
char *target_str; char *target_str;
switch_digit_action_target_t target = DIGIT_TARGET_SELF; switch_digit_action_target_t t, target = DIGIT_TARGET_SELF;
if (zstr((char *)data)) { if (zstr((char *)data)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "clear_digit_action called with no args"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "clear_digit_action called with no args");
@ -300,16 +300,27 @@ SWITCH_STANDARD_APP(clear_digit_action_function)
target = str2target(target_str); target = str2target(target_str);
} }
clear_next:
if (target == DIGIT_TARGET_BOTH) {
t = DIGIT_TARGET_PEER;
} else {
t = target;
}
if ((dmachine = switch_core_session_get_dmachine(session, target))) { if ((dmachine = switch_core_session_get_dmachine(session, t))) {
if (zstr(realm) || !strcasecmp(realm, "all")) { if (zstr(realm) || !strcasecmp(realm, "all")) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Digit parser %s: Clearing all realms\n", switch_ivr_dmachine_get_name(dmachine)); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Digit parser %s: Clearing all realms\n", switch_ivr_dmachine_get_name(dmachine));
switch_core_session_set_dmachine(session, NULL, target); switch_core_session_set_dmachine(session, NULL, t);
switch_ivr_dmachine_destroy(&dmachine); switch_ivr_dmachine_destroy(&dmachine);
} else { } else {
switch_ivr_dmachine_clear_realm(dmachine, realm); switch_ivr_dmachine_clear_realm(dmachine, realm);
} }
} }
if (target == DIGIT_TARGET_BOTH) {
target = DIGIT_TARGET_SELF;
goto clear_next;
}
} }
#define DIGIT_ACTION_SET_REALM_USAGE "<realm>[,<target>]" #define DIGIT_ACTION_SET_REALM_USAGE "<realm>[,<target>]"