2026-03-20 20:06:21 +02:00
|
|
|
import { app, ipcMain, shell } from 'electron';
|
|
|
|
|
import { IPC_CHANNELS } from './channels';
|
2026-04-02 13:26:32 +02:00
|
|
|
import {
|
|
|
|
|
getPermissionsStatus,
|
|
|
|
|
requestAccessibility,
|
2026-04-03 19:57:48 +02:00
|
|
|
requestScreenRecording,
|
2026-04-02 13:26:32 +02:00
|
|
|
restartApp,
|
|
|
|
|
} from '../modules/permissions';
|
2026-03-20 20:06:21 +02:00
|
|
|
|
|
|
|
|
export function registerIpcHandlers(): void {
|
|
|
|
|
ipcMain.on(IPC_CHANNELS.OPEN_EXTERNAL, (_event, url: string) => {
|
|
|
|
|
try {
|
|
|
|
|
const parsed = new URL(url);
|
|
|
|
|
if (parsed.protocol === 'http:' || parsed.protocol === 'https:') {
|
|
|
|
|
shell.openExternal(url);
|
|
|
|
|
}
|
|
|
|
|
} catch {
|
|
|
|
|
// invalid URL — ignore
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
ipcMain.handle(IPC_CHANNELS.GET_APP_VERSION, () => {
|
|
|
|
|
return app.getVersion();
|
|
|
|
|
});
|
2026-04-02 13:26:32 +02:00
|
|
|
|
|
|
|
|
ipcMain.handle(IPC_CHANNELS.GET_PERMISSIONS_STATUS, () => {
|
|
|
|
|
return getPermissionsStatus();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
ipcMain.handle(IPC_CHANNELS.REQUEST_ACCESSIBILITY, () => {
|
|
|
|
|
requestAccessibility();
|
|
|
|
|
});
|
|
|
|
|
|
2026-04-03 19:57:48 +02:00
|
|
|
ipcMain.handle(IPC_CHANNELS.REQUEST_SCREEN_RECORDING, () => {
|
|
|
|
|
requestScreenRecording();
|
|
|
|
|
});
|
|
|
|
|
|
2026-04-02 13:26:32 +02:00
|
|
|
ipcMain.handle(IPC_CHANNELS.RESTART_APP, () => {
|
|
|
|
|
restartApp();
|
|
|
|
|
});
|
2026-03-20 20:06:21 +02:00
|
|
|
}
|