[Freeswitch-svn] [commit] r13247 - in freeswitch/trunk/src: . mod/applications/mod_dptools

FreeSWITCH SVN mrene at freeswitch.org
Wed May 6 19:05:17 PDT 2009


Author: mrene
Date: Wed May  6 21:05:16 2009
New Revision: 13247

Log:
MODAPP-271

Modified:
   freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
   freeswitch/trunk/src/switch_ivr_originate.c

Modified: freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c	(original)
+++ freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c	Wed May  6 21:05:16 2009
@@ -2307,7 +2307,7 @@
 	static switch_call_cause_t cause = SWITCH_CAUSE_NONE;
 	unsigned int timelimit = 60;
 	switch_channel_t *new_channel = NULL;
-	switch_event_t *params = NULL;
+	switch_event_t *params = NULL, *var_event_orig = var_event;
 	char stupid[128] = "";
 	const char *skip = NULL, *var = NULL;
 
@@ -2357,7 +2357,13 @@
 
 			if (!strcasecmp(var, "dial-string")) {
 				dest = val;
-				break;
+			} else if (!strncasecmp(var, "dial-var-", 9)) {
+				if (!var_event) {
+					switch_event_create(&var_event, SWITCH_EVENT_GENERAL);
+				} else {
+					switch_event_del_header(var_event, var + 9);
+				}
+				switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, var + 9, val);
 			}
 		}
 	}
@@ -2369,7 +2375,13 @@
 
 			if (!strcasecmp(var, "dial-string")) {
 				dest = val;
-				break;
+			} else if (!strncasecmp(var, "dial-var-", 9)) {
+				if (!var_event) {
+					switch_event_create(&var_event, SWITCH_EVENT_GENERAL);
+				} else {
+					switch_event_del_header(var_event, var + 9);
+				}
+				switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, var + 9, val);
 			}
 		}
 	}
@@ -2381,7 +2393,13 @@
 
 			if (!strcasecmp(var, "dial-string")) {
 				dest = val;
-				break;
+			} else if (!strncasecmp(var, "dial-var-", 9)) {
+				if (!var_event) {
+					switch_event_create(&var_event, SWITCH_EVENT_GENERAL);
+				} else {
+					switch_event_del_header(var_event, var + 9);
+				}
+				switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, var + 9, val);
 			}
 		}
 	}
@@ -2489,6 +2507,10 @@
 	if (params) {
 		switch_event_destroy(&params);
 	}
+	
+	if (var_event && var_event_orig != var_event) {
+		switch_event_destroy(&var_event);
+	}
 
 	switch_safe_free(user);
 

Modified: freeswitch/trunk/src/switch_ivr_originate.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_originate.c	(original)
+++ freeswitch/trunk/src/switch_ivr_originate.c	Wed May  6 21:05:16 2009
@@ -1006,6 +1006,24 @@
 		}
 	}
 
+	if (vars) {					/* Parse parameters specified from the dialstring */
+		char *var_array[1024] = { 0 };
+		int var_count = 0;
+		if ((var_count = switch_separate_string(vars, ',', var_array, (sizeof(var_array) / sizeof(var_array[0]))))) {
+			int x = 0;
+			for (x = 0; x < var_count; x++) {
+				char *inner_var_array[2] = { 0 };
+				int inner_var_count;
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "variable string %d = [%s]\n", x, var_array[x]);
+				if ((inner_var_count =
+					 switch_separate_string(var_array[x], '=', inner_var_array, (sizeof(inner_var_array) / sizeof(inner_var_array[0])))) == 2) {
+					switch_event_del_header(var_event, inner_var_array[0]);
+					switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, inner_var_array[0], inner_var_array[1]);
+				}
+			}
+		}
+	}
+
 	if (oglobals.session) {
 		switch_event_header_t *hi;
 		const char *cdr_total_var;
@@ -1020,7 +1038,7 @@
 		}
 		
 
-		/* Copy all the applicable channel variables into the event */
+		/* Copy all the missing applicable channel variables from A-leg into the event */
 		if ((hi = switch_channel_variable_first(caller_channel))) {
 			for (; hi; hi = hi->next) {
 				int ok = 0;
@@ -1052,7 +1070,7 @@
 					ok = 1;
 				}
 
-				if (ok) {
+				if (ok && !switch_event_get_header(var_event, hi->name)) {
 					switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, (char *) hi->name, (char *) hi->value);
 				}
 			}
@@ -1071,24 +1089,6 @@
 		*/
 	}
 
-	if (vars) {					/* Parse parameters specified from the dialstring */
-		char *var_array[1024] = { 0 };
-		int var_count = 0;
-		if ((var_count = switch_separate_string(vars, ',', var_array, (sizeof(var_array) / sizeof(var_array[0]))))) {
-			int x = 0;
-			for (x = 0; x < var_count; x++) {
-				char *inner_var_array[2] = { 0 };
-				int inner_var_count;
-				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "variable string %d = [%s]\n", x, var_array[x]);
-				if ((inner_var_count =
-					 switch_separate_string(var_array[x], '=', inner_var_array, (sizeof(inner_var_array) / sizeof(inner_var_array[0])))) == 2) {
-					switch_event_del_header(var_event, inner_var_array[0]);
-					switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, inner_var_array[0], inner_var_array[1]);
-				}
-			}
-		}
-	}
-
 	if (caller_channel) {		/* ringback is only useful when there is an originator */
 		ringback_data = NULL;
 



More information about the Freeswitch-svn mailing list