feature/IO-3205-Paint-Scale-Integrations: init
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
// main/ipcMainConfig.ts
|
||||
import { app, ipcMain } from "electron";
|
||||
import log from "electron-log/main";
|
||||
import { autoUpdater } from "electron-updater";
|
||||
@@ -16,6 +17,12 @@ import {
|
||||
SettingsWatcherPollingSet,
|
||||
SettingEmsOutFilePathSet,
|
||||
SettingEmsOutFilePathGet,
|
||||
SettingsPaintScaleInputConfigsGet,
|
||||
SettingsPaintScaleInputConfigsSet,
|
||||
SettingsPaintScaleInputPathSet,
|
||||
SettingsPaintScaleOutputConfigsGet,
|
||||
SettingsPaintScaleOutputConfigsSet,
|
||||
SettingsPaintScaleOutputPathSet,
|
||||
} from "./ipcMainHandler.settings";
|
||||
import {
|
||||
ipcMainHandleAuthStateChanged,
|
||||
@@ -24,23 +31,19 @@ import {
|
||||
|
||||
// Log all IPC messages and their payloads
|
||||
const logIpcMessages = (): void => {
|
||||
// Get all message types from ipcTypes.toMain
|
||||
Object.keys(ipcTypes.toMain).forEach((key) => {
|
||||
const messageType = ipcTypes.toMain[key];
|
||||
|
||||
// Wrap the original handler with our logging
|
||||
const originalHandler = ipcMain.listeners(messageType)[0];
|
||||
const originalHandler = ipcMain.listeners(messageType)?.[0];
|
||||
if (originalHandler) {
|
||||
ipcMain.removeAllListeners(messageType);
|
||||
}
|
||||
ipcMain.on(messageType, (event, payload) => {
|
||||
log.info(
|
||||
`%c[IPC Main]%c${messageType}`,
|
||||
"color: red",
|
||||
"color: green",
|
||||
payload,
|
||||
`%c[IPC Main]%c${messageType}`,
|
||||
"color: red",
|
||||
"color: green",
|
||||
payload,
|
||||
);
|
||||
// Call original handler if it existed
|
||||
if (originalHandler) {
|
||||
originalHandler(event, payload);
|
||||
}
|
||||
@@ -49,20 +52,19 @@ const logIpcMessages = (): void => {
|
||||
};
|
||||
|
||||
ipcMain.on(ipcTypes.toMain.test, () =>
|
||||
console.log("** Verify that ipcMain is loaded and working."),
|
||||
console.log("** Verify that ipcMain is loaded and working."),
|
||||
);
|
||||
|
||||
//Auth handler
|
||||
// Auth handler
|
||||
ipcMain.on(ipcTypes.toMain.authStateChanged, ipcMainHandleAuthStateChanged);
|
||||
ipcMain.on(ipcTypes.toMain.user.resetPassword, ipMainHandleResetPassword);
|
||||
|
||||
//Add debug handlers if in development
|
||||
// Add debug handlers if in development
|
||||
if (import.meta.env.DEV) {
|
||||
log.debug("[IPC Debug Functions] Adding Debug Handlers");
|
||||
|
||||
ipcMain.on(ipcTypes.toMain.debug.decodeEstimate, async (): Promise<void> => {
|
||||
const relativeEmsFilepath = `_reference/ems/MPI_1/3698420.ENV`;
|
||||
// Get the app's root directory and create an absolute path
|
||||
const rootDir = app.getAppPath();
|
||||
const absoluteFilepath = path.join(rootDir, relativeEmsFilepath);
|
||||
|
||||
@@ -76,44 +78,72 @@ if (import.meta.env.DEV) {
|
||||
});
|
||||
}
|
||||
|
||||
//Settings Handlers
|
||||
// Settings Handlers
|
||||
ipcMain.handle(
|
||||
ipcTypes.toMain.settings.filepaths.get,
|
||||
SettingsWatchedFilePathsGet,
|
||||
ipcTypes.toMain.settings.filepaths.get,
|
||||
SettingsWatchedFilePathsGet,
|
||||
);
|
||||
ipcMain.handle(
|
||||
ipcTypes.toMain.settings.filepaths.add,
|
||||
SettingsWatchedFilePathsAdd,
|
||||
ipcTypes.toMain.settings.filepaths.add,
|
||||
SettingsWatchedFilePathsAdd,
|
||||
);
|
||||
ipcMain.handle(
|
||||
ipcTypes.toMain.settings.filepaths.remove,
|
||||
SettingsWatchedFilePathsRemove,
|
||||
ipcTypes.toMain.settings.filepaths.remove,
|
||||
SettingsWatchedFilePathsRemove,
|
||||
);
|
||||
ipcMain.handle(
|
||||
ipcTypes.toMain.settings.watcher.getpolling,
|
||||
SettingsWatcherPollingGet,
|
||||
ipcTypes.toMain.settings.watcher.getpolling,
|
||||
SettingsWatcherPollingGet,
|
||||
);
|
||||
ipcMain.handle(
|
||||
ipcTypes.toMain.settings.watcher.setpolling,
|
||||
SettingsWatcherPollingSet,
|
||||
ipcTypes.toMain.settings.watcher.setpolling,
|
||||
SettingsWatcherPollingSet,
|
||||
);
|
||||
|
||||
ipcMain.handle(ipcTypes.toMain.settings.getPpcFilePath, SettingsPpcFilePathGet);
|
||||
ipcMain.handle(ipcTypes.toMain.settings.setPpcFilePath, SettingsPpcFilePathSet);
|
||||
ipcMain.handle(
|
||||
ipcTypes.toMain.settings.getEmsOutFilePath,
|
||||
SettingEmsOutFilePathGet,
|
||||
ipcTypes.toMain.settings.getEmsOutFilePath,
|
||||
SettingEmsOutFilePathGet,
|
||||
);
|
||||
ipcMain.handle(
|
||||
ipcTypes.toMain.settings.setEmsOutFilePath,
|
||||
SettingEmsOutFilePathSet,
|
||||
ipcTypes.toMain.settings.setEmsOutFilePath,
|
||||
SettingEmsOutFilePathSet,
|
||||
);
|
||||
|
||||
// Paint Scale Input Settings Handlers
|
||||
ipcMain.handle(
|
||||
ipcTypes.toMain.settings.paintScale.getInputConfigs,
|
||||
SettingsPaintScaleInputConfigsGet,
|
||||
);
|
||||
ipcMain.handle(
|
||||
ipcTypes.toMain.settings.paintScale.setInputConfigs,
|
||||
SettingsPaintScaleInputConfigsSet,
|
||||
);
|
||||
ipcMain.handle(
|
||||
ipcTypes.toMain.settings.paintScale.setInputPath,
|
||||
SettingsPaintScaleInputPathSet,
|
||||
);
|
||||
|
||||
// Paint Scale Output Settings Handlers
|
||||
ipcMain.handle(
|
||||
ipcTypes.toMain.settings.paintScale.getOutputConfigs,
|
||||
SettingsPaintScaleOutputConfigsGet,
|
||||
);
|
||||
ipcMain.handle(
|
||||
ipcTypes.toMain.settings.paintScale.setOutputConfigs,
|
||||
SettingsPaintScaleOutputConfigsSet,
|
||||
);
|
||||
ipcMain.handle(
|
||||
ipcTypes.toMain.settings.paintScale.setOutputPath,
|
||||
SettingsPaintScaleOutputPathSet,
|
||||
);
|
||||
|
||||
ipcMain.handle(ipcTypes.toMain.user.getActiveShop, () => {
|
||||
return store.get("app.bodyshop.shopname");
|
||||
});
|
||||
|
||||
//Watcher Handlers
|
||||
// Watcher Handlers
|
||||
ipcMain.on(ipcTypes.toMain.watcher.start, () => {
|
||||
StartWatcher();
|
||||
});
|
||||
@@ -127,4 +157,4 @@ ipcMain.on(ipcTypes.toMain.updates.download, () => {
|
||||
autoUpdater.downloadUpdate();
|
||||
});
|
||||
|
||||
logIpcMessages();
|
||||
logIpcMessages();
|
||||
Reference in New Issue
Block a user