/* * Copyright (C) 2004-2021 Savoir-faire Linux Inc. * * Author: Emeric Vigier * Author: Asad Salman * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* File : nodejs_interface.i */ %module (directors="1") JamiService #define SWIG_JAVA_ATTACH_CURRENT_THREAD_AS_DAEMON %include "typemaps.i" %include "std_string.i" /* std::string typemaps */ %include "arrays_javascript.i"; %include "carrays.i"; %include "std_map.i"; %include "std_vector.i"; %include "stdint.i"; /* Avoid uint64_t to be converted to BigInteger */ %apply int64_t { uint64_t }; namespace std { %extend map { std::vector keys() const { std::vector k; k.reserve($self->size()); for (const auto& i : *$self) { k.push_back(i.first); } return k; } void setRaw(std::string key, const vector& value) { (*$self)[key] = std::string(value.data(), value.data()+value.size()); } std::vector getRaw(std::string key) { auto& v = $self->at(key); return {v.begin(), v.end()}; } } %template(StringMap) map; %template(StringVect) vector; %template(VectMap) vector< map >; %template(IntegerMap) map; %template(IntVect) vector; %template(UintVect) vector; %template(Blob) vector; %template(FloatVect) vector; } /* not parsed by SWIG but needed by generated C files */ %header %{ #include %} %include "managerimpl.i" %include "callmanager.i" %include "configurationmanager.i" %include "presencemanager.i" %include "callmanager.i" %include "videomanager.i" %header %{ #include "callback.h" %} //typemap for passing Callbacks %typemap(in) v8::Local { $1 = v8::Local::Cast($input); } //typemap for handling map of functions %typemap(in) SWIGV8_VALUE { $1 = $input; } %typemap(in) const SWIGV8_VALUE { $1 = $input; } %typemap(varin) SWIGV8_VALUE { $result = $input; } %typemap(varin) const SWIGV8_VALUE { $result = $input; } %inline %{ /* some functions that need to be declared in *_wrap.cpp * that are not declared elsewhere in the c++ code */ void init(const SWIGV8_VALUE& funcMap){ parseCbMap(funcMap); uv_async_init(uv_default_loop(), &signalAsync, handlePendingSignals); using namespace std::placeholders; using std::bind; using DRing::exportable_callback; using DRing::ConfigurationSignal; using DRing::CallSignal; using SharedCallback = std::shared_ptr; const std::map callEvHandlers = { exportable_callback(bind(&callStateChanged, _1, _2, _3)), exportable_callback(bind(&incomingMessage, _1, _2, _3)), exportable_callback(bind(&incomingCall, _1, _2, _3)), }; const std::map configEvHandlers = { exportable_callback(bind(&accountsChanged)), exportable_callback(bind(®istrationStateChanged, _1, _2, _3, _4)), exportable_callback(bind(&contactAdded, _1, _2, _3 )), exportable_callback(bind(&contactRemoved, _1, _2, _3 )), exportable_callback(bind(&exportOnRingEnded, _1, _2, _3 )), exportable_callback(bind(&nameRegistrationEnded, _1, _2, _3 )), exportable_callback(bind(®isteredNameFound, _1, _2, _3, _4 )), exportable_callback(bind(&volatileDetailsChanged, _1, _2)), exportable_callback(bind(&knownDevicesChanged, _1, _2 )), exportable_callback(bind(&incomingAccountMessage, _1, _2, _3, _4 )), exportable_callback(bind(&accountMessageStatusChanged, _1, _2, _3, _4 )), exportable_callback(bind(&incomingTrustRequest, _1, _2, _3, _4 )), }; if (!DRing::init(static_cast(DRing::DRING_FLAG_DEBUG | DRing::DRING_FLAG_CONSOLE_LOG))) return; registerSignalHandlers(configEvHandlers); registerSignalHandlers(callEvHandlers); DRing::start(); } %} #ifndef SWIG /* some bad declarations */ #endif