[Freeswitch-svn] [commit] r11983 - freeswitch/trunk/src/mod/languages/mod_spidermonkey

FreeSWITCH SVN anthm at freeswitch.org
Fri Feb 13 07:26:48 PST 2009


Author: anthm
Date: Fri Feb 13 09:26:48 2009
New Revision: 11983

Log:
block some unwanted behaviours regarding session.originate

Modified:
   freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c

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	Fri Feb 13 09:26:48 2009
@@ -2853,6 +2853,14 @@
 	jss = JS_GetPrivate(cx, obj);
 	jss->cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
 
+
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "This method is depricated, please use new Session(\"<dial string>\", a_leg) \n");
+
+	if (jss->session) {
+		eval_some_js("~throw new Error(\"cannot call this method on an initialized session\");", cx, obj, rval);
+		return JS_FALSE;
+	}
+
 	if (argc > 1) {
 		JSObject *session_obj;
 		switch_core_session_t *session = NULL, *peer_session = NULL;
@@ -2876,7 +2884,19 @@
 
 		if (JS_ValueToObject(cx, argv[0], &session_obj)) {
 			struct js_session *old_jss = NULL;
-			if (session_obj && (old_jss = JS_GetPrivate(cx, session_obj)) && old_jss->session) {
+			if (session_obj && (old_jss = JS_GetPrivate(cx, session_obj))) {
+				
+				if (old_jss == jss) {
+					eval_some_js("~throw new Error(\"Supplied a_leg session is the same as our session\");", cx, obj, rval);
+					return JS_FALSE;
+					
+				};
+				
+				if (!old_jss->session) {
+					eval_some_js("~throw new Error(\"Supplied a_leg session is not initilaized!\");", cx, obj, rval);
+					return JS_FALSE;
+				}
+				
 				session = old_jss->session;
 				orig_caller_profile = switch_channel_get_caller_profile(switch_core_session_get_channel(session));
 				dialplan = orig_caller_profile->dialplan;
@@ -2888,6 +2908,7 @@
 				context = orig_caller_profile->context;
 				username = orig_caller_profile->username;
 			}
+
 		}
 
 		if (!switch_strlen_zero(jss->dialplan))



More information about the Freeswitch-svn mailing list