From e494c3028daf656db86d5234dca22dbb65252acc Mon Sep 17 00:00:00 2001 From: hristoterezov Date: Tue, 29 Dec 2015 17:52:24 -0600 Subject: [PATCH] Adds SIP calls support --- app.js | 13 +++++-------- libs/lib-jitsi-meet.js | 20 +++++++++++++++++++- modules/UI/toolbars/Toolbar.js | 2 +- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/app.js b/app.js index 3d1f7e687..61bbf63bc 100644 --- a/app.js +++ b/app.js @@ -86,7 +86,6 @@ const APP = { membersCount: 0, audioMuted: false, videoMuted: false, - sipGatewayEnabled: false, //FIXME handle isLocalId (id) { return this.localId === id; }, @@ -186,6 +185,10 @@ function initConference(localTracks, connection) { APP.UI.addLocalStream(track); }; + APP.conference.sipGatewayEnabled = () => { + return room.isSIPCallingSupported(); + }; + function getDisplayName(id) { if (APP.conference.isLocalId(id)) { return APP.settings.getDisplayName(); @@ -442,13 +445,7 @@ function initConference(localTracks, connection) { }); APP.UI.addListener(UIEvents.SIP_DIAL, function (sipNumber) { - // FIXME add dial - // APP.xmpp.dial( - // sipNumber, - // 'fromnumber', - // APP.conference.roomName, - // roomLocker.password - // ); + room.dial(sipNumber); }); diff --git a/libs/lib-jitsi-meet.js b/libs/lib-jitsi-meet.js index 251e21076..fd5ab62f4 100644 --- a/libs/lib-jitsi-meet.js +++ b/libs/lib-jitsi-meet.js @@ -579,6 +579,15 @@ JitsiConference.prototype.toggleRecording = function (token, followEntity) { reject(new Error("The conference is not created yet!"))}); } +/** + * Returns true if the SIP calls are supported and false otherwise + */ +JitsiConference.prototype.isSIPCallingSupported = function () { + if(this.room) + return this.room.isSIPCallingSupported(); + return false; +} + /** * Dials a number. * @param number the number @@ -6753,6 +6762,15 @@ ChatRoom.prototype.toggleRecording = function (token, followEntity) { reject(new Error("The conference is not created yet!"))}); } +/** + * Returns true if the SIP calls are supported and false otherwise + */ +ChatRoom.prototype.isSIPCallingSupported = function () { + if(this.moderator) + return this.moderator.isSipGatewayEnabled(); + return false; +} + /** * Dials a number. * @param number the number @@ -10552,7 +10570,7 @@ function Moderator(roomName, xmpp, emitter) { // Sip gateway can be enabled by configuring Jigasi host in config.js or // it will be enabled automatically if focus detects the component through // service discovery. - this.sipGatewayEnabled = + this.sipGatewayEnabled = this.xmppService.options.hosts && this.xmppService.options.hosts.call_control !== undefined; this.eventEmitter = emitter; diff --git a/modules/UI/toolbars/Toolbar.js b/modules/UI/toolbars/Toolbar.js index 72431d0c4..ee43423ad 100644 --- a/modules/UI/toolbars/Toolbar.js +++ b/modules/UI/toolbars/Toolbar.js @@ -311,7 +311,7 @@ const Toolbar = { // Shows or hides SIP calls button showSipCallButton (show) { - if (APP.conference.sipGatewayEnabled && UIUtil.isButtonEnabled('sip') && show) { + if (APP.conference.sipGatewayEnabled() && UIUtil.isButtonEnabled('sip') && show) { $('#toolbar_button_sip').css({display: "inline-block"}); } else { $('#toolbar_button_sip').css({display: "none"});