Skip to content
Snippets Groups Projects
Commit d0496979 authored by Adrien Béraud's avatar Adrien Béraud
Browse files

nodejs: update JS wrapper

Change-Id: I127b987aa079b99f37346dad29291f1e2a2867bd
parent 1495e22e
No related branches found
No related tags found
No related merge requests found
......@@ -17,8 +17,9 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
"use strict";
"use strict";
class JamiDaemon {
constructor(callbackMap) {
if (callbackMap){
......@@ -28,12 +29,16 @@ class JamiDaemon {
}
boolToStr(bool) {
return bool ? "TRUE" : "FALSE";
return bool ? JamiDaemon.BOOL_TRUE : JamiDaemon.BOOL_FALSE;
}
addAccount(account) {
const params = new this.dring.StringMap();
params.set("Account.type", "RING");
if (account.managerUri)
params.set("Account.managerUri", account.managerUri);
if (account.managerUsername)
params.set("Account.managerUsername", account.managerUsername);
if (account.archivePassword) {
params.set("Account.archivePassword", account.archivePassword);
} else {
......@@ -56,9 +61,9 @@ class JamiDaemon {
params.set("Account.videoEnabled", this.boolToStr(account.videoEnabled));
if (account.useragent) {
params.set("Account.useragent", account.useragent);
params.set("Account.hasCustomUserAgent","TRUE");
params.set("Account.hasCustomUserAgent", JamiDaemon.BOOL_TRUE);
} else {
params.set("Account.hasCustomUserAgent","FALSE");
params.set("Account.hasCustomUserAgent", JamiDaemon.BOOL_FALSE);
}
if (account.audioPortMin)
params.set("Account.audioPortMin", account.audioPortMin);
......@@ -85,13 +90,22 @@ class JamiDaemon {
}
stringVectToArr(stringvect) {
const outputArr = [];
for(var i=0; i<stringvect.size(); i++)
for (let i = 0; i < stringvect.size(); i++)
outputArr.push(stringvect.get(i));
return outputArr;
}
mapToJs(m) {
const outputObj = {};
this.stringVectToArr(m.keys())
.forEach(k => outputObj[k] = m.get(k));
return outputObj;
}
getAccountList() {
return this.stringVectToArr(this.dring.getAccountList());
}
getAccountDetails(accountId) {
return this.mapToJs(this.dring.getAccountDetails(accountId));
}
getAudioOutputDeviceList() {
return this.stringVectToArr(this.dring.getAudioOutputDeviceList());
}
......@@ -108,4 +122,7 @@ class JamiDaemon {
}
}
JamiDaemon.BOOL_TRUE = "true"
JamiDaemon.BOOL_FALSE = "false"
module.exports = JamiDaemon;
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment