提交 b7623326 authored 作者: Peter Olsson's avatar Peter Olsson

Initial commit of mod_v8

上级 cc8a8c51
......@@ -169,6 +169,9 @@ Release/
/src/mod/say/mod_say_nl/Makefile
/src/mod/say/mod_say_th/Makefile
/src/mod/say/mod_say_zh/Makefile
/src/mod/languages/mod_v8/Makefile
/src/mod/languages/mod_v8/Makefile.in
/src/mod/languages/mod_v8/mod_v8.log
BuildLog.htm
......
差异被折叠。
......@@ -119,6 +119,7 @@ languages/mod_lua
#languages/mod_perl
#languages/mod_python
#languages/mod_spidermonkey
languages/mod_v8
#languages/mod_yaml
loggers/mod_console
loggers/mod_logfile
......
<configuration name="v8.conf" description="Google V8 JavaScript Plug-Ins">
<modules>
<!-- <load module="mod_v8_skel"/> -->
</modules>
</configuration>
......@@ -79,7 +79,8 @@
<!-- Timers -->
<!-- Languages -->
<load module="mod_spidermonkey"/>
<!-- <load module="mod_spidermonkey"/> -->
<load module="mod_v8"/>
<!-- <load module="mod_perl"/> -->
<!-- <load module="mod_python"/> -->
<!-- <load module="mod_java"/> -->
......
<configuration name="v8.conf" description="Google V8 JavaScript Plug-Ins">
<modules>
<!-- <load module="mod_v8_skel"/> -->
</modules>
</configuration>
......@@ -110,6 +110,7 @@
<!-- Languages -->
<!-- <load module="mod_spidermonkey"/> -->
<load module="mod_v8"/>
<!-- <load module="mod_perl"/> -->
<!-- <load module="mod_python"/> -->
<!-- <load module="mod_java"/> -->
......
<configuration name="v8.conf" description="Google V8 JavaScript Plug-Ins">
<modules>
<!-- <load module="mod_v8_skel"/> -->
</modules>
</configuration>
......@@ -1162,6 +1162,7 @@ AC_CONFIG_FILES([Makefile
src/mod/legacy/languages/mod_lua/Makefile
src/mod/languages/mod_python/Makefile
src/mod/languages/mod_spidermonkey/Makefile
src/mod/languages/mod_v8/Makefile
src/mod/event_handlers/mod_erlang_event/Makefile
src/include/switch_am_config.h
build/getsounds.sh
......
......@@ -115,6 +115,7 @@ getlibs () {
getlib http://files.freeswitch.org/downloads/libs/lame-3.98.4.tar.gz
getlib http://files.freeswitch.org/downloads/libs/libshout-2.2.2.tar.gz
getlib http://files.freeswitch.org/downloads/libs/mpg123-1.13.2.tar.gz
getlib http://files.freeswitch.org/downloads/libs/v8-3.24.14.tar.bz2
# cleanup mongo
(
cd mongo-cxx-driver-v1.8
......
......@@ -38,6 +38,7 @@ that much better:
Juan Jose Comellas <juanjo@comellas.org> - Patch to switch_utils for arg parsing.
Dale Thatcher <freeswitch at dalethatcher dot com> - Additions to mod_conference.
Simon Perreault & Marc Blanchet from Viagenie.ca - IPv6 Support.
Peter Olsson <peter@olssononline.se> - mod_v8, and other various patches.
A big THANK YOU goes to:
......
......@@ -3,7 +3,7 @@
# spec file for package freeswitch
#
# includes module(s): freeswitch-devel freeswitch-codec-passthru-amr freeswitch-codec-passthru-amrwb freeswitch-codec-passthru-g729
# freeswitch-codec-passthru-g7231 freeswitch-lua freeswitch-perl freeswitch-python freeswitch-spidermonkey
# freeswitch-codec-passthru-g7231 freeswitch-lua freeswitch-perl freeswitch-python freeswitch-spidermonkey freeswitch-v8
# freeswitch-lan-de freeswitch-lang-en freeswitch-lang-fr freeswitch-lang-hu freeswitch-lang-ru freeswitch-freetdm
#
# Initial Version Copyright (C) 2007 Peter Nixon and Michal Bielicki, All Rights Reserved.
......@@ -127,6 +127,7 @@ Source9: http://files.freeswitch.org/downloads/libs/communicator_semi_6000_20080
Source10: http://files.freeswitch.org/downloads/libs/libmemcached-0.32.tar.gz
Source11: http://files.freeswitch.org/downloads/libs/json-c-0.9.tar.gz
Source12: http://files.freeswitch.org/downloads/libs/opus-1.1.tar.gz
Source13: http://files.freeswitch.org/downloads/libs/v8-3.24.14.tar.bz2
Prefix: %{prefix}
......@@ -1102,10 +1103,17 @@ Requires: python
%package spidermonkey
Summary: JavaScript support for the FreeSWITCH open source telephony platform
Group: System/Libraries
Requires: %{name} = %{version}-%{release}
Requires: %{name} = %{version}-%{release}
%description spidermonkey
%package v8
Summary: JavaScript support for the FreeSWITCH open source telephony platform, using Google V8 JavaScript engine
Group: System/Libraries
Requires: %{name} = %{version}-%{release}
%description v8
######################################################################################################################
# FreeSWITCH Say Modules
######################################################################################################################
......@@ -1421,7 +1429,7 @@ FORMATS_MODULES+=" formats/mod_ssml"
# Embedded Languages
#
######################################################################################################################
LANGUAGES_MODULES="languages/mod_lua languages/mod_perl languages/mod_python languages/mod_spidermonkey"
LANGUAGES_MODULES="languages/mod_lua languages/mod_perl languages/mod_python languages/mod_spidermonkey languages/mod_v8"
######################################################################################################################
#
......@@ -2302,6 +2310,15 @@ fi
%dir %attr(0750, freeswitch, daemon) %{sysconfdir}/autoload_configs
%config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/spidermonkey.conf.xml
%files v8
%defattr(-,freeswitch,daemon)
%{MODINSTDIR}/mod_v8*.so*
%{LIBDIR}/libv8.so
%{LIBDIR}/libicui18n.so
%{LIBDIR}/libicuuc.so
%dir %attr(0750, freeswitch, daemon) %{sysconfdir}/autoload_configs
%config(noreplace) %attr(0640, freeswitch, daemon) %{sysconfdir}/autoload_configs/v8.conf.xml
######################################################################################################################
#
# Language Modules
......@@ -2427,6 +2444,8 @@ fi
#
######################################################################################################################
%changelog
* Mon Jan 13 2014 - peter@olssononline.se
- Add mod_v8
* Mon Dec 09 2013 - crienzo@grasshopper.com
- Add mod_ssml, mod_rayo
- Fix build on master
......
......@@ -980,6 +980,7 @@ opal
/zeromq-*/
/jpeg-8d/
/v8-*/
# build products we should remove
!/apr-util/xml/expat/conftools/config.guess
......
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectName>Download V8</ProjectName>
<ProjectGuid>{13077E43-E5DF-4EF6-9EB1-2A0B22E8DFAF}</ProjectGuid>
<RootNamespace>Download V8</RootNamespace>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Utility</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Utility</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<Import Project="$(SolutionDir)\w32\extdll.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(PlatformName)\V8\$(Configuration)\</IntDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(PlatformName)\V8\$(Configuration)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<BuildLog>
<Path>$(IntDir)BuildLog $(ProjectName).htm</Path>
</BuildLog>
<PreBuildEvent>
<Command>
</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<BuildLog>
<Path>$(IntDir)BuildLog $(ProjectName).htm</Path>
</BuildLog>
<PreBuildEvent>
<Command>
</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<CustomBuild Include="cleancount">
<FileType>Document</FileType>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Downloading V8.</Message>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">if not exist "$(ProjectDir)..\v8-3.24.14" cscript /nologo "$(ProjectDir)util.vbs" GetUnzip http://files.freeswitch.org/downloads/libs/v8-3.24.14.tar.bz2 "$(ProjectDir).."
if not exist "$(ProjectDir)..\v8-3.24.14\third_party\cygwin" cscript /nologo "$(ProjectDir)util.vbs" GetUnzip http://files.freeswitch.org/downloads/libs/v8-3.24.14-win.tar.bz2 "$(ProjectDir).."
</Command>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir)..\v8-3.24.14;%(Outputs)</Outputs>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Downloading V8.</Message>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">if not exist "$(ProjectDir)..\v8-3.24.14" cscript /nologo "$(ProjectDir)util.vbs" GetUnzip http://files.freeswitch.org/downloads/libs/v8-3.24.14.tar.bz2 "$(ProjectDir).."
if not exist "$(ProjectDir)..\v8-3.24.14\third_party\cygwin" cscript /nologo "$(ProjectDir)util.vbs" GetUnzip http://files.freeswitch.org/downloads/libs/v8-3.24.14-win.tar.bz2 "$(ProjectDir).."
</Command>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir)..\v8-3.24.14;%(Outputs)</Outputs>
</CustomBuild>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
@ECHO OFF
IF "%1" == "" GOTO Fail
IF "%2" == "" GOTO Fail
IF "%3" == "" GOTO Fail
cd "%3"
SET /P LAST_BUILD_INFO=<last_build
IF "%1-%2" == "%LAST_BUILD_INFO%" (
ECHO V8 is already built!
SET COPY_FILES_ONLY=1
)
SET LIB_DEST_DIR=
IF "%1" == "x64" (
IF NOT "%COPY_FILES_ONLY%" == "1" .\third_party\python_26\python.exe build\gyp_v8 -Dtarget_arch=x64 -Dcomponent=shared_library
IF NOT ERRORLEVEL 0 GOTO Fail
SET LIB_DEST_DIR=..\..\x64\%2\
)
IF "%1" == "x86" (
IF NOT "%COPY_FILES_ONLY%" == "1" .\third_party\python_26\python.exe build\gyp_v8 -Dcomponent=shared_library
IF NOT ERRORLEVEL 0 GOTO Fail
SET LIB_DEST_DIR=..\..\Win32\%2\
)
IF "%LIB_DEST_DIR%" == "" GOTO Fail
IF "%COPY_FILES_ONLY%" == "1" GOTO CopyFiles
devenv.com /clean %2 tools\gyp\v8.sln
IF NOT ERRORLEVEL 0 GOTO Fail
devenv.com /build %2 tools\gyp\v8.sln
IF NOT ERRORLEVEL 0 GOTO Fail
:CopyFiles
REM xcopy /C /F /R /Y .\build\%2\icudt.dll %LIB_DEST_DIR%
REM IF NOT ERRORLEVEL 0 GOTO Fail
xcopy /C /F /R /Y .\build\%2\icui18n.dll %LIB_DEST_DIR%
IF NOT ERRORLEVEL 0 GOTO Fail
xcopy /C /F /R /Y .\build\%2\icuuc.dll %LIB_DEST_DIR%
IF NOT ERRORLEVEL 0 GOTO Fail
xcopy /C /F /R /Y .\build\%2\v8.dll %LIB_DEST_DIR%
IF NOT ERRORLEVEL 0 GOTO Fail
ECHO %1-%2> last_build
exit
:Fail
exit /b 1
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectName>libv8</ProjectName>
<ProjectGuid>{AB03E82B-48B1-4374-B32A-A1AF83DDC6C2}</ProjectGuid>
<RootNamespace>libv8</RootNamespace>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Utility</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Utility</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Utility</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Utility</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<Import Project="$(SolutionDir)\w32\extdll.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(PlatformName)\V8\$(Configuration)\</IntDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(PlatformName)\V8\$(Configuration)\</IntDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(PlatformName)\V8\$(Configuration)\</IntDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(PlatformName)\V8\$(Configuration)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<BuildLog>
<Path>$(IntDir)BuildLog $(ProjectName).htm</Path>
</BuildLog>
<PreBuildEvent>
<Command>
</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Midl>
<TargetEnvironment>X64</TargetEnvironment>
</Midl>
<BuildLog>
<Path>$(IntDir)BuildLog $(ProjectName).htm</Path>
</BuildLog>
<PreBuildEvent>
<Command>
</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<BuildLog>
<Path>$(IntDir)BuildLog $(ProjectName).htm</Path>
</BuildLog>
<PreBuildEvent>
<Command>
</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Midl>
<TargetEnvironment>X64</TargetEnvironment>
</Midl>
<BuildLog>
<Path>$(IntDir)BuildLog $(ProjectName).htm</Path>
</BuildLog>
<PreBuildEvent>
<Command>
</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<CustomBuild Include="cleancount">
<FileType>Document</FileType>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Building Google V8</Message>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir)build-v8.bat x86 Release "$(ProjectDir)..\..\v8-3.24.14"
</Command>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir)..\..\v8-3.24.14;%(Outputs)</Outputs>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Building Google V8</Message>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir)build-v8.bat x86 Debug "$(ProjectDir)..\..\v8-3.24.14"
</Command>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir)..\..\v8-3.24.14;%(Outputs)</Outputs>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Building Google V8</Message>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectDir)build-v8.bat x64 Release "$(ProjectDir)..\..\v8-3.24.14"
</Command>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectDir)..\..\v8-3.24.14;%(Outputs)</Outputs>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Building Google V8</Message>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectDir)build-v8.bat x64 Debug "$(ProjectDir)..\..\v8-3.24.14"
</Command>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectDir)..\..\v8-3.24.14;%(Outputs)</Outputs>
</CustomBuild>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Download V8.2012.vcxproj">
<Project>{13077E43-E5DF-4EF6-9EB1-2A0B22E8DFAF}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
include $(top_srcdir)/build/modmake.rulesam
V8=v8-3.24.14
V8_DIR=$(switch_srcdir)/libs/$(V8)
V8_BUILDDIR=$(switch_builddir)/libs/$(V8)
V8SO=$(V8_DIR)/out/native/lib.target/libv8.so
CURL_DIR=$(switch_srcdir)/libs/curl
CURL_BUILDDIR=$(switch_builddir)/libs/curl
CURLLA=${switch_builddir}/libs/curl/lib/libcurl.la
MODNAME=mod_v8
AM_CFLAGS += -I. -I./include -I$(V8_DIR)/include
AM_CPPFLAGS += -I. -I./include -I$(V8_DIR)/include
AM_LIBADD = $(switch_builddir)/libfreeswitch.la -lv8 -licuuc -licui18n
AM_LDFLAGS += -avoid-version -module -no-undefined -shared
AM_LDFLAGS += -L$(V8_DIR)/out/native/lib.target
BUILT_SOURCES = $(V8SO) $(LIBCURL_DEPS)
if HAVE_ODBC
AM_CFLAGS += -DHAVE_ODBC $(ODBC_INC_FLAGS)
AM_CPPFLAGS += -DHAVE_ODBC $(ODBC_INC_FLAGS)
AM_LDFLAGS += -DHAVE_ODBC
endif
mod_LTLIBRARIES = mod_v8.la
mod_v8_la_SOURCES = mod_v8.cpp ./src/fscoredb.cpp ./src/fscurl.cpp ./src/fsdtmf.cpp ./src/fsevent.cpp ./src/fsfileio.cpp ./src/fsglobal.cpp ./src/fsodbc.cpp ./src/fspcre.cpp ./src/fsrequest.cpp ./src/fssession.cpp ./src/fssocket.cpp ./src/fsteletone.cpp ./src/fsxml.cpp ./src/fsfile.cpp ./src/jsbase.cpp ./src/jsmain.cpp
mod_v8_la_CFLAGS = $(AM_CFLAGS) $(LIBCURL_CPPFLAGS) -I$(switch_srcdir)/libs/libteletone/src
mod_v8_la_CPPFLAGS = $(AM_CPPFLAGS) $(LIBCURL_CPPFLAGS) -I$(switch_srcdir)/libs/libteletone/src
mod_v8_la_LIBADD = $(AM_LIBADD)
mod_v8_la_LDFLAGS = $(AM_LDFLAGS) $(LIBCURL)
#mod_LTLIBRARIES += mod_v8_skel.la
#mod_v8_skel_la_SOURCES = mod_v8_skel.cpp
#mod_v8_skel_la_CFLAGS = $(AM_CFLAGS) -DJSMOD_IMPORT
#mod_v8_skel_la_CPPFLAGS = $(AM_CPPFLAGS) -DJSMOD_IMPORT
#mod_v8_skel_la_LIBADD = $(AM_LIBADD)
#mod_v8_skel_la_LDFLAGS = $(AM_LDFLAGS)
$(SOURCES): $(BUILT_SOURCES)
$(V8_DIR):
$(GETLIB) $(V8).tar.bz2
$(V8SO): $(V8_DIR)
cd $(V8_BUILDDIR) && $(MAKE) library=shared native
$(CURLLA):
@cd $(CURL_BUILDDIR) && $(MAKE)
$(TOUCH_TARGET)
install-exec-local: $(DESTDIR)$(libdir)/libv8.so
$(DESTDIR)$(libdir)/libv8.so: $(V8SO)
rm -f $(DESTDIR)$(libdir)/libv8.so && cp -a $(V8_DIR)/out/native/lib.target/libv8.so $(DESTDIR)$(libdir)/libv8.so
rm -f $(DESTDIR)$(libdir)/libicuuc.so && cp -a $(V8_DIR)/out/native/lib.target/libicuuc.so $(DESTDIR)$(libdir)/libicuuc.so
rm -f $(DESTDIR)$(libdir)/libicui18n.so && cp -a $(V8_DIR)/out/native/lib.target/libicui18n.so $(DESTDIR)$(libdir)/libicui18n.so
<configuration name="v8.conf" description="Google V8 JavaScript Plug-Ins">
<modules>
<!-- <load module="mod_v8_skel"/> -->
</modules>
</configuration>
/*
* mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2013-2014, Peter Olsson <peter@olssononline.se>
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is
* Peter Olsson <peter@olssononline.se>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Peter Olsson <peter@olssononline.se>
*
* fscoredb.hpp -- JavaScript CoreDB class header
*
*/
#ifndef FS_COREDB_H
#define FS_COREDB_H
#include "mod_v8.h"
/* Macros for easier V8 callback definitions */
#define JS_COREDB_GET_PROPERTY_DEF(method_name) JS_GET_PROPERTY_DEF(method_name, FSCoreDB)
#define JS_COREDB_SET_PROPERTY_DEF(method_name) JS_SET_PROPERTY_DEF(method_name, FSCoreDB)
#define JS_COREDB_FUNCTION_DEF(method_name) JS_FUNCTION_DEF(method_name, FSCoreDB)
#define JS_COREDB_GET_PROPERTY_IMPL(method_name) JS_GET_PROPERTY_IMPL(method_name, FSCoreDB)
#define JS_COREDB_SET_PROPERTY_IMPL(method_name) JS_SET_PROPERTY_IMPL(method_name, FSCoreDB)
#define JS_COREDB_FUNCTION_IMPL(method_name) JS_FUNCTION_IMPL(method_name, FSCoreDB)
class FSCoreDB : public JSBase
{
private:
switch_memory_pool_t *_pool;
switch_core_db_t *_db;
switch_core_db_stmt_t *_stmt;
const char *_dbname;
v8::Persistent<v8::Function> _callback;
void Init();
void DoClose();
void StepEx(const v8::FunctionCallbackInfo<v8::Value>& info, int stepSuccessCode);
static int Callback(void *pArg, int argc, char **argv, char **columnNames);
public:
FSCoreDB(JSMain *owner) : JSBase(owner) { Init(); }
FSCoreDB(const v8::FunctionCallbackInfo<v8::Value>& info) : JSBase(info) { Init(); }
virtual ~FSCoreDB(void);
virtual std::string GetJSClassName();
static const v8_mod_interface_t *GetModuleInterface();
/* Methods available from JavaScript */
static void *Construct(const v8::FunctionCallbackInfo<v8::Value>& info);
JS_COREDB_FUNCTION_DEF(Exec);
JS_COREDB_FUNCTION_DEF(Close);
JS_COREDB_FUNCTION_DEF(Next);
JS_COREDB_FUNCTION_DEF(Step);
JS_COREDB_FUNCTION_DEF(Fetch);
JS_COREDB_FUNCTION_DEF(Prepare);
JS_COREDB_FUNCTION_DEF(BindText);
JS_COREDB_FUNCTION_DEF(BindInt);
JS_COREDB_GET_PROPERTY_DEF(GetProperty);
};
#endif /* FS_COREDB_H */
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
*/
/*
* mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2013-2014, Peter Olsson <peter@olssononline.se>
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is
* Peter Olsson <peter@olssononline.se>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Peter Olsson <peter@olssononline.se>
*
* fscurl.hpp -- JavaScript CURL class header
*
*/
#ifndef FS_CURL_H
#define FS_CURL_H
#include "mod_v8.h"
#include <switch_curl.h>
/* Macros for easier V8 callback definitions */
#define JS_CURL_GET_PROPERTY_DEF(method_name) JS_GET_PROPERTY_DEF(method_name, FSCURL)
#define JS_CURL_SET_PROPERTY_DEF(method_name) JS_SET_PROPERTY_DEF(method_name, FSCURL)
#define JS_CURL_FUNCTION_DEF(method_name) JS_FUNCTION_DEF(method_name, FSCURL)
#define JS_CURL_GET_PROPERTY_IMPL(method_name) JS_GET_PROPERTY_IMPL(method_name, FSCURL)
#define JS_CURL_SET_PROPERTY_IMPL(method_name) JS_SET_PROPERTY_IMPL(method_name, FSCURL)
#define JS_CURL_FUNCTION_IMPL(method_name) JS_FUNCTION_IMPL(method_name, FSCURL)
class FSCURL : public JSBase
{
private:
switch_CURL *_curl_handle;
v8::Persistent<v8::Function> _function;
v8::Persistent<v8::Object> _user_data;
v8::Persistent<v8::Value> _ret;
void Init(void);
static size_t FileCallback(void *ptr, size_t size, size_t nmemb, void *data);
public:
FSCURL(JSMain *owner) : JSBase(owner) { Init(); }
FSCURL(const v8::FunctionCallbackInfo<v8::Value>& info) : JSBase(info) { Init(); }
virtual ~FSCURL(void);
virtual std::string GetJSClassName();
static const v8_mod_interface_t *GetModuleInterface();
/* Methods available from JavaScript */
static void *Construct(const v8::FunctionCallbackInfo<v8::Value>& info);
JS_CURL_FUNCTION_DEF(Run);
};
#endif /* FS_CURL_H */
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
*/
/*
* mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2013-2014, Peter Olsson <peter@olssononline.se>
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is
* Peter Olsson <peter@olssononline.se>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Peter Olsson <peter@olssononline.se>
*
* fsdtmf.hpp -- JavaScript DTMF class header
*
*/
#ifndef FS_DTMF_H
#define FS_DTMF_H
#include "javascript.hpp"
#include <switch.h>
/* Macros for easier V8 callback definitions */
#define JS_DTMF_GET_PROPERTY_DEF(method_name) JS_GET_PROPERTY_DEF(method_name, FSDTMF)
#define JS_DTMF_SET_PROPERTY_DEF(method_name) JS_SET_PROPERTY_DEF(method_name, FSDTMF)
#define JS_DTMF_FUNCTION_DEF(method_name) JS_FUNCTION_DEF(method_name, FSDTMF)
#define JS_DTMF_GET_PROPERTY_IMPL(method_name) JS_GET_PROPERTY_IMPL(method_name, FSDTMF)
#define JS_DTMF_SET_PROPERTY_IMPL(method_name) JS_SET_PROPERTY_IMPL(method_name, FSDTMF)
#define JS_DTMF_FUNCTION_IMPL(method_name) JS_FUNCTION_IMPL(method_name, FSDTMF)
class FSDTMF : public JSBase
{
private:
switch_dtmf_t *_dtmf;
public:
FSDTMF(JSMain *owner) : JSBase(owner) { _dtmf = NULL; }
FSDTMF(const v8::FunctionCallbackInfo<v8::Value>& info) : JSBase(info) { _dtmf = NULL; }
virtual ~FSDTMF(void);
virtual std::string GetJSClassName();
static const js_class_definition_t *GetClassDefinition();
/* Methods available from JavaScript */
static void *Construct(const v8::FunctionCallbackInfo<v8::Value>& info);
static v8::Handle<v8::Object> New(switch_dtmf_t *dtmf, const char *name, JSMain *js);
JS_DTMF_GET_PROPERTY_DEF(GetProperty);
};
#endif /* FS_DTMF_H */
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
*/
/*
* mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2013-2014, Peter Olsson <peter@olssononline.se>
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is
* Peter Olsson <peter@olssononline.se>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Peter Olsson <peter@olssononline.se>
*
* fsevent.hpp -- JavaScript Event class header
*
*/
#ifndef FS_EVENT_H
#define FS_EVENT_H
#include "javascript.hpp"
#include <switch.h>
/* Macros for easier V8 callback definitions */
#define JS_EVENT_GET_PROPERTY_DEF(method_name) JS_GET_PROPERTY_DEF(method_name, FSEvent)
#define JS_EVENT_SET_PROPERTY_DEF(method_name) JS_SET_PROPERTY_DEF(method_name, FSEvent)
#define JS_EVENT_FUNCTION_DEF(method_name) JS_FUNCTION_DEF(method_name, FSEvent)
#define JS_EVENT_GET_PROPERTY_IMPL(method_name) JS_GET_PROPERTY_IMPL(method_name, FSEvent)
#define JS_EVENT_SET_PROPERTY_IMPL(method_name) JS_SET_PROPERTY_IMPL(method_name, FSEvent)
#define JS_EVENT_FUNCTION_IMPL(method_name) JS_FUNCTION_IMPL(method_name, FSEvent)
#define JS_EVENT_GET_PROPERTY_IMPL_STATIC(method_name) JS_GET_PROPERTY_IMPL_STATIC(method_name, FSEvent)
#define JS_EVENT_SET_PROPERTY_IMPL_STATIC(method_name) JS_SET_PROPERTY_IMPL_STATIC(method_name, FSEvent)
#define JS_EVENT_FUNCTION_IMPL_STATIC(method_name) JS_FUNCTION_IMPL_STATIC(method_name, FSEvent)
class FSEvent : public JSBase
{
private:
switch_event_t *_event;
int _freed;
void Init();
public:
FSEvent(JSMain *owner) : JSBase(owner) { Init(); }
FSEvent(const v8::FunctionCallbackInfo<v8::Value>& info) : JSBase(info) { Init(); }
virtual ~FSEvent(void);
virtual std::string GetJSClassName();
static const js_class_definition_t *GetClassDefinition();
void SetEvent(switch_event_t *event, int freed = 0);
switch_event_t **GetEvent();
/* Methods available from JavaScript */
static void *Construct(const v8::FunctionCallbackInfo<v8::Value>& info);
static v8::Handle<v8::Object> New(switch_event_t *event, const char *name, JSMain *js);
JS_EVENT_FUNCTION_DEF(AddHeader);
JS_EVENT_FUNCTION_DEF(GetHeader);
JS_EVENT_FUNCTION_DEF(AddBody);
JS_EVENT_FUNCTION_DEF(GetBody);
JS_EVENT_FUNCTION_DEF(GetType);
JS_EVENT_FUNCTION_DEF(Serialize);
JS_EVENT_FUNCTION_DEF(ChatExecute);
JS_FUNCTION_DEF_STATIC(Fire); // This will also destroy the C++ object
JS_FUNCTION_DEF_STATIC(Destroy); // This will also destroy the C++ object
JS_EVENT_GET_PROPERTY_DEF(GetProperty);
};
#endif /* FS_EVENT_H */
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
*/
/*
* mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2013-2014, Peter Olsson <peter@olssononline.se>
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is
* Peter Olsson <peter@olssononline.se>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Peter Olsson <peter@olssononline.se>
*
* fsfile.hpp -- JavaScript File class header
*
*/
#ifndef FS_FILE_H
#define FS_FILE_H
#include "mod_v8.h"
/* Macros for easier V8 callback definitions */
#define JS_FILE_GET_PROPERTY_DEF(method_name) JS_GET_PROPERTY_DEF(method_name, FSFile)
#define JS_FILE_SET_PROPERTY_DEF(method_name) JS_SET_PROPERTY_DEF(method_name, FSFile)
#define JS_FILE_FUNCTION_DEF(method_name) JS_FUNCTION_DEF(method_name, FSFile)
#define JS_FILE_GET_PROPERTY_IMPL(method_name) JS_GET_PROPERTY_IMPL(method_name, FSFile)
#define JS_FILE_SET_PROPERTY_IMPL(method_name) JS_SET_PROPERTY_IMPL(method_name, FSFile)
#define JS_FILE_FUNCTION_IMPL(method_name) JS_FUNCTION_IMPL(method_name, FSFile)
class FSFile : public JSBase
{
private:
void Init();
public:
FSFile(JSMain *owner) : JSBase(owner) { }
FSFile(const v8::FunctionCallbackInfo<v8::Value>& info) : JSBase(info) { }
virtual ~FSFile(void);
virtual std::string GetJSClassName();
static const v8_mod_interface_t *GetModuleInterface();
/* Methods available from JavaScript */
static void *Construct(const v8::FunctionCallbackInfo<v8::Value>& info);
JS_FILE_FUNCTION_DEF(Close);
JS_FILE_FUNCTION_DEF(CopyTo);
JS_FILE_FUNCTION_DEF(Flush);
JS_FILE_FUNCTION_DEF(List);
JS_FILE_FUNCTION_DEF(MkDir);
JS_FILE_FUNCTION_DEF(Open);
JS_FILE_FUNCTION_DEF(Read);
JS_FILE_FUNCTION_DEF(ReadAll);
JS_FILE_FUNCTION_DEF(ReadLn);
JS_FILE_FUNCTION_DEF(Remove);
JS_FILE_FUNCTION_DEF(RenameTo);
JS_FILE_FUNCTION_DEF(Seek);
JS_FILE_FUNCTION_DEF(ToString);
JS_FILE_FUNCTION_DEF(ToURL);
JS_FILE_FUNCTION_DEF(Write);
JS_FILE_FUNCTION_DEF(WriteAll);
JS_FILE_FUNCTION_DEF(WriteLn);
JS_FILE_GET_PROPERTY_DEF(GetPropCanAppend);
JS_FILE_GET_PROPERTY_DEF(GetPropCanRead);
JS_FILE_GET_PROPERTY_DEF(GetPropCanReplace);
JS_FILE_GET_PROPERTY_DEF(GetPropCanWrite);
JS_FILE_GET_PROPERTY_DEF(GetPropCreationTime);
JS_FILE_GET_PROPERTY_DEF(GetPropExists);
JS_FILE_GET_PROPERTY_DEF(GetPropHasAutoFlush);
JS_FILE_GET_PROPERTY_DEF(GetPropHasRandomAccess);
JS_FILE_GET_PROPERTY_DEF(GetPropIsDirectory);
JS_FILE_GET_PROPERTY_DEF(GetPropIsFile);
JS_FILE_GET_PROPERTY_DEF(GetPropIsNative);
JS_FILE_GET_PROPERTY_DEF(GetPropIsOpen);
JS_FILE_GET_PROPERTY_DEF(GetPropLastModified);
JS_FILE_GET_PROPERTY_DEF(GetPropLength);
JS_FILE_GET_PROPERTY_DEF(GetPropMode);
JS_FILE_GET_PROPERTY_DEF(GetPropName);
JS_FILE_GET_PROPERTY_DEF(GetPropParent);
JS_FILE_GET_PROPERTY_DEF(GetPropPath);
JS_FILE_GET_PROPERTY_DEF(GetPropPosition);
JS_FILE_SET_PROPERTY_DEF(SetPropPosition);
JS_FILE_GET_PROPERTY_DEF(GetPropSize);
JS_FILE_GET_PROPERTY_DEF(GetPropType);
};
#endif /* FS_FILE_H */
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
*/
/*
* mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2013-2014, Peter Olsson <peter@olssononline.se>
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is
* Peter Olsson <peter@olssononline.se>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Peter Olsson <peter@olssononline.se>
*
* fsfileio.hpp -- JavaScript FileIO class header
*
*/
#ifndef FS_FILEIO_H
#define FS_FILEIO_H
#include "javascript.hpp"
#include <switch.h>
/* Macros for easier V8 callback definitions */
#define JS_FILEIO_GET_PROPERTY_DEF(method_name) JS_GET_PROPERTY_DEF(method_name, FSFileIO)
#define JS_FILEIO_SET_PROPERTY_DEF(method_name) JS_SET_PROPERTY_DEF(method_name, FSFileIO)
#define JS_FILEIO_FUNCTION_DEF(method_name) JS_FUNCTION_DEF(method_name, FSFileIO)
#define JS_FILEIO_GET_PROPERTY_IMPL(method_name) JS_GET_PROPERTY_IMPL(method_name, FSFileIO)
#define JS_FILEIO_SET_PROPERTY_IMPL(method_name) JS_SET_PROPERTY_IMPL(method_name, FSFileIO)
#define JS_FILEIO_FUNCTION_IMPL(method_name) JS_FUNCTION_IMPL(method_name, FSFileIO)
class FSFileIO : public JSBase
{
private:
char *_path;
unsigned int _flags;
switch_file_t *_fd;
switch_memory_pool_t *_pool;
char *_buf;
switch_size_t _buflen;
int32_t _bufsize;
void Init();
public:
FSFileIO(JSMain *owner) : JSBase(owner) { Init(); }
FSFileIO(const v8::FunctionCallbackInfo<v8::Value>& info) : JSBase(info) { Init(); }
virtual ~FSFileIO(void);
virtual std::string GetJSClassName();
static const js_class_definition_t *GetClassDefinition();
/* Methods available from JavaScript */
static void *Construct(const v8::FunctionCallbackInfo<v8::Value>& info);
JS_FILEIO_FUNCTION_DEF(Read);
JS_FILEIO_FUNCTION_DEF(Write);
JS_FILEIO_FUNCTION_DEF(GetData);
JS_FILEIO_GET_PROPERTY_DEF(GetProperty);
};
#endif /* FS_FILEIO_H */
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
*/
/*
* mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2013-2014, Peter Olsson <peter@olssononline.se>
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is
* Peter Olsson <peter@olssononline.se>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Peter Olsson <peter@olssononline.se>
*
* fsglobal.hpp -- JavaScript Global functions
*
*/
#ifndef FS_GLOBAL_H
#define FS_GLOBAL_H
#include "javascript.hpp"
#include <switch.h>
/* Macros for easier V8 callback definitions */
#define JS_GLOBAL_FUNCTION_IMPL_STATIC(method_name) JS_FUNCTION_IMPL_STATIC(method_name, FSGlobal)
/* All globally available functions (not related to objects) */
class FSGlobal
{
private:
static size_t HashCallback(void *ptr, size_t size, size_t nmemb, void *data);
static size_t FileCallback(void *ptr, size_t size, size_t nmemb, void *data);
static size_t FetchUrlCallback(void *ptr, size_t size, size_t nmemb, void *data);
public:
static const js_function_t *GetFunctionDefinitions();
/* Methods available from JavaScript */
JS_FUNCTION_DEF_STATIC(Log);
JS_FUNCTION_DEF_STATIC(GlobalGet);
JS_FUNCTION_DEF_STATIC(GlobalSet);
JS_FUNCTION_DEF_STATIC(Exit);
JS_FUNCTION_DEF_STATIC(Include);
JS_FUNCTION_DEF_STATIC(Bridge);
JS_FUNCTION_DEF_STATIC(Email);
JS_FUNCTION_DEF_STATIC(ApiExecute);
JS_FUNCTION_DEF_STATIC(Use);
JS_FUNCTION_DEF_STATIC(Sleep);
JS_FUNCTION_DEF_STATIC(FileDelete);
JS_FUNCTION_DEF_STATIC(System);
JS_FUNCTION_DEF_STATIC(FetchURL);
JS_FUNCTION_DEF_STATIC(FetchURLHash);
JS_FUNCTION_DEF_STATIC(FetchURLFile);
};
#endif /* FS_GLOBAL_H */
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
*/
/*
* mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2013-2014, Peter Olsson <peter@olssononline.se>
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is
* Peter Olsson <peter@olssononline.se>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Peter Olsson <peter@olssononline.se>
*
* fsodbc.hpp -- JavaScript ODBC class header
*
*/
#ifndef FS_ODBC_H
#define FS_ODBC_H
#include "mod_v8.h"
#if defined(WIN32) && !defined(HAVE_ODBC)
#define HAVE_ODBC
#endif
#ifdef HAVE_ODBC
#include <sql.h>
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable:4201)
#include <sqlext.h>
#pragma warning(pop)
#else
#include <sqlext.h>
#endif
#include <sqltypes.h>
/* Macros for easier V8 callback definitions */
#define JS_ODBC_GET_PROPERTY_DEF(method_name) JS_GET_PROPERTY_DEF(method_name, FSODBC)
#define JS_ODBC_SET_PROPERTY_DEF(method_name) JS_SET_PROPERTY_DEF(method_name, FSODBC)
#define JS_ODBC_FUNCTION_DEF(method_name) JS_FUNCTION_DEF(method_name, FSODBC)
#define JS_ODBC_GET_PROPERTY_IMPL(method_name) JS_GET_PROPERTY_IMPL(method_name, FSODBC)
#define JS_ODBC_SET_PROPERTY_IMPL(method_name) JS_SET_PROPERTY_IMPL(method_name, FSODBC)
#define JS_ODBC_FUNCTION_IMPL(method_name) JS_FUNCTION_IMPL(method_name, FSODBC)
#define JS_ODBC_GET_PROPERTY_IMPL_STATIC(method_name) JS_GET_PROPERTY_IMPL_STATIC(method_name, FSODBC)
#define JS_ODBC_SET_PROPERTY_IMPL_STATIC(method_name) JS_SET_PROPERTY_IMPL_STATIC(method_name, FSODBC)
#define JS_ODBC_FUNCTION_IMPL_STATIC(method_name) JS_FUNCTION_IMPL_STATIC(method_name, FSODBC)
class FSODBC : public JSBase
{
private:
switch_odbc_handle_t *_handle;
SQLHSTMT _stmt;
SQLCHAR *_colbuf;
int32_t _cblen;
std::string _dsn;
void Init();
public:
FSODBC(JSMain *owner) : JSBase(owner) { Init(); }
FSODBC(const v8::FunctionCallbackInfo<v8::Value>& info) : JSBase(info) { Init(); }
virtual ~FSODBC(void);
virtual std::string GetJSClassName();
static const v8_mod_interface_t *GetModuleInterface();
static FSODBC *New(char *dsn, char *username, char *password, const v8::FunctionCallbackInfo<v8::Value>& info);
switch_odbc_status_t Connect();
/* Methods available from JavaScript */
static void *Construct(const v8::FunctionCallbackInfo<v8::Value>& info);
JS_ODBC_FUNCTION_DEF(Connect);
JS_ODBC_FUNCTION_DEF(Disconnect);
JS_ODBC_FUNCTION_DEF(Exec);
JS_ODBC_FUNCTION_DEF(Execute);
JS_ODBC_FUNCTION_DEF(NumRows);
JS_ODBC_FUNCTION_DEF(NumCols);
JS_ODBC_FUNCTION_DEF(NextRow);
JS_ODBC_FUNCTION_DEF(GetData);
JS_FUNCTION_DEF_STATIC(Close); // This will also destroy the C++ object
JS_ODBC_GET_PROPERTY_DEF(GetProperty);
};
#endif /* HAVE_ODBC */
#endif /* FS_ODBC_H */
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
*/
/*
* mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2013-2014, Peter Olsson <peter@olssononline.se>
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is
* Peter Olsson <peter@olssononline.se>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Peter Olsson <peter@olssononline.se>
*
* fspcre.hpp -- JavaScript PCRE class header
*
*/
#ifndef FS_PCRE_H
#define FS_PCRE_H
#include "javascript.hpp"
#include <switch.h>
/* Macros for easier V8 callback definitions */
#define JS_PCRE_GET_PROPERTY_DEF(method_name) JS_GET_PROPERTY_DEF(method_name, FSPCRE)
#define JS_PCRE_SET_PROPERTY_DEF(method_name) JS_SET_PROPERTY_DEF(method_name, FSPCRE)
#define JS_PCRE_FUNCTION_DEF(method_name) JS_FUNCTION_DEF(method_name, FSPCRE)
#define JS_PCRE_GET_PROPERTY_IMPL(method_name) JS_GET_PROPERTY_IMPL(method_name, FSPCRE)
#define JS_PCRE_SET_PROPERTY_IMPL(method_name) JS_SET_PROPERTY_IMPL(method_name, FSPCRE)
#define JS_PCRE_FUNCTION_IMPL(method_name) JS_FUNCTION_IMPL(method_name, FSPCRE)
class FSPCRE : public JSBase
{
private:
switch_regex_t *_re;
char *_str;
int _proceed;
int _ovector[30];
int _freed;
void Init();
public:
FSPCRE(JSMain *owner) : JSBase(owner) { Init(); }
FSPCRE(const v8::FunctionCallbackInfo<v8::Value>& info) : JSBase(info) { Init(); }
virtual ~FSPCRE(void);
virtual std::string GetJSClassName();
static const js_class_definition_t *GetClassDefinition();
/* Methods available from JavaScript */
static void *Construct(const v8::FunctionCallbackInfo<v8::Value>& info);
JS_PCRE_FUNCTION_DEF(Compile);
JS_PCRE_FUNCTION_DEF(Substitute);
JS_PCRE_GET_PROPERTY_DEF(GetProperty);
};
#endif /* FS_PCRE_H */
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
*/
/*
* mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2013-2014, Peter Olsson <peter@olssononline.se>
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is
* Peter Olsson <peter@olssononline.se>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Peter Olsson <peter@olssononline.se>
*
* fsrequest.hpp -- JavaScript Request class header
*
*/
#ifndef FS_REQUEST_H
#define FS_REQUEST_H
#include "javascript.hpp"
#include <switch.h>
/* Macros for easier V8 callback definitions */
#define JS_REQUEST_GET_PROPERTY_DEF(method_name) JS_GET_PROPERTY_DEF(method_name, FSRequest)
#define JS_REQUEST_SET_PROPERTY_DEF(method_name) JS_SET_PROPERTY_DEF(method_name, FSRequest)
#define JS_REQUEST_FUNCTION_DEF(method_name) JS_FUNCTION_DEF(method_name, FSRequest)
#define JS_REQUEST_GET_PROPERTY_IMPL(method_name) JS_GET_PROPERTY_IMPL(method_name, FSRequest)
#define JS_REQUEST_SET_PROPERTY_IMPL(method_name) JS_SET_PROPERTY_IMPL(method_name, FSRequest)
#define JS_REQUEST_FUNCTION_IMPL(method_name) JS_FUNCTION_IMPL(method_name, FSRequest)
class FSRequest : public JSBase
{
private:
const char *_cmd;
switch_stream_handle_t *_stream;
void Init();
public:
FSRequest(JSMain *owner) : JSBase(owner) { Init(); }
FSRequest(const v8::FunctionCallbackInfo<v8::Value>& info) : JSBase(info) { Init(); }
virtual ~FSRequest(void);
virtual std::string GetJSClassName();
static const js_class_definition_t *GetClassDefinition();
void Init(const char *cmd, switch_stream_handle_t *stream);
/* Methods available from JavaScript */
JS_REQUEST_FUNCTION_DEF(Write);
JS_REQUEST_FUNCTION_DEF(GetHeader);
JS_REQUEST_FUNCTION_DEF(AddHeader);
JS_REQUEST_FUNCTION_DEF(DumpEnv);
JS_REQUEST_GET_PROPERTY_DEF(GetProperty);
};
#endif /* FS_REQUEST_H */
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
*/
/*
* mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2013-2014, Peter Olsson <peter@olssononline.se>
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is
* Peter Olsson <peter@olssononline.se>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Peter Olsson <peter@olssononline.se>
*
* fssession.hpp -- JavaScript Session class header
*
*/
#ifndef FS_SESSION_H
#define FS_SESSION_H
#include "javascript.hpp"
#include <switch.h>
typedef struct {
switch_speech_handle_t sh;
switch_codec_t codec;
int speaking;
} js_session_speech_t;
typedef enum {
S_HUP = (1 << 0),
} session_flag_t;
/* Macros for easier V8 callback definitions */
#define JS_SESSION_GET_PROPERTY_DEF(method_name) JS_GET_PROPERTY_DEF(method_name, FSSession)
#define JS_SESSION_SET_PROPERTY_DEF(method_name) JS_SET_PROPERTY_DEF(method_name, FSSession)
#define JS_SESSION_FUNCTION_DEF(method_name) JS_FUNCTION_DEF(method_name, FSSession)
#define JS_SESSION_GET_PROPERTY_IMPL(method_name) JS_GET_PROPERTY_IMPL(method_name, FSSession)
#define JS_SESSION_SET_PROPERTY_IMPL(method_name) JS_SET_PROPERTY_IMPL(method_name, FSSession)
#define JS_SESSION_FUNCTION_IMPL(method_name) JS_FUNCTION_IMPL(method_name, FSSession)
class FSSession : public JSBase
{
private:
switch_core_session_t *_session; // The FS session
unsigned int flags; // Flags related to this session
switch_call_cause_t _cause; // Hangup cause
v8::Persistent<v8::Function> _on_hangup;// Hangup hook
int _stack_depth;
switch_channel_state_t _hook_state;
char *_destination_number;
char *_dialplan;
char *_caller_id_name;
char *_caller_id_number;
char *_network_addr;
char *_ani;
char *_aniii;
char *_rdnis;
char *_context;
char *_username;
int _check_state;
js_session_speech_t *_speech;
void Init(void);
switch_status_t InitSpeechEngine(const char *engine, const char *voice);
void DestroySpeechEngine();
static switch_status_t CommonCallback(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen);
static switch_status_t StreamInputCallback(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen);
static switch_status_t RecordInputCallback(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen);
static bool CheckHangupHook(FSSession *obj, bool *ret);
static switch_status_t HangupHook(switch_core_session_t *session);
public:
FSSession(JSMain *owner) : JSBase(owner) { Init(); }
FSSession(const v8::FunctionCallbackInfo<v8::Value>& info) : JSBase(info) { Init(); }
virtual ~FSSession(void);
virtual std::string GetJSClassName();
static const js_class_definition_t *GetClassDefinition();
switch_core_session_t *GetSession();
void Init(switch_core_session_t *session, unsigned int flags);
static switch_status_t CollectInputCallback(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen);
/* Methods available from JavaScript */
static void *Construct(const v8::FunctionCallbackInfo<v8::Value>& info);
JS_SESSION_FUNCTION_DEF(Originate);
JS_SESSION_FUNCTION_DEF(SetCallerdata);
JS_SESSION_FUNCTION_DEF(SetHangupHook);
JS_SESSION_FUNCTION_DEF(SetAutoHangup);
JS_SESSION_FUNCTION_DEF(SayPhrase);
JS_SESSION_FUNCTION_DEF(StreamFile);
JS_SESSION_FUNCTION_DEF(CollectInput);
JS_SESSION_FUNCTION_DEF(RecordFile);
JS_SESSION_FUNCTION_DEF(FlushEvents);
JS_SESSION_FUNCTION_DEF(FlushDigits);
JS_SESSION_FUNCTION_DEF(Speak);
JS_SESSION_FUNCTION_DEF(SetVariable);
JS_SESSION_FUNCTION_DEF(GetVariable);
JS_SESSION_FUNCTION_DEF(GetDigits);
JS_SESSION_FUNCTION_DEF(Answer);
JS_SESSION_FUNCTION_DEF(PreAnswer);
JS_SESSION_FUNCTION_DEF(GenerateXmlCdr);
JS_SESSION_FUNCTION_DEF(Ready);
JS_SESSION_FUNCTION_DEF(Answered);
JS_SESSION_FUNCTION_DEF(MediaReady);
JS_SESSION_FUNCTION_DEF(RingReady);
JS_SESSION_FUNCTION_DEF(WaitForAnswer);
JS_SESSION_FUNCTION_DEF(WaitForMedia);
JS_SESSION_FUNCTION_DEF(GetEvent);
JS_SESSION_FUNCTION_DEF(SendEvent);
JS_SESSION_FUNCTION_DEF(Hangup);
JS_SESSION_FUNCTION_DEF(Execute);
JS_SESSION_FUNCTION_DEF(Detach);
JS_SESSION_FUNCTION_DEF(Sleep);
JS_SESSION_FUNCTION_DEF(Bridge);
JS_SESSION_GET_PROPERTY_DEF(GetProperty);
};
class FSInputCallbackState
{
public:
FSSession *session_state;
char code_buffer[1024];
size_t code_buffer_len;
char ret_buffer[1024];
int ret_buffer_len;
int digit_count;
v8::Persistent<v8::Function> function;
v8::Persistent<v8::Value> arg;
v8::Persistent<v8::Value> ret;
void *extra;
FSSession *jss_a;
FSSession *jss_b;
v8::Persistent<v8::Object> session_obj_a;
v8::Persistent<v8::Object> session_obj_b;
FSInputCallbackState(void);
~FSInputCallbackState(void);
};
#endif /* FS_SESSION_H */
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
*/
/*
* mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2013-2014, Peter Olsson <peter@olssononline.se>
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is
* Peter Olsson <peter@olssononline.se>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Peter Olsson <peter@olssononline.se>
*
* fssocket.hpp -- JavaScript Socket class header
*
*/
#ifndef FS_SOCKET_H
#define FS_SOCKET_H
#include "mod_v8.h"
/* Macros for easier V8 callback definitions */
#define JS_SOCKET_GET_PROPERTY_DEF(method_name) JS_GET_PROPERTY_DEF(method_name, FSSocket)
#define JS_SOCKET_SET_PROPERTY_DEF(method_name) JS_SET_PROPERTY_DEF(method_name, FSSocket)
#define JS_SOCKET_FUNCTION_DEF(method_name) JS_FUNCTION_DEF(method_name, FSSocket)
#define JS_SOCKET_GET_PROPERTY_IMPL(method_name) JS_GET_PROPERTY_IMPL(method_name, FSSocket)
#define JS_SOCKET_SET_PROPERTY_IMPL(method_name) JS_SET_PROPERTY_IMPL(method_name, FSSocket)
#define JS_SOCKET_FUNCTION_IMPL(method_name) JS_FUNCTION_IMPL(method_name, FSSocket)
class FSSocket : public JSBase
{
private:
switch_socket_t *_socket;
switch_memory_pool_t *_pool;
char *_read_buffer;
switch_size_t _buffer_size;
int _state;
void Init();
public:
FSSocket(JSMain *owner) : JSBase(owner) { Init(); }
FSSocket(const v8::FunctionCallbackInfo<v8::Value>& info) : JSBase(info) { Init(); }
virtual ~FSSocket(void);
virtual std::string GetJSClassName();
static const v8_mod_interface_t *GetModuleInterface();
/* Methods available from JavaScript */
static void *Construct(const v8::FunctionCallbackInfo<v8::Value>& info);
JS_SOCKET_FUNCTION_DEF(Connect);
JS_SOCKET_FUNCTION_DEF(Close);
JS_SOCKET_FUNCTION_DEF(Send);
JS_SOCKET_FUNCTION_DEF(ReadBytes);
JS_SOCKET_FUNCTION_DEF(Read);
JS_SOCKET_GET_PROPERTY_DEF(GetProperty);
};
#endif /* FS_SOCKET_H */
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
*/
/*
* mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2013-2014, Peter Olsson <peter@olssononline.se>
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is
* Peter Olsson <peter@olssononline.se>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Peter Olsson <peter@olssononline.se>
*
* fsteletone.hpp -- JavaScript TeleTone class header
*
*/
#ifndef FS_TELETONE_H
#define FS_TELETONE_H
#include "mod_v8.h"
#include <libteletone.h>
/* Macros for easier V8 callback definitions */
#define JS_TELETONE_GET_PROPERTY_DEF(method_name) JS_GET_PROPERTY_DEF(method_name, FSTeleTone)
#define JS_TELETONE_SET_PROPERTY_DEF(method_name) JS_SET_PROPERTY_DEF(method_name, FSTeleTone)
#define JS_TELETONE_FUNCTION_DEF(method_name) JS_FUNCTION_DEF(method_name, FSTeleTone)
#define JS_TELETONE_GET_PROPERTY_IMPL(method_name) JS_GET_PROPERTY_IMPL(method_name, FSTeleTone)
#define JS_TELETONE_SET_PROPERTY_IMPL(method_name) JS_SET_PROPERTY_IMPL(method_name, FSTeleTone)
#define JS_TELETONE_FUNCTION_IMPL(method_name) JS_FUNCTION_IMPL(method_name, FSTeleTone)
class FSTeleTone : public JSBase
{
private:
teletone_generation_session_t _ts;
switch_core_session_t *_session;
switch_codec_t _codec;
switch_buffer_t *_audio_buffer;
switch_memory_pool_t *_pool;
switch_timer_t *_timer;
switch_timer_t _timer_base;
v8::Persistent<v8::Function> _function;
v8::Persistent<v8::Value> _arg;
unsigned int flags;
void Init();
public:
FSTeleTone(JSMain *owner) : JSBase(owner) { Init(); }
FSTeleTone(const v8::FunctionCallbackInfo<v8::Value>& info) : JSBase(info) { Init(); }
virtual ~FSTeleTone(void);
virtual std::string GetJSClassName();
static const v8_mod_interface_t *GetModuleInterface();
static int Handler(teletone_generation_session_t *ts, teletone_tone_map_t *map);
/* Methods available from JavaScript */
static void *Construct(const v8::FunctionCallbackInfo<v8::Value>& info);
JS_TELETONE_FUNCTION_DEF(Generate);
JS_TELETONE_FUNCTION_DEF(OnDTMF);
JS_TELETONE_FUNCTION_DEF(AddTone);
JS_TELETONE_GET_PROPERTY_DEF(GetNameProperty);
};
#endif /* FS_TELETONE_H */
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
*/
/*
* mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2013-2014, Peter Olsson <peter@olssononline.se>
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is
* Peter Olsson <peter@olssononline.se>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Peter Olsson <peter@olssononline.se>
*
* fsxml.hpp -- JavaScript XML class header
*
*/
#ifndef FS_XML_H
#define FS_XML_H
#include "mod_v8.h"
/* Macros for easier V8 callback definitions */
#define JS_XML_GET_PROPERTY_DEF(method_name) JS_GET_PROPERTY_DEF(method_name, FSXML)
#define JS_XML_SET_PROPERTY_DEF(method_name) JS_SET_PROPERTY_DEF(method_name, FSXML)
#define JS_XML_FUNCTION_DEF(method_name) JS_FUNCTION_DEF(method_name, FSXML)
#define JS_XML_GET_PROPERTY_IMPL(method_name) JS_GET_PROPERTY_IMPL(method_name, FSXML)
#define JS_XML_SET_PROPERTY_IMPL(method_name) JS_SET_PROPERTY_IMPL(method_name, FSXML)
#define JS_XML_FUNCTION_IMPL(method_name) JS_FUNCTION_IMPL(method_name, FSXML)
#define JS_XML_IMPL_STATIC(method_name) JS_FUNCTION_IMPL_STATIC(method_name, FSXML)
class FSXML : public JSBase
{
private:
switch_xml_t _xml;
v8::Persistent<v8::Object> _rootJSObject; /* Always keep a reference to the root, so JS doesn't try to clean it up in GC */
FSXML *_rootObject;
switch_hash_t *_obj_hash;
switch_memory_pool_t *_pool;
void Init();
void InitRootObject();
v8::Handle<v8::Value> GetJSObjFromXMLObj(const switch_xml_t xml, const v8::FunctionCallbackInfo<v8::Value>& info);
void StoreObjectInHash(switch_xml_t xml, FSXML *obj);
FSXML *FindObjectInHash(switch_xml_t xml);
void DeleteObjectInHash(switch_xml_t xml);
void DestroyHash();
public:
FSXML(JSMain *owner) : JSBase(owner) { Init(); }
FSXML(const v8::FunctionCallbackInfo<v8::Value>& info) : JSBase(info) { Init(); }
virtual ~FSXML(void);
virtual std::string GetJSClassName();
static const v8_mod_interface_t *GetModuleInterface();
/* Methods available from JavaScript */
static void *Construct(const v8::FunctionCallbackInfo<v8::Value>& info);
JS_XML_FUNCTION_DEF(GetChild);
JS_XML_FUNCTION_DEF(AddChild);
JS_XML_FUNCTION_DEF(Next);
JS_XML_FUNCTION_DEF(GetAttribute);
JS_XML_FUNCTION_DEF(SetAttribute);
JS_FUNCTION_DEF_STATIC(Remove);
JS_XML_FUNCTION_DEF(Copy);
JS_XML_FUNCTION_DEF(Serialize);
JS_XML_GET_PROPERTY_DEF(GetNameProperty);
JS_XML_GET_PROPERTY_DEF(GetDataProperty);
JS_XML_SET_PROPERTY_DEF(SetDataProperty);
JS_XML_GET_PROPERTY_DEF(GetXmlErrorProperty);
};
#endif /* FS_XML_H */
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
*/
差异被折叠。
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="mod_v8.cpp" />
<ClCompile Include=".\src\jsmain.cpp">
<Filter>BaseClasses</Filter>
</ClCompile>
<ClCompile Include=".\src\jsbase.cpp">
<Filter>BaseClasses</Filter>
</ClCompile>
<ClCompile Include=".\src\fscoredb.cpp">
<Filter>FSClasses</Filter>
</ClCompile>
<ClCompile Include=".\src\fscurl.cpp">
<Filter>FSClasses</Filter>
</ClCompile>
<ClCompile Include=".\src\fsdtmf.cpp">
<Filter>FSClasses</Filter>
</ClCompile>
<ClCompile Include=".\src\fsevent.cpp">
<Filter>FSClasses</Filter>
</ClCompile>
<ClCompile Include="src\fsfile.cpp">
<Filter>FSClasses</Filter>
</ClCompile>
<ClCompile Include=".\src\fsfileio.cpp">
<Filter>FSClasses</Filter>
</ClCompile>
<ClCompile Include=".\src\fsglobal.cpp">
<Filter>FSClasses</Filter>
</ClCompile>
<ClCompile Include=".\src\fsodbc.cpp">
<Filter>FSClasses</Filter>
</ClCompile>
<ClCompile Include=".\src\fspcre.cpp">
<Filter>FSClasses</Filter>
</ClCompile>
<ClCompile Include=".\src\fsrequest.cpp">
<Filter>FSClasses</Filter>
</ClCompile>
<ClCompile Include=".\src\fssession.cpp">
<Filter>FSClasses</Filter>
</ClCompile>
<ClCompile Include=".\src\fssocket.cpp">
<Filter>FSClasses</Filter>
</ClCompile>
<ClCompile Include=".\src\fsteletone.cpp">
<Filter>FSClasses</Filter>
</ClCompile>
<ClCompile Include="src\fsxml.cpp">
<Filter>FSClasses</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="mod_v8.h" />
<ClInclude Include=".\include\javascript.hpp">
<Filter>BaseClasses\include</Filter>
</ClInclude>
<ClInclude Include=".\include\fscoredb.hpp">
<Filter>FSClasses\include</Filter>
</ClInclude>
<ClInclude Include=".\include\fscurl.hpp">
<Filter>FSClasses\include</Filter>
</ClInclude>
<ClInclude Include=".\include\fsdtmf.hpp">
<Filter>FSClasses\include</Filter>
</ClInclude>
<ClInclude Include=".\include\fsevent.hpp">
<Filter>FSClasses\include</Filter>
</ClInclude>
<ClInclude Include="include\fsfile.hpp">
<Filter>FSClasses\include</Filter>
</ClInclude>
<ClInclude Include=".\include\fsfileio.hpp">
<Filter>FSClasses\include</Filter>
</ClInclude>
<ClInclude Include=".\include\fsglobal.hpp">
<Filter>FSClasses\include</Filter>
</ClInclude>
<ClInclude Include=".\include\fsodbc.hpp">
<Filter>FSClasses\include</Filter>
</ClInclude>
<ClInclude Include=".\include\fspcre.hpp">
<Filter>FSClasses\include</Filter>
</ClInclude>
<ClInclude Include=".\include\fsrequest.hpp">
<Filter>FSClasses\include</Filter>
</ClInclude>
<ClInclude Include=".\include\fssession.hpp">
<Filter>FSClasses\include</Filter>
</ClInclude>
<ClInclude Include=".\include\fssocket.hpp">
<Filter>FSClasses\include</Filter>
</ClInclude>
<ClInclude Include=".\include\fsteletone.hpp">
<Filter>FSClasses\include</Filter>
</ClInclude>
<ClInclude Include="include\fsxml.hpp">
<Filter>FSClasses\include</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="BaseClasses">
<UniqueIdentifier>{57f55a0b-1790-4632-95e6-19acbe9015d3}</UniqueIdentifier>
</Filter>
<Filter Include="FSClasses">
<UniqueIdentifier>{dcda9b2f-890a-4820-84e3-4bbcf8f0b62c}</UniqueIdentifier>
</Filter>
<Filter Include="FSClasses\include">
<UniqueIdentifier>{ed9652cf-79bd-4567-9a98-1ed5077d5805}</UniqueIdentifier>
</Filter>
<Filter Include="BaseClasses\include">
<UniqueIdentifier>{3efc073f-f052-4e3d-921c-8d6b6a5a7215}</UniqueIdentifier>
</Filter>
</ItemGroup>
</Project>
\ No newline at end of file
差异被折叠。
/*
* mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2013-2014, Peter Olsson <peter@olssononline.se>
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is ported from FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is
* Anthony Minessale II <anthm@freeswitch.org>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Peter Olsson <peter@olssononline.se>
* Anthony Minessale II <anthm@freeswitch.org>
*
* mod_v8.h -- JavaScript FreeSWITCH module header file
*
*/
#ifndef MOD_V8_H
#define MOD_V8_H
#include "javascript.hpp"
#include <switch.h>
SWITCH_BEGIN_EXTERN_C
#define JS_BUFFER_SIZE 1024 * 32
#define JS_BLOCK_SIZE JS_BUFFER_SIZE
typedef switch_status_t (*v8_mod_load_t) (const v8::FunctionCallbackInfo<v8::Value>& info);
typedef struct {
const char *name;
v8_mod_load_t v8_mod_load;
} v8_mod_interface_t;
typedef switch_status_t (*v8_mod_init_t) (const v8_mod_interface_t **module_interface);
typedef struct {
switch_hash_t *load_hash;
switch_memory_pool_t *pool;
} module_manager_t;
extern module_manager_t module_manager;
SWITCH_END_EXTERN_C
#endif /* MOD_V8_H */
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
*/
/*
* mod_v8_skel for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2013-2014, Peter Olsson <peter@olssononline.se>
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mod_v8_skel for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is
* Peter Olsson <peter@olssononline.se>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Peter Olsson <peter@olssononline.se>
*
* mod_v8_skel.cpp -- JavaScript example extension module
*
*/
/* This class is only to demonstrate how to create an external loadable extension module to mod_v8. */
#include "mod_v8.h"
using namespace std;
using namespace v8;
static const char js_class_name[] = "Skel";
/* Macros for easier V8 callback definitions */
#define JS_SKEL_GET_PROPERTY_DEF(method_name) JS_GET_PROPERTY_DEF(method_name, FSSkel)
#define JS_SKEL_SET_PROPERTY_DEF(method_name) JS_SET_PROPERTY_DEF(method_name, FSSkel)
#define JS_SKEL_FUNCTION_DEF(method_name) JS_FUNCTION_DEF(method_name, FSSkel)
#define JS_SKEL_GET_PROPERTY_IMPL(method_name) JS_GET_PROPERTY_IMPL(method_name, FSSkel)
#define JS_SKEL_SET_PROPERTY_IMPL(method_name) JS_SET_PROPERTY_IMPL(method_name, FSSkel)
#define JS_SKEL_FUNCTION_IMPL(method_name) JS_FUNCTION_IMPL(method_name, FSSkel)
class FSSkel : public JSBase
{
private:
int x;
string y;
public:
FSSkel(const v8::FunctionCallbackInfo<Value>& info);
virtual ~FSSkel(void);
virtual string GetJSClassName() { return js_class_name; }
/* JS methods */
static void *Construct(const v8::FunctionCallbackInfo<Value>& info);
JS_SKEL_GET_PROPERTY_DEF(GetPropertyX);
JS_SKEL_SET_PROPERTY_DEF(SetPropertyX);
JS_SKEL_GET_PROPERTY_DEF(GetPropertyY);
JS_SKEL_SET_PROPERTY_DEF(SetPropertyY);
JS_SKEL_GET_PROPERTY_DEF(GetPropertyZ);
JS_SKEL_FUNCTION_DEF(MyFunction);
JS_SKEL_FUNCTION_DEF(MyFunction2);
};
/* =============================================================================== */
FSSkel::FSSkel(const v8::FunctionCallbackInfo<Value>& info) : JSBase(info)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "FSSkel::FSSkel()\n");
x = 0;
y = "";
}
FSSkel::~FSSkel(void)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "FSSkel::~FSSkel()\n");
}
void *FSSkel::Construct(const v8::FunctionCallbackInfo<Value>& info)
{
FSSkel *obj;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "FSSkel::Constructor\n");
obj = new FSSkel(info);
/* Parse input variables */
if (info.Length() > 0) {
if (!info[0].IsEmpty() && info[0]->IsInt32()) {
obj->x = info[0]->Int32Value();
}
if (!info[1].IsEmpty() && info[1]->IsString()) {
String::Utf8Value str(info[1]);
if (*str) {
obj->y = *str;
}
}
}
return obj;
}
JS_SKEL_GET_PROPERTY_IMPL(GetPropertyX)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "FSSkel::GetPropertyX (%d)\n", x);
info.GetReturnValue().Set(x);
}
JS_SKEL_SET_PROPERTY_IMPL(SetPropertyX)
{
x = value->Int32Value();
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "FSSkel::SetPropertyX to %d\n", x);
}
JS_SKEL_GET_PROPERTY_IMPL(GetPropertyY)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "FSSkel::GetPropertyY (%s)\n", y.c_str());
info.GetReturnValue().Set(String::NewFromUtf8(info.GetIsolate(), y.c_str()));
}
JS_SKEL_SET_PROPERTY_IMPL(SetPropertyY)
{
String::Utf8Value str(value);
y = js_safe_str(*str);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "FSSkel::SetPropertyY to '%s'\n", y.c_str());
}
JS_SKEL_GET_PROPERTY_IMPL(GetPropertyZ)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "FSSkel::GetPropertyZ (z)\n");
info.GetReturnValue().Set(String::NewFromUtf8(info.GetIsolate(), "z"));
}
JS_SKEL_FUNCTION_IMPL(MyFunction)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "FSSkel::MyFunction\n");
}
JS_SKEL_FUNCTION_IMPL(MyFunction2)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "FSSkel::MyFunction2 - will twrow a JavaScript exception\n");
info.GetIsolate()->ThrowException(String::NewFromUtf8(info.GetIsolate(), "Error in MyFunction2()"));
}
/* Add the JS methods here */
static const js_function_t skel_methods[] = {
{"myFunction", FSSkel::MyFunction},
{"myFunction2", FSSkel::MyFunction2},
{0}
};
/* Add the JS properties here */
static const js_property_t skel_props[] = {
{"x", FSSkel::GetPropertyX, FSSkel::SetPropertyX},
{"y", FSSkel::GetPropertyY, FSSkel::SetPropertyY},
{"z", FSSkel::GetPropertyZ, JSBase::DefaultSetProperty},
{0}
};
/* The main definition of the JS Class, holding the name of the class, the constructor and the moethods and properties */
static const js_class_definition_t skel_desc = {
js_class_name,
FSSkel::Construct,
skel_methods,
skel_props
};
SWITCH_BEGIN_EXTERN_C
/* Called from mod_v8 when user scripts [use('Skel');] inside the script. This will load the class into the current JS execution */
static switch_status_t skel_load(const v8::FunctionCallbackInfo<Value>& info)
{
JSBase::Register(info.GetIsolate(), &skel_desc);
return SWITCH_STATUS_SUCCESS;
}
/* The module interface that mod_v8 will get when loading this module */
static const v8_mod_interface_t skel_module_interface = {
/*.name = */ js_class_name,
/*.js_mod_load */ skel_load
};
/* The exported method called from the module to get this module's inteface */
SWITCH_MOD_DECLARE_NONSTD(switch_status_t) v8_mod_init(const v8_mod_interface_t **module_interface)
{
*module_interface = &skel_module_interface;
return SWITCH_STATUS_SUCCESS;
}
SWITCH_END_EXTERN_C
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
*/
差异被折叠。
/*
* mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2013-2014, Peter Olsson <peter@olssononline.se>
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* Ported from the Original Code in FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is
* Anthony Minessale II <anthm@freeswitch.org>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Peter Olsson <peter@olssononline.se>
* Anthony Minessale II <anthm@freeswitch.org>
*
* fscurl.cpp -- JavaScript CURL class
*
*/
#include "fscurl.hpp"
using namespace std;
using namespace v8;
static const char js_class_name[] = "CURL";
FSCURL::~FSCURL(void)
{
_function.Reset();
_user_data.Reset();
_ret.Reset();
if (_curl_handle) {
switch_curl_easy_cleanup(_curl_handle);
}
}
void FSCURL::Init(void)
{
_curl_handle = NULL;
}
string FSCURL::GetJSClassName()
{
return js_class_name;
}
size_t FSCURL::FileCallback(void *ptr, size_t size, size_t nmemb, void *data)
{
FSCURL *obj = static_cast<FSCURL *>(data);
HandleScope handle_scope(obj->GetIsolate());
register unsigned int realsize = (unsigned int) (size * nmemb);
uint32_t argc = 0;
Handle<Value> argv[4];
if (!obj) {
return 0;
}
Handle<Function> func;
if (!obj->_function.IsEmpty()) {
func = Handle<Function>::New(obj->GetIsolate(), obj->_function);
}
if (!func.IsEmpty()) {
char *ret;
if (ptr) {
argv[argc++] = String::NewFromUtf8(obj->GetIsolate(), (char *)ptr);
} else {
argv[argc++] = String::NewFromUtf8(obj->GetIsolate(), "");
}
if (!obj->_user_data.IsEmpty()) {
argv[argc++] = Handle<Value>::New(obj->GetIsolate(), Persistent<Value>::Cast(obj->_user_data));
}
Handle<Value> res = func->Call(obj->GetIsolate()->GetCurrentContext()->Global(), argc, argv);
if (!res.IsEmpty()){
obj->_ret.Reset(obj->GetIsolate(), res);
} else {
obj->_ret.Reset();
}
String::Utf8Value str(Handle<Value>::New(obj->GetIsolate(), res));
if ((ret = *str)) {
if (!strcmp(ret, "true") || !strcmp(ret, "undefined")) {
return realsize;
} else {
return 0;
}
}
}
return realsize;
}
void *FSCURL::Construct(const v8::FunctionCallbackInfo<Value>& info)
{
FSCURL *obj = new FSCURL(info);
switch_assert(obj);
return obj;
}
JS_CURL_FUNCTION_IMPL(Run)
{
HandleScope handle_scope(info.GetIsolate());
const char *method, *url;
const char *url_p = NULL;
char *durl = NULL;
string data, cred;
long httpRes = 0;
struct curl_slist *headers = NULL;
int32_t timeout = 0;
char ct[80] = "Content-Type: application/x-www-form-urlencoded";
if (info.Length() < 2) {
info.GetIsolate()->ThrowException(String::NewFromUtf8(info.GetIsolate(), "Invalid arguments"));
return;
}
String::Utf8Value str1(info[0]);
String::Utf8Value str2(info[1]);
method = js_safe_str(*str1);
url = js_safe_str(*str2);
_curl_handle = switch_curl_easy_init();
if (!strncasecmp(url, "https", 5)) {
switch_curl_easy_setopt(_curl_handle, CURLOPT_SSL_VERIFYPEER, 0);
switch_curl_easy_setopt(_curl_handle, CURLOPT_SSL_VERIFYHOST, 0);
}
if (info.Length() > 2) {
String::Utf8Value str3(info[2]);
data = js_safe_str(*str3);
}
if (info.Length() > 3) {
Handle<Function> func = JSBase::GetFunctionFromArg(info.GetIsolate(), info[3]);
if (!func.IsEmpty() && func->IsFunction()) {
_function.Reset(info.GetIsolate(), func);
}
}
if (info.Length() > 4) {
_user_data.Reset(info.GetIsolate(), Handle<Object>::Cast(info[4]));
}
if (info.Length() > 5) {
String::Utf8Value str4(info[5]);
cred = js_safe_str(*str4);
if (cred.length() > 0) {
switch_curl_easy_setopt(_curl_handle, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
switch_curl_easy_setopt(_curl_handle, CURLOPT_USERPWD, cred.c_str());
}
}
if (info.Length() > 6) {
timeout = info[6]->Int32Value();
if (timeout > 0) {
switch_curl_easy_setopt(_curl_handle, CURLOPT_TIMEOUT, timeout);
}
}
if (info.Length() > 7) {
String::Utf8Value str5(info[7]);
const char *content_type = js_safe_str(*str5);
switch_snprintf(ct, sizeof(ct), "Content-Type: %s", content_type);
}
headers = curl_slist_append(headers, ct);
switch_curl_easy_setopt(_curl_handle, CURLOPT_HTTPHEADER, headers);
url_p = url;
if (!strcasecmp(method, "post")) {
switch_curl_easy_setopt(_curl_handle, CURLOPT_POST, 1);
if (!data.c_str()) {
data = "";
}
switch_curl_easy_setopt(_curl_handle, CURLOPT_POSTFIELDS, data.c_str());
} else if (data.length() > 0) {
durl = switch_mprintf("%s?%s", url, data.c_str());
url_p = durl;
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Running: method: [%s] url: [%s] data: [%s] cred=[%s] cb: [%s]\n",
method, url_p, data.c_str(), switch_str_nil(cred.c_str()), !_function.IsEmpty() ? "yes" : "no");
switch_curl_easy_setopt(_curl_handle, CURLOPT_URL, url_p);
switch_curl_easy_setopt(_curl_handle, CURLOPT_NOSIGNAL, 1);
switch_curl_easy_setopt(_curl_handle, CURLOPT_WRITEFUNCTION, FSCURL::FileCallback);
switch_curl_easy_setopt(_curl_handle, CURLOPT_WRITEDATA, (void *) this);
switch_curl_easy_setopt(_curl_handle, CURLOPT_USERAGENT, "freeswitch-v8-curl/1.0");
switch_curl_easy_perform(_curl_handle);
switch_curl_easy_getinfo(_curl_handle, CURLINFO_RESPONSE_CODE, &httpRes);
switch_curl_easy_cleanup(_curl_handle);
curl_slist_free_all(headers);
_curl_handle = NULL;
_function.Reset();
_user_data.Reset();
switch_safe_free(durl);
if (!_ret.IsEmpty()) {
info.GetReturnValue().Set(_ret);
_ret.Reset();
}
}
static const js_function_t curl_methods[] = {
{"run", FSCURL::Run},
{0}
};
static const js_property_t curl_props[] = {
{0}
};
static const js_class_definition_t curl_desc = {
js_class_name,
FSCURL::Construct,
curl_methods,
curl_props
};
static switch_status_t curl_load(const v8::FunctionCallbackInfo<Value>& info)
{
JSBase::Register(info.GetIsolate(), &curl_desc);
return SWITCH_STATUS_SUCCESS;
}
static const v8_mod_interface_t curl_module_interface = {
/*.name = */ js_class_name,
/*.js_mod_load */ curl_load
};
const v8_mod_interface_t *FSCURL::GetModuleInterface()
{
return &curl_module_interface;
}
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
*/
/*
* mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2013-2014, Peter Olsson <peter@olssononline.se>
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* Ported from the Original Code in FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is
* Anthony Minessale II <anthm@freeswitch.org>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Peter Olsson <peter@olssononline.se>
* Anthony Minessale II <anthm@freeswitch.org>
* William King <william.king@quentustech.com>
*
* fsdtmf.cpp -- JavaScript DTMF class
*
*/
#include "fsdtmf.hpp"
using namespace std;
using namespace v8;
static const char js_class_name[] = "DTMF";
FSDTMF::~FSDTMF(void)
{
switch_safe_free(_dtmf);
}
string FSDTMF::GetJSClassName()
{
return js_class_name;
}
Handle<Object> FSDTMF::New(switch_dtmf_t *dtmf, const char *name, JSMain *js)
{
FSDTMF *obj;
switch_dtmf_t *ddtmf;
if ((obj = new FSDTMF(js))) {
if ((ddtmf = (switch_dtmf_t *)malloc(sizeof(*ddtmf)))) {
*ddtmf = *dtmf;
obj->_dtmf = ddtmf;
obj->RegisterInstance(obj->GetIsolate(), js_safe_str(name), true);
return obj->GetJavaScriptObject();
} else {
delete obj;
}
}
return Handle<Object>();
}
void *FSDTMF::Construct(const v8::FunctionCallbackInfo<Value>& info)
{
HandleScope handle_scope(info.GetIsolate());
switch_dtmf_t *dtmf;
int32_t duration = switch_core_default_dtmf_duration(0);
const char *dtmf_char;
if (info.Length() <= 0) {
info.GetIsolate()->ThrowException(String::NewFromUtf8(info.GetIsolate(), "Invalid Args"));
return NULL;
}
String::Utf8Value str(info[0]);
dtmf_char = *str;
if (info.Length() > 1) {
duration = info[1]->Int32Value();
if (duration <= 0) {
duration = switch_core_default_dtmf_duration(0);
}
}
if ((dtmf = (switch_dtmf_t *)malloc(sizeof(*dtmf)))) {
FSDTMF *obj = new FSDTMF(info);
obj->_dtmf = dtmf;
if (dtmf_char && *dtmf_char) {
obj->_dtmf->digit = *dtmf_char;
}
obj->_dtmf->duration = duration;
return obj;
}
info.GetIsolate()->ThrowException(String::NewFromUtf8(info.GetIsolate(), "Memory error"));
return NULL;
}
JS_DTMF_GET_PROPERTY_IMPL(GetProperty)
{
HandleScope handle_scope(info.GetIsolate());
FSDTMF *obj = JSBase::GetInstance<FSDTMF>(info.Holder());
if (!obj) {
info.GetReturnValue().Set(false);
return;
}
String::Utf8Value str(property);
const char *prop = js_safe_str(*str);
if (!strcmp(prop, "digit")) {
char tmp[2] = { obj->_dtmf->digit, '\0' };
info.GetReturnValue().Set(String::NewFromUtf8(info.GetIsolate(), tmp));
} else if (!strcmp(prop, "duration")) {
info.GetReturnValue().Set(Integer::New(info.GetIsolate(), obj->_dtmf->duration));
} else {
info.GetIsolate()->ThrowException(String::NewFromUtf8(info.GetIsolate(), "Bad property"));
}
}
static const js_function_t dtmf_proc[] = {
{0}
};
static const js_property_t dtmf_prop[] = {
{"digit", FSDTMF::GetProperty, JSBase::DefaultSetProperty},
{"duration", FSDTMF::GetProperty, JSBase::DefaultSetProperty},
{0}
};
static const js_class_definition_t dtmf_desc = {
js_class_name,
FSDTMF::Construct,
dtmf_proc,
dtmf_prop
};
const js_class_definition_t *FSDTMF::GetClassDefinition()
{
return &dtmf_desc;
}
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
*/
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
/*
* mod_v8 for FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2013-2014, Peter Olsson <peter@olssononline.se>
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* Ported from the Original Code in FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is
* Anthony Minessale II <anthm@freeswitch.org>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Peter Olsson <peter@olssononline.se>
* Anthony Minessale II <anthm@freeswitch.org>
* William King <william.king@quentustech.com>
*
* fspcre.cpp -- JavaScript PCRE class
*
*/
#include "fspcre.hpp"
using namespace std;
using namespace v8;
static const char js_class_name[] = "PCRE";
FSPCRE::~FSPCRE(void)
{
if (!_freed && _re) {
switch_regex_safe_free(_re);
switch_safe_free(_str);
}
}
string FSPCRE::GetJSClassName()
{
return js_class_name;
}
void FSPCRE::Init()
{
_re = NULL;
_str = NULL;
_proceed = 0;
memset(&_ovector, 0, sizeof(_ovector));
_freed = 0;
}
void *FSPCRE::Construct(const v8::FunctionCallbackInfo<Value>& info)
{
return new FSPCRE(info);
}
JS_PCRE_FUNCTION_IMPL(Compile)
{
HandleScope handle_scope(info.GetIsolate());
const char *string, *regex_string;
if (info.Length() > 1) {
String::Utf8Value str1(info[0]);
String::Utf8Value str2(info[1]);
string = js_safe_str(*str1);
regex_string = js_safe_str(*str2);
switch_regex_safe_free(this->_re);
switch_safe_free(this->_str);
js_strdup(this->_str, string);
this->_proceed = switch_regex_perform(this->_str, regex_string, &this->_re, this->_ovector,
sizeof(this->_ovector) / sizeof(this->_ovector[0]));
info.GetReturnValue().Set(this->_proceed ? true : false);
} else {
info.GetIsolate()->ThrowException(String::NewFromUtf8(info.GetIsolate(), "Invalid args"));
}
}
JS_PCRE_FUNCTION_IMPL(Substitute)
{
HandleScope handle_scope(info.GetIsolate());
const char *subst_string;
char *substituted;
if (!this->_proceed) {
info.GetIsolate()->ThrowException(String::NewFromUtf8(info.GetIsolate(), "REGEX is not compiled or has no matches"));
return;
}
if (info.Length() > 0) {
uint32_t len;
String::Utf8Value str(info[0]);
subst_string = js_safe_str(*str);
len = (uint32_t) (strlen(this->_str) + strlen(subst_string) + 10) * this->_proceed;
substituted = (char *)malloc(len);
switch_assert(substituted != NULL);
switch_perform_substitution(this->_re, this->_proceed, subst_string, this->_str, substituted, len, this->_ovector);
info.GetReturnValue().Set(String::NewFromUtf8(info.GetIsolate(), substituted));
free(substituted);
} else {
info.GetIsolate()->ThrowException(String::NewFromUtf8(info.GetIsolate(), "Invalid Args"));
}
}
JS_PCRE_GET_PROPERTY_IMPL(GetProperty)
{
HandleScope handle_scope(info.GetIsolate());
String::Utf8Value str(property);
if (!strcmp(js_safe_str(*str), "ready")) {
info.GetReturnValue().Set(true);
} else {
info.GetIsolate()->ThrowException(String::NewFromUtf8(info.GetIsolate(), "Bad property"));
}
}
static const js_function_t pcre_proc[] = {
{"compile", FSPCRE::Compile},
{"substitute", FSPCRE::Substitute},
{0}
};
static const js_property_t pcre_prop[] = {
{"ready", FSPCRE::GetProperty, JSBase::DefaultSetProperty},
{0}
};
static const js_class_definition_t pcre_desc = {
js_class_name,
FSPCRE::Construct,
pcre_proc,
pcre_prop
};
const js_class_definition_t *FSPCRE::GetClassDefinition()
{
return &pcre_desc;
}
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
*/
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets">
<Import Project="curl.props" Condition=" '$(CurlPropsImported)' == '' "/>
</ImportGroup>
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
<AdditionalIncludeDirectories>$(SolutionDir)libs\v8-3.24.14\include;$(SolutionDir)src\mod\languages\mod_v8;$(SolutionDir)src\mod\languages\mod_v8\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<AdditionalLibraryDirectories>$(SolutionDir)libs\v8-3.24.14\build\$(Configuration)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>icui18n.lib;icuuc.lib;v8.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
</Project>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论