From 22abe48d869738d76a8883555e18648625edd86d Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Tue, 1 Apr 2008 17:41:38 +0000 Subject: [PATCH] update git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7999 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/mod/endpoints/mod_sofia/sofia.c | 51 ++++++++++++++++++++++------- 1 file changed, 39 insertions(+), 12 deletions(-) diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index ba2234f87f..5418131c15 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -908,6 +908,30 @@ static void parse_gateways(sofia_profile_t *profile, switch_xml_t gateways_tag) } } + +static void parse_domain_tag(sofia_profile_t *profile, switch_xml_t x_domain_tag, const char *dname, const char *parse, const char *alias) +{ + + if (switch_true(alias)) { + if (sofia_glue_add_profile(switch_core_strdup(profile->pool, dname), profile) == SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Adding Alias [%s] for profile [%s]\n", dname, profile->name); + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Adding Alias [%s] for profile [%s] (name in use)\n", + dname, profile->name); + } + } + + if (switch_true(parse)) { + switch_xml_t ut, gateways_tag; + for (ut = switch_xml_child(x_domain_tag, "user"); ut; ut = ut->next) { + if (((gateways_tag = switch_xml_child(ut, "gateways")))) { + parse_gateways(profile, gateways_tag); + } + } + } +} + + switch_status_t config_sofia(int reload, char *profile_name) { char *cf = "sofia.conf"; @@ -1344,22 +1368,25 @@ switch_status_t config_sofia(int reload, char *profile_name) if ((domains_tag = switch_xml_child(xprofile, "domains"))) { for (domain_tag = switch_xml_child(domains_tag, "domain"); domain_tag; domain_tag = domain_tag->next) { - switch_xml_t droot, actual_domain_tag, ut; - char *dname = (char *) switch_xml_attr_soft(domain_tag, "name"); - char *parse = (char *) switch_xml_attr_soft(domain_tag, "parse"); - + switch_xml_t droot, x_domain_tag; + const char *dname = switch_xml_attr_soft(domain_tag, "name"); + const char *parse = switch_xml_attr_soft(domain_tag, "parse"); + const char *alias = switch_xml_attr_soft(domain_tag, "alias"); + if (!switch_strlen_zero(dname)) { - if (switch_true(parse)) { - if (switch_xml_locate_domain(dname, NULL, &droot, &actual_domain_tag) == SWITCH_STATUS_SUCCESS) { - for (ut = switch_xml_child(actual_domain_tag, "user"); ut; ut = ut->next) { - if (((gateways_tag = switch_xml_child(ut, "gateways")))) { - parse_gateways(profile, gateways_tag); - } + if (!strcasecmp(dname, "all")) { + switch_xml_t xml_root, x_domains; + if (switch_xml_locate("directory", NULL, NULL, NULL, &xml_root, &x_domains, NULL) == SWITCH_STATUS_SUCCESS) { + for(x_domain_tag = switch_xml_child(x_domains, "domain"); x_domain_tag; x_domain_tag = x_domain_tag->next) { + dname = switch_xml_attr_soft(x_domain_tag, "name"); + parse_domain_tag(profile, x_domain_tag, dname, parse, alias); } - switch_xml_free(droot); + switch_xml_free(xml_root); } + } else if (switch_xml_locate_domain(dname, NULL, &droot, &x_domain_tag) == SWITCH_STATUS_SUCCESS) { + parse_domain_tag(profile, x_domain_tag, dname, parse, alias); + switch_xml_free(droot); } - sofia_glue_add_profile(switch_core_strdup(profile->pool, dname), profile); } } }