spring cleaning

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4795 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale
2007-03-29 22:31:56 +00:00
parent a021945cef
commit 3a54126261
143 changed files with 22413 additions and 31567 deletions
@@ -1,4 +1,4 @@
#ifndef FREESWITCH_PYTHON_H
#ifndef FREESWITCH_PYTHON_H
#define FREESWITCH_PYTHON_H
#include <Python.h>
@@ -9,45 +9,41 @@ extern "C" {
#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);
extern void *globalDTMFCallbackFunction;
extern switch_status_t PythonDTMFCallback(switch_core_session * session,
void *input, switch_input_type_t itype, void *buf, unsigned int buflen);
class SessionContainer {
private:
switch_core_session_t *session;
switch_channel_t *channel;
char *uuid;
PyObject *dtmfCallbackFunction;
char *tts_name;
char *voice_name;
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);
void set_tts_parms(char *tts_name, char *voice_name);
int get_digits(char *dtmf_buf, int len, char *terminators, char *terminator, int timeout);
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);
protected:
};
class SessionContainer {
private:
switch_core_session_t *session;
switch_channel_t *channel;
char *uuid;
PyObject *dtmfCallbackFunction;
char *tts_name;
char *voice_name;
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);
void set_tts_parms(char *tts_name, char *voice_name);
int get_digits(char *dtmf_buf, int len, char *terminators, char *terminator, int timeout);
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);
protected:
};
#ifdef __cplusplus
}
#endif
#endif
+31 -29
View File
@@ -50,54 +50,55 @@ const char modname[] = "mod_python";
static void python_function(switch_core_session_t *session, char *data)
{
char *uuid = switch_core_session_get_uuid(session);
char *argv[1];
FILE* pythonfile;
char *argv[1];
FILE *pythonfile;
argv[0] = uuid;
pythonfile = fopen(data, "r");
argv[0] = uuid;
pythonfile = fopen(data, "r");
Py_Initialize();
PySys_SetArgv(1, argv);
init_freeswitch();
PyRun_SimpleFile(pythonfile, "");
Py_Finalize();
Py_Initialize();
PySys_SetArgv(1, argv);
init_freeswitch();
PyRun_SimpleFile(pythonfile, "");
Py_Finalize();
}
static switch_status_t launch_python(char *text, switch_core_session_t *session, switch_stream_handle_t *stream)
{
FILE* pythonfile;
FILE *pythonfile;
if (switch_strlen_zero(text)) {
stream->write_function(stream, "USAGE: %s\n", python_run_interface.syntax);
return SWITCH_STATUS_SUCCESS;
}
if (switch_strlen_zero(text)) {
stream->write_function(stream, "USAGE: %s\n", python_run_interface.syntax);
return SWITCH_STATUS_SUCCESS;
}
pythonfile = fopen(text, "r");
pythonfile = fopen(text, "r");
Py_Initialize();
init_freeswitch();
PyRun_SimpleFile(pythonfile, "");
Py_Finalize();
Py_Initialize();
init_freeswitch();
PyRun_SimpleFile(pythonfile, "");
Py_Finalize();
stream->write_function(stream, "OK\n");
return SWITCH_STATUS_SUCCESS;
stream->write_function(stream, "OK\n");
return SWITCH_STATUS_SUCCESS;
}
static const switch_application_interface_t python_application_interface = {
/*.interface_name */ "python",
/*.application_function */ python_function,
NULL, NULL, NULL,
/* flags */ SAF_NONE, /* should we support no media mode here? If so, we need to detect the mode, and either disable the media functions or indicate media if/when we need */
/*.next*/ NULL
/* flags */ SAF_NONE,
/* should we support no media mode here? If so, we need to detect the mode, and either disable the media functions or indicate media if/when we need */
/*.next */ NULL
};
static switch_api_interface_t python_run_interface = {
/*.interface_name */ "python",
/*.desc */ "run a python script",
/*.function */ launch_python,
/*.syntax */ "python </path/to/script>",
/*.next */ NULL
/*.interface_name */ "python",
/*.desc */ "run a python script",
/*.function */ launch_python,
/*.syntax */ "python </path/to/script>",
/*.next */ NULL
};
static switch_loadable_module_interface_t python_module_interface = {
@@ -113,7 +114,8 @@ static switch_loadable_module_interface_t python_module_interface = {
/*.directory_interface */ NULL
};
SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_module_interface_t **module_interface, char *filename)
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;
File diff suppressed because it is too large Load Diff