[Freeswitch-svn] [commit] r2351 - in freeswitch/trunk/src: . mod/endpoints/mod_exosip mod/languages/mod_spidermonkey

Freeswitch SVN anthm at freeswitch.org
Mon Aug 21 16:16:29 EDT 2006


Author: anthm
Date: Mon Aug 21 16:16:28 2006
New Revision: 2351

Modified:
   freeswitch/trunk/src/mod/endpoints/mod_exosip/mod_exosip.c
   freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
   freeswitch/trunk/src/switch_ivr.c

Log:
bunch of tweaks to make ivr more fun

Modified: freeswitch/trunk/src/mod/endpoints/mod_exosip/mod_exosip.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_exosip/mod_exosip.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_exosip/mod_exosip.c	Mon Aug 21 16:16:28 2006
@@ -1217,6 +1217,7 @@
 
 		snprintf(name, sizeof(name), "Exosip/%s-%04x", event->request->from->url->username, rand() & 0xffff);
 		switch_channel_set_name(channel, name);
+		switch_channel_set_variable(channel, "endpoint_disposition", "INVITE");
 
 		if (osip_message_header_get_byname (event->request, "SrtpRealm", 0, &tedious)) {
 			tech_pvt->realm = switch_core_session_strdup(session, osip_header_get_value(tedious));
@@ -1503,31 +1504,31 @@
 
 	switch (event->type) {
 	case EXOSIP_CALL_RELEASED:
-		switch_channel_set_variable(channel, "exosip_disposition", "RELEASED");
+		switch_channel_set_variable(channel, "endpoint_disposition", "RELEASED");
 		cause = SWITCH_CAUSE_NORMAL_CLEARING;
 		break;
 	case EXOSIP_CALL_CLOSED:
-		switch_channel_set_variable(channel, "exosip_disposition", "CLOSED");
+		switch_channel_set_variable(channel, "endpoint_disposition", "CLOSED");
 		cause = SWITCH_CAUSE_NORMAL_CLEARING;
 		break;
 	case EXOSIP_CALL_NOANSWER:
-		switch_channel_set_variable(channel, "exosip_disposition", "NO ANSWER");
+		switch_channel_set_variable(channel, "endpoint_disposition", "NO ANSWER");
 		cause = SWITCH_CAUSE_NO_ANSWER;
 		break;
 	case EXOSIP_CALL_REQUESTFAILURE:
-		switch_channel_set_variable(channel, "exosip_disposition", "REQUEST FAILURE");
+		switch_channel_set_variable(channel, "endpoint_disposition", "REQUEST FAILURE");
 		cause = SWITCH_CAUSE_REQUESTED_CHAN_UNAVAIL;
 		break;
 	case EXOSIP_CALL_SERVERFAILURE:
-		switch_channel_set_variable(channel, "exosip_disposition", "SERVER FAILURE");
+		switch_channel_set_variable(channel, "endpoint_disposition", "SERVER FAILURE");
 		cause = SWITCH_CAUSE_CALL_REJECTED;
 		break;
 	case EXOSIP_CALL_GLOBALFAILURE:
-		switch_channel_set_variable(channel, "exosip_disposition", "GLOBAL FAILURE");
+		switch_channel_set_variable(channel, "endpoint_disposition", "GLOBAL FAILURE");
 		cause = SWITCH_CAUSE_CALL_REJECTED;
 		break;
 	default:
-		switch_channel_set_variable(channel, "exosip_disposition", "UNKNOWN");
+		switch_channel_set_variable(channel, "endpoint_disposition", "UNKNOWN");
 		cause = SWITCH_CAUSE_SWITCH_CONGESTION;
 		break;
 	}
@@ -1735,6 +1736,8 @@
 		switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
 		return;
 	}
+
+	switch_channel_set_variable(channel, "endpoint_disposition", "ANSWER");
 
 
 	conn = eXosip_get_audio_connection(remote_sdp);

Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c	(original)
+++ freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c	Mon Aug 21 16:16:28 2006
@@ -803,6 +803,55 @@
 	return (switch_channel_ready(channel)) ? JS_TRUE : JS_FALSE;
 }
 
