]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
block some unwanted behaviours regarding session.originate
authorAnthony Minessale <anthony.minessale@gmail.com>
Fri, 13 Feb 2009 15:26:48 +0000 (15:26 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Fri, 13 Feb 2009 15:26:48 +0000 (15:26 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@11983 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/languages/mod_spidermonkey/mod_spidermonkey.c

index 2d2b369ddd6ceb84fa009b131c82cc1e3891b8bc..d0f77e4a43a92d6fb3adf2b790219e34f29f56dc 100644 (file)
@@ -2853,6 +2853,14 @@ static JSBool session_originate(JSContext * cx, JSObject * obj, uintN argc, jsva
        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 @@ static JSBool session_originate(JSContext * cx, JSObject * obj, uintN argc, jsva
 
                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 @@ static JSBool session_originate(JSContext * cx, JSObject * obj, uintN argc, jsva
                                context = orig_caller_profile->context;
                                username = orig_caller_profile->username;
                        }
+
                }
 
                if (!switch_strlen_zero(jss->dialplan))