[Freeswitch-svn] [commit] r7999 - freeswitch/trunk/src/mod/endpoints/mod_sofia

Freeswitch SVN anthm at freeswitch.org
Tue Apr 1 13:41:39 EDT 2008


Author: anthm
Date: Tue Apr  1 13:41:38 2008
New Revision: 7999

Modified:
   freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c

Log:
update

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c	Tue Apr  1 13:41:38 2008
@@ -908,6 +908,30 @@
 	}
 }
 
+
+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 @@
 
 				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);
 						}
 					}
 				}



More information about the Freeswitch-svn mailing list