Revision
15121
Author
anthm
Date
2009-10-08 12:43:51 -0500 (Thu, 08 Oct 2009)

Log Message

move accidental new behaviour behind new param originate_continue_on_timeout=true

Modified Paths

Diff

Modified: freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c (15120 => 15121)


--- freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c	2009-10-08 17:15:01 UTC (rev 15120)
+++ freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c	2009-10-08 17:43:51 UTC (rev 15121)
@@ -1595,12 +1595,10 @@
 
 SWITCH_STANDARD_APP(att_xfer_function)
 {
-	const char *var;
 	switch_core_session_t *peer_session = NULL;
 	switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING;
 	switch_channel_t *channel, *peer_channel = NULL;
 	const char *bond = NULL;
-	int timelimit = 60;
 	switch_core_session_t *b_session = NULL;
 
 	channel = switch_core_session_get_channel(session);
@@ -1612,11 +1610,7 @@
 	switch_channel_set_variable(channel, SWITCH_SOFT_HOLDING_UUID_VARIABLE, bond);
 	switch_channel_set_flag(channel, CF_XFER_ZOMBIE);
 
-	if ((var = switch_channel_get_variable(channel, SWITCH_CALL_TIMEOUT_VARIABLE))) {
-		timelimit = atoi(var);
-	}
-
-	if (switch_ivr_originate(session, &peer_session, &cause, data, timelimit, NULL, NULL, NULL, NULL, NULL, SOF_NONE) 
+	if (switch_ivr_originate(session, &peer_session, &cause, data, 0, NULL, NULL, NULL, NULL, NULL, SOF_NONE) 
 		!= SWITCH_STATUS_SUCCESS || !peer_session) {
 		goto end;
 	}
@@ -2125,22 +2119,17 @@
 {
 	switch_channel_t *caller_channel = switch_core_session_get_channel(session);
 	switch_core_session_t *peer_session = NULL;
-	unsigned int timelimit = 60;
-	const char *var, *continue_on_fail = NULL, *failure_causes = NULL;
+	const char *continue_on_fail = NULL, *failure_causes = NULL;
 	switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING;
 
 	if (switch_strlen_zero(data)) {
 		return;
 	}
 
-	if ((var = switch_channel_get_variable(caller_channel, SWITCH_CALL_TIMEOUT_VARIABLE))) {
-		timelimit = atoi(var);
-	}
-
 	continue_on_fail = switch_channel_get_variable(caller_channel, "continue_on_fail");
 	failure_causes = switch_channel_get_variable(caller_channel, "failure_causes");
 
-	if (switch_ivr_originate(session, &peer_session, &cause, data, timelimit, NULL, NULL, NULL, NULL, NULL, SOF_NONE) != SWITCH_STATUS_SUCCESS) {
+	if (switch_ivr_originate(session, &peer_session, &cause, data, 0, NULL, NULL, NULL, NULL, NULL, SOF_NONE) != SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Originate Failed.  Cause: %s\n", switch_channel_cause2str(cause));
 
 		/* 
@@ -2258,11 +2247,11 @@
 	switch_originate_flag_t myflags = SOF_NONE;
 	char *cid_name_override = NULL;
 	char *cid_num_override = NULL;
-	const char *var, *skip = NULL;
-	unsigned int timelimit = 60;
 	char *domain = NULL;
 	switch_channel_t *new_channel = NULL;
-	
+	unsigned int timelimit = 60;
+	const char *skip, *var;
+
 	group = strdup(outbound_profile->destination_number);
 
 	if (!group) goto done;

Modified: freeswitch/trunk/src/switch_ivr_originate.c (15120 => 15121)


--- freeswitch/trunk/src/switch_ivr_originate.c	2009-10-08 17:15:01 UTC (rev 15120)
+++ freeswitch/trunk/src/switch_ivr_originate.c	2009-10-08 17:43:51 UTC (rev 15121)
@@ -113,6 +113,7 @@
 	int monitor_early_media_ring_count;
 	int monitor_early_media_ring_total;
 	int cancel_timeout;
+	int continue_on_timeout;
 } originate_global_t;
 
 
@@ -755,7 +756,7 @@
 				switch_core_session_set_read_codec(session, &write_codec);
 			}
 		}
-			
+		
 		if (ringback_data) {
 			char *tmp_data = NULL;
 
@@ -1033,10 +1034,16 @@
 	switch_channel_state_t wait_state = 0;
 
 	if (session) {
+		const char *to_var;
 		caller_channel = switch_core_session_get_channel(session);
 		switch_channel_set_flag(caller_channel, CF_ORIGINATOR);
 		oglobals.session = session;
 
+
+		if ((to_var = switch_channel_get_variable(caller_channel, SWITCH_CALL_TIMEOUT_VARIABLE))) {
+			timelimit_sec = atoi(to_var);
+		}
+
 		if (switch_true(switch_channel_get_variable(caller_channel, SWITCH_PROXY_MEDIA_VARIABLE))) {
 			switch_channel_set_flag(caller_channel, CF_PROXY_MEDIA);
 		}
@@ -1060,6 +1067,10 @@
 		}
 	}
 
+	if (timelimit_sec <= 0) {
+		timelimit_sec = 60;
+	}
+
 	
 	oglobals.idx = IDX_NADA;
 	oglobals.early_ok = 1;
@@ -1193,6 +1204,8 @@
 					ok = 1;
 				} else if (!strcasecmp((char *) hi->name, "ignore_early_media")) {
 					ok = 1;
+				} else if (!strcasecmp((char *) hi->name, "originate_continue_on_timeout")) {
+					ok = 1;
 				} else if (!strcasecmp((char *) hi->name, "ignore_ring_ready")) {
 					ok = 1;
 				} else if (!strcasecmp((char *) hi->name, "monitor_early_media_ring")) {
@@ -1296,6 +1309,10 @@
 		oglobals.ignore_early_media = 1;
 	}
 
+	if ((var_val = switch_event_get_header(var_event, "originate_continue_on_timeout")) && switch_true(var_val)) {
+		oglobals.continue_on_timeout = 1;
+	}
+
 	if ((var_val = switch_event_get_header(var_event, "ignore_ring_ready")) && switch_true(var_val)) {
 		oglobals.ignore_ring_ready = 1;
 	}
@@ -2145,7 +2162,7 @@
 				switch_core_session_reset(oglobals.session, SWITCH_FALSE, SWITCH_TRUE);
 			}
 
-			if ((oglobals.idx == IDX_TIMEOUT || oglobals.idx == IDX_KEY_CANCEL) && switch_channel_ready(caller_channel)) {
+			if ((oglobals.idx == IDX_TIMEOUT || oglobals.idx == IDX_KEY_CANCEL) && (caller_channel && switch_channel_ready(caller_channel))) {
 				holding = NULL;
 			}
 
@@ -2465,6 +2482,10 @@
 				if (ok) {
 					goto outer_for;
 				}
+
+				if (to && !oglobals.continue_on_timeout) {
+					goto outer_for;
+				}
 			}
 		}
 	}