feat(remotecontrol): Implements config option that removes the auth window by default

Use the auth dialog provided by Jitsi Meet instead.
This commit is contained in:
hristoterezov 2017-05-04 11:52:23 -05:00 committed by Saúl Ibarra Corretgé
parent 26727cf8d8
commit a94732fff5
4 changed files with 35 additions and 18 deletions

View file

@ -1,3 +1,13 @@
module.exports = { module.exports = {
jitsiMeetURL: "https://meet.jit.si/" /**
* The URL of the Jitsi Meet deployment that will be used.
*/
jitsiMeetURL: "https://meet.jit.si/",
/**
* If true, the authorization of remote control will be handled by jitsi
* meet electron app. Otherwise the authorization will be handled in Jitsi
* Meet.
*/
handleRemoteControlAuthorization: false
}; };

View file

@ -25,7 +25,7 @@ module.exports = {
}, },
/** /**
* The type of remote control events sent trough the API module. * The name of remote control events sent trough the API module.
*/ */
REMOTE_CONTROL_EVENT_TYPE: "remote-control-event" REMOTE_CONTROL_EVENT_NAME: "remote-control-event"
}; };

View file

@ -1,6 +1,6 @@
let robot = require("robotjs"); let robot = require("robotjs");
const constants = require("../../modules/remotecontrol/constants"); const constants = require("../../modules/remotecontrol/constants");
const {EVENT_TYPES, PERMISSIONS_ACTIONS, REMOTE_CONTROL_EVENT_TYPE} = constants; const {EVENT_TYPES, PERMISSIONS_ACTIONS, REMOTE_CONTROL_EVENT_NAME} = constants;
/** /**
* Attaching to the window for debug purposes. * Attaching to the window for debug purposes.
@ -64,17 +64,21 @@ class RemoteControl {
/** /**
* Initializes the remote control functionality. * Initializes the remote control functionality.
*/ */
init(channel, windowManager) { init(channel, windowManager, handleAuthorization) {
this.handleAuthorization = handleAuthorization;
this.windowManager = windowManager; this.windowManager = windowManager;
this.channel = channel; this.channel = channel;
this.channel.ready(() => { this.channel.ready(() => {
this.channel.listen('message', message => { this.channel.listen('message', message => {
const event = message.data; const event = message.data;
if(event.name === REMOTE_CONTROL_EVENT_TYPE) { if(event.name === REMOTE_CONTROL_EVENT_NAME) {
this.onRemoteControlEvent(event); this.onRemoteControlEvent(event);
} }
}); });
this.sendEvent({type: EVENT_TYPES.supported}); this.sendEvent({type: EVENT_TYPES.supported});
if (!handleAuthorization) {
this.start();
}
}); });
} }
@ -177,16 +181,16 @@ class RemoteControl {
break; break;
} }
case EVENT_TYPES.permissions: { case EVENT_TYPES.permissions: {
if(event.action !== PERMISSIONS_ACTIONS.request) if(event.action === PERMISSIONS_ACTIONS.request
break; && this.handleAuthorization) {
// Open Dialog and answer
//Open Dialog and answer this.handlePermissionRequest({
this.handlePermissionRequest({ userId: event.userId,
userId: event.userId, userJID: event.userJID,
userJID: event.userJID, displayName: event.displayName,
displayName: event.displayName, screenSharing: event.screenSharing
screenSharing: event.screenSharing });
}); }
break; break;
} }
case EVENT_TYPES.stop: { case EVENT_TYPES.stop: {
@ -204,7 +208,7 @@ class RemoteControl {
*/ */
sendEvent(event) { sendEvent(event) {
const remoteControlEvent = Object.assign( const remoteControlEvent = Object.assign(
{ name: REMOTE_CONTROL_EVENT_TYPE }, { name: REMOTE_CONTROL_EVENT_NAME },
event event
); );
this.channel.send({ this.channel.send({

View file

@ -78,7 +78,10 @@ function onload() {
window: iframe.contentWindow, window: iframe.contentWindow,
windowForEventListening: window windowForEventListening: window
}); });
remoteControl.init(channel, dialogFactory); remoteControl.init(
channel,
dialogFactory,
config.handleRemoteControlAuthorization);
} }
/** /**