SWITCH_DECLARE(switch_status_t) switch_ivr_dmachine_bind(switch_ivr_dmachine_t *dmachine,
const char *realm,
const char *digits,
+ switch_byte_t is_priority,
int32_t key,
switch_ivr_dmachine_callback_t callback,
void *user_data);
}
binding->handler = handler;
- switch_ivr_dmachine_bind(member->dmachine, "conf", digits, 0, conference_loop_dmachine_dispatcher, binding);
-
+ switch_ivr_dmachine_bind(member->dmachine, "conf", digits, 0, 0, conference_loop_dmachine_dispatcher, binding);
}
void conference_member_bind_controls(conference_member_t *member, const char *controls)
switch_ivr_dmachine_t *dmachine;
switch_channel_t *channel = switch_core_session_get_channel(session);
const char *terminators = NULL;
+ switch_byte_t is_priority = 0;
if (!(dmachine = switch_core_session_get_dmachine(session, target))) {
uint32_t digit_timeout = 1500;
act->value = switch_core_session_strdup(session, arg3);
act->target = bind_target;
act->session = session;
- switch_ivr_dmachine_bind(dmachine, act->realm, act->input, 0, digit_action_callback, act);
+ if (!strncasecmp(act->string, "exec", 4) || !strncasecmp(act->string, "api:", 4)) {
+ char *flags, *e;
+ char *string = switch_core_session_strdup(session, act->string);
+
+ string += 4;
+ if (*string == '[') {
+ flags = string;
+ if ((e = switch_find_end_paren(flags, '[', ']'))) {
+ if (e && *(e+1) == ':') {
+ flags++;
+ *e = '\0';
+ if (strchr(flags, 'P'))
+ is_priority = 1;
+ }
+ }
+ }
+ }
+
+ switch_ivr_dmachine_bind(dmachine, act->realm, act->input, is_priority, 0, digit_action_callback, act);
+
if ((terminators = switch_channel_get_variable(channel, "bda_terminators"))) {
switch_ivr_dmachine_set_terminators(dmachine, terminators);
}
action_binding->error_file = (char *) error_file;
action_binding->parent = top_action_binding;
- switch_ivr_dmachine_bind(dmachine, action_binding->realm, action_binding->input, 0, digit_action_callback, action_binding);
+ switch_ivr_dmachine_bind(dmachine, action_binding->realm, action_binding->input, 0, 0, digit_action_callback, action_binding);
bind = bind->next;
}
action_binding->error_file = (char *) error_file;
action_binding->parent = top_action_binding;
- switch_ivr_dmachine_bind(dmachine, action_binding->realm, action_binding->input, 0, digit_action_callback, action_binding);
+ switch_ivr_dmachine_bind(dmachine, action_binding->realm, action_binding->input, 0, 0, digit_action_callback, action_binding);
bind = bind->next;
}
uint8_t rmatch;
switch_ivr_dmachine_callback_t callback;
switch_byte_t is_regex;
+ switch_byte_t is_priority;
void *user_data;
struct switch_ivr_dmachine_binding *next;
};
SWITCH_DECLARE(switch_status_t) switch_ivr_dmachine_bind(switch_ivr_dmachine_t *dmachine,
const char *realm,
- const char *digits,
+ const char *digits,
+ switch_byte_t is_priority,
int32_t key,
switch_ivr_dmachine_callback_t callback,
void *user_data)
binding->key = key;
binding->digits = switch_core_strdup(dmachine->pool, digits);
+ binding->is_priority = is_priority;
binding->callback = callback;
binding->user_data = user_data;
if (bp->is_regex) {
switch_status_t r_status = switch_regex_match(dmachine->digits, bp->digits);
- if (r_status == SWITCH_STATUS_SUCCESS) {
- bp->rmatch++;
- } else {
- bp->rmatch = 0;
- }
+ bp->rmatch = r_status == SWITCH_STATUS_SUCCESS;
rmatches++;
pmatches++;
} else {
if (!strncmp(dmachine->digits, bp->digits, strlen(dmachine->digits))) {
pmatches++;
- ematches = 1;
+ if (dmachine->cur_digit_len == strlen(bp->digits)) {
+ ematches++;
+ }
}
}
}
for(bp = dmachine->realm->binding_list; bp; bp = bp->next) {
if (bp->is_regex) {
if (bp->rmatch) {
- if (is_timeout || (bp == dmachine->realm->binding_list && !bp->next)) {
+ if ((bp->is_priority && ! ematches) || is_timeout || (bp == dmachine->realm->binding_list && !bp->next)) {
best = DM_MATCH_EXACT;
exact_bp = bp;
break;
} else {
int pmatch = !strncmp(dmachine->digits, bp->digits, strlen(dmachine->digits));
- if (!exact_bp && pmatch && (((pmatches == 1 || ematches == 1) && !rmatches) || is_timeout) && !strcmp(bp->digits, dmachine->digits)) {
+ if (!exact_bp && pmatch && (!rmatches || bp->is_priority || is_timeout) && !strcmp(bp->digits, dmachine->digits)) {
best = DM_MATCH_EXACT;
exact_bp = bp;
- if (dmachine->cur_digit_len == dmachine->max_digit_len) break;
+ if (bp->is_priority || dmachine->cur_digit_len == dmachine->max_digit_len) break;
}
if (!(both_bp && partial_bp) && strlen(bp->digits) != strlen(dmachine->digits) && pmatch) {