diff --git a/src/CallHandler.js b/src/CallHandler.js index cf8460db6c..b3af0e8337 100644 --- a/src/CallHandler.js +++ b/src/CallHandler.js @@ -173,17 +173,27 @@ function _onAction(payload) { console.error("Unknown conf call type: %s", payload.type); } } + var ErrorDialog = sdk.getComponent("organisms.ErrorDialog"); switch (payload.action) { case 'place_call': if (module.exports.getAnyActiveCall()) { - var ErrorDialog = sdk.getComponent("organisms.ErrorDialog"); Modal.createDialog(ErrorDialog, { title: "Existing Call", description: "You are already in a call." }); return; // don't allow >1 call to be placed. } + + // if the runtime env doesn't do VoIP, whine. + if (!MatrixClientPeg.get().supportsVoip()) { + Modal.createDialog(ErrorDialog, { + title: "VoIP is unsupported", + description: "You cannot place VoIP calls in this browser." + }); + return; + } + var room = MatrixClientPeg.get().getRoom(payload.room_id); if (!room) { console.error("Room %s does not exist.", payload.room_id); @@ -218,11 +228,17 @@ function _onAction(payload) { case 'place_conference_call': console.log("Place conference call in %s", payload.room_id); if (!Modulator.hasConferenceHandler()) { - var ErrorDialog = sdk.getComponent("organisms.ErrorDialog"); Modal.createDialog(ErrorDialog, { description: "Conference calls are not supported in this client" }); - } else { + } + else if (!MatrixClientPeg.get().supportsVoip()) { + Modal.createDialog(ErrorDialog, { + title: "VoIP is unsupported", + description: "You cannot place VoIP calls in this browser." + }); + } + else { var ConferenceHandler = Modulator.getConferenceHandler(); ConferenceHandler.createNewMatrixCall( MatrixClientPeg.get(), payload.room_id @@ -238,6 +254,12 @@ function _onAction(payload) { payload.call.hangup("busy"); return; // don't allow >1 call to be received, hangup newer one. } + + // if the runtime env doesn't do VoIP, stop here. + if (!MatrixClientPeg.get().supportsVoip()) { + return; + } + var call = payload.call; _setCallListeners(call); _setCallState(call, call.roomId, "ringing"); diff --git a/src/TextForEvent.js b/src/TextForEvent.js index d784fa7c38..439d7b9ef5 100644 --- a/src/TextForEvent.js +++ b/src/TextForEvent.js @@ -1,3 +1,4 @@ +var MatrixClientPeg = require("./MatrixClientPeg"); function textForMemberEvent(ev) { // XXX: SYJS-16 "sender is sometimes null for join messages" @@ -78,12 +79,14 @@ function textForMessageEvent(ev) { function textForCallAnswerEvent(event) { var senderName = event.sender ? event.sender.name : "Someone"; - return senderName + " answered the call."; + var supported = MatrixClientPeg.get().supportsVoip() ? "" : " (not supported by this browser)"; + return senderName + " answered the call." + supported; }; function textForCallHangupEvent(event) { var senderName = event.sender ? event.sender.name : "Someone"; - return senderName + " ended the call."; + var supported = MatrixClientPeg.get().supportsVoip() ? "" : " (not supported by this browser)"; + return senderName + " ended the call." + supported; }; function textForCallInviteEvent(event) { @@ -94,7 +97,8 @@ function textForCallInviteEvent(event) { event.getContent().offer.sdp.indexOf('m=video') !== -1) { type = "video"; } - return senderName + " placed a " + type + " call."; + var supported = MatrixClientPeg.get().supportsVoip() ? "" : " (not supported by this browser)"; + return senderName + " placed a " + type + " call." + supported; }; var handlers = {