Unverified Commit 3fc78d78 authored by Pavel Ševčík's avatar Pavel Ševčík
Browse files

get mediaAccess from main process

parent c6ed1f33
......@@ -10,13 +10,13 @@
*
* @flow
*/
import { app, BrowserWindow, ipcMain } from 'electron';
import { app, BrowserWindow, ipcMain, systemPreferences } from 'electron';
import { autoUpdater } from 'electron-updater';
import log from 'electron-log';
import MenuBuilder from './menu';
import { CliLocal } from './mainProcess/cliLocal';
import fs from "fs";
import { GUI_LOG_FILE } from './const';
import { GUI_LOG_FILE, IPC_CAMERA } from './const';
export default class AppUpdater {
......@@ -91,6 +91,20 @@ else {
}
});
ipcMain.on(IPC_CAMERA.REQUEST, async (event) => {
if (process.platform !== 'darwin' || systemPreferences.getMediaAccessStatus("camera") !== "granted") {
event.reply(IPC_CAMERA.GRANTED)
} else {
const granted = await systemPreferences.askForMediaAccess("camera");
if (granted) {
event.reply(IPC_CAMERA.GRANTED)
} else {
event.reply(IPC_CAMERA.DENIED)
}
}
});
// init cliLocal
const guiLogStream = fs.createWriteStream(GUI_LOG_FILE, { flags: 'a' })
new CliLocal(ipcMain, mainWindow.webContents, guiLogStream)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment