]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add read
authorAnthony Minessale <anthony.minessale@gmail.com>
Fri, 2 May 2008 19:04:13 +0000 (19:04 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Fri, 2 May 2008 19:04:13 +0000 (19:04 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8254 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/switch_cpp.h
src/mod/languages/mod_java/src/org/freeswitch/swig/CoreSession.java
src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitchJNI.java
src/mod/languages/mod_java/switch_swig_wrap.cpp
src/mod/languages/mod_lua/mod_lua_wrap.cpp
src/mod/languages/mod_perl/freeswitch.pm
src/mod/languages/mod_perl/mod_perl_wrap.cpp
src/mod/languages/mod_python/freeswitch.py
src/mod/languages/mod_python/mod_python_wrap.cpp
src/switch_cpp.cpp

index fb16a409d1b10fd12a0a37245fdd1791af8449ad..fd513fa961e00b2a1c8961e74780b05b5c970167 100644 (file)
@@ -254,6 +254,13 @@ class CoreSession {
        
        SWITCH_DECLARE(int) transfer(char *extensions, char *dialplan, char *context);
 
+
+       SWITCH_DECLARE(char *) read(int min_digits,
+                                                               int max_digits,
+                                                               const char *prompt_audio_file,
+                                                               int timeout,
+                                                               const char *valid_terminators);
+       
        /** \brief Play a file into channel and collect dtmfs
         * 
      * See API docs in switch_ivr.h: switch_play_and_get_digits(..)
index bea5ff17292791875e8caa79fa438994b84c4322..0e97042037cf1c8e840bf2f2c454197c0042d015 100644 (file)
@@ -169,6 +169,10 @@ public class CoreSession {
     return freeswitchJNI.CoreSession_transfer(swigCPtr, this, extensions, dialplan, context);
   }
 
+  public String read(int min_digits, int max_digits, String prompt_audio_file, int timeout, String valid_terminators) {
+    return freeswitchJNI.CoreSession_read(swigCPtr, this, min_digits, max_digits, prompt_audio_file, timeout, valid_terminators);
+  }
+
   public String playAndGetDigits(int min_digits, int max_digits, int max_tries, int timeout, String terminators, String audio_files, String bad_input_audio_files, String digits_regex) {
     return freeswitchJNI.CoreSession_playAndGetDigits(swigCPtr, this, min_digits, max_digits, max_tries, timeout, terminators, audio_files, bad_input_audio_files, digits_regex);
   }
index 45e423706fe0f4beeded71ce2c6b5014aaf3aef1..c83c971f0b88b3461c37c31b74f5deadb9507e8d 100644 (file)
@@ -93,6 +93,7 @@ class freeswitchJNI {
   public final static native int CoreSession_collectDigits(long jarg1, CoreSession jarg1_, int jarg2);
   public final static native String CoreSession_getDigits(long jarg1, CoreSession jarg1_, int jarg2, String jarg3, int jarg4);
   public final static native int CoreSession_transfer(long jarg1, CoreSession jarg1_, String jarg2, String jarg3, String jarg4);
+  public final static native String CoreSession_read(long jarg1, CoreSession jarg1_, int jarg2, int jarg3, String jarg4, int jarg5, String jarg6);
   public final static native String CoreSession_playAndGetDigits(long jarg1, CoreSession jarg1_, int jarg2, int jarg3, int jarg4, int jarg5, String jarg6, String jarg7, String jarg8, String jarg9);
   public final static native int CoreSession_streamFile__SWIG_0(long jarg1, CoreSession jarg1_, String jarg2, int jarg3);
   public final static native int CoreSession_streamFile__SWIG_1(long jarg1, CoreSession jarg1_, String jarg2);
index 5b00c3c79c84ec0f77b5d0c1353fe1e74864e51d..977bddfc8be7ff37525c8b3dbb896b592af80ecd 100644 (file)
@@ -1776,6 +1776,41 @@ SWIGEXPORT jint JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1tran
 }
 
 
+SWIGEXPORT jstring JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1read(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2, jint jarg3, jstring jarg4, jint jarg5, jstring jarg6) {
+  jstring jresult = 0 ;
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  int arg2 ;
+  int arg3 ;
+  char *arg4 = (char *) 0 ;
+  int arg5 ;
+  char *arg6 = (char *) 0 ;
+  char *result = 0 ;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(CoreSession **)&jarg1; 
+  arg2 = (int)jarg2; 
+  arg3 = (int)jarg3; 
+  arg4 = 0;
+  if (jarg4) {
+    arg4 = (char *)jenv->GetStringUTFChars(jarg4, 0);
+    if (!arg4) return 0;
+  }
+  arg5 = (int)jarg5; 
+  arg6 = 0;
+  if (jarg6) {
+    arg6 = (char *)jenv->GetStringUTFChars(jarg6, 0);
+    if (!arg6) return 0;
+  }
+  result = (char *)(arg1)->read(arg2,arg3,(char const *)arg4,arg5,(char const *)arg6);
+  if(result) jresult = jenv->NewStringUTF((const char *)result);
+  if (arg4) jenv->ReleaseStringUTFChars(jarg4, (const char *)arg4);
+  if (arg6) jenv->ReleaseStringUTFChars(jarg6, (const char *)arg6);
+  return jresult;
+}
+
+
 SWIGEXPORT jstring JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1playAndGetDigits(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2, jint jarg3, jint jarg4, jint jarg5, jstring jarg6, jstring jarg7, jstring jarg8, jstring jarg9) {
   jstring jresult = 0 ;
   CoreSession *arg1 = (CoreSession *) 0 ;
index cb7c7de8ae943cc79ad041a50965f1be2aa13415..f13e1e61e1530c27b96a4d3beaec9da4ecdfc5b4 100644 (file)
@@ -4331,6 +4331,46 @@ fail:
 }
 
 
+static int _wrap_CoreSession_read(lua_State* L) {
+  int SWIG_arg = -1;
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  int arg2 ;
+  int arg3 ;
+  char *arg4 = (char *) 0 ;
+  int arg5 ;
+  char *arg6 = (char *) 0 ;
+  char *result = 0 ;
+  
+  SWIG_check_num_args("read",6,6)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("read",1,"CoreSession *");
+  if(!lua_isnumber(L,2)) SWIG_fail_arg("read",2,"int");
+  if(!lua_isnumber(L,3)) SWIG_fail_arg("read",3,"int");
+  if(!lua_isstring(L,4)) SWIG_fail_arg("read",4,"char const *");
+  if(!lua_isnumber(L,5)) SWIG_fail_arg("read",5,"int");
+  if(!lua_isstring(L,6)) SWIG_fail_arg("read",6,"char const *");
+  
+  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
+    SWIG_fail_ptr("CoreSession_read",1,SWIGTYPE_p_CoreSession);
+  }
+  
+  arg2 = (int)lua_tonumber(L, 2);
+  arg3 = (int)lua_tonumber(L, 3);
+  arg4 = (char *)lua_tostring(L, 4);
+  arg5 = (int)lua_tonumber(L, 5);
+  arg6 = (char *)lua_tostring(L, 6);
+  result = (char *)(arg1)->read(arg2,arg3,(char const *)arg4,arg5,(char const *)arg6);
+  SWIG_arg=0;
+  lua_pushstring(L,(const char*)result); SWIG_arg++;
+  return SWIG_arg;
+  
+  if(0) SWIG_fail;
+  
+fail:
+  lua_error(L);
+  return SWIG_arg;
+}
+
+
 static int _wrap_CoreSession_playAndGetDigits(lua_State* L) {
   int SWIG_arg = -1;
   CoreSession *arg1 = (CoreSession *) 0 ;
@@ -4874,6 +4914,7 @@ static swig_lua_method swig_CoreSession_methods[] = {
     {"collectDigits", _wrap_CoreSession_collectDigits}, 
     {"getDigits", _wrap_CoreSession_getDigits}, 
     {"transfer", _wrap_CoreSession_transfer}, 
+    {"read", _wrap_CoreSession_read}, 
     {"playAndGetDigits", _wrap_CoreSession_playAndGetDigits}, 
     {"streamFile", _wrap_CoreSession_streamFile}, 
     {"flushEvents", _wrap_CoreSession_flushEvents}, 
index af4791517e3755e41ac1489a4050977efb5df3c9..dfe5caff93cf91c98bd326f4dc39e2c8b5359f3b 100644 (file)
@@ -316,6 +316,7 @@ sub DESTROY {
 *collectDigits = *freeswitchc::CoreSession_collectDigits;
 *getDigits = *freeswitchc::CoreSession_getDigits;
 *transfer = *freeswitchc::CoreSession_transfer;
+*read = *freeswitchc::CoreSession_read;
 *playAndGetDigits = *freeswitchc::CoreSession_playAndGetDigits;
 *streamFile = *freeswitchc::CoreSession_streamFile;
 *flushEvents = *freeswitchc::CoreSession_flushEvents;
index 685fcab1fc16046b81841c6f5e3098089d90215d..3aa4e5f4a3ef4589a4409839365ad319466089ab 100644 (file)
@@ -5632,6 +5632,86 @@ XS(_wrap_CoreSession_transfer) {
 }
 
 
+XS(_wrap_CoreSession_read) {
+  {
+    CoreSession *arg1 = (CoreSession *) 0 ;
+    int arg2 ;
+    int arg3 ;
+    char *arg4 = (char *) 0 ;
+    int arg5 ;
+    char *arg6 = (char *) 0 ;
+    char *result = 0 ;
+    void *argp1 = 0 ;
+    int res1 = 0 ;
+    int val2 ;
+    int ecode2 = 0 ;
+    int val3 ;
+    int ecode3 = 0 ;
+    int res4 ;
+    char *buf4 = 0 ;
+    int alloc4 = 0 ;
+    int val5 ;
+    int ecode5 = 0 ;
+    int res6 ;
+    char *buf6 = 0 ;
+    int alloc6 = 0 ;
+    int argvi = 0;
+    dXSARGS;
+    
+    if ((items < 6) || (items > 6)) {
+      SWIG_croak("Usage: CoreSession_read(self,min_digits,max_digits,prompt_audio_file,timeout,valid_terminators);");
+    }
+    res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_CoreSession, 0 |  0 );
+    if (!SWIG_IsOK(res1)) {
+      SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CoreSession_read" "', argument " "1"" of type '" "CoreSession *""'"); 
+    }
+    arg1 = reinterpret_cast< CoreSession * >(argp1);
+    ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2);
+    if (!SWIG_IsOK(ecode2)) {
+      SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "CoreSession_read" "', argument " "2"" of type '" "int""'");
+    } 
+    arg2 = static_cast< int >(val2);
+    ecode3 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(2), &val3);
+    if (!SWIG_IsOK(ecode3)) {
+      SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "CoreSession_read" "', argument " "3"" of type '" "int""'");
+    } 
+    arg3 = static_cast< int >(val3);
+    res4 = SWIG_AsCharPtrAndSize(ST(3), &buf4, NULL, &alloc4);
+    if (!SWIG_IsOK(res4)) {
+      SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "CoreSession_read" "', argument " "4"" of type '" "char const *""'");
+    }
+    arg4 = reinterpret_cast< char * >(buf4);
+    ecode5 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(4), &val5);
+    if (!SWIG_IsOK(ecode5)) {
+      SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "CoreSession_read" "', argument " "5"" of type '" "int""'");
+    } 
+    arg5 = static_cast< int >(val5);
+    res6 = SWIG_AsCharPtrAndSize(ST(5), &buf6, NULL, &alloc6);
+    if (!SWIG_IsOK(res6)) {
+      SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "CoreSession_read" "', argument " "6"" of type '" "char const *""'");
+    }
+    arg6 = reinterpret_cast< char * >(buf6);
+    result = (char *)(arg1)->read(arg2,arg3,(char const *)arg4,arg5,(char const *)arg6);
+    ST(argvi) = SWIG_FromCharPtr((const char *)result); argvi++ ;
+    
+    
+    
+    if (alloc4 == SWIG_NEWOBJ) delete[] buf4;
+    
+    if (alloc6 == SWIG_NEWOBJ) delete[] buf6;
+    XSRETURN(argvi);
+  fail:
+    
+    
+    
+    if (alloc4 == SWIG_NEWOBJ) delete[] buf4;
+    
+    if (alloc6 == SWIG_NEWOBJ) delete[] buf6;
+    SWIG_croak_null();
+  }
+}
+
+
 XS(_wrap_CoreSession_playAndGetDigits) {
   {
     CoreSession *arg1 = (CoreSession *) 0 ;
@@ -7413,6 +7493,7 @@ static swig_command_info swig_commands[] = {
 {"freeswitchc::CoreSession_collectDigits", _wrap_CoreSession_collectDigits},
 {"freeswitchc::CoreSession_getDigits", _wrap_CoreSession_getDigits},
 {"freeswitchc::CoreSession_transfer", _wrap_CoreSession_transfer},
+{"freeswitchc::CoreSession_read", _wrap_CoreSession_read},
 {"freeswitchc::CoreSession_playAndGetDigits", _wrap_CoreSession_playAndGetDigits},
 {"freeswitchc::CoreSession_streamFile", _wrap_CoreSession_streamFile},
 {"freeswitchc::CoreSession_flushEvents", _wrap_CoreSession_flushEvents},
index f0799dca0bb23a0fe652c255ed61b4e7e3caf157..3b6e239edfd34aff7127547c11b4dd2ebd7e3e1a 100644 (file)
@@ -207,6 +207,7 @@ class CoreSession(_object):
     def collectDigits(*args): return _freeswitch.CoreSession_collectDigits(*args)
     def getDigits(*args): return _freeswitch.CoreSession_getDigits(*args)
     def transfer(*args): return _freeswitch.CoreSession_transfer(*args)
+    def read(*args): return _freeswitch.CoreSession_read(*args)
     def playAndGetDigits(*args): return _freeswitch.CoreSession_playAndGetDigits(*args)
     def streamFile(*args): return _freeswitch.CoreSession_streamFile(*args)
     def flushEvents(*args): return _freeswitch.CoreSession_flushEvents(*args)
index e0a63802a7dcad1bf3013bff87eca9a09bc1ba4a..ed335505feced8459c8dce8184d836b460c2d553 100644 (file)
@@ -6017,6 +6017,79 @@ fail:
 }
 
 
+SWIGINTERN PyObject *_wrap_CoreSession_read(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  CoreSession *arg1 = (CoreSession *) 0 ;
+  int arg2 ;
+  int arg3 ;
+  char *arg4 = (char *) 0 ;
+  int arg5 ;
+  char *arg6 = (char *) 0 ;
+  char *result = 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  int val2 ;
+  int ecode2 = 0 ;
+  int val3 ;
+  int ecode3 = 0 ;
+  int res4 ;
+  char *buf4 = 0 ;
+  int alloc4 = 0 ;
+  int val5 ;
+  int ecode5 = 0 ;
+  int res6 ;
+  char *buf6 = 0 ;
+  int alloc6 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  PyObject * obj2 = 0 ;
+  PyObject * obj3 = 0 ;
+  PyObject * obj4 = 0 ;
+  PyObject * obj5 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OOOOOO:CoreSession_read",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) 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_read" "', argument " "1"" of type '" "CoreSession *""'"); 
+  }
+  arg1 = reinterpret_cast< CoreSession * >(argp1);
+  ecode2 = SWIG_AsVal_int(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "CoreSession_read" "', argument " "2"" of type '" "int""'");
+  } 
+  arg2 = static_cast< int >(val2);
+  ecode3 = SWIG_AsVal_int(obj2, &val3);
+  if (!SWIG_IsOK(ecode3)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "CoreSession_read" "', 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_read" "', argument " "4"" of type '" "char const *""'");
+  }
+  arg4 = reinterpret_cast< char * >(buf4);
+  ecode5 = SWIG_AsVal_int(obj4, &val5);
+  if (!SWIG_IsOK(ecode5)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "CoreSession_read" "', argument " "5"" of type '" "int""'");
+  } 
+  arg5 = static_cast< int >(val5);
+  res6 = SWIG_AsCharPtrAndSize(obj5, &buf6, NULL, &alloc6);
+  if (!SWIG_IsOK(res6)) {
+    SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "CoreSession_read" "', argument " "6"" of type '" "char const *""'");
+  }
+  arg6 = reinterpret_cast< char * >(buf6);
+  result = (char *)(arg1)->read(arg2,arg3,(char const *)arg4,arg5,(char const *)arg6);
+  resultobj = SWIG_FromCharPtr((const char *)result);
+  if (alloc4 == SWIG_NEWOBJ) delete[] buf4;
+  if (alloc6 == SWIG_NEWOBJ) delete[] buf6;
+  return resultobj;
+fail:
+  if (alloc4 == SWIG_NEWOBJ) delete[] buf4;
+  if (alloc6 == SWIG_NEWOBJ) delete[] buf6;
+  return NULL;
+}
+
+
 SWIGINTERN PyObject *_wrap_CoreSession_playAndGetDigits(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CoreSession *arg1 = (CoreSession *) 0 ;
@@ -7207,6 +7280,7 @@ static PyMethodDef SwigMethods[] = {
         { (char *)"CoreSession_collectDigits", _wrap_CoreSession_collectDigits, METH_VARARGS, NULL},
         { (char *)"CoreSession_getDigits", _wrap_CoreSession_getDigits, METH_VARARGS, NULL},
         { (char *)"CoreSession_transfer", _wrap_CoreSession_transfer, METH_VARARGS, NULL},
+        { (char *)"CoreSession_read", _wrap_CoreSession_read, 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},
index fc9a49856bb72cc25c355cd5e3786391ac24490f..fa33341c48880a67b2b61a3c6f93dd54baf9836d 100644 (file)
@@ -561,6 +561,29 @@ SWITCH_DECLARE(int) CoreSession::transfer(char *extension, char *dialplan, char
     return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
 }
 
+
+SWITCH_DECLARE(char *) CoreSession::read(int min_digits,
+                                                                                int max_digits,
+                                                                                const char *prompt_audio_file,
+                                                                                int timeout,
+                                                                                const char *valid_terminators)
+{
+       if (min_digits < 1) {
+               min_digits = 1;
+       }
+
+       if (max_digits < 1) {
+               max_digits = 1;
+       }
+
+       if (timeout < 1) {
+               timeout = 1;
+       }
+
+       switch_ivr_read(session, min_digits, max_digits, prompt_audio_file, NULL, dtmf_buf, sizeof(dtmf_buf), timeout, valid_terminators);
+       return dtmf_buf;
+}
+
 SWITCH_DECLARE(char *) CoreSession::playAndGetDigits(int min_digits, 
                                                                                                  int max_digits, 
                                                                                                  int max_tries,