[Freeswitch-svn] [commit] r9571 - in freeswitch/trunk/src: . include mod/languages/mod_java mod/languages/mod_java/src/org/freeswitch/swig mod/languages/mod_lua mod/languages/mod_perl mod/languages/mod_python

Freeswitch SVN anthm at freeswitch.org
Mon Sep 15 17:44:44 EDT 2008


Author: anthm
Date: Mon Sep 15 17:44:43 2008
New Revision: 9571

Modified:
   freeswitch/trunk/src/include/switch_cpp.h
   freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/CoreSession.java
   freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitchJNI.java
   freeswitch/trunk/src/mod/languages/mod_java/switch_swig_wrap.cpp
   freeswitch/trunk/src/mod/languages/mod_lua/mod_lua_wrap.cpp
   freeswitch/trunk/src/mod/languages/mod_perl/freeswitch.pm
   freeswitch/trunk/src/mod/languages/mod_perl/mod_perl_wrap.cpp
   freeswitch/trunk/src/mod/languages/mod_python/freeswitch.py
   freeswitch/trunk/src/mod/languages/mod_python/mod_python_wrap.cpp
   freeswitch/trunk/src/switch_cpp.cpp

Log:
add session destroy psuedo method to sort of destroy a session at least for the sake of FS

Modified: freeswitch/trunk/src/include/switch_cpp.h
==============================================================================
--- freeswitch/trunk/src/include/switch_cpp.h	(original)
+++ freeswitch/trunk/src/include/switch_cpp.h	Mon Sep 15 17:44:43 2008
@@ -254,6 +254,8 @@
 		 SWITCH_DECLARE(int) originate(CoreSession * a_leg_session, char *dest, int timeout = 60);
 
 
