// src/main/ipc/system-handlers.ts import { ipcMain, app, systemPreferences } from 'electron' import { IPC_CHANNELS } from '@d3ro/core/ipc-channels' import { ipcSuccess } from '@d3ro/core/errors' import type { PermissionStatus, PlaySoundParams, SetSoundEnabledParams } from '@d3ro/core/types' import { getSoundEffectService } from '../services/SoundEffectService' export function registerSystemHandlers(): void { ipcMain.handle(IPC_CHANNELS.SYSTEM.GET_PLATFORM, async () => { return ipcSuccess(process.platform) }) ipcMain.handle(IPC_CHANNELS.SYSTEM.GET_VERSION, async () => { return ipcSuccess(app.getVersion()) }) ipcMain.handle(IPC_CHANNELS.SYSTEM.CHECK_MIC_PERMISSION, async () => { let status: PermissionStatus = 'unknown' if (process.platform === 'darwin') { const macStatus = systemPreferences.getMediaAccessStatus('microphone') status = macStatus === 'granted' ? 'granted' : macStatus === 'denied' ? 'denied' : 'unknown' } else { // Windows: 마이크 권한은 별도 체크 불필요 (시스템 설정에서 관리) status = 'granted' } return ipcSuccess(status) }) // ── Sound Effect ── ipcMain.handle(IPC_CHANNELS.SYSTEM.PLAY_SOUND, async (_event, params: PlaySoundParams) => { getSoundEffectService().play(params.sound as 'recording-start' | 'recording-stop' | 'error' | 'cancel') return ipcSuccess(undefined) }) ipcMain.handle(IPC_CHANNELS.SYSTEM.SET_SOUND_ENABLED, async (_event, params: SetSoundEnabledParams) => { getSoundEffectService().setEnabled(params.enabled) return ipcSuccess(undefined) }) ipcMain.handle(IPC_CHANNELS.SYSTEM.IS_SOUND_ENABLED, async () => { return ipcSuccess(getSoundEffectService().isEnabled()) }) }