[Freeswitch-svn] [commit] r5098 - freeswitch/trunk/src/mod/languages/mod_python

Freeswitch SVN anthm at freeswitch.org
Mon May 7 17:27:42 EDT 2007


Author: anthm
Date: Mon May  7 17:27:42 2007
New Revision: 5098

Modified:
   freeswitch/trunk/src/mod/languages/mod_python/freeswitch.py
   freeswitch/trunk/src/mod/languages/mod_python/freeswitch_python.cpp
   freeswitch/trunk/src/mod/languages/mod_python/freeswitch_python.h
   freeswitch/trunk/src/mod/languages/mod_python/mod_python.c
   freeswitch/trunk/src/mod/languages/mod_python/mod_python.i
   freeswitch/trunk/src/mod/languages/mod_python/mod_python_wrap.cpp

Log:
anti-venom for a nasty python byte

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 May  7 17:27:42 2007
@@ -32,6 +32,10 @@
 
 
 PythonDTMFCallback = _freeswitch.PythonDTMFCallback
+
+console_log = _freeswitch.console_log
+
+console_clean_log = _freeswitch.console_clean_log
 class SessionContainer(_object):
     __swig_setmethods__ = {}
     __setattr__ = lambda self, name, value: _swig_setattr(self, SessionContainer, name, value)
@@ -46,8 +50,6 @@
         try:
             if self.thisown: destroy(self)
         except: pass
-    def console_log(*args): return _freeswitch.SessionContainer_console_log(*args)
-    def console_clean_log(*args): return _freeswitch.SessionContainer_console_clean_log(*args)
     def answer(*args): return _freeswitch.SessionContainer_answer(*args)
     def pre_answer(*args): return _freeswitch.SessionContainer_pre_answer(*args)
     def hangup(*args): return _freeswitch.SessionContainer_hangup(*args)
@@ -68,6 +70,5 @@
         if not hasattr(self,"thisown"): _swig_setattr(self, SessionContainer, 'thisown', 0)
         _swig_setattr(self, SessionContainer,self.__class__,SessionContainer)
 _freeswitch.SessionContainer_swigregister(SessionContainerPtr)
-cvar = _freeswitch.cvar
 
 

Modified: freeswitch/trunk/src/mod/languages/mod_python/freeswitch_python.cpp
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_python/freeswitch_python.cpp	(original)
+++ freeswitch/trunk/src/mod/languages/mod_python/freeswitch_python.cpp	Mon May  7 17:27:42 2007
@@ -1,6 +1,6 @@
 #include "freeswitch_python.h"
 
-void *globalDTMFCallbackFunction;
+#define sanity_check(x) do { if (!session) { switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "session is not initalized\n"); return x;}} while(0)
 
 SessionContainer::SessionContainer(char *nuuid)
 {
@@ -8,35 +8,25 @@
     dtmfCallbackFunction = NULL;
     tts_name = NULL;
     voice_name = NULL;
-    if ((session = switch_core_session_locate(uuid))) {
-        switch_core_session_rwunlock(session);
-        channel = switch_core_session_get_channel(session);
+
+	if (session = switch_core_session_locate(uuid)) {
+		channel = switch_core_session_get_channel(session);
     }
 }
 
 SessionContainer::~SessionContainer()
 {
 
-}
-
-void SessionContainer::console_log(char *level_str, char *msg)
-{
-    switch_log_level_t level = SWITCH_LOG_DEBUG;
-    if (level_str) {
-        level = switch_log_str2level(level_str);
-    }
-    switch_log_printf(SWITCH_CHANNEL_LOG, level, msg);
-}
-
-void SessionContainer::console_clean_log(char *msg)
-{
-    switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN,SWITCH_LOG_DEBUG, msg);
+	if (session) {
+		switch_core_session_rwunlock(session);
+	}
 }
 
 int SessionContainer::answer()
 {
     switch_status_t status;
-    
+
+	sanity_check(-1);
     status = switch_channel_answer(channel);
     return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
 }