+		 SWITCH_DECLARE(void) destroy(void);
+
 	/** \brief set a DTMF callback function
 	 * 
 	 * The DTMF callback function will be set and persist

Modified: freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/CoreSession.java
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/CoreSession.java	(original)
+++ freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/CoreSession.java	Mon Sep 15 17:44:43 2008
@@ -189,6 +189,10 @@
     return freeswitchJNI.CoreSession_originate__SWIG_1(swigCPtr, this, CoreSession.getCPtr(a_leg_session), a_leg_session, dest);
   }
 
+  public void destroy() {
+    freeswitchJNI.CoreSession_destroy(swigCPtr, this);
+  }
+
   public void setDTMFCallback(SWIGTYPE_p_void cbfunc, String funcargs) {
     freeswitchJNI.CoreSession_setDTMFCallback(swigCPtr, this, SWIGTYPE_p_void.getCPtr(cbfunc), funcargs);
   }

Modified: freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitchJNI.java
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitchJNI.java	(original)
+++ freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitchJNI.java	Mon Sep 15 17:44:43 2008
@@ -122,6 +122,7 @@
   public final static native void CoreSession_setCallerData(long jarg1, CoreSession jarg1_, String jarg2, String jarg3);
   public final static native int CoreSession_originate__SWIG_0(long jarg1, CoreSession jarg1_, long jarg2, CoreSession jarg2_, String jarg3, int jarg4);
   public final static native int CoreSession_originate__SWIG_1(long jarg1, CoreSession jarg1_, long jarg2, CoreSession jarg2_, String jarg3);
+  public final static native void CoreSession_destroy(long jarg1, CoreSession jarg1_);
   public final static native void CoreSession_setDTMFCallback(long jarg1, CoreSession jarg1_, long jarg2, String jarg3);
   public final static native int CoreSession_speak(long jarg1, CoreSession jarg1_, String jarg2);
   public final static native void CoreSession_set_tts_parms(long jarg1, CoreSession jarg1_, String jarg2, String jarg3);

Modified: freeswitch/trunk/src/mod/languages/mod_java/switch_swig_wrap.cpp
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_java/switch_swig_wrap.cpp	(original)
+++ freeswitch/trunk/src/mod/languages/mod_java/switch_swig_wrap.cpp	Mon Sep 15 17:44:43 2008
@@ -2304,6 +2304,17 @@
 }
 
 
+SWIGEXPORT void JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1destroy(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_) {
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(CoreSession **)&jarg1; 
+  (arg1)->destroy();
+}
+
+
 SWIGEXPORT void JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1setDTMFCallback(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2, jstring jarg3) {
   CoreSession *arg1 = (CoreSession *) 0 ;
   void *arg2 = (void *) 0 ;

Modified: freeswitch/trunk/src/mod/languages/mod_lua/mod_lua_wrap.cpp
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/mod_lua_wrap.cpp	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/mod_lua_wrap.cpp	Mon Sep 15 17:44:43 2008
@@ -5405,6 +5405,30 @@
 }
 
 
+static int _wrap_CoreSession_destroy(lua_State* L) {
+  int SWIG_arg = -1;
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  
+  SWIG_check_num_args("destroy",1,1)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("destroy",1,"CoreSession *");
+  
+  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
+    SWIG_fail_ptr("CoreSession_destroy",1,SWIGTYPE_p_CoreSession);
+  }
+  
+  (arg1)->destroy();
+  SWIG_arg=0;
+  
+  return SWIG_arg;
+  
+  if(0) SWIG_fail;
+  
+fail:
+  lua_error(L);
+  return SWIG_arg;
+}
+
+
 static int _wrap_CoreSession_setDTMFCallback(lua_State* L) {
   int SWIG_arg = -1;
   CoreSession *arg1 = (CoreSession *) 0 ;
@@ -6674,6 +6698,7 @@
     {"recordFile", _wrap_CoreSession_recordFile}, 
     {"setCallerData", _wrap_CoreSession_setCallerData}, 
     {"originate", _wrap_CoreSession_originate}, 
+    {"destroy", _wrap_CoreSession_destroy}, 
     {"setDTMFCallback", _wrap_CoreSession_setDTMFCallback}, 
     {"speak", _wrap_CoreSession_speak}, 
     {"set_tts_parms", _wrap_CoreSession_set_tts_parms}, 

Modified: freeswitch/trunk/src/mod/languages/mod_perl/freeswitch.pm
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_perl/freeswitch.pm	(original)
+++ freeswitch/trunk/src/mod/languages/mod_perl/freeswitch.pm	Mon Sep 15 17:44:43 2008
@@ -410,6 +410,7 @@
 *recordFile = *freeswitchc::CoreSession_recordFile;
 *setCallerData = *freeswitchc::CoreSession_setCallerData;
 *originate = *freeswitchc::CoreSession_originate;
+*destroy = *freeswitchc::CoreSession_destroy;
 *setDTMFCallback = *freeswitchc::CoreSession_setDTMFCallback;
 *speak = *freeswitchc::CoreSession_speak;
 *set_tts_parms = *freeswitchc::CoreSession_set_tts_parms;

Modified: freeswitch/trunk/src/mod/languages/mod_perl/mod_perl_wrap.cpp
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_perl/mod_perl_wrap.cpp	(original)
+++ freeswitch/trunk/src/mod/languages/mod_perl/mod_perl_wrap.cpp	Mon Sep 15 17:44:43 2008
@@ -7030,6 +7030,33 @@
 }
 
 
+XS(_wrap_CoreSession_destroy) {
+  {
+    CoreSession *arg1 = (CoreSession *) 0 ;
+    void *argp1 = 0 ;
+    int res1 = 0 ;
+    int argvi = 0;
+    dXSARGS;
+    
+    if ((items < 1) || (items > 1)) {
+      SWIG_croak("Usage: CoreSession_destroy(self);");
+    }
+    res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_CoreSession, 0 |  0 );
+    if (!SWIG_IsOK(res1)) {
+      SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CoreSession_destroy" "', argument " "1"" of type '" "CoreSession *""'"); 
+    }
+    arg1 = reinterpret_cast< CoreSession * >(argp1);
+    (arg1)->destroy();
+    
+    
+    XSRETURN(argvi);
+  fail:
+    
+    SWIG_croak_null();
+  }
+}
+
+
 XS(_wrap_CoreSession_setDTMFCallback) {
   {
     CoreSession *arg1 = (CoreSession *) 0 ;
@@ -10588,6 +10615,7 @@
 {"freeswitchc::CoreSession_recordFile", _wrap_CoreSession_recordFile},
 {"freeswitchc::CoreSession_setCallerData", _wrap_CoreSession_setCallerData},
 {"freeswitchc::CoreSession_originate", _wrap_CoreSession_originate},
+{"freeswitchc::CoreSession_destroy", _wrap_CoreSession_destroy},
 {"freeswitchc::CoreSession_setDTMFCallback", _wrap_CoreSession_setDTMFCallback},
 {"freeswitchc::CoreSession_speak", _wrap_CoreSession_speak},
 {"freeswitchc::CoreSession_set_tts_parms", _wrap_CoreSession_set_tts_parms},

Modified: freeswitch/trunk/src/mod/languages/mod_python/freeswitch.py
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_python/freeswitch.py	(original)
+++ freeswitch/trunk/src/mod/languages/mod_python/freeswitch.py	Mon Sep 15 17:44:43 2008
@@ -268,6 +268,7 @@
     def recordFile(*args): return _freeswitch.CoreSession_recordFile(*args)
     def setCallerData(*args): return _freeswitch.CoreSession_setCallerData(*args)
     def originate(*args): return _freeswitch.CoreSession_originate(*args)
+    def destroy(*args): return _freeswitch.CoreSession_destroy(*args)
     def setDTMFCallback(*args): return _freeswitch.CoreSession_setDTMFCallback(*args)
     def speak(*args): return _freeswitch.CoreSession_speak(*args)
     def set_tts_parms(*args): return _freeswitch.CoreSession_set_tts_parms(*args)

Modified: freeswitch/trunk/src/mod/languages/mod_python/mod_python_wrap.cpp
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_python/mod_python_wrap.cpp	(original)
+++ freeswitch/trunk/src/mod/languages/mod_python/mod_python_wrap.cpp	Mon Sep 15 17:44:43 2008
@@ -7131,6 +7131,27 @@
 }
 
 
+SWIGINTERN PyObject *_wrap_CoreSession_destroy(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:CoreSession_destroy",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CoreSession, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CoreSession_destroy" "', argument " "1"" of type '" "CoreSession *""'"); 
+  }
+  arg1 = reinterpret_cast< CoreSession * >(argp1);
+  (arg1)->destroy();
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
 SWIGINTERN PyObject *_wrap_CoreSession_setDTMFCallback(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CoreSession *arg1 = (CoreSession *) 0 ;
@@ -9639,6 +9660,7 @@
 	 { (char *)"CoreSession_recordFile", _wrap_CoreSession_recordFile, METH_VARARGS, NULL},
 	 { (char *)"CoreSession_setCallerData", _wrap_CoreSession_setCallerData, METH_VARARGS, NULL},
 	 { (char *)"CoreSession_originate", _wrap_CoreSession_originate, METH_VARARGS, NULL},
+	 { (char *)"CoreSession_destroy", _wrap_CoreSession_destroy, METH_VARARGS, NULL},
 	 { (char *)"CoreSession_setDTMFCallback", _wrap_CoreSession_setDTMFCallback, METH_VARARGS, NULL},
 	 { (char *)"CoreSession_speak", _wrap_CoreSession_speak, METH_VARARGS, NULL},
 	 { (char *)"CoreSession_set_tts_parms", _wrap_CoreSession_set_tts_parms, METH_VARARGS, NULL},

Modified: freeswitch/trunk/src/switch_cpp.cpp
==============================================================================
--- freeswitch/trunk/src/switch_cpp.cpp	(original)
+++ freeswitch/trunk/src/switch_cpp.cpp	Mon Sep 15 17:44:43 2008
@@ -459,22 +459,8 @@
 
 SWITCH_DECLARE_CONSTRUCTOR CoreSession::~CoreSession()
 {
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CoreSession::~CoreSession desctructor\n");
-	switch_channel_t *channel = NULL;
-	
 	this_check_void();
-	switch_safe_free(xml_cdr_text);
-	switch_safe_free(uuid);	
-	switch_safe_free(tts_name);
-	switch_safe_free(voice_name);
-
-	if (session) {
-		channel = switch_core_session_get_channel(session);
-		if (switch_test_flag(this, S_HUP) && !switch_channel_test_flag(channel, CF_TRANSFER)) {
-			switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
-		}
-		switch_core_session_rwunlock(session);
-	}
+	destroy();
 }
 
 SWITCH_DECLARE(char *) CoreSession::getXMLCDR()
@@ -850,6 +836,28 @@
 	return switch_channel_test_flag(channel, CF_ANSWERED) != 0;
 }
 
+SWITCH_DECLARE(void) CoreSession::destroy(void)
+{
+	this_check_void();
+
+	switch_safe_free(xml_cdr_text);
+	switch_safe_free(uuid);	
+	switch_safe_free(tts_name);
+	switch_safe_free(voice_name);
+
+	if (session) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "destroy/unlink session from object\n");
+        if (switch_test_flag(this, S_HUP) && !switch_channel_test_flag(channel, CF_TRANSFER)) {
+            switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
+        }
+        switch_core_session_rwunlock(session);
+		session = NULL;
+    }
+
+	allocated = 0;
+	
+}
+
 SWITCH_DECLARE(int) CoreSession::originate(CoreSession *a_leg_session, char *dest, int timeout)
 {
 



More information about the Freeswitch-svn mailing list