+static JSBool session_set_variable(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+{
+	struct js_session *jss = JS_GetPrivate(cx, obj);
+    switch_channel_t *channel;
+
+	channel = switch_core_session_get_channel(jss->session);
+    assert(channel != NULL);
+
+	if (argc > 1) {
+		char *var, *val;
+
+		var = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
+		val = JS_GetStringBytes(JS_ValueToString(cx, argv[1]));
+		switch_channel_set_variable(channel, var, val);
+		*rval = BOOLEAN_TO_JSVAL( JS_TRUE );
+	} else {
+		*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+	}
+ 	
+	return JS_TRUE;
+}
+
+static JSBool session_get_variable(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+{
+	struct js_session *jss = JS_GetPrivate(cx, obj);
+    switch_channel_t *channel;
+
+	channel = switch_core_session_get_channel(jss->session);
+    assert(channel != NULL);
+
+	if (argc > 0) {
+		char *var, *val;
+		
+		var = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
+		val = switch_channel_get_variable(channel, var);
+
+		if (val) {
+			*rval = STRING_TO_JSVAL (JS_NewStringCopyZ(cx, val));
+		} else {
+			*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+		}
+	} else {
+		*rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+	}
+ 	
+	return JS_TRUE;
+}
+
+
 static JSBool session_speak(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
 {
 	struct js_session *jss = JS_GetPrivate(cx, obj);
@@ -1193,6 +1242,8 @@
 	{"flushEvents", session_flush_events, 1}, 
 	{"flushDigits", session_flush_digits, 1}, 
 	{"speak", session_speak, 1}, 
+	{"setVariable", session_set_variable, 1}, 
+	{"getVariable", session_get_variable, 1}, 
 	{"getDigits", session_get_digits, 1},
 	{"answer", session_answer, 0}, 
 	{"ready", session_ready, 0}, 
@@ -1414,7 +1465,7 @@
 												   context,
 												   dest);
 		
-		if (switch_ivr_originate(NULL, &peer_session, dest, to ? atoi(to) : 60, NULL, NULL, NULL, caller_profile) != SWITCH_STATUS_SUCCESS) {
+		if (switch_ivr_originate(session, &peer_session, dest, to ? atoi(to) : 60, NULL, NULL, NULL, caller_profile) != SWITCH_STATUS_SUCCESS) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Cannot Create Outgoing Channel! [%s]\n", dest);
 			return JS_TRUE;
 		}

Modified: freeswitch/trunk/src/switch_ivr.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr.c	(original)
+++ freeswitch/trunk/src/switch_ivr.c	Mon Aug 21 16:16:28 2006
@@ -1328,11 +1328,13 @@
 		status = SWITCH_STATUS_GENERR;
 		goto done;
 	}
-	
+
 	if (session) {
 		caller_channel = switch_core_session_get_channel(session);
 		assert(caller_channel != NULL);
 
+		switch_channel_set_variable(caller_channel, "originate_disposition", "failure");
+
 		if ((var = switch_channel_get_variable(caller_channel, "group_confirm_key"))) {
 			key = switch_core_session_strdup(session, var);
 			if ((var = switch_channel_get_variable(caller_channel, "group_confirm_file"))) {
@@ -1399,21 +1401,35 @@
 				goto done;
 			}
 
-			caller_profiles[i] = switch_caller_profile_new(pool,
-														   NULL,
-														   NULL,
-														   cid_name_override,
-														   cid_num_override,
-														   NULL,
-														   NULL, 
-														   NULL,
-														   NULL,
-														   __FILE__,
-														   NULL,
-														   chan_data);
+			if (caller_profile_override) {
+				caller_profiles[i] = switch_caller_profile_new(pool,
+															   caller_profile_override->username,
+															   caller_profile_override->dialplan,
+															   caller_profile_override->caller_id_name,
+															   caller_profile_override->caller_id_number,
+															   caller_profile_override->network_addr, 
+															   caller_profile_override->ani,
+															   caller_profile_override->ani2,
+															   caller_profile_override->rdnis,
+															   caller_profile_override->source,
+															   caller_profile_override->context,
+															   chan_data);
+			} else {
+				caller_profiles[i] = switch_caller_profile_new(pool,
+															   NULL,
+															   NULL,
+															   cid_name_override,
+															   cid_num_override,
+															   NULL,
+															   NULL, 
+															   NULL,
+															   NULL,
+															   __FILE__,
+															   NULL,
+															   chan_data);
+			}
 		}
 
-
 		if (switch_core_session_outgoing_channel(session, chan_type, caller_profiles[i], &peer_sessions[i], pool) != SWITCH_STATUS_SUCCESS) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot Create Outgoing Channel!\n");
 			if (pool) {
@@ -1526,10 +1542,7 @@
 			continue;
 		}
 		if (i != idx) {
-			if (caller_channel) {
-				switch_channel_set_variable(caller_channel, "originate_disposition", "lost race");
-				switch_channel_hangup(peer_channels[i], SWITCH_CAUSE_LOSE_RACE);
-			}
+			switch_channel_hangup(peer_channels[i], SWITCH_CAUSE_LOSE_RACE);
 		}
 	}
 



More information about the Freeswitch-svn mailing list