@@ -44,30 +34,34 @@
 int SessionContainer::pre_answer()
 {
     switch_status_t status;
-
+	sanity_check(-1);
     switch_channel_pre_answer(channel);
     return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
 }
 
 void SessionContainer::hangup(char *cause)
 {
+	sanity_check();
     switch_channel_hangup(channel, switch_channel_str2cause(cause));
 }
 
 void SessionContainer::set_variable(char *var, char *val)
 {
+	sanity_check();
     switch_channel_set_variable(channel, var, val);
 }
 
 void SessionContainer::get_variable(char *var, char *val)
 {
+	sanity_check();
     switch_channel_get_variable(channel, var);
 }
 
 void SessionContainer::set_state(char *state)
 {
-    switch_channel_state_t current_state = switch_channel_get_state(channel);
-
+    switch_channel_state_t current_state;
+	sanity_check();
+	current_state = switch_channel_get_state(channel);
     if ((current_state = switch_channel_name_state(state)) < CS_HANGUP) {
         switch_channel_set_state(channel, current_state);
     }
@@ -76,26 +70,26 @@
 int SessionContainer::play_file(char *file, char *timer_name)
 {
     switch_status_t status;
-    switch_input_args_t args = { 0 };
+    switch_input_args_t args = { 0 }, *ap = NULL;
+	sanity_check(-1);
 
     if (switch_strlen_zero(timer_name)) {
         timer_name = NULL;
     }
 
-    if (!dtmfCallbackFunction) {
-        status = switch_ivr_play_file(session, NULL, file, &args);
-    } 
-    else {
-        globalDTMFCallbackFunction = dtmfCallbackFunction;
+    if (dtmfCallbackFunction) {
+		args.buf = dtmfCallbackFunction;
         args.input_callback = PythonDTMFCallback;
-        status = switch_ivr_play_file(session, NULL, file, &args);
+		ap = &args;
     }
 
+	status = switch_ivr_play_file(session, NULL, file, ap);
     return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
 }
 
 void SessionContainer::set_dtmf_callback(PyObject *pyfunc)
 {
+	sanity_check();
     if (!PyCallable_Check(pyfunc)) {
         dtmfCallbackFunction = NULL;
         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "DTMF function is not a python function.");
@@ -109,25 +103,24 @@
 {
     switch_status_t status;
     switch_codec_t *codec;
-    switch_input_args_t args = { 0 };
+    switch_input_args_t args = { 0 }, *ap = NULL;
+
+	sanity_check(-1);
 
     codec = switch_core_session_get_read_codec(session);
-    if (!dtmfCallbackFunction) {
-        status = switch_ivr_speak_text(session, tts_name, voice_name, 
-                codec->implementation->samples_per_second, text, &args);
-    }
-    else {
-        globalDTMFCallbackFunction = dtmfCallbackFunction;
+    if (dtmfCallbackFunction) {
+		args.buf = dtmfCallbackFunction;
         args.input_callback = PythonDTMFCallback;
-        status = switch_ivr_speak_text(session, tts_name, voice_name, 
-                codec->implementation->samples_per_second, text, &args);
+		ap = &args;
     }
 
+	status = switch_ivr_speak_text(session, tts_name, voice_name, codec->implementation->samples_per_second, text, ap);
     return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
 }
 
 void SessionContainer::set_tts_parms(char *tts_name_p, char *voice_name_p)
 {
+	sanity_check();
     tts_name = tts_name_p;
     voice_name = voice_name_p;
 }
@@ -135,7 +128,7 @@
 int SessionContainer::get_digits(char *dtmf_buf, int len, char *terminators, char *terminator, int timeout)
 {
     switch_status_t status;
-
+	sanity_check(-1);
     status = switch_ivr_collect_digits_count(session, dtmf_buf,(uint32_t) len,(uint32_t) len, terminators, terminator, (uint32_t) timeout);
     return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
 }
@@ -143,7 +136,7 @@
 int SessionContainer::transfer(char *extension, char *dialplan, char *context)
 {
     switch_status_t status;
-
+	sanity_check(-1);
     status = switch_ivr_session_transfer(session, extension, dialplan, context);
     return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
 }
@@ -152,7 +145,7 @@
                 char *audio_files, char *bad_input_audio_files, char *dtmf_buf, char *digits_regex)
 {
     switch_status_t status;
-
+	sanity_check(-1);
     status = switch_play_and_get_digits( session, (uint32_t) min_digits,(uint32_t) max_digits,
             (uint32_t) max_tries, (uint32_t) timeout, 
             terminators, audio_files, bad_input_audio_files, dtmf_buf, 128, digits_regex);

Modified: freeswitch/trunk/src/mod/languages/mod_python/freeswitch_python.h
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_python/freeswitch_python.h	(original)
+++ freeswitch/trunk/src/mod/languages/mod_python/freeswitch_python.h	Mon May  7 17:27:42 2007
@@ -9,8 +9,9 @@
 
 #include <switch.h>
 
-	extern void *globalDTMFCallbackFunction;
 	extern switch_status_t PythonDTMFCallback(switch_core_session * session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen);
+	void console_log(char *level_str, char *msg);
+	void console_clean_log(char *msg);
 
 	class SessionContainer {
 	  private:
@@ -23,8 +24,8 @@
 	  public:
 		     SessionContainer(char *uuid);
 		    ~SessionContainer();
-		void console_log(char *level_str, char *msg);
-		void console_clean_log(char *msg);
+			//void console_log(char *level_str, char *msg);
+			//void console_clean_log(char *msg);
 		int answer();
 		int pre_answer();
 		void hangup(char *cause);

Modified: freeswitch/trunk/src/mod/languages/mod_python/mod_python.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_python/mod_python.c	(original)
+++ freeswitch/trunk/src/mod/languages/mod_python/mod_python.c	Mon May  7 17:27:42 2007
@@ -42,43 +42,127 @@
 
 #include <switch.h>
 
+
+
 void init_freeswitch(void);
 static switch_api_interface_t python_run_interface;
 
 const char modname[] = "mod_python";
 
+static void eval_some_python(char *uuid, char *args)
+{
+	PyThreadState *tstate;
+	FILE *pythonfile = NULL;
+	char *dupargs = NULL;
+	char *argv[128] = {0};
+	int argc;
+	int lead = 0;
+	char *script = NULL;
+
+	if (args) {
+		dupargs = strdup(args);
+	} else {
+		return;
+	}
+
+	assert(dupargs != NULL);
+	
+	if (!(argc = switch_separate_string(dupargs, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No script name specified!\n");
+		goto done;
+	}
+
+	script = argv[0];
+	
+	if (uuid) {
+		argv[0] = uuid;
+	} else {
+		lead = 1;
+	}
+
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "running %s\n", script);
+
+
+	if ((pythonfile = fopen(script, "r"))) {
+		PyEval_AcquireLock();
+		tstate = Py_NewInterpreter();
+		PyEval_ReleaseLock(); 
+
+		if (!tstate) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "error acquiring tstate\n");
+			goto done;
+		}
+
+
+		init_freeswitch();
+		PySys_SetArgv(argc - lead, &argv[lead]);
+		PyRun_SimpleFile(pythonfile, "");
+		Py_EndInterpreter(tstate);
+		
+	} else {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "error running %s\n", script);
+	}
+
+
+ done:
+
+	if (pythonfile) {
+		fclose(pythonfile);
+	}
+
+	switch_safe_free(dupargs);
+}
+
 static void python_function(switch_core_session_t *session, char *data)
 {
-	char *uuid = switch_core_session_get_uuid(session);
-	char *argv[1];
-	FILE *pythonfile;
 
-	argv[0] = uuid;
-	pythonfile = fopen(data, "r");
+	eval_some_python(switch_core_session_get_uuid(session), (char *)data);
+	
+}
 
-	Py_Initialize();
-	PySys_SetArgv(1, argv);
-	init_freeswitch();
-	PyRun_SimpleFile(pythonfile, "");
-	Py_Finalize();
+struct switch_py_thread {
+	char *args;
+	switch_memory_pool_t *pool;
+};
 
+static void *SWITCH_THREAD_FUNC py_thread_run(switch_thread_t *thread, void *obj)
+{
+	switch_memory_pool_t *pool;
+	struct switch_py_thread *pt = (struct switch_py_thread *) obj;
+
+	eval_some_python(NULL, strdup(pt->args));
+
+	pool = pt->pool;
+	switch_core_destroy_memory_pool(&pool);
+
+	return NULL;
 }
 
 static switch_status_t launch_python(char *text, switch_core_session_t *session, switch_stream_handle_t *stream)
 {
-	FILE *pythonfile;
+	switch_thread_t *thread;
+    switch_threadattr_t *thd_attr = NULL;
+	switch_memory_pool_t *pool;
+	struct switch_py_thread *pt;
 
 	if (switch_strlen_zero(text)) {
 		stream->write_function(stream, "USAGE: %s\n", python_run_interface.syntax);
 		return SWITCH_STATUS_SUCCESS;
 	}
-
-	pythonfile = fopen(text, "r");
-
-	Py_Initialize();
-	init_freeswitch();
-	PyRun_SimpleFile(pythonfile, "");
-	Py_Finalize();
+	
+	switch_core_new_memory_pool(&pool);
+	assert(pool != NULL);
+
+	pt = switch_core_alloc(pool, sizeof(*pt));
+	assert(pt != NULL);
+
+	pt->pool = pool;
+	pt->args = switch_core_strdup(pt->pool, text);
+	
+    switch_threadattr_create(&thd_attr, pt->pool);
+    switch_threadattr_detach_set(thd_attr, 1);
+    switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
+    switch_thread_create(&thread, thd_attr, py_thread_run, pt, pt->pool);
 
 	stream->write_function(stream, "OK\n");
 	return SWITCH_STATUS_SUCCESS;
@@ -114,32 +198,46 @@
 	/*.directory_interface */ NULL
 };
 
+//static PyThreadState *gtstate;
+static PyThreadState *mainThreadState;
+
 SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
 {
 	/* connect my internal structure to the blank pointer passed to me */
 	*module_interface = &python_module_interface;
-
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Python Framework Loading...\n");
+	
+	Py_Initialize();
+	PyEval_InitThreads();
+
+	mainThreadState = PyThreadState_Get();
+
+	PyEval_ReleaseLock();	
 
 	/* indicate that the module should continue to be loaded */
 	return SWITCH_STATUS_SUCCESS;
 }
 
 /*
-  Called when the system shuts down
-  SWITCH_MOD_DECLARE(switch_status) switch_module_shutdown(void)
-  {
-  return SWITCH_STATUS_SUCCESS;
-  }
-*/
+  Called when the system shuts down*/
+SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void)
+{
+
+	PyInterpreterState *mainInterpreterState;
+	PyThreadState *myThreadState;
+
+	PyEval_AcquireLock();
+	mainInterpreterState = mainThreadState->interp;
+	myThreadState = PyThreadState_New(mainInterpreterState);
+	PyThreadState_Swap(myThreadState);
+	PyEval_ReleaseLock();
+
+	Py_Finalize();
+	PyEval_ReleaseLock();
+	return SWITCH_STATUS_SUCCESS;
+}
+
 
-/*
-  If it exists, this is called in it's own thread when the module-load completes
-  SWITCH_MOD_DECLARE(switch_status) switch_module_shutdown(void)
-  {
-  return SWITCH_STATUS_SUCCESS;
-  }
-*/
 
 
 /* Return the number of arguments of the application command line */

Modified: freeswitch/trunk/src/mod/languages/mod_python/mod_python.i
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_python/mod_python.i	(original)
+++ freeswitch/trunk/src/mod/languages/mod_python/mod_python.i	Mon May  7 17:27:42 2007
@@ -22,9 +22,9 @@
    PyObject *result;
    switch_status_t dres = SWITCH_STATUS_FALSE;
    
-   func = (PyObject *) globalDTMFCallbackFunction;               // Get Python function
-   arglist = Py_BuildValue("(sisi)",input,itype,buf,buflen);             // Build argument list
-   result = PyEval_CallObject(func,arglist);     // Call Python
+   func = (PyObject *) buf;               // Get Python function
+   arglist = Py_BuildValue("(si)", input, itype);             // Build argument list
+   result = PyEval_CallObject(func, arglist);     // Call Python
    Py_DECREF(arglist);                           // Trash arglist
    if (result) {                                 // If no errors, return double
      dres = (switch_status_t) PyInt_AsLong(result);
@@ -33,5 +33,22 @@
    return dres;
 }
 
+
+void console_log(char *level_str, char *msg)
+{
+    switch_log_level_t level = SWITCH_LOG_DEBUG;
+    if (level_str) {
+        level = switch_log_str2level(level_str);
+    }
+    switch_log_printf(SWITCH_CHANNEL_LOG, level, msg);
+}
+
+void console_clean_log(char *msg)
+{
+    switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN,SWITCH_LOG_DEBUG, msg);
+}
+
+
+
 %}
 

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 May  7 17:27:42 2007
@@ -702,10 +702,9 @@
 
 #define  SWIGTYPE_p_switch_status_t swig_types[0] 
 #define  SWIGTYPE_p_switch_input_type_t swig_types[1] 
