mirror of
https://github.com/netzbegruenung/jitsi-meet-electron.git
synced 2024-05-08 11:43:42 +02:00
fix(): Issues related to requesting permissions
This commit is contained in:
parent
ded3650705
commit
26a6d2bbae
|
@ -67,7 +67,6 @@ class RemoteControl {
|
|||
init(channel, windowManager) {
|
||||
this.windowManager = windowManager;
|
||||
this.channel = channel;
|
||||
this.start();
|
||||
this.channel.ready(() => {
|
||||
this.channel.listen(REMOTE_CONTROL_EVENT_TYPE,
|
||||
event => this.onRemoteControlEvent(event));
|
||||
|
@ -75,6 +74,15 @@ class RemoteControl {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Disposes the remote control functionality.
|
||||
*/
|
||||
dispose() {
|
||||
this.windowManager = null;
|
||||
this.channel = null;
|
||||
this.stop();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles permission requests from Jitsi Meet.
|
||||
* @param {object} userInfo - information about the user that has requested
|
||||
|
@ -82,6 +90,8 @@ class RemoteControl {
|
|||
* @param {string} userInfo.displayName - display name
|
||||
* @param {string} userInfo.userJID - the JID of the user.
|
||||
* @param {string} userInfo.userId - the user id (the resource of the JID)
|
||||
* @param {boolean} userInfo.screenSharing - true if the screen sharing
|
||||
* is started.
|
||||
*/
|
||||
handlePermissionRequest(userInfo) {
|
||||
this.windowManager.requestRemoteControlPermissions(userInfo)
|
||||
|
@ -119,7 +129,6 @@ class RemoteControl {
|
|||
* @param {Object} event the remote-control-event.
|
||||
*/
|
||||
onRemoteControlEvent(event) {
|
||||
|
||||
if(!this.started && event.type !== EVENT_TYPES.permissions) {
|
||||
return;
|
||||
}
|
||||
|
@ -171,7 +180,9 @@ class RemoteControl {
|
|||
this.handlePermissionRequest({
|
||||
userId: event.userId,
|
||||
userJID: event.userJID,
|
||||
displayName: event.displayName});
|
||||
displayName: event.displayName,
|
||||
screenSharing: event.screenSharing
|
||||
});
|
||||
break;
|
||||
}
|
||||
case EVENT_TYPES.stop: {
|
||||
|
|
|
@ -34,16 +34,24 @@ class DialogFactory {
|
|||
* request:
|
||||
* @param {string} userInfo.displayName - display name
|
||||
* @param {string} userInfo.userJID - the JID of the user.
|
||||
* @param {boolean} userInfo.screenSharing - true if the screen sharing
|
||||
* is started.
|
||||
*/
|
||||
requestRemoteControlPermissions(userInfo) {
|
||||
return new Promise( resolve =>
|
||||
dialog.showMessageBox({
|
||||
type: "question",
|
||||
buttons: ["Yes", "No"],
|
||||
buttons: [
|
||||
"Yes",
|
||||
"No"
|
||||
],
|
||||
defaultId: 0,
|
||||
title: "Request for permission for remote control",
|
||||
message: "Would you like to allow " + userInfo.displayName
|
||||
+ " to remotely control your desktop.",
|
||||
+ " to remotely control your desktop?"
|
||||
+ (userInfo.screenSharing ? ""
|
||||
: "\nNote: If you press \"Yes\" the screen sharing "
|
||||
+ "will start!"),
|
||||
detail: "userId: " + userInfo.userJID,
|
||||
cancelId: 1
|
||||
}, response => resolve(response === 0? true : false))
|
||||
|
@ -56,13 +64,6 @@ class DialogFactory {
|
|||
*/
|
||||
const dialogFactory = new DialogFactory();
|
||||
|
||||
/**
|
||||
* Boolean variable that indicates whether the onloaded function was already
|
||||
* called.
|
||||
* NOTE: Used to not initialize more thean once some objects.
|
||||
*/
|
||||
let loaded = false;
|
||||
|
||||
/**
|
||||
* Handles loaded event for iframe:
|
||||
* Enables screen sharing functionality to the iframe webpage.
|
||||
|
@ -70,14 +71,20 @@ let loaded = false;
|
|||
* Initializes remote control.
|
||||
*/
|
||||
function onload() {
|
||||
loaded = true;
|
||||
setupScreenSharingForWindow(iframe.contentWindow);
|
||||
if(loaded) {
|
||||
return;
|
||||
}
|
||||
iframe.contentWindow.onunload = onunload;
|
||||
channel = postis({
|
||||
window: iframe.contentWindow,
|
||||
windowForEventListening: window
|
||||
});
|
||||
remoteControl.init(channel, dialogFactory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the postis objects and remoteControl.
|
||||
*/
|
||||
function onunload() {
|
||||
channel.destroy();
|
||||
channel = null;
|
||||
remoteControl.dispose();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue