#include "freeswitch_python.h"
#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)
-#define init_vars() do { caller_profile.source = "mod_python"; } while(0)
+#define init_vars() do { caller_profile.source = "mod_python"; swapstate = S_SWAPPED_IN; } while(0)
PySession::PySession() : CoreSession()
{
sanity_check();
if (!PyCallable_Check(pyfunc)) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "DTMF function is not a python function.");
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "DTMF function is not a python function.\n");
+ return;
}
- else {
- cb_state.funcargs = funcargs;
- cb_state.function = (void *) pyfunc;
-
- args.buf = &cb_state;
- args.buflen = sizeof(cb_state); // not sure what this is used for, copy mod_spidermonkey
-
- // we cannot set the actual callback to a python function, because
- // the callback is a function pointer with a specific signature.
- // so, set it to the following c function which will act as a proxy,
- // finding the python callback in the args callback args structure
- args.input_callback = PythonDTMFCallback; // defined in mod_python.i
- ap = &args;
+ Py_XINCREF(pyfunc);
+ CoreSession::setDTMFCallback((void *) pyfunc, funcargs);
+
+
+}
+
+void PySession::setHangupHook(PyObject *pyfunc) {
+ if (!PyCallable_Check(pyfunc)) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Hangup hook is not a python function.\n");
+ return;
}
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "dtmf callback was set, pyfunc: %p. cb_state: %p\n", pyfunc, &cb_state);
+ // without this Py_XINCREF, there will be segfaults. basically the python
+ // interpreter will not know that it should not GC this object.
+ // callback example: http://docs.python.org/ext/callingPython.html
+ Py_XINCREF(pyfunc);
+ CoreSession::setHangupHook((void *) pyfunc);
}
-void PySession::begin_allow_threads(void) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "PySession::begin_allow_threads() called\n");
+void PySession::check_hangup_hook() {
+ PyObject *func;
+ PyObject *result;
+ char *resultStr;
+ bool did_swap_in = false;
- // swap out threadstate and store in instance variable
- threadState = (void *) PyEval_SaveThread();
- cb_state.threadState = threadState;
- args.buf = &cb_state;
- ap = &args;
-}
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "check_hangup_hook called\n");
-void PySession::end_allow_threads(void) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "PySession::end_allow_threads() called\n");
- // swap in threadstate from instance variable saved earlier
- PyEval_RestoreThread(((PyThreadState *)threadState));
-}
+ if (!session) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "No valid session\n");
+ return;
+ }
-PySession::~PySession() {
- // Should we do any cleanup here?
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "PySession::~PySession desctructor\n");
-}
+ // The did_swap_in boolean was added to fix the following problem:
+ // Design flaw - we swap in threadstate based on the assumption that thread state
+ // is currently _swapped out_ when this hangup hook is called. However, nothing known to
+ // guarantee that, and if thread state is already swapped in when this is invoked,
+ // bad things will happen.
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "check hangup hook end_allow_threads\n");
+ did_swap_in = end_allow_threads();
+
+ if (on_hangup == NULL) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "on_hangup is null\n");
+ return;
+ }
+ func = (PyObject *) on_hangup;
-/* ----- functions not bound to PySession instance ------ */
+ // TODO: to match js implementation, should pass the _python_ PySession
+ // object instance wrapping this C++ PySession instance. but how do we do that?
+ // for now, pass the uuid since its better than nothing
+ PyObject* func_arg = Py_BuildValue("(s)", uuid);
+ result = PyEval_CallObject(func, func_arg);
+ Py_XDECREF(func_arg);
+
+ if (result) {
+ resultStr = (char *) PyString_AsString(result);
+ // currently just ignore the result
+ }
+ else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to call python hangup callback\n");
+ PyErr_Print();
+ PyErr_Clear();
+ }
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "check hangup hook begin_allow_threads\n");
+ if (did_swap_in) {
+ begin_allow_threads();
+ }
+
+ Py_XDECREF(result);
+
+}
+
+switch_status_t PySession::run_dtmf_callback(void *input,
+ switch_input_type_t itype) {
-switch_status_t PythonDTMFCallback(switch_core_session_t *session,
- void *input,
- switch_input_type_t itype,
- void *buf,
- unsigned int buflen)
-{
PyObject *func, *arglist;
- PyObject *result;
+ PyObject *pyresult;
char *resultStr;
char *funcargs;
- input_callback_state_t *cb_state;
switch_file_handle_t *fh = NULL;
- PyThreadState *threadState = NULL;
+ bool did_swap_in = false;
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "PythonDTMFCallback\n");
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "run_dtmf_callback\n");
+
- if (!buf) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "buf pointer is null");
+ if (!cb_state.function) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "cb_state->function is null\n");
return SWITCH_STATUS_FALSE;
- }
-
- cb_state = (input_callback_state *) buf;
+ }
- func = (PyObject *) cb_state->function;
+ func = (PyObject *) cb_state.function;
if (!func) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cb_state->function is null\n");
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "cb_state->function is null\n");
return SWITCH_STATUS_FALSE;
}
else {
return SWITCH_STATUS_FALSE;
}
- funcargs = (char *) cb_state->funcargs;
+ funcargs = (char *) cb_state.funcargs;
arglist = Py_BuildValue("(sis)", input, itype, funcargs);
if (!arglist) {
return SWITCH_STATUS_FALSE;
}
- threadState = (PyThreadState *) cb_state->threadState;
- if (!threadState) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "error, invalid threadstate\n");
- return SWITCH_STATUS_FALSE;
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "run_dtmf_callback end_allow_threads\n");
+ did_swap_in = end_allow_threads();
+
+ pyresult = PyEval_CallObject(func, arglist);
+
+
+ Py_XDECREF(arglist); // Trash arglist
+ if (pyresult && pyresult != Py_None) {
+ resultStr = (char *) PyString_AsString(pyresult);
+ switch_status_t cbresult = process_callback_result(resultStr, &cb_state, session);
+ return cbresult;
}
else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "restoring threadstate: %p\n", threadState);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error calling python callback\n");
+ PyErr_Print();
+ PyErr_Clear();
}
- PyEval_RestoreThread(threadState); // nasty stuff happens when py interp has no thread state
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "run_dtmf_callback begin_allow_threads\n");
+ if (did_swap_in) {
+ begin_allow_threads();
+ }
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "restored threadstate, calling python function: %p\n", func);
-
- result = PyEval_CallObject(func, arglist);
-
- threadState = PyEval_SaveThread();
+ Py_XDECREF(pyresult);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "called python function\n");
+ return SWITCH_STATUS_SUCCESS;
- Py_DECREF(arglist); // Trash arglist
- if (result && result != Py_None) {
- resultStr = (char *) PyString_AsString(result);
- Py_XDECREF(result);
- return process_callback_result(resultStr, cb_state, session);
- }
- else {
- return SWITCH_STATUS_FALSE;
- }
+}
+
+bool PySession::begin_allow_threads(void) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "PySession::begin_allow_threads() called\n");
+
+ // swap out threadstate and store in instance variable
+ switch_channel_t *channel = switch_core_session_get_channel(session);
+ PyThreadState *swapin_tstate = (PyThreadState *) switch_channel_get_private(channel, "SwapInThreadState");
+ // so lets assume the thread state was swapped in when the python script was started,
+ // therefore swapin_tstate will be NULL (because there is nothing to swap in, since its
+ // _already_ swapped in.)
+ if (swapin_tstate == NULL) {
+ // currently swapped in
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Threadstate swap-out!\n");
+ swapin_tstate = PyEval_SaveThread();
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "swapin_tstate: %p\n", swapin_tstate);
+ // give future swapper-inners something to actually swap in
+ switch_channel_set_private(channel, "SwapInThreadState", (void *) swapin_tstate);
+ cb_state.threadState = threadState; // TODO: get rid of this
+ args.buf = &cb_state;
+ ap = &args;
+ return true;
+
+ }
+ else {
+ // currently swapped out
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Threadstate already swapd-out! Skipping\n");
+ return false;
+ }
+
+}
+
+bool PySession::end_allow_threads(void) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "PySession::end_allow_threads() called\n");
+ // swap in threadstate from instance variable saved earlier
+ switch_channel_t *channel = switch_core_session_get_channel(session);
+ PyThreadState *swapin_tstate = (PyThreadState *) switch_channel_get_private(channel, "SwapInThreadState");
+ if (swapin_tstate == NULL) {
+ // currently swapped in
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Threadstate double swap-in! Skipping\n");
+ return false;
+ }
+ else {
+ // currently swapped out
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Threadstate swap-in!\n");
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "swapin_tstate: %p\n", swapin_tstate);
+ PyEval_RestoreThread(swapin_tstate);
+ // dont give any swapper-inners the opportunity to do a double swap
+ switch_channel_set_private(channel, "SwapInThreadState", NULL);
+ return true;
+ }
}
+void PySession::hangup(char *cause) {
+
+
+ // since we INCREF'd this function pointer earlier (so the py gc didnt reclaim it)
+ // we have to DECREF it, or else the PySession dtor will never get called and
+ // a zombie channel will be left over using up resources
+
+ if (cb_state.function != NULL) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "xdecref on cb_state_function\n");
+ PyObject * func = (PyObject *) cb_state.function;
+ Py_XDECREF(func);
+ }
+ else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "cb_state.function is null\n");
+ }
+
+
+ CoreSession::hangup(cause);
+
+}
+
+
+PySession::~PySession() {
+ // Should we do any cleanup here?
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "PySession::~PySession started\n");
+
+ if (on_hangup) {
+ PyObject * func = (PyObject *) on_hangup;
+ Py_XDECREF(func);
+ }
+
+
+ if (cb_state.function != NULL) {
+ PyObject * func = (PyObject *) cb_state.function;
+ Py_XDECREF(func);
+ }
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "PySession::~PySession finished\n");
+
+}
+
+
+
+
#define SWIGTYPE_p_PySession swig_types[1]
#define SWIGTYPE_p_char swig_types[2]
#define SWIGTYPE_p_input_callback_state swig_types[3]
-#define SWIGTYPE_p_switch_channel_t swig_types[4]
-#define SWIGTYPE_p_switch_core_session swig_types[5]
-#define SWIGTYPE_p_switch_core_session_t swig_types[6]
-#define SWIGTYPE_p_switch_input_args_t swig_types[7]
-#define SWIGTYPE_p_switch_input_callback_function_t swig_types[8]
-#define SWIGTYPE_p_switch_input_type_t swig_types[9]
-#define SWIGTYPE_p_switch_status_t swig_types[10]
-#define SWIGTYPE_p_uint32_t swig_types[11]
+#define SWIGTYPE_p_session_flag_t swig_types[4]
+#define SWIGTYPE_p_swap_state_t swig_types[5]
+#define SWIGTYPE_p_switch_channel_state_t swig_types[6]
+#define SWIGTYPE_p_switch_channel_t swig_types[7]
+#define SWIGTYPE_p_switch_core_session_t swig_types[8]
+#define SWIGTYPE_p_switch_input_args_t swig_types[9]
+#define SWIGTYPE_p_switch_input_type_t swig_types[10]
+#define SWIGTYPE_p_switch_status_t swig_types[11]
#define SWIGTYPE_p_void swig_types[12]
static swig_type_info *swig_types[14];
static swig_module_info swig_module = {swig_types, 13, 0, 0, 0, 0};
SWIGINTERN int
-SWIG_AsVal_long (PyObject *obj, long* val)
+SWIG_AsVal_unsigned_SS_long (PyObject *obj, unsigned long *val)
{
if (PyInt_Check(obj)) {
- if (val) *val = PyInt_AsLong(obj);
- return SWIG_OK;
+ long v = PyInt_AsLong(obj);
+ if (v >= 0) {
+ if (val) *val = v;
+ return SWIG_OK;
+ } else {
+ return SWIG_OverflowError;
+ }
} else if (PyLong_Check(obj)) {
- long v = PyLong_AsLong(obj);
+ unsigned long v = PyLong_AsUnsignedLong(obj);
if (!PyErr_Occurred()) {
if (val) *val = v;
return SWIG_OK;
#ifdef SWIG_PYTHON_CAST_MODE
{
int dispatch = 0;
- long v = PyInt_AsLong(obj);
+ unsigned long v = PyLong_AsUnsignedLong(obj);
if (!PyErr_Occurred()) {
if (val) *val = v;
return SWIG_AddCast(SWIG_OK);
if (!dispatch) {
double d;
int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d));
- if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, LONG_MIN, LONG_MAX)) {
- if (val) *val = (long)(d);
+ if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, ULONG_MAX)) {
+ if (val) *val = (unsigned long)(d);
return res;
}
}
SWIGINTERN int
-SWIG_AsVal_int (PyObject * obj, int *val)
+SWIG_AsVal_unsigned_SS_int (PyObject * obj, unsigned int *val)
{
- long v;
- int res = SWIG_AsVal_long (obj, &v);
+ unsigned long v;
+ int res = SWIG_AsVal_unsigned_SS_long (obj, &v);
if (SWIG_IsOK(res)) {
- if ((v < INT_MIN || v > INT_MAX)) {
+ if ((v > UINT_MAX)) {
return SWIG_OverflowError;
} else {
- if (val) *val = static_cast< int >(v);
+ if (val) *val = static_cast< unsigned int >(v);
}
}
return res;
}
-SWIGINTERNINLINE PyObject*
- SWIG_From_bool (bool value)
+SWIGINTERNINLINE PyObject*
+SWIG_From_unsigned_SS_long (unsigned long value)
{
- return PyBool_FromLong(value ? 1 : 0);
+ return (value > LONG_MAX) ?
+ PyLong_FromUnsignedLong(value) : PyInt_FromLong(static_cast< long >(value));
+}
+
+
+SWIGINTERNINLINE PyObject *
+SWIG_From_unsigned_SS_int (unsigned int value)
+{
+ return SWIG_From_unsigned_SS_long (value);
}
SWIGINTERN int
-SWIG_AsVal_unsigned_SS_long (PyObject *obj, unsigned long *val)
+SWIG_AsVal_long (PyObject *obj, long* val)
{
if (PyInt_Check(obj)) {
- long v = PyInt_AsLong(obj);
- if (v >= 0) {
- if (val) *val = v;
- return SWIG_OK;
- } else {
- return SWIG_OverflowError;
- }
+ if (val) *val = PyInt_AsLong(obj);
+ return SWIG_OK;
} else if (PyLong_Check(obj)) {
- unsigned long v = PyLong_AsUnsignedLong(obj);
+ long v = PyLong_AsLong(obj);
if (!PyErr_Occurred()) {
if (val) *val = v;
return SWIG_OK;
#ifdef SWIG_PYTHON_CAST_MODE
{
int dispatch = 0;
- unsigned long v = PyLong_AsUnsignedLong(obj);
+ long v = PyInt_AsLong(obj);
if (!PyErr_Occurred()) {
if (val) *val = v;
return SWIG_AddCast(SWIG_OK);
if (!dispatch) {
double d;
int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d));
- if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, ULONG_MAX)) {
- if (val) *val = (unsigned long)(d);
+ if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, LONG_MIN, LONG_MAX)) {
+ if (val) *val = (long)(d);
return res;
}
}
SWIGINTERN int
-SWIG_AsVal_unsigned_SS_int (PyObject * obj, unsigned int *val)
+SWIG_AsVal_int (PyObject * obj, int *val)
{
- unsigned long v;
- int res = SWIG_AsVal_unsigned_SS_long (obj, &v);
+ long v;
+ int res = SWIG_AsVal_long (obj, &v);
if (SWIG_IsOK(res)) {
- if ((v > UINT_MAX)) {
+ if ((v < INT_MIN || v > INT_MAX)) {
return SWIG_OverflowError;
} else {
- if (val) *val = static_cast< unsigned int >(v);
+ if (val) *val = static_cast< int >(v);
}
}
return res;
}
+
+SWIGINTERN int
+SWIG_AsVal_bool (PyObject *obj, bool *val)
+{
+ if (obj == Py_True) {
+ if (val) *val = true;
+ return SWIG_OK;
+ } else if (obj == Py_False) {
+ if (val) *val = false;
+ return SWIG_OK;
+ } else {
+ long v = 0;
+ int res = SWIG_AddCast(SWIG_AsVal_long (obj, val ? &v : 0));
+ if (SWIG_IsOK(res) && val) *val = v ? true : false;
+ return res;
+ }
+}
+
+
+SWIGINTERNINLINE PyObject*
+ SWIG_From_bool (bool value)
+{
+ return PyBool_FromLong(value ? 1 : 0);
+}
+
#ifdef __cplusplus
extern "C" {
#endif
return SWIG_Py_Void();
}
-SWIGINTERN PyObject *_wrap_new_CoreSession__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
- PyObject *resultobj = 0;
- CoreSession *result = 0 ;
-
- if (!PyArg_ParseTuple(args,(char *)":new_CoreSession")) SWIG_fail;
- result = (CoreSession *)new CoreSession();
- resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_CoreSession, SWIG_POINTER_NEW | 0 );
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_new_CoreSession__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
- PyObject *resultobj = 0;
- char *arg1 = (char *) 0 ;
- CoreSession *result = 0 ;
- int res1 ;
- char *buf1 = 0 ;
- int alloc1 = 0 ;
- PyObject * obj0 = 0 ;
-
- if (!PyArg_ParseTuple(args,(char *)"O:new_CoreSession",&obj0)) SWIG_fail;
- res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1);
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_CoreSession" "', argument " "1"" of type '" "char *""'");
- }
- arg1 = reinterpret_cast< char * >(buf1);
- result = (CoreSession *)new CoreSession(arg1);
- resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_CoreSession, SWIG_POINTER_NEW | 0 );
- if (alloc1 == SWIG_NEWOBJ) delete[] buf1;
- return resultobj;
-fail:
- if (alloc1 == SWIG_NEWOBJ) delete[] buf1;
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_new_CoreSession__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
- PyObject *resultobj = 0;
- switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
- CoreSession *result = 0 ;
- void *argp1 = 0 ;
- int res1 = 0 ;
- PyObject * obj0 = 0 ;
-
- if (!PyArg_ParseTuple(args,(char *)"O:new_CoreSession",&obj0)) SWIG_fail;
- res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_switch_core_session_t, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_CoreSession" "', argument " "1"" of type '" "switch_core_session_t *""'");
- }
- arg1 = reinterpret_cast< switch_core_session_t * >(argp1);
- result = (CoreSession *)new CoreSession(arg1);
- resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_CoreSession, SWIG_POINTER_NEW | 0 );
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_new_CoreSession(PyObject *self, PyObject *args) {
- int argc;
- PyObject *argv[2];
- int ii;
-
- if (!PyTuple_Check(args)) SWIG_fail;
- argc = PyObject_Length(args);
- for (ii = 0; (ii < argc) && (ii < 1); ii++) {
- argv[ii] = PyTuple_GET_ITEM(args,ii);
- }
- if (argc == 0) {
- return _wrap_new_CoreSession__SWIG_0(self, args);
- }
- if (argc == 1) {
- int _v;
- void *vptr = 0;
- int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_switch_core_session_t, 0);
- _v = SWIG_CheckState(res);
- if (_v) {
- return _wrap_new_CoreSession__SWIG_2(self, args);
- }
- }
- if (argc == 1) {
- int _v;
- int res = SWIG_AsCharPtrAndSize(argv[0], 0, NULL, 0);
- _v = SWIG_CheckState(res);
- if (_v) {
- return _wrap_new_CoreSession__SWIG_1(self, args);
- }
- }
-
-fail:
- SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'new_CoreSession'.\n Possible C/C++ prototypes are:\n CoreSession()\n CoreSession(char *)\n CoreSession(switch_core_session_t *)\n");
- return NULL;
-}
-
-
SWIGINTERN PyObject *_wrap_delete_CoreSession(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
CoreSession *arg1 = (CoreSession *) 0 ;
}
+SWIGINTERN PyObject *_wrap_CoreSession_flags_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ CoreSession *arg1 = (CoreSession *) 0 ;
+ unsigned int arg2 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ unsigned int val2 ;
+ int ecode2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:CoreSession_flags_set",&obj0,&obj1)) 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_flags_set" "', argument " "1"" of type '" "CoreSession *""'");
+ }
+ arg1 = reinterpret_cast< CoreSession * >(argp1);
+ ecode2 = SWIG_AsVal_unsigned_SS_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "CoreSession_flags_set" "', argument " "2"" of type '" "unsigned int""'");
+ }
+ arg2 = static_cast< unsigned int >(val2);
+ if (arg1) (arg1)->flags = arg2;
+
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_CoreSession_flags_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ CoreSession *arg1 = (CoreSession *) 0 ;
+ unsigned int result;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:CoreSession_flags_get",&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_flags_get" "', argument " "1"" of type '" "CoreSession *""'");
+ }
+ arg1 = reinterpret_cast< CoreSession * >(argp1);
+ result = (unsigned int) ((arg1)->flags);
+ resultobj = SWIG_From_unsigned_SS_int(static_cast< unsigned int >(result));
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
SWIGINTERN PyObject *_wrap_CoreSession_cb_state_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
CoreSession *arg1 = (CoreSession *) 0 ;
}
+SWIGINTERN PyObject *_wrap_CoreSession_hook_state_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ CoreSession *arg1 = (CoreSession *) 0 ;
+ switch_channel_state_t arg2 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ void *argp2 ;
+ int res2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:CoreSession_hook_state_set",&obj0,&obj1)) 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_hook_state_set" "', argument " "1"" of type '" "CoreSession *""'");
+ }
+ arg1 = reinterpret_cast< CoreSession * >(argp1);
+ {
+ res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_switch_channel_state_t, 0 | 0);
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CoreSession_hook_state_set" "', argument " "2"" of type '" "switch_channel_state_t""'");
+ }
+ if (!argp2) {
+ SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "CoreSession_hook_state_set" "', argument " "2"" of type '" "switch_channel_state_t""'");
+ } else {
+ switch_channel_state_t * temp = reinterpret_cast< switch_channel_state_t * >(argp2);
+ arg2 = *temp;
+ if (SWIG_IsNewObj(res2)) delete temp;
+ }
+ }
+ if (arg1) (arg1)->hook_state = arg2;
+
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_CoreSession_hook_state_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ CoreSession *arg1 = (CoreSession *) 0 ;
+ switch_channel_state_t result;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:CoreSession_hook_state_get",&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_hook_state_get" "', argument " "1"" of type '" "CoreSession *""'");
+ }
+ arg1 = reinterpret_cast< CoreSession * >(argp1);
+ result = ((arg1)->hook_state);
+ resultobj = SWIG_NewPointerObj((new switch_channel_state_t(static_cast< const switch_channel_state_t& >(result))), SWIGTYPE_p_switch_channel_state_t, SWIG_POINTER_OWN | 0 );
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
SWIGINTERN PyObject *_wrap_CoreSession_answer(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
CoreSession *arg1 = (CoreSession *) 0 ;
SWIGINTERN PyObject *_wrap_CoreSession_setDTMFCallback(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
CoreSession *arg1 = (CoreSession *) 0 ;
- switch_input_callback_function_t arg2 ;
- void *arg3 = (void *) 0 ;
- uint32_t arg4 ;
+ void *arg2 = (void *) 0 ;
+ char *arg3 = (char *) 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
- void *argp2 ;
- int res2 = 0 ;
+ int res2 ;
int res3 ;
- void *argp4 ;
- int res4 = 0 ;
+ char *buf3 = 0 ;
+ int alloc3 = 0 ;
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
PyObject * obj2 = 0 ;
- PyObject * obj3 = 0 ;
- if (!PyArg_ParseTuple(args,(char *)"OOOO:CoreSession_setDTMFCallback",&obj0,&obj1,&obj2,&obj3)) SWIG_fail;
+ if (!PyArg_ParseTuple(args,(char *)"OOO:CoreSession_setDTMFCallback",&obj0,&obj1,&obj2)) 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_setDTMFCallback" "', argument " "1"" of type '" "CoreSession *""'");
}
arg1 = reinterpret_cast< CoreSession * >(argp1);
- {
- res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_switch_input_callback_function_t, 0 | 0);
- if (!SWIG_IsOK(res2)) {
- SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CoreSession_setDTMFCallback" "', argument " "2"" of type '" "switch_input_callback_function_t""'");
- }
- if (!argp2) {
- SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "CoreSession_setDTMFCallback" "', argument " "2"" of type '" "switch_input_callback_function_t""'");
- } else {
- switch_input_callback_function_t * temp = reinterpret_cast< switch_input_callback_function_t * >(argp2);
- arg2 = *temp;
- if (SWIG_IsNewObj(res2)) delete temp;
- }
+ res2 = SWIG_ConvertPtr(obj1,SWIG_as_voidptrptr(&arg2), 0, 0);
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CoreSession_setDTMFCallback" "', argument " "2"" of type '" "void *""'");
}
- res3 = SWIG_ConvertPtr(obj2,SWIG_as_voidptrptr(&arg3), 0, 0);
+ res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3);
if (!SWIG_IsOK(res3)) {
- SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "CoreSession_setDTMFCallback" "', argument " "3"" of type '" "void *""'");
- }
- {
- res4 = SWIG_ConvertPtr(obj3, &argp4, SWIGTYPE_p_uint32_t, 0 | 0);
- if (!SWIG_IsOK(res4)) {
- SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "CoreSession_setDTMFCallback" "', argument " "4"" of type '" "uint32_t""'");
- }
- if (!argp4) {
- SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "CoreSession_setDTMFCallback" "', argument " "4"" of type '" "uint32_t""'");
- } else {
- uint32_t * temp = reinterpret_cast< uint32_t * >(argp4);
- arg4 = *temp;
- if (SWIG_IsNewObj(res4)) delete temp;
- }
+ SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "CoreSession_setDTMFCallback" "', argument " "3"" of type '" "char *""'");
}
- (arg1)->setDTMFCallback(arg2,arg3,arg4);
+ arg3 = reinterpret_cast< char * >(buf3);
+ (arg1)->setDTMFCallback(arg2,arg3);
resultobj = SWIG_Py_Void();
+ if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
return resultobj;
fail:
+ if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
return NULL;
}
CoreSession *arg1 = (CoreSession *) 0 ;
char *arg2 = (char *) 0 ;
int arg3 ;
- char *arg4 = (char *) 0 ;
+ int arg4 ;
char *arg5 = (char *) 0 ;
- int arg6 ;
+ char *arg6 = (char *) 0 ;
+ int arg7 ;
int result;
void *argp1 = 0 ;
int res1 = 0 ;
int alloc2 = 0 ;
int val3 ;
int ecode3 = 0 ;
- int res4 ;
- char *buf4 = 0 ;
- int alloc4 = 0 ;
+ int val4 ;
+ int ecode4 = 0 ;
int res5 ;
- char temp5[8+1] ;
- char *t5 = 0 ;
- size_t n5 = 0 ;
+ char *buf5 = 0 ;
int alloc5 = 0 ;
- int val6 ;
- int ecode6 = 0 ;
+ int res6 ;
+ char temp6[8+1] ;
+ char *t6 = 0 ;
+ size_t n6 = 0 ;
+ int alloc6 = 0 ;
+ int val7 ;
+ int ecode7 = 0 ;
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
PyObject * obj2 = 0 ;
PyObject * obj3 = 0 ;
PyObject * obj4 = 0 ;
PyObject * obj5 = 0 ;
+ PyObject * obj6 = 0 ;
- if (!PyArg_ParseTuple(args,(char *)"OOOOOO:CoreSession_getDigits",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail;
+ if (!PyArg_ParseTuple(args,(char *)"OOOOOOO:CoreSession_getDigits",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6)) 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_getDigits" "', argument " "1"" of type '" "CoreSession *""'");
SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "CoreSession_getDigits" "', argument " "3"" of type '" "int""'");
}
arg3 = static_cast< int >(val3);
- res4 = SWIG_AsCharPtrAndSize(obj3, &buf4, NULL, &alloc4);
- if (!SWIG_IsOK(res4)) {
- SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "CoreSession_getDigits" "', argument " "4"" of type '" "char *""'");
- }
- arg4 = reinterpret_cast< char * >(buf4);
- res5 = SWIG_AsCharPtrAndSize(obj4, &t5, &n5, &alloc5);
+ ecode4 = SWIG_AsVal_int(obj3, &val4);
+ if (!SWIG_IsOK(ecode4)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "CoreSession_getDigits" "', argument " "4"" of type '" "int""'");
+ }
+ arg4 = static_cast< int >(val4);
+ res5 = SWIG_AsCharPtrAndSize(obj4, &buf5, NULL, &alloc5);
if (!SWIG_IsOK(res5)) {
- SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "CoreSession_getDigits" "', argument " "5"" of type '" "char *terminator""'");
- }
- if ( n5 > (size_t) 8 ) n5 = (size_t) 8;
- memcpy(temp5, t5, sizeof(char)*n5);
- if (alloc5 == SWIG_NEWOBJ) delete[] t5;
- temp5[n5 - 1] = 0;
- arg5 = (char *) temp5;
- ecode6 = SWIG_AsVal_int(obj5, &val6);
- if (!SWIG_IsOK(ecode6)) {
- SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "CoreSession_getDigits" "', argument " "6"" of type '" "int""'");
+ SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "CoreSession_getDigits" "', argument " "5"" of type '" "char *""'");
+ }
+ arg5 = reinterpret_cast< char * >(buf5);
+ res6 = SWIG_AsCharPtrAndSize(obj5, &t6, &n6, &alloc6);
+ if (!SWIG_IsOK(res6)) {
+ SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "CoreSession_getDigits" "', argument " "6"" of type '" "char *terminator""'");
+ }
+ if ( n6 > (size_t) 8 ) n6 = (size_t) 8;
+ memcpy(temp6, t6, sizeof(char)*n6);
+ if (alloc6 == SWIG_NEWOBJ) delete[] t6;
+ temp6[n6 - 1] = 0;
+ arg6 = (char *) temp6;
+ ecode7 = SWIG_AsVal_int(obj6, &val7);
+ if (!SWIG_IsOK(ecode7)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "CoreSession_getDigits" "', argument " "7"" of type '" "int""'");
}
- arg6 = static_cast< int >(val6);
- result = (int)(arg1)->getDigits(arg2,arg3,arg4,arg5,arg6);
+ arg7 = static_cast< int >(val7);
+ result = (int)(arg1)->getDigits(arg2,arg3,arg4,arg5,arg6,arg7);
resultobj = SWIG_From_int(static_cast< int >(result));
arg2[128] = 0;
resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_FromCharPtr(arg2));
- arg5[8] = 0;
- resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_FromCharPtr(arg5));
- if (alloc4 == SWIG_NEWOBJ) delete[] buf4;
+ arg6[8] = 0;
+ resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_FromCharPtr(arg6));
+ if (alloc5 == SWIG_NEWOBJ) delete[] buf5;
return resultobj;
fail:
- if (alloc4 == SWIG_NEWOBJ) delete[] buf4;
+ if (alloc5 == SWIG_NEWOBJ) delete[] buf5;
return NULL;
}
}
+SWIGINTERN PyObject *_wrap_CoreSession_flushEvents(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ CoreSession *arg1 = (CoreSession *) 0 ;
+ int result;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:CoreSession_flushEvents",&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_flushEvents" "', argument " "1"" of type '" "CoreSession *""'");
+ }
+ arg1 = reinterpret_cast< CoreSession * >(argp1);
+ result = (int)(arg1)->flushEvents();
+ resultobj = SWIG_From_int(static_cast< int >(result));
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_CoreSession_flushDigits(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ CoreSession *arg1 = (CoreSession *) 0 ;
+ int result;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:CoreSession_flushDigits",&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_flushDigits" "', argument " "1"" of type '" "CoreSession *""'");
+ }
+ arg1 = reinterpret_cast< CoreSession * >(argp1);
+ result = (int)(arg1)->flushDigits();
+ resultobj = SWIG_From_int(static_cast< int >(result));
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_CoreSession_setAutoHangup(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ CoreSession *arg1 = (CoreSession *) 0 ;
+ bool arg2 ;
+ int result;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ bool val2 ;
+ int ecode2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:CoreSession_setAutoHangup",&obj0,&obj1)) 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_setAutoHangup" "', argument " "1"" of type '" "CoreSession *""'");
+ }
+ arg1 = reinterpret_cast< CoreSession * >(argp1);
+ ecode2 = SWIG_AsVal_bool(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "CoreSession_setAutoHangup" "', argument " "2"" of type '" "bool""'");
+ }
+ arg2 = static_cast< bool >(val2);
+ result = (int)(arg1)->setAutoHangup(arg2);
+ resultobj = SWIG_From_int(static_cast< int >(result));
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_CoreSession_setHangupHook(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ CoreSession *arg1 = (CoreSession *) 0 ;
+ void *arg2 = (void *) 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int res2 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:CoreSession_setHangupHook",&obj0,&obj1)) 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_setHangupHook" "', argument " "1"" of type '" "CoreSession *""'");
+ }
+ arg1 = reinterpret_cast< CoreSession * >(argp1);
+ res2 = SWIG_ConvertPtr(obj1,SWIG_as_voidptrptr(&arg2), 0, 0);
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CoreSession_setHangupHook" "', argument " "2"" of type '" "void *""'");
+ }
+ (arg1)->setHangupHook(arg2);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
SWIGINTERN PyObject *_wrap_CoreSession_ready(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
CoreSession *arg1 = (CoreSession *) 0 ;
SWIGINTERN PyObject *_wrap_CoreSession_begin_allow_threads(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
CoreSession *arg1 = (CoreSession *) 0 ;
+ bool result;
void *argp1 = 0 ;
int res1 = 0 ;
PyObject * obj0 = 0 ;
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CoreSession_begin_allow_threads" "', argument " "1"" of type '" "CoreSession *""'");
}
arg1 = reinterpret_cast< CoreSession * >(argp1);
- (arg1)->begin_allow_threads();
- resultobj = SWIG_Py_Void();
+ result = (bool)(arg1)->begin_allow_threads();
+ resultobj = SWIG_From_bool(static_cast< bool >(result));
return resultobj;
fail:
return NULL;
SWIGINTERN PyObject *_wrap_CoreSession_end_allow_threads(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
CoreSession *arg1 = (CoreSession *) 0 ;
+ bool result;
void *argp1 = 0 ;
int res1 = 0 ;
PyObject * obj0 = 0 ;
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CoreSession_end_allow_threads" "', argument " "1"" of type '" "CoreSession *""'");
}
arg1 = reinterpret_cast< CoreSession * >(argp1);
- (arg1)->end_allow_threads();
- resultobj = SWIG_Py_Void();
+ result = (bool)(arg1)->end_allow_threads();
+ resultobj = SWIG_From_bool(static_cast< bool >(result));
return resultobj;
fail:
return NULL;
}
+SWIGINTERN PyObject *_wrap_CoreSession_check_hangup_hook(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_check_hangup_hook",&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_check_hangup_hook" "', argument " "1"" of type '" "CoreSession *""'");
+ }
+ arg1 = reinterpret_cast< CoreSession * >(argp1);
+ (arg1)->check_hangup_hook();
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_CoreSession_run_dtmf_callback(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ CoreSession *arg1 = (CoreSession *) 0 ;
+ void *arg2 = (void *) 0 ;
+ switch_input_type_t arg3 ;
+ switch_status_t result;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int res2 ;
+ void *argp3 ;
+ int res3 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ PyObject * obj2 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OOO:CoreSession_run_dtmf_callback",&obj0,&obj1,&obj2)) 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_run_dtmf_callback" "', argument " "1"" of type '" "CoreSession *""'");
+ }
+ arg1 = reinterpret_cast< CoreSession * >(argp1);
+ res2 = SWIG_ConvertPtr(obj1,SWIG_as_voidptrptr(&arg2), 0, 0);
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CoreSession_run_dtmf_callback" "', argument " "2"" of type '" "void *""'");
+ }
+ {
+ res3 = SWIG_ConvertPtr(obj2, &argp3, SWIGTYPE_p_switch_input_type_t, 0 | 0);
+ if (!SWIG_IsOK(res3)) {
+ SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "CoreSession_run_dtmf_callback" "', argument " "3"" of type '" "switch_input_type_t""'");
+ }
+ if (!argp3) {
+ SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "CoreSession_run_dtmf_callback" "', argument " "3"" of type '" "switch_input_type_t""'");
+ } else {
+ switch_input_type_t * temp = reinterpret_cast< switch_input_type_t * >(argp3);
+ arg3 = *temp;
+ if (SWIG_IsNewObj(res3)) delete temp;
+ }
+ }
+ result = (arg1)->run_dtmf_callback(arg2,arg3);
+ resultobj = SWIG_NewPointerObj((new switch_status_t(static_cast< const switch_status_t& >(result))), SWIGTYPE_p_switch_status_t, SWIG_POINTER_OWN | 0 );
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
SWIGINTERN PyObject *CoreSession_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *obj;
if (!PyArg_ParseTuple(args,(char*)"O|swigregister", &obj)) return NULL;
}
-SWIGINTERN PyObject *_wrap_PythonDTMFCallback(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_hanguphook(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
+ switch_status_t result;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:hanguphook",&obj0)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_switch_core_session_t, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "hanguphook" "', argument " "1"" of type '" "switch_core_session_t *""'");
+ }
+ arg1 = reinterpret_cast< switch_core_session_t * >(argp1);
+ result = hanguphook(arg1);
+ resultobj = SWIG_NewPointerObj((new switch_status_t(static_cast< const switch_status_t& >(result))), SWIGTYPE_p_switch_status_t, SWIG_POINTER_OWN | 0 );
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_dtmf_callback(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
- switch_core_session *arg1 = (switch_core_session *) 0 ;
+ switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
void *arg2 = (void *) 0 ;
switch_input_type_t arg3 ;
void *arg4 = (void *) 0 ;
PyObject * obj3 = 0 ;
PyObject * obj4 = 0 ;
- if (!PyArg_ParseTuple(args,(char *)"OOOOO:PythonDTMFCallback",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail;
- res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_switch_core_session, 0 | 0 );
+ if (!PyArg_ParseTuple(args,(char *)"OOOOO:dtmf_callback",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_switch_core_session_t, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PythonDTMFCallback" "', argument " "1"" of type '" "switch_core_session *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dtmf_callback" "', argument " "1"" of type '" "switch_core_session_t *""'");
}
- arg1 = reinterpret_cast< switch_core_session * >(argp1);
+ arg1 = reinterpret_cast< switch_core_session_t * >(argp1);
res2 = SWIG_ConvertPtr(obj1,SWIG_as_voidptrptr(&arg2), 0, 0);
if (!SWIG_IsOK(res2)) {
- SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "PythonDTMFCallback" "', argument " "2"" of type '" "void *""'");
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "dtmf_callback" "', argument " "2"" of type '" "void *""'");
}
{
res3 = SWIG_ConvertPtr(obj2, &argp3, SWIGTYPE_p_switch_input_type_t, 0 | 0);
if (!SWIG_IsOK(res3)) {
- SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "PythonDTMFCallback" "', argument " "3"" of type '" "switch_input_type_t""'");
+ SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "dtmf_callback" "', argument " "3"" of type '" "switch_input_type_t""'");
}
if (!argp3) {
- SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "PythonDTMFCallback" "', argument " "3"" of type '" "switch_input_type_t""'");
+ SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "dtmf_callback" "', argument " "3"" of type '" "switch_input_type_t""'");
} else {
switch_input_type_t * temp = reinterpret_cast< switch_input_type_t * >(argp3);
arg3 = *temp;
}
res4 = SWIG_ConvertPtr(obj3,SWIG_as_voidptrptr(&arg4), 0, 0);
if (!SWIG_IsOK(res4)) {
- SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "PythonDTMFCallback" "', argument " "4"" of type '" "void *""'");
+ SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "dtmf_callback" "', argument " "4"" of type '" "void *""'");
}
ecode5 = SWIG_AsVal_unsigned_SS_int(obj4, &val5);
if (!SWIG_IsOK(ecode5)) {
- SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "PythonDTMFCallback" "', argument " "5"" of type '" "unsigned int""'");
+ SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "dtmf_callback" "', argument " "5"" of type '" "unsigned int""'");
}
arg5 = static_cast< unsigned int >(val5);
- result = PythonDTMFCallback(arg1,arg2,arg3,arg4,arg5);
+ result = dtmf_callback(arg1,arg2,arg3,arg4,arg5);
resultobj = SWIG_NewPointerObj((new switch_status_t(static_cast< const switch_status_t& >(result))), SWIGTYPE_p_switch_status_t, SWIG_POINTER_OWN | 0 );
return resultobj;
fail:
}
+SWIGINTERN PyObject *_wrap_PySession_setHangupHook(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ PySession *arg1 = (PySession *) 0 ;
+ PyObject *arg2 = (PyObject *) 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:PySession_setHangupHook",&obj0,&obj1)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_PySession, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PySession_setHangupHook" "', argument " "1"" of type '" "PySession *""'");
+ }
+ arg1 = reinterpret_cast< PySession * >(argp1);
+ arg2 = obj1;
+ (arg1)->setHangupHook(arg2);
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_PySession_check_hangup_hook(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ PySession *arg1 = (PySession *) 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:PySession_check_hangup_hook",&obj0)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_PySession, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PySession_check_hangup_hook" "', argument " "1"" of type '" "PySession *""'");
+ }
+ arg1 = reinterpret_cast< PySession * >(argp1);
+ (arg1)->check_hangup_hook();
+ resultobj = SWIG_Py_Void();
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_PySession_hangup(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ PySession *arg1 = (PySession *) 0 ;
+ char *arg2 = (char *) 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int res2 ;
+ char *buf2 = 0 ;
+ int alloc2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OO:PySession_hangup",&obj0,&obj1)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_PySession, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PySession_hangup" "', argument " "1"" of type '" "PySession *""'");
+ }
+ arg1 = reinterpret_cast< PySession * >(argp1);
+ res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2);
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "PySession_hangup" "', argument " "2"" of type '" "char *""'");
+ }
+ arg2 = reinterpret_cast< char * >(buf2);
+ (arg1)->hangup(arg2);
+ resultobj = SWIG_Py_Void();
+ if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
+ return resultobj;
+fail:
+ if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
+ return NULL;
+}
+
+
SWIGINTERN PyObject *_wrap_PySession_begin_allow_threads(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
PySession *arg1 = (PySession *) 0 ;
+ bool result;
void *argp1 = 0 ;
int res1 = 0 ;
PyObject * obj0 = 0 ;
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PySession_begin_allow_threads" "', argument " "1"" of type '" "PySession *""'");
}
arg1 = reinterpret_cast< PySession * >(argp1);
- (arg1)->begin_allow_threads();
- resultobj = SWIG_Py_Void();
+ result = (bool)(arg1)->begin_allow_threads();
+ resultobj = SWIG_From_bool(static_cast< bool >(result));
return resultobj;
fail:
return NULL;
SWIGINTERN PyObject *_wrap_PySession_end_allow_threads(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
PySession *arg1 = (PySession *) 0 ;
+ bool result;
void *argp1 = 0 ;
int res1 = 0 ;
PyObject * obj0 = 0 ;
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PySession_end_allow_threads" "', argument " "1"" of type '" "PySession *""'");
}
arg1 = reinterpret_cast< PySession * >(argp1);
- (arg1)->end_allow_threads();
- resultobj = SWIG_Py_Void();
+ result = (bool)(arg1)->end_allow_threads();
+ resultobj = SWIG_From_bool(static_cast< bool >(result));
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_PySession_run_dtmf_callback(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ PySession *arg1 = (PySession *) 0 ;
+ void *arg2 = (void *) 0 ;
+ switch_input_type_t arg3 ;
+ switch_status_t result;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int res2 ;
+ void *argp3 ;
+ int res3 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ PyObject * obj2 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"OOO:PySession_run_dtmf_callback",&obj0,&obj1,&obj2)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_PySession, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PySession_run_dtmf_callback" "', argument " "1"" of type '" "PySession *""'");
+ }
+ arg1 = reinterpret_cast< PySession * >(argp1);
+ res2 = SWIG_ConvertPtr(obj1,SWIG_as_voidptrptr(&arg2), 0, 0);
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "PySession_run_dtmf_callback" "', argument " "2"" of type '" "void *""'");
+ }
+ {
+ res3 = SWIG_ConvertPtr(obj2, &argp3, SWIGTYPE_p_switch_input_type_t, 0 | 0);
+ if (!SWIG_IsOK(res3)) {
+ SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "PySession_run_dtmf_callback" "', argument " "3"" of type '" "switch_input_type_t""'");
+ }
+ if (!argp3) {
+ SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "PySession_run_dtmf_callback" "', argument " "3"" of type '" "switch_input_type_t""'");
+ } else {
+ switch_input_type_t * temp = reinterpret_cast< switch_input_type_t * >(argp3);
+ arg3 = *temp;
+ if (SWIG_IsNewObj(res3)) delete temp;
+ }
+ }
+ result = (arg1)->run_dtmf_callback(arg2,arg3);
+ resultobj = SWIG_NewPointerObj((new switch_status_t(static_cast< const switch_status_t& >(result))), SWIGTYPE_p_switch_status_t, SWIG_POINTER_OWN | 0 );
return resultobj;
fail:
return NULL;
{ (char *)"new_input_callback_state_t", _wrap_new_input_callback_state_t, METH_VARARGS, NULL},
{ (char *)"delete_input_callback_state_t", _wrap_delete_input_callback_state_t, METH_VARARGS, NULL},
{ (char *)"input_callback_state_t_swigregister", input_callback_state_t_swigregister, METH_VARARGS, NULL},
- { (char *)"new_CoreSession", _wrap_new_CoreSession, METH_VARARGS, NULL},
{ (char *)"delete_CoreSession", _wrap_delete_CoreSession, METH_VARARGS, NULL},
{ (char *)"CoreSession_session_set", _wrap_CoreSession_session_set, METH_VARARGS, NULL},
{ (char *)"CoreSession_session_get", _wrap_CoreSession_session_get, METH_VARARGS, NULL},
{ (char *)"CoreSession_channel_set", _wrap_CoreSession_channel_set, METH_VARARGS, NULL},
{ (char *)"CoreSession_channel_get", _wrap_CoreSession_channel_get, METH_VARARGS, NULL},
+ { (char *)"CoreSession_flags_set", _wrap_CoreSession_flags_set, METH_VARARGS, NULL},
+ { (char *)"CoreSession_flags_get", _wrap_CoreSession_flags_get, METH_VARARGS, NULL},
{ (char *)"CoreSession_cb_state_set", _wrap_CoreSession_cb_state_set, METH_VARARGS, NULL},
{ (char *)"CoreSession_cb_state_get", _wrap_CoreSession_cb_state_get, METH_VARARGS, NULL},
+ { (char *)"CoreSession_hook_state_set", _wrap_CoreSession_hook_state_set, METH_VARARGS, NULL},
+ { (char *)"CoreSession_hook_state_get", _wrap_CoreSession_hook_state_get, METH_VARARGS, NULL},
{ (char *)"CoreSession_answer", _wrap_CoreSession_answer, METH_VARARGS, NULL},
{ (char *)"CoreSession_preAnswer", _wrap_CoreSession_preAnswer, METH_VARARGS, NULL},
{ (char *)"CoreSession_hangup", _wrap_CoreSession_hangup, METH_VARARGS, NULL},
{ (char *)"CoreSession_transfer", _wrap_CoreSession_transfer, METH_VARARGS, NULL},
{ (char *)"CoreSession_playAndGetDigits", _wrap_CoreSession_playAndGetDigits, METH_VARARGS, NULL},
{ (char *)"CoreSession_streamfile", _wrap_CoreSession_streamfile, METH_VARARGS, NULL},
+ { (char *)"CoreSession_flushEvents", _wrap_CoreSession_flushEvents, METH_VARARGS, NULL},
+ { (char *)"CoreSession_flushDigits", _wrap_CoreSession_flushDigits, METH_VARARGS, NULL},
+ { (char *)"CoreSession_setAutoHangup", _wrap_CoreSession_setAutoHangup, METH_VARARGS, NULL},
+ { (char *)"CoreSession_setHangupHook", _wrap_CoreSession_setHangupHook, METH_VARARGS, NULL},
{ (char *)"CoreSession_ready", _wrap_CoreSession_ready, METH_VARARGS, NULL},
{ (char *)"CoreSession_execute", _wrap_CoreSession_execute, METH_VARARGS, NULL},
{ (char *)"CoreSession_begin_allow_threads", _wrap_CoreSession_begin_allow_threads, METH_VARARGS, NULL},
{ (char *)"CoreSession_end_allow_threads", _wrap_CoreSession_end_allow_threads, METH_VARARGS, NULL},
{ (char *)"CoreSession_get_uuid", _wrap_CoreSession_get_uuid, METH_VARARGS, NULL},
{ (char *)"CoreSession_get_cb_args", _wrap_CoreSession_get_cb_args, METH_VARARGS, NULL},
+ { (char *)"CoreSession_check_hangup_hook", _wrap_CoreSession_check_hangup_hook, METH_VARARGS, NULL},
+ { (char *)"CoreSession_run_dtmf_callback", _wrap_CoreSession_run_dtmf_callback, METH_VARARGS, NULL},
{ (char *)"CoreSession_swigregister", CoreSession_swigregister, METH_VARARGS, NULL},
{ (char *)"bridge", _wrap_bridge, METH_VARARGS, NULL},
- { (char *)"PythonDTMFCallback", _wrap_PythonDTMFCallback, METH_VARARGS, NULL},
+ { (char *)"hanguphook", _wrap_hanguphook, METH_VARARGS, NULL},
+ { (char *)"dtmf_callback", _wrap_dtmf_callback, METH_VARARGS, NULL},
{ (char *)"new_PySession", _wrap_new_PySession, METH_VARARGS, NULL},
{ (char *)"delete_PySession", _wrap_delete_PySession, METH_VARARGS, NULL},
{ (char *)"PySession_setDTMFCallback", _wrap_PySession_setDTMFCallback, METH_VARARGS, NULL},
+ { (char *)"PySession_setHangupHook", _wrap_PySession_setHangupHook, METH_VARARGS, NULL},
+ { (char *)"PySession_check_hangup_hook", _wrap_PySession_check_hangup_hook, METH_VARARGS, NULL},
+ { (char *)"PySession_hangup", _wrap_PySession_hangup, METH_VARARGS, NULL},
{ (char *)"PySession_begin_allow_threads", _wrap_PySession_begin_allow_threads, METH_VARARGS, NULL},
{ (char *)"PySession_end_allow_threads", _wrap_PySession_end_allow_threads, METH_VARARGS, NULL},
+ { (char *)"PySession_run_dtmf_callback", _wrap_PySession_run_dtmf_callback, METH_VARARGS, NULL},
{ (char *)"PySession_swigregister", PySession_swigregister, METH_VARARGS, NULL},
{ NULL, NULL, 0, NULL }
};
static swig_type_info _swigt__p_PySession = {"_p_PySession", "PySession *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_input_callback_state = {"_p_input_callback_state", "input_callback_state *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_session_flag_t = {"_p_session_flag_t", "enum session_flag_t *|session_flag_t *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_swap_state_t = {"_p_swap_state_t", "enum swap_state_t *|swap_state_t *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_switch_channel_state_t = {"_p_switch_channel_state_t", "switch_channel_state_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_switch_channel_t = {"_p_switch_channel_t", "switch_channel_t *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_switch_core_session = {"_p_switch_core_session", "switch_core_session *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_switch_core_session_t = {"_p_switch_core_session_t", "switch_core_session_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_switch_input_args_t = {"_p_switch_input_args_t", "switch_input_args_t *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_switch_input_callback_function_t = {"_p_switch_input_callback_function_t", "switch_input_callback_function_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_switch_input_type_t = {"_p_switch_input_type_t", "switch_input_type_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_switch_status_t = {"_p_switch_status_t", "switch_status_t *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_uint32_t = {"_p_uint32_t", "uint32_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_void = {"_p_void", "void *", 0, 0, (void*)0, 0};
static swig_type_info *swig_type_initial[] = {
&_swigt__p_PySession,
&_swigt__p_char,
&_swigt__p_input_callback_state,
+ &_swigt__p_session_flag_t,
+ &_swigt__p_swap_state_t,
+ &_swigt__p_switch_channel_state_t,
&_swigt__p_switch_channel_t,
- &_swigt__p_switch_core_session,
&_swigt__p_switch_core_session_t,
&_swigt__p_switch_input_args_t,
- &_swigt__p_switch_input_callback_function_t,
&_swigt__p_switch_input_type_t,
&_swigt__p_switch_status_t,
- &_swigt__p_uint32_t,
&_swigt__p_void,
};
static swig_cast_info _swigc__p_PySession[] = { {&_swigt__p_PySession, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_input_callback_state[] = { {&_swigt__p_input_callback_state, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_session_flag_t[] = { {&_swigt__p_session_flag_t, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_swap_state_t[] = { {&_swigt__p_swap_state_t, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_switch_channel_state_t[] = { {&_swigt__p_switch_channel_state_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_switch_channel_t[] = { {&_swigt__p_switch_channel_t, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_switch_core_session[] = { {&_swigt__p_switch_core_session, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_switch_core_session_t[] = { {&_swigt__p_switch_core_session_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_switch_input_args_t[] = { {&_swigt__p_switch_input_args_t, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_switch_input_callback_function_t[] = { {&_swigt__p_switch_input_callback_function_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_switch_input_type_t[] = { {&_swigt__p_switch_input_type_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_switch_status_t[] = { {&_swigt__p_switch_status_t, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_uint32_t[] = { {&_swigt__p_uint32_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_void[] = { {&_swigt__p_void, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info *swig_cast_initial[] = {
_swigc__p_PySession,
_swigc__p_char,
_swigc__p_input_callback_state,
+ _swigc__p_session_flag_t,
+ _swigc__p_swap_state_t,
+ _swigc__p_switch_channel_state_t,
_swigc__p_switch_channel_t,
- _swigc__p_switch_core_session,
_swigc__p_switch_core_session_t,
_swigc__p_switch_input_args_t,
- _swigc__p_switch_input_callback_function_t,
_swigc__p_switch_input_type_t,
_swigc__p_switch_status_t,
- _swigc__p_uint32_t,
_swigc__p_void,
};
SWIG_InstallConstants(d,swig_const_table);
+ SWIG_Python_SetConstant(d, "S_HUP",SWIG_From_int(static_cast< int >(S_HUP)));
+ SWIG_Python_SetConstant(d, "S_FREE",SWIG_From_int(static_cast< int >(S_FREE)));
+ SWIG_Python_SetConstant(d, "S_RDLOCK",SWIG_From_int(static_cast< int >(S_RDLOCK)));
+ SWIG_Python_SetConstant(d, "S_SWAPPED_IN",SWIG_From_int(static_cast< int >(S_SWAPPED_IN)));
+ SWIG_Python_SetConstant(d, "S_SWAPPED_OUT",SWIG_From_int(static_cast< int >(S_SWAPPED_OUT)));
}
#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)
#define sanity_check_noreturn do { if (!session) { switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "session is not initalized\n"); return;}} while(0)
-#define init_vars() do { session = NULL; channel = NULL; uuid = NULL; tts_name = NULL; voice_name = NULL; memset(&args, 0, sizeof(args)); ap = NULL; caller_profile.source = "mod_unknown"; caller_profile.dialplan = ""; caller_profile.context = ""; caller_profile.caller_id_name = ""; caller_profile.caller_id_number = ""; caller_profile.network_addr = ""; caller_profile.ani = ""; caller_profile.aniii = ""; caller_profile.rdnis = ""; caller_profile.username = ""; } while(0)
+#define init_vars() do { session = NULL; channel = NULL; uuid = NULL; tts_name = NULL; voice_name = NULL; memset(&args, 0, sizeof(args)); ap = NULL; caller_profile.source = "mod_unknown"; caller_profile.dialplan = ""; caller_profile.context = ""; caller_profile.caller_id_name = ""; caller_profile.caller_id_number = ""; caller_profile.network_addr = ""; caller_profile.ani = ""; caller_profile.aniii = ""; caller_profile.rdnis = ""; caller_profile.username = ""; on_hangup = NULL; cb_state.function = NULL; } while(0)
CoreSession::~CoreSession()
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CoreSession::~CoreSession desctructor");
+ switch_channel_t *channel = NULL;
if (session) {
+ channel = switch_core_session_get_channel(session);
+ if (channel && switch_test_flag(this, S_HUP)) {
+ switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
+ }
switch_core_session_rwunlock(session);
}
timer_name = NULL;
}
store_file_handle(&fh);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "playFile begin_allow_threads\n");
begin_allow_threads();
status = switch_ivr_play_file(session, &fh, file, ap);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "playFile end_allow_threads\n");
end_allow_threads();
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
}
-void CoreSession::setDTMFCallback(switch_input_callback_function_t cb,
- void *buf,
- uint32_t buflen)
-{
- sanity_check_noreturn;
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CoreSession::setDTMFCallback.");
- if (cb) {
- args.buf = buf;
- args.buflen = buflen;
- args.input_callback = cb;
- ap = &args;
- } else {
- memset(&args, 0, sizeof(args));
- ap = NULL;
- }
-}
+void CoreSession::setDTMFCallback(void *cbfunc, char *funcargs) {
+
+ cb_state.funcargs = funcargs;
+ cb_state.function = cbfunc;
+
+ args.buf = &cb_state;
+ args.buflen = sizeof(cb_state); // not sure what this is used for, copy mod_spidermonkey
+
+ switch_channel_set_private(channel, "CoreSession", this);
+
+ // we cannot set the actual callback to a python function, because
+ // the callback is a function pointer with a specific signature.
+ // so, set it to the following c function which will act as a proxy,
+ // finding the python callback in the args callback args structure
+ args.input_callback = dtmf_callback;
+ ap = &args;
+
+
+}
int CoreSession::speak(char *text)
{
switch_codec_t *codec;
sanity_check(-1);
+
+ // create and store an empty filehandle in callback args
+ // to workaround a bug in the presumptuous process_callback_result()
+ switch_file_handle_t fh = { 0 };
+ store_file_handle(&fh);
+
if (!tts_name) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No TTS engine specified");
return SWITCH_STATUS_FALSE;
}
int CoreSession::getDigits(char *dtmf_buf,
- int len,
+ int buflen,
+ int maxdigits,
char *terminators,
char *terminator,
int timeout)
switch_status_t status;
sanity_check(-1);
begin_allow_threads();
+
status = switch_ivr_collect_digits_count(session,
dtmf_buf,
- (uint32_t) len,
- (uint32_t) len,
+ (uint32_t) buflen,
+ (uint32_t) maxdigits,
terminators,
terminator,
(uint32_t) timeout);
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "getDigits dtmf_buf: %s\n", dtmf_buf);
end_allow_threads();
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
}
bad_input_audio_files,
dtmf_buf, 128,
digits_regex);
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "playAndGetDigits dtmf_buf: %s\n", dtmf_buf);
+
end_allow_threads();
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
}
}
+int CoreSession::flushEvents()
+{
+ switch_event_t *event;
+ switch_channel_t *channel;
+
+ if (!session) {
+ return SWITCH_STATUS_FALSE;
+ }
+ channel = switch_core_session_get_channel(session);
+ assert(channel != NULL);
+
+ while (switch_core_session_dequeue_event(session, &event) == SWITCH_STATUS_SUCCESS) {
+ switch_event_destroy(&event);
+ }
+ return SWITCH_STATUS_SUCCESS;
+}
+
+int CoreSession::flushDigits()
+{
+ char buf[256];
+ switch_size_t has;
+ switch_channel_t *channel;
+
+
+ channel = switch_core_session_get_channel(session);
+ assert(channel != NULL);
+
+ while ((has = switch_channel_has_dtmf(channel))) {
+ switch_channel_dequeue_dtmf(channel, buf, sizeof(buf));
+ }
+ return SWITCH_STATUS_SUCCESS;
+}
+
+int CoreSession::setAutoHangup(bool val)
+{
+ if (!session) {
+ return SWITCH_STATUS_FALSE;
+ }
+ if (val) {
+ switch_set_flag(this, S_HUP);
+ } else {
+ switch_clear_flag(this, S_HUP);
+ }
+ return SWITCH_STATUS_SUCCESS;
+}
+
void CoreSession::setCallerData(char *var, char *val) {
if (strcmp(var, "dialplan") == 0) {
}
-void CoreSession::begin_allow_threads() {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CoreSession::begin_allow_threads() called and does nothing\n");
-}
+void CoreSession::setHangupHook(void *hangup_func) {
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CoreSession::seHangupHook, hangup_func: %p\n", hangup_func);
+ on_hangup = hangup_func;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
+ assert(channel != NULL);
+
+ hook_state = switch_channel_get_state(channel);
+ switch_channel_set_private(channel, "CoreSession", this);
+ switch_core_event_hook_add_state_change(session, hanguphook);
-void CoreSession::end_allow_threads() {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CoreSession::end_allow_threads() called and does nothing\n");
}
/** \brief Store a file handle in the callback args
}
+switch_status_t hanguphook(switch_core_session_t *session_hungup)
+{
+ switch_channel_t *channel;
+ CoreSession *coresession = NULL;
+ switch_channel_state_t state;
+
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "hangup_hook called\n");
+ fflush(stdout);
+
+ channel = switch_core_session_get_channel(session_hungup);
+ assert(channel != NULL);
+
+ state = switch_channel_get_state(channel);
+
+ if ((coresession = (CoreSession *) switch_channel_get_private(channel, "CoreSession"))) {
+ if (coresession->hook_state != state) {
+ coresession->hook_state = state;
+ coresession->check_hangup_hook();
+ }
+ }
+
+ return SWITCH_STATUS_SUCCESS;
+}
+
+
+switch_status_t dtmf_callback(switch_core_session_t *session_cb,
+ void *input,
+ switch_input_type_t itype,
+ void *buf,
+ unsigned int buflen) {
+
+ switch_channel_t *channel;
+ CoreSession *coresession = NULL;
+ switch_status_t result;
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "dtmf_callback called\n");
+ fflush(stdout);
+
+ channel = switch_core_session_get_channel(session_cb);
+ assert(channel != NULL);
+
+ coresession = (CoreSession *) switch_channel_get_private(channel, "CoreSession");
+ if (!coresession) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid CoreSession\n");
+ return SWITCH_STATUS_FALSE;
+ }
+
+ result = coresession->run_dtmf_callback(input, itype);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "process_callback_result returned\n");
+ if (result) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "process_callback_result returned: %d\n", result);
+ }
+ return result;
+
+}
+
+
switch_status_t process_callback_result(char *ret,
struct input_callback_state *cb_state,
{
switch_file_handle_t *fh = NULL;
+
+ if (!cb_state) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Process callback result aborted because cb_state is null\n");
+ return SWITCH_STATUS_FALSE;
+ }
+
+ if (!cb_state->extra) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Process callback result aborted because cb_state->extra is null\n");
+ return SWITCH_STATUS_FALSE;
+ }
+
fh = (switch_file_handle_t *) cb_state->extra;
if (!fh) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Process callback result aborted because fh is null\n");
+ return SWITCH_STATUS_FALSE;
+ }
+
+ if (!fh->file_interface) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Process callback result aborted because fh->file_interface is null\n");
return SWITCH_STATUS_FALSE;
}
if (!ret) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Process callback result aborted because ret is null\n");
+ return SWITCH_STATUS_FALSE;
+ }
+
+ if (!session) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Process callback result aborted because session is null\n");
return SWITCH_STATUS_FALSE;
}
+
if (!strncasecmp(ret, "speed", 4)) {
char *p;
unsigned int pos = 0;
char *p;
codec = switch_core_session_get_read_codec(session);
-
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "got codec\n");
if ((p = strchr(ret, ':'))) {
p++;
if (*p == '+' || *p == '-') {
}
if (step > 0) {
samps = step * (codec->implementation->samples_per_second / 1000);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "going to seek\n");
switch_core_file_seek(fh, &pos, samps, SEEK_CUR);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "done seek\n");
} else {
samps = step * (codec->implementation->samples_per_second / 1000);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "going to seek\n");
switch_core_file_seek(fh, &pos, fh->pos - samps, SEEK_SET);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "done seek\n");
}
} else {
samps = atoi(p) * (codec->implementation->samples_per_second / 1000);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "going to seek\n");
switch_core_file_seek(fh, &pos, samps, SEEK_SET);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "done seek\n");
}
}
}
if (!strcmp(ret, "true") || !strcmp(ret, "undefined")) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "return success\n");
return SWITCH_STATUS_SUCCESS;
}
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "no match, return false\n");
return SWITCH_STATUS_FALSE;