mirror of
https://github.com/netzbegruenung/jitsi-meet-electron.git
synced 2024-04-27 06:24:52 +02:00
84 lines
2 KiB
JavaScript
84 lines
2 KiB
JavaScript
/* global __dirname, process */
|
|
//Electron includes
|
|
const electron = require("electron");
|
|
const APP = electron.app;
|
|
const BrowserWindow = electron.BrowserWindow;
|
|
|
|
const path = require("path");
|
|
const url = require("url");
|
|
|
|
/**
|
|
* URL for index.html which will be our entry point.
|
|
*/
|
|
const indexURL = url.format({
|
|
pathname: path.join(__dirname, "windows", "jitsi-meet", "index.html"),
|
|
protocol: "file:",
|
|
slashes: true
|
|
});
|
|
|
|
/**
|
|
* The window object that will load the iframe with Jitsi Meet.
|
|
* IMPORTANT: Must be defined as global in order to not be garbage collected
|
|
* acidentally.
|
|
*/
|
|
let jitsiMeetWindow = null;
|
|
|
|
/**
|
|
* Options used when creating the main Jitsi Meet window.
|
|
*/
|
|
const jitsiMeetWindowOptions = {
|
|
width: 800,
|
|
height: 600,
|
|
minWidth: 800,
|
|
minHeight: 600,
|
|
titleBarStyle: 'hidden'
|
|
};
|
|
|
|
/**
|
|
* Sets the APP object listeners.
|
|
*/
|
|
function setAPPListeners () {
|
|
APP.on("ready", createJitsiMeetWindow);
|
|
APP.on("window-all-closed", () => {
|
|
// Don"t quit the application for Mac OS
|
|
if (process.platform !== "darwin") {
|
|
APP.quit();
|
|
}
|
|
});
|
|
APP.on("activate", () => {
|
|
if (jitsiMeetWindow === null) {
|
|
createJitsiMeetWindow();
|
|
}
|
|
});
|
|
APP.on('certificate-error',
|
|
(event, webContents, url, error, certificate, callback) => {
|
|
if (url.startsWith('https://localhost')) {
|
|
event.preventDefault();
|
|
callback(true);
|
|
} else {
|
|
callback(false);
|
|
}
|
|
}
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Opens new window with index.html(Jitsi Meet is loaded in iframe there).
|
|
*/
|
|
function createJitsiMeetWindow () {
|
|
jitsiMeetWindow = new BrowserWindow(jitsiMeetWindowOptions);
|
|
jitsiMeetWindow.loadURL(indexURL);
|
|
|
|
jitsiMeetWindow.webContents.on('new-window', function(event, url) {
|
|
event.preventDefault();
|
|
electron.shell.openExternal(url);
|
|
});
|
|
|
|
jitsiMeetWindow.on("closed", () => {
|
|
jitsiMeetWindow = null;
|
|
});
|
|
}
|
|
|
|
//Start the application:
|
|
setAPPListeners();
|