From f87dd96375448ae1d038708ff55743e24b451eaf Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 15 Oct 2010 18:00:49 -0500 Subject: [PATCH] more dmachine improvements --- src/include/switch_ivr.h | 2 ++ src/include/switch_types.h | 1 + src/switch_ivr_async.c | 27 ++++++++++++++++++++++++--- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/include/switch_ivr.h b/src/include/switch_ivr.h index fb023848ec..34c5db8e42 100644 --- a/src/include/switch_ivr.h +++ b/src/include/switch_ivr.h @@ -845,6 +845,8 @@ SWITCH_DECLARE(switch_bool_t) switch_ivr_uuid_exists(const char *uuid); +SWITCH_DECLARE(void) switch_ivr_dmachine_set_match_callback(switch_ivr_dmachine_t *dmachine, switch_ivr_dmachine_callback_t match_callback); +SWITCH_DECLARE(void) switch_ivr_dmachine_set_nonmatch_callback(switch_ivr_dmachine_t *dmachine, switch_ivr_dmachine_callback_t nonmatch_callback); SWITCH_DECLARE(switch_status_t) switch_ivr_dmachine_create(switch_ivr_dmachine_t **dmachine_p, const char *name, switch_memory_pool_t *pool, diff --git a/src/include/switch_types.h b/src/include/switch_types.h index cf27cb747e..c3622e3195 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -840,6 +840,7 @@ typedef enum { SWITCH_STATUS_IGNORE, SWITCH_STATUS_TOO_SMALL, SWITCH_STATUS_FOUND, + SWITCH_STATUS_CONTINUE, SWITCH_STATUS_NOT_INITALIZED } switch_status_t; diff --git a/src/switch_ivr_async.c b/src/switch_ivr_async.c index dae7ee07e6..467ea93e59 100644 --- a/src/switch_ivr_async.c +++ b/src/switch_ivr_async.c @@ -72,6 +72,21 @@ struct switch_ivr_dmachine { void *user_data; }; + +SWITCH_DECLARE(void) switch_ivr_dmachine_set_match_callback(switch_ivr_dmachine_t *dmachine, switch_ivr_dmachine_callback_t match_callback) +{ + + dmachine->match_callback = match_callback; + +} + +SWITCH_DECLARE(void) switch_ivr_dmachine_set_nonmatch_callback(switch_ivr_dmachine_t *dmachine, switch_ivr_dmachine_callback_t nonmatch_callback) +{ + + dmachine->nonmatch_callback = nonmatch_callback; + +} + SWITCH_DECLARE(switch_status_t) switch_ivr_dmachine_create(switch_ivr_dmachine_t **dmachine_p, const char *name, switch_memory_pool_t *pool, @@ -366,12 +381,16 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_dmachine_ping(switch_ivr_dmachine_t * dmachine->match.type = DM_MATCH_POSITIVE; if (dmachine->last_matching_binding->callback) { - dmachine->last_matching_binding->callback(&dmachine->match); + if (dmachine->last_matching_binding->callback(&dmachine->match) == SWITCH_STATUS_CONTINUE) { + r = SWITCH_STATUS_SUCCESS; + } } if (dmachine->match_callback) { dmachine->match.user_data = dmachine->user_data; - dmachine->match_callback(&dmachine->match); + if (dmachine->match_callback(&dmachine->match) == SWITCH_STATUS_CONTINUE) { + r = SWITCH_STATUS_SUCCESS; + } } clear++; } else if (is_timeout) { @@ -390,7 +409,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_dmachine_ping(switch_ivr_dmachine_t * if (dmachine->nonmatch_callback) { dmachine->match.user_data = dmachine->user_data; - dmachine->nonmatch_callback(&dmachine->match); + if (dmachine->nonmatch_callback(&dmachine->match) == SWITCH_STATUS_CONTINUE) { + r = SWITCH_STATUS_SUCCESS; + } } clear++;