diff --git a/src/CallHandler.js b/src/CallHandler.js index 5b58400ae657..6f67a5f9efd0 100644 --- a/src/CallHandler.js +++ b/src/CallHandler.js @@ -1,6 +1,7 @@ /* Copyright 2015, 2016 OpenMarket Ltd Copyright 2017, 2018 New Vector Ltd +Copyright 2019 The Matrix.org Foundation C.I.C. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -64,6 +65,7 @@ import { showUnknownDeviceDialogForCalls } from './cryptodevices'; import WidgetUtils from './utils/WidgetUtils'; import WidgetEchoStore from './stores/WidgetEchoStore'; import ScalarAuthClient from './ScalarAuthClient'; +import SettingsStore, { SettingLevel } from './settings/SettingsStore'; global.mxCalls = { //room_id: MatrixCall @@ -117,8 +119,7 @@ function _reAttemptCall(call) { function _setCallListeners(call) { call.on("error", function(err) { - console.error("Call error: %s", err); - console.error(err.stack); + console.error("Call error:", err); if (err.code === 'unknown_devices') { const QuestionDialog = sdk.getComponent("dialogs.QuestionDialog"); @@ -146,8 +147,15 @@ function _setCallListeners(call) { }, }); } else { - const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); + if ( + MatrixClientPeg.get().getTurnServers().length === 0 && + SettingsStore.getValue("fallbackICEServerAllowed") === null + ) { + _showICEFallbackPrompt(_t("Call Failed")); + return; + } + const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); Modal.createTrackedDialog('Call Failed', '', ErrorDialog, { title: _t('Call Failed'), description: err.message, @@ -217,6 +225,39 @@ function _setCallState(call, roomId, status) { }); } +function _showICEFallbackPrompt(title) { + const cli = MatrixClientPeg.get(); + const QuestionDialog = sdk.getComponent("dialogs.QuestionDialog"); + const code = sub => {sub}; + Modal.createTrackedDialog('No TURN servers', '', QuestionDialog, { + title, + description:
+

{ _t( + "Your homeserver %(homeserverDomain)s is " + + "currently not configured to assist with calls by offering a " + + "TURN server, which means it is likely that voice and video " + + "calls will fail. Please notify your homeserver administrator " + + "so that they can address this.", + { homeserverDomain: cli.getDomain() }, { code }, + ) }

+

{ _t( + "Riot can use a fallback server turn.matrix.org " + + "if you urgently need to make a call. Your IP address would be " + + "shared with this fallback server only if you agree and later " + + "place or receive a call. You can change this permission later " + + "in the Voice & Video section of Settings.", + null, { code }, + )}

+
, + button: _t('Allow Fallback'), + cancelButton: _t('Dismiss'), + onFinished: (allow) => { + SettingsStore.setValue("fallbackICEServerAllowed", null, SettingLevel.DEVICE, allow); + cli.setFallbackICEServerAllowed(allow); + }, + }, null, true); +} + function _onAction(payload) { function placeCall(newCall) { _setCallListeners(newCall); @@ -270,6 +311,14 @@ function _onAction(payload) { return; } + if ( + MatrixClientPeg.get().getTurnServers().length === 0 && + SettingsStore.getValue("fallbackICEServerAllowed") === null + ) { + _showICEFallbackPrompt(_t("Homeserver not configured to support calls")); + return; + } + const room = MatrixClientPeg.get().getRoom(payload.room_id); if (!room) { console.error("Room %s does not exist.", payload.room_id); diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index f935303c0aa8..b8903076c768 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -1370,37 +1370,6 @@ export default React.createClass({ call: call, }, true); }); - cli.on('Call.noTURNServers', () => { - const QuestionDialog = sdk.getComponent("dialogs.QuestionDialog"); - const code = sub => {sub}; - Modal.createTrackedDialog('No TURN servers', '', QuestionDialog, { - title: _t('Homeserver not configured to support calls'), - description:
-

{ _t( - "Your homeserver %(homeserverDomain)s is " + - "currently not configured to assist with calls by offering a " + - "TURN server, which means it is likely that voice and video " + - "calls will fail. Please notify your homeserver administrator " + - "so that they can address this.", - { homeserverDomain: cli.getDomain() }, { code }, - ) }

-

{ _t( - "Riot can use a fallback server turn.matrix.org " + - "if you urgently need to make a call. Your IP address would be " + - "shared with this fallback server only if you agree and later " + - "place or receive a call. You can change this permission later " + - "in the Voice & Video section of Settings.", - null, { code }, - )}

-
, - button: _t('Allow Fallback'), - cancelButton: _t('Dismiss'), - onFinished: (allow) => { - SettingsStore.setValue("fallbackICEServerAllowed", null, SettingLevel.DEVICE, allow); - cli.setFallbackICEServerAllowed(allow); - }, - }, null, true); - }); cli.on('Session.logged_out', function(errObj) { if (Lifecycle.isLoggingOut()) return; diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 8c1ec230232d..1260ed3f4927 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -28,11 +28,16 @@ "Answer": "Answer", "Call Timeout": "Call Timeout", "The remote side failed to pick up": "The remote side failed to pick up", + "Your homeserver %(homeserverDomain)s is currently not configured to assist with calls by offering a TURN server, which means it is likely that voice and video calls will fail. Please notify your homeserver administrator so that they can address this.": "Your homeserver %(homeserverDomain)s is currently not configured to assist with calls by offering a TURN server, which means it is likely that voice and video calls will fail. Please notify your homeserver administrator so that they can address this.", + "Riot can use a fallback server turn.matrix.org if you urgently need to make a call. Your IP address would be shared with this fallback server only if you agree and later place or receive a call. You can change this permission later in the Voice & Video section of Settings.": "Riot can use a fallback server turn.matrix.org if you urgently need to make a call. Your IP address would be shared with this fallback server only if you agree and later place or receive a call. You can change this permission later in the Voice & Video section of Settings.", + "Allow Fallback": "Allow Fallback", + "Dismiss": "Dismiss", "Unable to capture screen": "Unable to capture screen", "Existing Call": "Existing Call", "You are already in a call.": "You are already in a call.", "VoIP is unsupported": "VoIP is unsupported", "You cannot place VoIP calls in this browser.": "You cannot place VoIP calls in this browser.", + "Homeserver not configured to support calls": "Homeserver not configured to support calls", "You cannot place a call with yourself.": "You cannot place a call with yourself.", "Could not connect to the integration server": "Could not connect to the integration server", "A conference call could not be started because the integrations server is not available": "A conference call could not be started because the integrations server is not available", @@ -94,7 +99,6 @@ "Unnamed Room": "Unnamed Room", "Error": "Error", "Unable to load! Check your network connectivity and try again.": "Unable to load! Check your network connectivity and try again.", - "Dismiss": "Dismiss", "Riot does not have permission to send you notifications - please check your browser settings": "Riot does not have permission to send you notifications - please check your browser settings", "Riot was not given permission to send notifications - please try again": "Riot was not given permission to send notifications - please try again", "Unable to enable Notifications": "Unable to enable Notifications", @@ -1490,10 +1494,6 @@ "Failed to leave room": "Failed to leave room", "Can't leave Server Notices room": "Can't leave Server Notices room", "This room is used for important messages from the Homeserver, so you cannot leave it.": "This room is used for important messages from the Homeserver, so you cannot leave it.", - "Homeserver not configured to support calls": "Homeserver not configured to support calls", - "Your homeserver %(homeserverDomain)s is currently not configured to assist with calls by offering a TURN server, which means it is likely that voice and video calls will fail. Please notify your homeserver administrator so that they can address this.": "Your homeserver %(homeserverDomain)s is currently not configured to assist with calls by offering a TURN server, which means it is likely that voice and video calls will fail. Please notify your homeserver administrator so that they can address this.", - "Riot can use a fallback server turn.matrix.org if you urgently need to make a call. Your IP address would be shared with this fallback server only if you agree and later place or receive a call. You can change this permission later in the Voice & Video section of Settings.": "Riot can use a fallback server turn.matrix.org if you urgently need to make a call. Your IP address would be shared with this fallback server only if you agree and later place or receive a call. You can change this permission later in the Voice & Video section of Settings.", - "Allow Fallback": "Allow Fallback", "Signed Out": "Signed Out", "For security, this session has been signed out. Please sign in again.": "For security, this session has been signed out. Please sign in again.", "Terms and Conditions": "Terms and Conditions",