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

Freeswitch SVN anthm at freeswitch.org
Tue Oct 21 18:40:21 EDT 2008


Author: anthm
Date: Tue Oct 21 18:40:20 2008
New Revision: 10103

Modified:
   freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
   freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h
   freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c

Log:
Add optional <variables> and <params> tag to <gateway> tag.

current gateways are:
<gateway>
 <param name="foo" value="bar"/>
</gateway>

now can also be:
<gateway>
 <params>
  <param name="foo" value="bar"/>
 </params>
</gateway>

now can also be:
<gateway>
 <params>
  <param name="foo" value="bar"/>
 </params>
 <variables>
  <variable name="myvar" val="myval"/>
 </variables>
</gateway>

any variables will be set on all outgoing channels using that gateway.




Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c	Tue Oct 21 18:40:20 2008
@@ -2029,6 +2029,16 @@
 		} else {
 			tech_pvt->invite_contact = switch_core_session_strdup(nsession, gateway_ptr->register_contact);
 		}
+
+		if (gateway_ptr->vars) {
+			switch_event_header_t *hp;
+			for(hp = gateway_ptr->vars->headers; hp; hp = hp->next) {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s setting variable [%s]=[%s]\n",
+								  switch_channel_get_name(nchannel), hp->name, hp->value);
+				switch_channel_set_variable(nchannel, hp->name, hp->value);
+			}
+		}
+
 	} else {
 		if (!(dest = strchr(profile_name, '/'))) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid URL\n");

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h	Tue Oct 21 18:40:20 2008
@@ -297,6 +297,7 @@
 	reg_state_t state;
 	switch_memory_pool_t *pool;
 	int deleted;
+	switch_event_t *vars;
 	struct sofia_gateway *next;
 };
 

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c	Tue Oct 21 18:40:20 2008
@@ -93,6 +93,9 @@
 			switch_core_hash_delete(mod_sofia_globals.gateway_hash, gateway_ptr->register_from);
 			switch_core_hash_delete(mod_sofia_globals.gateway_hash, gateway_ptr->register_contact);
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Deleted gateway %s\n", gateway_ptr->name);
+			if (gateway_ptr->vars) {
+				switch_event_destroy(&gateway_ptr->vars);
+			}
 		} else {
 			last = gateway_ptr;
 		}



More information about the Freeswitch-svn mailing list