From 10f6af463b70c4fde35876c2c65580e4e45b7daf Mon Sep 17 00:00:00 2001 From: Asad Salman <me@asad.co> Date: Mon, 24 Jul 2017 08:07:43 +0500 Subject: [PATCH] nodejs: changes for electron compatibility Change-Id: Icfb6ca3858450eaf2b5bbfbb16fcc024c8c9d772 --- bin/nodejs/Makefile.am | 4 ++-- bin/nodejs/index.js | 27 ++++++++++++--------------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/bin/nodejs/Makefile.am b/bin/nodejs/Makefile.am index bc18443eb5..6d91b7cd76 100644 --- a/bin/nodejs/Makefile.am +++ b/bin/nodejs/Makefile.am @@ -9,11 +9,11 @@ ring_wrapper.cpp: nodejs_interface.i configurationmanager.i managerimpl.i $(SWIG) -v -c++ -javascript -node -o ring_wrapper.cpp nodejs_interface.i build/Makefile: ring_wrapper.cpp binding.gyp - node-gyp configure + node-gyp configure --target=1.6.2 --arch=x64 --dist-url=https://atom.io/download/electron build/Release/obj.target/dring.node: build/Makefile ring_wrapper.cpp callback.h node-gyp build CLEANFILES= \ $(BUILT_SOURCES) \ - build/Release/dring.node + build/Release/dring.node \ No newline at end of file diff --git a/bin/nodejs/index.js b/bin/nodejs/index.js index 5c9ea4eba3..e8becd7381 100755 --- a/bin/nodejs/index.js +++ b/bin/nodejs/index.js @@ -23,7 +23,7 @@ class RingDaemon{ constructor(callbackMap) { if(callbackMap){ - this.dring = require("./build/Release/dring"); + this.dring = require("./build/Release/dring.node"); this.dring.init(callbackMap); var that = this; this.pollIntervalId = setInterval(function () { @@ -92,16 +92,18 @@ class RingDaemon{ this.dring.addAccount(params); } - + stringVectToArr(stringvect){ + var outputArr = []; + for(var i=0; i<stringvect.size(); i++) + outputArr.push(stringvect.get(i)); + return outputArr; + } + getAccountList(){ + return this.stringVectToArr(this.dring.getAccountList()); + } getAudioOutputDeviceList() { - var devicesVect = this.dring.getAudioOutputDeviceList(); - var outputDevices = []; - for(var i=0; i<devicesVect.size(); i++) - outputDevices.push(devicesVect.get(i)); - - return outputDevices; + return this.stringVectToArr(this.dring.getAudioOutputDeviceList()); } - getVolume(deviceName) { return this.dring.getVolume(deviceName); } @@ -116,9 +118,4 @@ class RingDaemon{ } } -var f = function(){ - console.log("RegistrationStateChanged JS"); -}; - -var daemon = new RingDaemon({"RegistrationStateChanged": f}); -//daemon.stop(); \ No newline at end of file +module.exports = RingDaemon; \ No newline at end of file -- GitLab