diff --git a/libs/esl/lua/esl_wrap.cpp b/libs/esl/lua/esl_wrap.cpp index 1a22d5d18d..0cd8fca5fa 100644 --- a/libs/esl/lua/esl_wrap.cpp +++ b/libs/esl/lua/esl_wrap.cpp @@ -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; diff --git a/libs/esl/perl/esl_wrap.cpp b/libs/esl/perl/esl_wrap.cpp index 5dbf3cd7a1..ebe1f97cd2 100644 --- a/libs/esl/perl/esl_wrap.cpp +++ b/libs/esl/perl/esl_wrap.cpp @@ -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; diff --git a/libs/esl/perl/server2.pl b/libs/esl/perl/server2.pl index 7ac7a8b6d4..e1565bb5d6 100644 --- a/libs/esl/perl/server2.pl +++ b/libs/esl/perl/server2.pl @@ -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"); diff --git a/libs/esl/php/ESL.php b/libs/esl/php/ESL.php index 1eb2044666..0a16ee2a6b 100644 --- a/libs/esl/php/ESL.php +++ b/libs/esl/php/ESL.php @@ -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) { diff --git a/libs/esl/php/esl_wrap.cpp b/libs/esl/php/esl_wrap.cpp index 434bf7487d..6c47ae84dd 100644 --- a/libs/esl/php/esl_wrap.cpp +++ b/libs/esl/php/esl_wrap.cpp @@ -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: diff --git a/libs/esl/python/esl_wrap.cpp b/libs/esl/python/esl_wrap.cpp index 6bb5e51ac2..1aea25d20f 100644 --- a/libs/esl/python/esl_wrap.cpp +++ b/libs/esl/python/esl_wrap.cpp @@ -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; diff --git a/libs/esl/ruby/esl_wrap.cpp b/libs/esl/ruby/esl_wrap.cpp index 92dee380e8..2fbde81323 100644 --- a/libs/esl/ruby/esl_wrap.cpp +++ b/libs/esl/ruby/esl_wrap.cpp @@ -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; diff --git a/libs/esl/src/esl_oop.cpp b/libs/esl/src/esl_oop.cpp index f5020f2ac8..1fa01b2058 100644 --- a/libs/esl/src/esl_oop.cpp +++ b/libs/esl/src/esl_oop.cpp @@ -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) diff --git a/libs/esl/src/include/esl_oop.h b/libs/esl/src/include/esl_oop.h index e7d1d29fa3..f1b167f8c8 100644 --- a/libs/esl/src/include/esl_oop.h +++ b/libs/esl/src/include/esl_oop.h @@ -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);