]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add session destroy psuedo method to sort of destroy a session at least for the sake...
authorAnthony Minessale <anthony.minessale@gmail.com>
Mon, 15 Sep 2008 21:44:43 +0000 (21:44 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Mon, 15 Sep 2008 21:44:43 +0000 (21:44 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9571 d0543943-73ff-0310-b7d9-9358b9ac24b2

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

index 58f46eafafc044f8f767d146348262867d12677a..f799c57ce0301a8d9707382f214c15f8c087e177 100644 (file)
@@ -254,6 +254,8 @@ SWITCH_DECLARE(void) consoleCleanLog(char *msg);
                 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
index 3519d69898417fb3b367447d82538c0a56768f25..fd2f6f02940360e69a63d1f8f1cb2e3643829940 100644 (file)
@@ -189,6 +189,10 @@ public class CoreSession {
     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);
   }
index 9fbb64bb471bbc6c700e581d10f6d3c023d4f057..20b5dd5913de4b219271dc96fd97b1232c572ec9 100644 (file)
@@ -122,6 +122,7 @@ class freeswitchJNI {
   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);
index 88ffa0af1ba85085af1e11bc36ce30594d0fbb16..942504dc5db46a8a3aeed055a69726e4b343e759 100644 (file)
@@ -2304,6 +2304,17 @@ SWIGEXPORT jint JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1orig
 }
 
 
+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 ;
index c1c864fb798d065778fdc9b8876934512084fda9..bbb01e55ad8151d2f7478829866bc4bc3a6b8f2d 100644 (file)
@@ -5405,6 +5405,30 @@ static int _wrap_CoreSession_originate(lua_State* L) {
 }
 
 
+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 @@ static swig_lua_method swig_CoreSession_methods[] = {
     {"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}, 
index 3d1fbb805b2563cd88e63ce6c9de8459fd716c74..6b92a1ba0390f768a2a0a353b728c6aa2b72a965 100644 (file)
@@ -410,6 +410,7 @@ sub DESTROY {
 *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;
index 0d606dd77ae38464ecf51f73c5f018367bda1022..900b725ae0db214765993b07cf873ccc3b042e0b 100644 (file)
@@ -7030,6 +7030,33 @@ XS(_wrap_CoreSession_originate) {
 }
 
 
+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 @@ static swig_command_info swig_commands[] = {
 {"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},
index 720be0205bddbd3381e404f8128b1abb1fcc30d9..01d8a883335f77ab670df50617e0a6a48d2e96e3 100644 (file)
@@ -268,6 +268,7 @@ class CoreSession(_object):
     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)
index 60155d014b9a8c2ba1a6fee8ee7532dbc423b3b7..79a30dcdadaa427b1b7d72d824158d7a96ead003 100644 (file)
@@ -7131,6 +7131,27 @@ fail:
 }
 
 
+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 @@ static PyMethodDef SwigMethods[] = {
         { (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},
index 7b81769b54206e06cb226be379367e96a2be2eaf..a2aa3d64fe89b6b35500623a5ce72f74b0fb37c8 100644 (file)
@@ -459,22 +459,8 @@ SWITCH_DECLARE_CONSTRUCTOR CoreSession::CoreSession(switch_core_session_t *new_s
 
 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 @@ SWITCH_DECLARE(bool) CoreSession::answered() {
        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)
 {