more py stuff
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5099 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
46c14326b3
commit
ba652e4f94
|
@ -36,6 +36,10 @@ PythonDTMFCallback = _freeswitch.PythonDTMFCallback
|
|||
console_log = _freeswitch.console_log
|
||||
|
||||
console_clean_log = _freeswitch.console_clean_log
|
||||
|
||||
api_execute = _freeswitch.api_execute
|
||||
|
||||
api_reply_delete = _freeswitch.api_reply_delete
|
||||
class SessionContainer(_object):
|
||||
__swig_setmethods__ = {}
|
||||
__setattr__ = lambda self, name, value: _swig_setattr(self, SessionContainer, name, value)
|
||||
|
@ -55,7 +59,6 @@ class SessionContainer(_object):
|
|||
def hangup(*args): return _freeswitch.SessionContainer_hangup(*args)
|
||||
def set_variable(*args): return _freeswitch.SessionContainer_set_variable(*args)
|
||||
def get_variable(*args): return _freeswitch.SessionContainer_get_variable(*args)
|
||||
def set_state(*args): return _freeswitch.SessionContainer_set_state(*args)
|
||||
def play_file(*args): return _freeswitch.SessionContainer_play_file(*args)
|
||||
def set_dtmf_callback(*args): return _freeswitch.SessionContainer_set_dtmf_callback(*args)
|
||||
def speak_text(*args): return _freeswitch.SessionContainer_speak_text(*args)
|
||||
|
@ -63,6 +66,7 @@ class SessionContainer(_object):
|
|||
def get_digits(*args): return _freeswitch.SessionContainer_get_digits(*args)
|
||||
def transfer(*args): return _freeswitch.SessionContainer_transfer(*args)
|
||||
def play_and_get_digits(*args): return _freeswitch.SessionContainer_play_and_get_digits(*args)
|
||||
def execute(*args): return _freeswitch.SessionContainer_execute(*args)
|
||||
|
||||
class SessionContainerPtr(SessionContainer):
|
||||
def __init__(self, this):
|
||||
|
|
|
@ -57,14 +57,14 @@ void SessionContainer::get_variable(char *var, char *val)
|
|||
switch_channel_get_variable(channel, var);
|
||||
}
|
||||
|
||||
void SessionContainer::set_state(char *state)
|
||||
void SessionContainer::execute(char *app, char *data)
|
||||
{
|
||||
switch_channel_state_t current_state;
|
||||
const switch_application_interface_t *application_interface;
|
||||
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);
|
||||
}
|
||||
|
||||
if ((application_interface = switch_loadable_module_get_application_interface(app))) {
|
||||
switch_core_session_exec(session, application_interface, data);
|
||||
}
|
||||
}
|
||||
|
||||
int SessionContainer::play_file(char *file, char *timer_name)
|
||||
|
|
|
@ -12,6 +12,8 @@ extern "C" {
|
|||
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);
|
||||
char *api_execute(char *cmd, char *arg);
|
||||
void api_reply_delete(char *reply);
|
||||
|
||||
class SessionContainer {
|
||||
private:
|
||||
|
@ -24,14 +26,11 @@ extern "C" {
|
|||
public:
|
||||
SessionContainer(char *uuid);
|
||||
~SessionContainer();
|
||||
//void console_log(char *level_str, char *msg);
|
||||
//void console_clean_log(char *msg);
|
||||
int answer();
|
||||
int pre_answer();
|
||||
void hangup(char *cause);
|
||||
void set_variable(char *var, char *val);
|
||||
void get_variable(char *var, char *val);
|
||||
void set_state(char *state);
|
||||
int play_file(char *file, char *timer_name);
|
||||
void set_dtmf_callback(PyObject * pyfunc);
|
||||
int speak_text(char *text);
|
||||
|
@ -40,6 +39,7 @@ extern "C" {
|
|||
int transfer(char *extensions, char *dialplan, char *context);
|
||||
int play_and_get_digits(int min_digits, int max_digits, int max_tries, int timeout, char *terminators,
|
||||
char *audio_files, char *bad_input_audio_files, char *dtmf_buf, char *digits_regex);
|
||||
void SessionContainer::execute(char *app, char *data);
|
||||
protected:
|
||||
};
|
||||
|
||||
|
|
|
@ -49,6 +49,21 @@ void console_clean_log(char *msg)
|
|||
}
|
||||
|
||||
|
||||
char *api_execute(char *cmd, char *arg)
|
||||
{
|
||||
switch_stream_handle_t stream = { 0 };
|
||||
SWITCH_STANDARD_STREAM(stream);
|
||||
switch_api_execute(cmd, arg, NULL, &stream);
|
||||
return (char *) stream.data;
|
||||
}
|
||||
|
||||
void api_reply_delete(char *reply)
|
||||
{
|
||||
if (!switch_strlen_zero(reply)) {
|
||||
free(reply);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
%}
|
||||
|
||||
|
|
|
@ -785,6 +785,21 @@ void console_clean_log(char *msg)
|
|||
}
|
||||
|
||||
|
||||
char *api_execute(char *cmd, char *arg)
|
||||
{
|
||||
switch_stream_handle_t stream = { 0 };
|
||||
SWITCH_STANDARD_STREAM(stream);
|
||||
switch_api_execute(cmd, arg, NULL, &stream);
|
||||
return (char *) stream.data;
|
||||
}
|
||||
|
||||
void api_reply_delete(char *reply)
|
||||
{
|
||||
if (!switch_strlen_zero(reply)) {
|
||||
free(reply);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -855,6 +870,36 @@ static PyObject *_wrap_console_clean_log(PyObject *self, PyObject *args) {
|
|||
}
|
||||
|
||||
|
||||
static PyObject *_wrap_api_execute(PyObject *self, PyObject *args) {
|
||||
PyObject *resultobj;
|
||||
char *arg1 ;
|
||||
char *arg2 ;
|
||||
char *result;
|
||||
|
||||
if(!PyArg_ParseTuple(args,(char *)"ss:api_execute",&arg1,&arg2)) goto fail;
|
||||
result = (char *)api_execute(arg1,arg2);
|
||||
|
||||
resultobj = result ? PyString_FromString(result) : Py_BuildValue((char*)"");
|
||||
return resultobj;
|
||||
fail:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *_wrap_api_reply_delete(PyObject *self, PyObject *args) {
|
||||
PyObject *resultobj;
|
||||
char *arg1 ;
|
||||
|
||||
if(!PyArg_ParseTuple(args,(char *)"s:api_reply_delete",&arg1)) goto fail;
|
||||
api_reply_delete(arg1);
|
||||
|
||||
Py_INCREF(Py_None); resultobj = Py_None;
|
||||
return resultobj;
|
||||
fail:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *_wrap_new_SessionContainer(PyObject *self, PyObject *args) {
|
||||
PyObject *resultobj;
|
||||
char *arg1 ;
|
||||
|
@ -973,23 +1018,6 @@ static PyObject *_wrap_SessionContainer_get_variable(PyObject *self, PyObject *a
|
|||
}
|
||||
|
||||
|
||||
static PyObject *_wrap_SessionContainer_set_state(PyObject *self, PyObject *args) {
|
||||
PyObject *resultobj;
|
||||
SessionContainer *arg1 = (SessionContainer *) 0 ;
|
||||
char *arg2 ;
|
||||
PyObject * obj0 = 0 ;
|
||||
|
||||
if(!PyArg_ParseTuple(args,(char *)"Os:SessionContainer_set_state",&obj0,&arg2)) goto fail;
|
||||
if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_SessionContainer,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
|
||||
(arg1)->set_state(arg2);
|
||||
|
||||
Py_INCREF(Py_None); resultobj = Py_None;
|
||||
return resultobj;
|
||||
fail:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static PyObject *_wrap_SessionContainer_play_file(PyObject *self, PyObject *args) {
|
||||
PyObject *resultobj;
|
||||
SessionContainer *arg1 = (SessionContainer *) 0 ;
|
||||
|
@ -1174,6 +1202,24 @@ static PyObject *_wrap_SessionContainer_play_and_get_digits(PyObject *self, PyOb
|
|||
}
|
||||
|
||||
|
||||
static PyObject *_wrap_SessionContainer_execute(PyObject *self, PyObject *args) {
|
||||
PyObject *resultobj;
|
||||
SessionContainer *arg1 = (SessionContainer *) 0 ;
|
||||
char *arg2 ;
|
||||
char *arg3 ;
|
||||
PyObject * obj0 = 0 ;
|
||||
|
||||
if(!PyArg_ParseTuple(args,(char *)"Oss:SessionContainer_execute",&obj0,&arg2,&arg3)) goto fail;
|
||||
if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_SessionContainer,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
|
||||
(arg1)->execute(arg2,arg3);
|
||||
|
||||
Py_INCREF(Py_None); resultobj = Py_None;
|
||||
return resultobj;
|
||||
fail:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static PyObject * SessionContainer_swigregister(PyObject *self, PyObject *args) {
|
||||
PyObject *obj;
|
||||
if (!PyArg_ParseTuple(args,(char*)"O", &obj)) return NULL;
|
||||
|
@ -1185,6 +1231,8 @@ 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 *)"api_execute", _wrap_api_execute, METH_VARARGS },
|
||||
{ (char *)"api_reply_delete", _wrap_api_reply_delete, METH_VARARGS },
|
||||
{ (char *)"new_SessionContainer", _wrap_new_SessionContainer, METH_VARARGS },
|
||||
{ (char *)"delete_SessionContainer", _wrap_delete_SessionContainer, METH_VARARGS },
|
||||
{ (char *)"SessionContainer_answer", _wrap_SessionContainer_answer, METH_VARARGS },
|
||||
|
@ -1192,7 +1240,6 @@ static PyMethodDef SwigMethods[] = {
|
|||
{ (char *)"SessionContainer_hangup", _wrap_SessionContainer_hangup, METH_VARARGS },
|
||||
{ (char *)"SessionContainer_set_variable", _wrap_SessionContainer_set_variable, METH_VARARGS },
|
||||
{ (char *)"SessionContainer_get_variable", _wrap_SessionContainer_get_variable, METH_VARARGS },
|
||||
{ (char *)"SessionContainer_set_state", _wrap_SessionContainer_set_state, METH_VARARGS },
|
||||
{ (char *)"SessionContainer_play_file", _wrap_SessionContainer_play_file, METH_VARARGS },
|
||||
{ (char *)"SessionContainer_set_dtmf_callback", _wrap_SessionContainer_set_dtmf_callback, METH_VARARGS },
|
||||
{ (char *)"SessionContainer_speak_text", _wrap_SessionContainer_speak_text, METH_VARARGS },
|
||||
|
@ -1200,6 +1247,7 @@ static PyMethodDef SwigMethods[] = {
|
|||
{ (char *)"SessionContainer_get_digits", _wrap_SessionContainer_get_digits, METH_VARARGS },
|
||||
{ (char *)"SessionContainer_transfer", _wrap_SessionContainer_transfer, METH_VARARGS },
|
||||
{ (char *)"SessionContainer_play_and_get_digits", _wrap_SessionContainer_play_and_get_digits, METH_VARARGS },
|
||||
{ (char *)"SessionContainer_execute", _wrap_SessionContainer_execute, METH_VARARGS },
|
||||
{ (char *)"SessionContainer_swigregister", SessionContainer_swigregister, METH_VARARGS },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue