[Freeswitch-trunk] [commit] r12488 - in freeswitch/trunk/libs/esl: lua perl php python ruby src src/include
FreeSWITCH SVN
anthm at freeswitch.org
Fri Mar 6 11:24:10 PST 2009
Author: anthm
Date: Fri Mar 6 13:24:10 2009
New Revision: 12488
Log:
change api to return event on filter command
Modified:
freeswitch/trunk/libs/esl/lua/esl_wrap.cpp
freeswitch/trunk/libs/esl/perl/esl_wrap.cpp
freeswitch/trunk/libs/esl/perl/server2.pl
freeswitch/trunk/libs/esl/php/ESL.php
freeswitch/trunk/libs/esl/php/esl_wrap.cpp
freeswitch/trunk/libs/esl/python/esl_wrap.cpp
freeswitch/trunk/libs/esl/ruby/esl_wrap.cpp
freeswitch/trunk/libs/esl/src/esl_oop.cpp
freeswitch/trunk/libs/esl/src/include/esl_oop.h
Modified: freeswitch/trunk/libs/esl/lua/esl_wrap.cpp
==============================================================================
--- freeswitch/trunk/libs/esl/lua/esl_wrap.cpp (original)
+++ freeswitch/trunk/libs/esl/lua/esl_wrap.cpp Fri Mar 6 13:24:10 2009
@@ -2537,7 +2537,7 @@
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 @@
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;
Modified: freeswitch/trunk/libs/esl/perl/esl_wrap.cpp
==============================================================================
--- freeswitch/trunk/libs/esl/perl/esl_wrap.cpp (original)
+++ freeswitch/trunk/libs/esl/perl/esl_wrap.cpp Fri Mar 6 13:24:10 2009
@@ -3092,7 +3092,7 @@
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 @@
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;
Modified: freeswitch/trunk/libs/esl/perl/server2.pl
==============================================================================
--- freeswitch/trunk/libs/esl/perl/server2.pl (original)
+++ freeswitch/trunk/libs/esl/perl/server2.pl Fri Mar 6 13:24:10 2009
@@ -26,7 +26,17 @@
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");
Modified: freeswitch/trunk/libs/esl/php/ESL.php
==============================================================================
--- freeswitch/trunk/libs/esl/php/ESL.php (original)
+++ freeswitch/trunk/libs/esl/php/ESL.php Fri Mar 6 13:24:10 2009
@@ -170,7 +170,8 @@
}
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) {
Modified: freeswitch/trunk/libs/esl/php/esl_wrap.cpp
==============================================================================
--- freeswitch/trunk/libs/esl/php/esl_wrap.cpp (original)
+++ freeswitch/trunk/libs/esl/php/esl_wrap.cpp Fri Mar 6 13:24:10 2009
@@ -2120,7 +2120,7 @@
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 @@
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:
Modified: freeswitch/trunk/libs/esl/python/esl_wrap.cpp
==============================================================================
--- freeswitch/trunk/libs/esl/python/esl_wrap.cpp (original)
+++ freeswitch/trunk/libs/esl/python/esl_wrap.cpp Fri Mar 6 13:24:10 2009
@@ -3956,7 +3956,7 @@
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 @@
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;
Modified: freeswitch/trunk/libs/esl/ruby/esl_wrap.cpp
==============================================================================
--- freeswitch/trunk/libs/esl/ruby/esl_wrap.cpp (original)
+++ freeswitch/trunk/libs/esl/ruby/esl_wrap.cpp Fri Mar 6 13:24:10 2009
@@ -3087,7 +3087,7 @@
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 @@
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;
Modified: freeswitch/trunk/libs/esl/src/esl_oop.cpp
==============================================================================
--- freeswitch/trunk/libs/esl/src/esl_oop.cpp (original)
+++ freeswitch/trunk/libs/esl/src/esl_oop.cpp Fri Mar 6 13:24:10 2009
@@ -189,9 +189,18 @@
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)
Modified: freeswitch/trunk/libs/esl/src/include/esl_oop.h
==============================================================================
--- freeswitch/trunk/libs/esl/src/include/esl_oop.h (original)
+++ freeswitch/trunk/libs/esl/src/include/esl_oop.h Fri Mar 6 13:24:10 2009
@@ -86,7 +86,7 @@
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);
More information about the Freeswitch-trunk
mailing list