From ea7f6a18576d66007593368555e8aea140c7ea30 Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Mon, 24 Oct 2011 09:53:24 -0400 Subject: [PATCH] add lookup params to presence_map --- src/switch_ivr.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/switch_ivr.c b/src/switch_ivr.c index 99fa2ff290..608e34d191 100644 --- a/src/switch_ivr.c +++ b/src/switch_ivr.c @@ -3142,17 +3142,29 @@ SWITCH_DECLARE(char *) switch_ivr_check_presence_mapping(const char *exten_name, char *cf = "presence_map.conf"; switch_xml_t cfg, xml, x_domains, x_domain, x_exten; char *r = NULL; + switch_event_t *params = NULL; switch_regex_t *re = NULL; int proceed = 0, ovector[100]; - if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) { + switch_event_create(¶ms, SWITCH_EVENT_REQUEST_PARAMS); + switch_assert(params); + + if ( !zstr(domain_name) ) { + switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "domain", domain_name); + } + + if ( !zstr(exten_name) ) { + switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "exten", exten_name); + } + + if (!(xml = switch_xml_open_cfg(cf, &cfg, params))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed\n", cf); - return NULL; + goto end; } if (!(x_domains = switch_xml_child(cfg, "domains"))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't find any domains!\n"); - return NULL; + goto end; } for (x_domain = switch_xml_child(x_domains, "domain"); x_domain; x_domain = x_domain->next) { @@ -3179,7 +3191,8 @@ SWITCH_DECLARE(char *) switch_ivr_check_presence_mapping(const char *exten_name, } end: - + switch_event_destroy(¶ms); + if (xml) { switch_xml_free(xml); }