[Freeswitch-branches] [commit] r3660 - in freeswitch/branches/jkr888/trunk: scripts src/mod/languages/mod_python
Freeswitch SVN
jkr888 at freeswitch.org
Thu Dec 14 17:37:56 EST 2006
Author: jkr888
Date: Thu Dec 14 17:37:54 2006
New Revision: 3660
Modified:
freeswitch/branches/jkr888/trunk/scripts/mytest.py
freeswitch/branches/jkr888/trunk/src/mod/languages/mod_python/Makefile
freeswitch/branches/jkr888/trunk/src/mod/languages/mod_python/freeswitch_python.cpp
freeswitch/branches/jkr888/trunk/src/mod/languages/mod_python/freeswitch_python.h
freeswitch/branches/jkr888/trunk/src/mod/languages/mod_python/mod_python.i
freeswitch/branches/jkr888/trunk/src/mod/languages/mod_python/mod_python_wrap.cpp
Log:
Modified: freeswitch/branches/jkr888/trunk/scripts/mytest.py
==============================================================================
--- freeswitch/branches/jkr888/trunk/scripts/mytest.py (original)
+++ freeswitch/branches/jkr888/trunk/scripts/mytest.py Thu Dec 14 17:37:54 2006
@@ -13,22 +13,22 @@
newSession = SessionContainer(sys.argv[0])
-newSession.console_log("1","test from my python program\n")
-newSession.console_clean_log("This is fs_consol_clean\n")
+#newSession.console_log("1","test from my python program\n")
+#newSession.console_clean_log("This is fs_consol_clean\n")
newSession.answer()
-newSession.set_dtmf_callback(onDTMF)
-newSession.set_tts_parms("cepstral", "david")
+#newSession.set_dtmf_callback(onDTMF)
+#newSession.set_tts_parms("cepstral", "david")
-newSession.play_file("/root/test.gsm", "")
-newSession.speak_text("Please enter telephone number with area code and press pound sign. ")
+#newSession.play_file("/root/test.gsm", "")
+#newSession.speak_text("Please enter telephone number with area code and press pound sign. ")
-input = newSession.get_digits("", 11, "*#", 10000)
+#input = newSession.get_digits("", 11, "*#", 10000)
-newSession.console_log("1","result from get digits is "+ input +"\n")
+#newSession.console_log("1","result from get digits is "+ input +"\n")
-phone_number = newSession.play_and_get_digits(5, 10, 3, 10000, "*#", "/var/lib/asterisk/sounds/callfwd-intro-us-only.gsm",
- "/var/lib/asterisk/sounds/callfwd-invalid-entry.gsm", "", "");
+phone_number = newSession.play_and_get_digits(5, 11, 3, 10000, "*#", "/var/lib/asterisk/sounds/callfwd-intro-us-only.gsm",
+ "/var/lib/asterisk/sounds/callfwd-invalid-entry.gsm", "", "^17322969239$");
newSession.console_log("1","result from play_and_get_digits is "+ phone_number +"\n")
newSession.transfer("1000", "XML", "default")
Modified: freeswitch/branches/jkr888/trunk/src/mod/languages/mod_python/Makefile
==============================================================================
--- freeswitch/branches/jkr888/trunk/src/mod/languages/mod_python/Makefile (original)
+++ freeswitch/branches/jkr888/trunk/src/mod/languages/mod_python/Makefile Thu Dec 14 17:37:54 2006
@@ -50,4 +50,5 @@
install:
# cp -f py_$(PYMOD).$(DYNAMIC_LIB_EXTEN) $(PREFIX)/mod
cp -f $(MODNAME).$(DYNAMIC_LIB_EXTEN) $(PREFIX)/mod
+ cp -f freeswitch.py $(PREFIX)/lib/python2.4/site-packages/
Modified: freeswitch/branches/jkr888/trunk/src/mod/languages/mod_python/freeswitch_python.cpp
==============================================================================
--- freeswitch/branches/jkr888/trunk/src/mod/languages/mod_python/freeswitch_python.cpp (original)
+++ freeswitch/branches/jkr888/trunk/src/mod/languages/mod_python/freeswitch_python.cpp Thu Dec 14 17:37:54 2006
@@ -33,14 +33,20 @@
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN,SWITCH_LOG_DEBUG, msg);
}
-void SessionContainer::answer()
+int SessionContainer::answer()
{
- switch_channel_answer(channel);
+ switch_status_t status;
+
+ status = switch_channel_answer(channel);
+ return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
}
-void SessionContainer::pre_answer()
+int SessionContainer::pre_answer()
{
+ switch_status_t status;
+
switch_channel_pre_answer(channel);
+ return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
}
void SessionContainer::hangup(char *cause)
@@ -70,6 +76,7 @@
int SessionContainer::play_file(char *file, char *timer_name)
{
switch_status_t status;
+
if (switch_strlen_zero(timer_name)) {
timer_name = NULL;
}
@@ -83,7 +90,6 @@
}
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
-
}
void SessionContainer::set_dtmf_callback(PyObject *pyfunc)
@@ -118,23 +124,30 @@
voice_name = voice_name_p;
}
-void SessionContainer::get_digits(char *dtmf_buf, int len, char *terminators, int timeout)
+int SessionContainer::get_digits(char *dtmf_buf, int len, char *terminators, char *terminator, int timeout)
{
- char terminator;
+ switch_status_t status;
- switch_ivr_collect_digits_count(session, dtmf_buf,(uint32_t) len,(uint32_t) len, terminators, &terminator, (uint32_t) timeout);
-
+ 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;
}
-void SessionContainer::transfer(char *extension, char *dialplan, char *context)
+int SessionContainer::transfer(char *extension, char *dialplan, char *context)
{
- switch_ivr_session_transfer(session, extension, dialplan, context);
+ switch_status_t status;
+
+ status = switch_ivr_session_transfer(session, extension, dialplan, context);
+ return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
}
-void SessionContainer::play_and_get_digits(int min_digits, int max_digits, int max_tries, int timeout, char *terminators,
+int SessionContainer::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)
{
- switch_play_and_get_digits( session, (uint32_t) min_digits,(uint32_t) max_digits,(uint32_t) max_tries, (uint32_t) timeout,
+ switch_status_t status;
+
+ 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);
+ return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
}
Modified: freeswitch/branches/jkr888/trunk/src/mod/languages/mod_python/freeswitch_python.h
==============================================================================
--- freeswitch/branches/jkr888/trunk/src/mod/languages/mod_python/freeswitch_python.h (original)
+++ freeswitch/branches/jkr888/trunk/src/mod/languages/mod_python/freeswitch_python.h Thu Dec 14 17:37:54 2006
@@ -29,8 +29,8 @@
~SessionContainer();
void console_log(char *level_str, char *msg);
void console_clean_log(char *msg);
- void answer();
- void pre_answer();
+ int answer();
+ int pre_answer();
void hangup(char *cause);
void set_variable(char *var, char *val);
void get_variable(char *var, char *val);
@@ -39,9 +39,9 @@
void set_dtmf_callback(PyObject *pyfunc);
int speak_text(char *text);
void set_tts_parms(char *tts_name, char *voice_name);
- void get_digits(char *dtmf_buf, int len, char *terminators, int timeout);
- void transfer(char *extensions, char *dialplan, char *context);
- void play_and_get_digits(int min_digits, int max_digits, int max_tries, int timeout, char *terminators,
+ 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:
};
Modified: freeswitch/branches/jkr888/trunk/src/mod/languages/mod_python/mod_python.i
==============================================================================
--- freeswitch/branches/jkr888/trunk/src/mod/languages/mod_python/mod_python.i (original)
+++ freeswitch/branches/jkr888/trunk/src/mod/languages/mod_python/mod_python.i Thu Dec 14 17:37:54 2006
@@ -2,6 +2,7 @@
%include "cstring.i"
%cstring_bounded_mutable(char *dtmf_buf, 128);
+%cstring_bounded_mutable(char *terminator, 8);
%{
#include "freeswitch_python.h"
Modified: freeswitch/branches/jkr888/trunk/src/mod/languages/mod_python/mod_python_wrap.cpp
==============================================================================
--- freeswitch/branches/jkr888/trunk/src/mod/languages/mod_python/mod_python_wrap.cpp (original)
+++ freeswitch/branches/jkr888/trunk/src/mod/languages/mod_python/mod_python_wrap.cpp Thu Dec 14 17:37:54 2006
@@ -1933,14 +1933,17 @@
static PyObject *_wrap_SessionContainer_answer(PyObject *, PyObject *args) {
PyObject *resultobj = NULL;
SessionContainer *arg1 = (SessionContainer *) 0 ;
+ int result;
PyObject * obj0 = 0 ;
if(!PyArg_ParseTuple(args,(char *)"O:SessionContainer_answer",&obj0)) goto fail;
SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_SessionContainer, SWIG_POINTER_EXCEPTION | 0);
if (SWIG_arg_fail(1)) SWIG_fail;
- (arg1)->answer();
+ result = (int)(arg1)->answer();
- Py_INCREF(Py_None); resultobj = Py_None;
+ {
+ resultobj = SWIG_From_int(static_cast<int >(result));
+ }
return resultobj;
fail:
return NULL;
@@ -1950,14 +1953,17 @@
static PyObject *_wrap_SessionContainer_pre_answer(PyObject *, PyObject *args) {
PyObject *resultobj = NULL;
SessionContainer *arg1 = (SessionContainer *) 0 ;
+ int result;
PyObject * obj0 = 0 ;
if(!PyArg_ParseTuple(args,(char *)"O:SessionContainer_pre_answer",&obj0)) goto fail;
SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_SessionContainer, SWIG_POINTER_EXCEPTION | 0);
if (SWIG_arg_fail(1)) SWIG_fail;
- (arg1)->pre_answer();
+ result = (int)(arg1)->pre_answer();
- Py_INCREF(Py_None); resultobj = Py_None;
+ {
+ resultobj = SWIG_From_int(static_cast<int >(result));
+ }
return resultobj;
fail:
return NULL;
@@ -2170,15 +2176,19 @@
char *arg2 = (char *) 0 ;
int arg3 ;
char *arg4 = (char *) 0 ;
- int arg5 ;
+ char *arg5 = (char *) 0 ;
+ int arg6 ;
+ int result;
char temp2[128+1] ;
+ char temp5[8+1] ;
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
PyObject * obj2 = 0 ;
PyObject * obj3 = 0 ;
PyObject * obj4 = 0 ;
+ PyObject * obj5 = 0 ;
- if(!PyArg_ParseTuple(args,(char *)"OOOOO:SessionContainer_get_digits",&obj0,&obj1,&obj2,&obj3,&obj4)) goto fail;
+ if(!PyArg_ParseTuple(args,(char *)"OOOOOO:SessionContainer_get_digits",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) goto fail;
SWIG_Python_ConvertPtr(obj0, (void **)&arg1, SWIGTYPE_p_SessionContainer, SWIG_POINTER_EXCEPTION | 0);
if (SWIG_arg_fail(1)) SWIG_fail;
{
@@ -2198,13 +2208,25 @@
SWIG_arg_fail(4);SWIG_fail;
}
{
- arg5 = static_cast<int >(SWIG_As_int(obj4));
- if (SWIG_arg_fail(5)) SWIG_fail;
+ char *t = 0; size_t n;
+ SWIG_AsCharPtrAndSize(obj4, &t, &n);
+ if (SWIG_arg_fail(5)) SWIG_fail;
+ if ( n > (size_t)8 ) n = (size_t)8;
+ memcpy(temp5, t, sizeof(char)*n);
+ temp5[n] = 0;
+ arg5 = (char *) temp5;
}
- (arg1)->get_digits(arg2,arg3,arg4,arg5);
+ {
+ arg6 = static_cast<int >(SWIG_As_int(obj5));
+ if (SWIG_arg_fail(6)) SWIG_fail;
+ }
+ result = (int)(arg1)->get_digits(arg2,arg3,arg4,arg5,arg6);
- Py_INCREF(Py_None); resultobj = Py_None;
+ {
+ resultobj = SWIG_From_int(static_cast<int >(result));
+ }
arg2[128] = 0; resultobj = t_output_helper(resultobj, SWIG_FromCharPtr(arg2));
+ arg5[8] = 0; resultobj = t_output_helper(resultobj, SWIG_FromCharPtr(arg5));
return resultobj;
fail:
return NULL;
@@ -2217,6 +2239,7 @@
char *arg2 = (char *) 0 ;
char *arg3 = (char *) 0 ;
char *arg4 = (char *) 0 ;
+ int result;
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
PyObject * obj2 = 0 ;
@@ -2234,9 +2257,11 @@
if (!SWIG_AsCharPtr(obj3, (char**)&arg4)) {
SWIG_arg_fail(4);SWIG_fail;
}
- (arg1)->transfer(arg2,arg3,arg4);
+ result = (int)(arg1)->transfer(arg2,arg3,arg4);
- Py_INCREF(Py_None); resultobj = Py_None;
+ {
+ resultobj = SWIG_From_int(static_cast<int >(result));
+ }
return resultobj;
fail:
return NULL;
@@ -2255,6 +2280,7 @@
char *arg8 = (char *) 0 ;
char *arg9 = (char *) 0 ;
char *arg10 = (char *) 0 ;
+ int result;
char temp9[128+1] ;
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
@@ -2307,9 +2333,11 @@
if (!SWIG_AsCharPtr(obj9, (char**)&arg10)) {
SWIG_arg_fail(10);SWIG_fail;
}
- (arg1)->play_and_get_digits(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10);
+ result = (int)(arg1)->play_and_get_digits(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10);
- Py_INCREF(Py_None); resultobj = Py_None;
+ {
+ resultobj = SWIG_From_int(static_cast<int >(result));
+ }
arg9[128] = 0; resultobj = t_output_helper(resultobj, SWIG_FromCharPtr(arg9));
return resultobj;
fail:
More information about the Freeswitch-branches
mailing list