]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
change api to return event on filter command
authorAnthony Minessale <anthony.minessale@gmail.com>
Fri, 6 Mar 2009 19:24:10 +0000 (19:24 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Fri, 6 Mar 2009 19:24:10 +0000 (19:24 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@12488 d0543943-73ff-0310-b7d9-9358b9ac24b2

libs/esl/lua/esl_wrap.cpp
libs/esl/perl/esl_wrap.cpp
libs/esl/perl/server2.pl
libs/esl/php/ESL.php
libs/esl/php/esl_wrap.cpp
libs/esl/python/esl_wrap.cpp
libs/esl/ruby/esl_wrap.cpp
libs/esl/src/esl_oop.cpp
libs/esl/src/include/esl_oop.h

index 1a22d5d18d5c9918f0c1f754d576a70e5d583807..0cd8fca5fa706e9d5e14605e8a594b28385b56b6 100644 (file)
@@ -2537,7 +2537,7 @@ static int _wrap_ESLconnection_filter(lua_State* L) {
   ESLconnection *arg1 = (ESLconnection *) 0 ;
   char *arg2 = (char *) 0 ;
   char *arg3 = (char *) 0 ;
-  int result;
+  ESLevent *result = 0 ;
   
   SWIG_check_num_args("filter",3,3)
   if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("filter",1,"ESLconnection *");
@@ -2550,9 +2550,9 @@ static int _wrap_ESLconnection_filter(lua_State* L) {
   
   arg2 = (char *)lua_tostring(L, 2);
   arg3 = (char *)lua_tostring(L, 3);
-  result = (int)(arg1)->filter((char const *)arg2,(char const *)arg3);
+  result = (ESLevent *)(arg1)->filter((char const *)arg2,(char const *)arg3);
   SWIG_arg=0;
-  lua_pushnumber(L, (lua_Number) result); SWIG_arg++;
+  SWIG_NewPointerObj(L,result,SWIGTYPE_p_ESLevent,0); SWIG_arg++; 
   return SWIG_arg;
   
   if(0) SWIG_fail;
index 5dbf3cd7a121ff51c56e4f0da20023e6949caf9a..ebe1f97cd288d2db115301aecfbce7b49e031318 100644 (file)
@@ -3092,7 +3092,7 @@ XS(_wrap_ESLconnection_filter) {
     ESLconnection *arg1 = (ESLconnection *) 0 ;
     char *arg2 = (char *) 0 ;
     char *arg3 = (char *) 0 ;
-    int result;
+    ESLevent *result = 0 ;
     void *argp1 = 0 ;
     int res1 = 0 ;
     int res2 ;
@@ -3122,8 +3122,8 @@ XS(_wrap_ESLconnection_filter) {
       SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ESLconnection_filter" "', argument " "3"" of type '" "char const *""'");
     }
     arg3 = reinterpret_cast< char * >(buf3);
-    result = (int)(arg1)->filter((char const *)arg2,(char const *)arg3);
-    ST(argvi) = SWIG_From_int  SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ;
+    result = (ESLevent *)(arg1)->filter((char const *)arg2,(char const *)arg3);
+    ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLevent, 0 | SWIG_SHADOW); argvi++ ;
     
     if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
     if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
index 7ac7a8b6d46898491363b91adebfcd5af85366e0..e1565bb5d62c5b14a928a64fe54952d45d82378e 100644 (file)
@@ -26,7 +26,17 @@ for(;;) {
 
   printf "Connected call %s, from %s\n", $uuid, $info->getHeader("caller-caller-id-number");
 
-  $con->sendRecv("myevents");
+  $e = $con->filter("unique-id", $uuid);
+  if ($e) {
+    print $e->serialize();
+  } else {
+    printf("WTF?\n");
+  }
+    
+  $con->events("plain", "all");
+
+
+  #$con->sendRecv("myevents");
   $con->execute("answer");
   $con->execute("playback", "/ram/swimp.raw");
   
index 1eb2044666531d00b6cbaefc34d8d71c8457b3f9..0a16ee2a6bc438f17c92b1e5ad1463b85d2ac913 100644 (file)
@@ -170,7 +170,8 @@ class ESLconnection {
        }
 
        function filter($header,$value) {
-               return ESLconnection_filter($this->_cPtr,$header,$value);
+               $r=ESLconnection_filter($this->_cPtr,$header,$value);
+               return is_resource($r) ? new ESLevent($r) : $r;
        }
 
        function events($etype,$value) {
index 434bf7487d8e6ce1b4e4e58cb26440f650da6f57..6c47ae84dd516f76ced84d56a99c1dbaa87824e9 100644 (file)
@@ -2120,7 +2120,7 @@ ZEND_NAMED_FUNCTION(_wrap_ESLconnection_filter) {
   ESLconnection *arg1 = (ESLconnection *) 0 ;
   char *arg2 = (char *) 0 ;
   char *arg3 = (char *) 0 ;
-  int result;
+  ESLevent *result = 0 ;
   zval **args[3];
   
   SWIG_ResetError();
@@ -2146,9 +2146,9 @@ ZEND_NAMED_FUNCTION(_wrap_ESLconnection_filter) {
   arg3 = (char *) Z_STRVAL_PP(args[2]);
   /*@SWIG@*/;
   
-  result = (int)(arg1)->filter((char const *)arg2,(char const *)arg3);
+  result = (ESLevent *)(arg1)->filter((char const *)arg2,(char const *)arg3);
   {
-    ZVAL_LONG(return_value,result);
+    SWIG_SetPointerZval(return_value, (void *)result, SWIGTYPE_p_ESLevent, 0);
   }
   return;
 fail:
index 6bb5e51ac2fddf7ff41350332ea92b416db98498..1aea25d20fb38a50d83b9485f63bd90ca323afe4 100644 (file)
@@ -3956,7 +3956,7 @@ SWIGINTERN PyObject *_wrap_ESLconnection_filter(PyObject *SWIGUNUSEDPARM(self),
   ESLconnection *arg1 = (ESLconnection *) 0 ;
   char *arg2 = (char *) 0 ;
   char *arg3 = (char *) 0 ;
-  int result;
+  ESLevent *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   int res2 ;
@@ -3985,8 +3985,8 @@ SWIGINTERN PyObject *_wrap_ESLconnection_filter(PyObject *SWIGUNUSEDPARM(self),
     SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ESLconnection_filter" "', argument " "3"" of type '" "char const *""'");
   }
   arg3 = reinterpret_cast< char * >(buf3);
-  result = (int)(arg1)->filter((char const *)arg2,(char const *)arg3);
-  resultobj = SWIG_From_int(static_cast< int >(result));
+  result = (ESLevent *)(arg1)->filter((char const *)arg2,(char const *)arg3);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLevent, 0 |  0 );
   if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
   if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
   return resultobj;
index 92dee380e8deaee21f290753d1979fc22cde5080..2fbde81323defd579e46f680a7966cbc81b7c665 100644 (file)
@@ -3087,7 +3087,7 @@ _wrap_ESLconnection_filter(int argc, VALUE *argv, VALUE self) {
   ESLconnection *arg1 = (ESLconnection *) 0 ;
   char *arg2 = (char *) 0 ;
   char *arg3 = (char *) 0 ;
-  int result;
+  ESLevent *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   int res2 ;
@@ -3116,8 +3116,8 @@ _wrap_ESLconnection_filter(int argc, VALUE *argv, VALUE self) {
     SWIG_exception_fail(SWIG_ArgError(res3), Ruby_Format_TypeError( "", "char const *","filter", 3, argv[1] ));
   }
   arg3 = reinterpret_cast< char * >(buf3);
-  result = (int)(arg1)->filter((char const *)arg2,(char const *)arg3);
-  vresult = SWIG_From_int(static_cast< int >(result));
+  result = (ESLevent *)(arg1)->filter((char const *)arg2,(char const *)arg3);
+  vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ESLevent, 0 |  0 );
   if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
   if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
   return vresult;
index f5020f2ac8e00ba26b33a8d91d8fa8e6f7e4a3a7..1fa01b205896f2cfbc042550037807f50e14e29f 100644 (file)
@@ -189,9 +189,18 @@ ESLevent *ESLconnection::recvEventTimed(int ms)
        return NULL;
 }
 
-int ESLconnection::filter(const char *header, const char *value)
+ESLevent *ESLconnection::filter(const char *header, const char *value)
 {
-       return esl_filter(&handle, header, value);
+       esl_status_t status = esl_filter(&handle, header, value);
+
+       if (status == ESL_SUCCESS && handle.last_sr_event) {
+               esl_event_t *event;
+               esl_event_dup(&event, handle.last_sr_event);
+               return new ESLevent(event, 1);
+       }
+
+       return NULL;
+
 }
 
 int ESLconnection::events(const char *etype, const char *value)
index e7d1d29fa3e07667860f786a37c4506ff7ddc3b6..f1b167f8c85e60553af068be31b36aaee57710bd 100644 (file)
@@ -86,7 +86,7 @@ class ESLconnection {
        int sendEvent(ESLevent *send_me);
        ESLevent *recvEvent();
        ESLevent *recvEventTimed(int ms);
-       int filter(const char *header, const char *value);
+       ESLevent *filter(const char *header, const char *value);
        int events(const char *etype, const char *value);
        int execute(const char *app, const char *arg = NULL, const char *uuid = NULL);
        int setBlockingExecute(const char *val);