-#define  SWIGTYPE_p_void swig_types[2] 
-#define  SWIGTYPE_p_switch_core_session swig_types[3] 
-#define  SWIGTYPE_p_SessionContainer swig_types[4] 
-static swig_type_info *swig_types[6];
+#define  SWIGTYPE_p_switch_core_session swig_types[2] 
+#define  SWIGTYPE_p_SessionContainer swig_types[3] 
+static swig_type_info *swig_types[5];
 
 /* -------- TYPES TABLE (END) -------- */
 
@@ -719,7 +718,6 @@
 
 #include "freeswitch_python.h"
 
-extern void *globalDTMFCallbackFunction;
 extern switch_status_t PythonDTMFCallback(switch_core_session *,void *,switch_input_type_t,void *,unsigned int);
 
 static PyObject* t_output_helper(PyObject* target, PyObject* o) {
@@ -760,9 +758,9 @@
    PyObject *result;
    switch_status_t dres = SWITCH_STATUS_FALSE;
    
-   func = (PyObject *) globalDTMFCallbackFunction;               // Get Python function
-   arglist = Py_BuildValue("(sisi)",input,itype,buf,buflen);             // Build argument list
-   result = PyEval_CallObject(func,arglist);     // Call Python
+   func = (PyObject *) buf;               // Get Python function
+   arglist = Py_BuildValue("(si)", input, itype);             // Build argument list
+   result = PyEval_CallObject(func, arglist);     // Call Python
    Py_DECREF(arglist);                           // Trash arglist
    if (result) {                                 // If no errors, return double
      dres = (switch_status_t) PyInt_AsLong(result);
@@ -772,30 +770,26 @@
 }
 
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-static int _wrap_globalDTMFCallbackFunction_set(PyObject *_val) {
-    {
-        void * temp;
-        if ((SWIG_ConvertPtr(_val,(void **) &temp, 0, SWIG_POINTER_EXCEPTION | SWIG_POINTER_DISOWN)) == -1) {
-            PyErr_SetString(PyExc_TypeError, "C variable 'globalDTMFCallbackFunction (void *)'");
-            return 1;
-        }
-        globalDTMFCallbackFunction = (void *) temp;
+void console_log(char *level_str, char *msg)
+{
+    switch_log_level_t level = SWITCH_LOG_DEBUG;
+    if (level_str) {
+        level = switch_log_str2level(level_str);
     }
-    return 0;
+    switch_log_printf(SWITCH_CHANNEL_LOG, level, msg);
 }
 
-
-static PyObject *_wrap_globalDTMFCallbackFunction_get() {
-    PyObject *pyobj;
-    
-    pyobj = SWIG_NewPointerObj((void *) globalDTMFCallbackFunction, SWIGTYPE_p_void, 0);
-    return pyobj;
+void console_clean_log(char *msg)
+{
+    switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN,SWITCH_LOG_DEBUG, msg);
 }
 
 
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 static PyObject *_wrap_PythonDTMFCallback(PyObject *self, PyObject *args) {
     PyObject *resultobj;
     switch_core_session *arg1 = (switch_core_session *) 0 ;
@@ -832,29 +826,27 @@
 }
 
 
-static PyObject *_wrap_new_SessionContainer(PyObject *self, PyObject *args) {
+static PyObject *_wrap_console_log(PyObject *self, PyObject *args) {
     PyObject *resultobj;
     char *arg1 ;
-    SessionContainer *result;
+    char *arg2 ;
     
-    if(!PyArg_ParseTuple(args,(char *)"s:new_SessionContainer",&arg1)) goto fail;
-    result = (SessionContainer *)new SessionContainer(arg1);
+    if(!PyArg_ParseTuple(args,(char *)"ss:console_log",&arg1,&arg2)) goto fail;
+    console_log(arg1,arg2);
     
-    resultobj = SWIG_NewPointerObj((void *) result, SWIGTYPE_p_SessionContainer, 1);
+    Py_INCREF(Py_None); resultobj = Py_None;
     return resultobj;
     fail:
     return NULL;
 }
 
 
-static PyObject *_wrap_delete_SessionContainer(PyObject *self, PyObject *args) {
+static PyObject *_wrap_console_clean_log(PyObject *self, PyObject *args) {
     PyObject *resultobj;
-    SessionContainer *arg1 = (SessionContainer *) 0 ;
-    PyObject * obj0 = 0 ;
+    char *arg1 ;
     
-    if(!PyArg_ParseTuple(args,(char *)"O:delete_SessionContainer",&obj0)) goto fail;
-    if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_SessionContainer,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
-    delete arg1;
+    if(!PyArg_ParseTuple(args,(char *)"s:console_clean_log",&arg1)) goto fail;
+    console_clean_log(arg1);
     
     Py_INCREF(Py_None); resultobj = Py_None;
     return resultobj;
@@ -863,33 +855,29 @@
 }
 
 
-static PyObject *_wrap_SessionContainer_console_log(PyObject *self, PyObject *args) {
+static PyObject *_wrap_new_SessionContainer(PyObject *self, PyObject *args) {
     PyObject *resultobj;
-    SessionContainer *arg1 = (SessionContainer *) 0 ;
-    char *arg2 ;
-    char *arg3 ;
-    PyObject * obj0 = 0 ;
+    char *arg1 ;
+    SessionContainer *result;
     
-    if(!PyArg_ParseTuple(args,(char *)"Oss:SessionContainer_console_log",&obj0,&arg2,&arg3)) goto fail;
-    if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_SessionContainer,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
-    (arg1)->console_log(arg2,arg3);
+    if(!PyArg_ParseTuple(args,(char *)"s:new_SessionContainer",&arg1)) goto fail;
+    result = (SessionContainer *)new SessionContainer(arg1);
     
-    Py_INCREF(Py_None); resultobj = Py_None;
+    resultobj = SWIG_NewPointerObj((void *) result, SWIGTYPE_p_SessionContainer, 1);
     return resultobj;
     fail:
     return NULL;
 }
 
 
-static PyObject *_wrap_SessionContainer_console_clean_log(PyObject *self, PyObject *args) {
+static PyObject *_wrap_delete_SessionContainer(PyObject *self, PyObject *args) {
     PyObject *resultobj;
     SessionContainer *arg1 = (SessionContainer *) 0 ;
-    char *arg2 ;
     PyObject * obj0 = 0 ;
     
-    if(!PyArg_ParseTuple(args,(char *)"Os:SessionContainer_console_clean_log",&obj0,&arg2)) goto fail;
+    if(!PyArg_ParseTuple(args,(char *)"O:delete_SessionContainer",&obj0)) goto fail;
     if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_SessionContainer,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
-    (arg1)->console_clean_log(arg2);
+    delete arg1;
     
     Py_INCREF(Py_None); resultobj = Py_None;
     return resultobj;
@@ -1195,10 +1183,10 @@
 }
 static PyMethodDef SwigMethods[] = {
 	 { (char *)"PythonDTMFCallback", _wrap_PythonDTMFCallback, METH_VARARGS },
+	 { (char *)"console_log", _wrap_console_log, METH_VARARGS },
+	 { (char *)"console_clean_log", _wrap_console_clean_log, METH_VARARGS },
 	 { (char *)"new_SessionContainer", _wrap_new_SessionContainer, METH_VARARGS },
 	 { (char *)"delete_SessionContainer", _wrap_delete_SessionContainer, METH_VARARGS },
-	 { (char *)"SessionContainer_console_log", _wrap_SessionContainer_console_log, METH_VARARGS },
-	 { (char *)"SessionContainer_console_clean_log", _wrap_SessionContainer_console_clean_log, METH_VARARGS },
 	 { (char *)"SessionContainer_answer", _wrap_SessionContainer_answer, METH_VARARGS },
 	 { (char *)"SessionContainer_pre_answer", _wrap_SessionContainer_pre_answer, METH_VARARGS },
 	 { (char *)"SessionContainer_hangup", _wrap_SessionContainer_hangup, METH_VARARGS },
@@ -1221,14 +1209,12 @@
 
 static swig_type_info _swigt__p_switch_status_t[] = {{"_p_switch_status_t", 0, "switch_status_t *", 0},{"_p_switch_status_t"},{0}};
 static swig_type_info _swigt__p_switch_input_type_t[] = {{"_p_switch_input_type_t", 0, "switch_input_type_t *", 0},{"_p_switch_input_type_t"},{0}};
-static swig_type_info _swigt__p_void[] = {{"_p_void", 0, "void *", 0},{"_p_void"},{0}};
 static swig_type_info _swigt__p_switch_core_session[] = {{"_p_switch_core_session", 0, "switch_core_session *", 0},{"_p_switch_core_session"},{0}};
 static swig_type_info _swigt__p_SessionContainer[] = {{"_p_SessionContainer", 0, "SessionContainer *", 0},{"_p_SessionContainer"},{0}};
 
 static swig_type_info *swig_types_initial[] = {
 _swigt__p_switch_status_t, 
 _swigt__p_switch_input_type_t, 
-_swigt__p_void, 
 _swigt__p_switch_core_session, 
 _swigt__p_SessionContainer, 
 0
@@ -1264,7 +1250,5 @@
     }
     SWIG_InstallConstants(d,swig_const_table);
     
-    PyDict_SetItemString(d,(char*)"cvar", SWIG_globals);
-    SWIG_addvarlink(SWIG_globals,(char*)"globalDTMFCallbackFunction",_wrap_globalDTMFCallbackFunction_get, _wrap_globalDTMFCallbackFunction_set);
 }
 



More information about the Freeswitch-svn mailing list