2021-09-04 18:23:58 +00:00
|
|
|
const {
|
|
|
|
app,
|
|
|
|
BrowserWindow,
|
2022-03-10 18:45:37 +00:00
|
|
|
ipcMain,
|
|
|
|
dialog,
|
|
|
|
shell
|
2022-02-08 14:27:34 +00:00
|
|
|
} = require('electron');
|
2022-02-22 10:06:22 +00:00
|
|
|
const { autoUpdater } = require('electron-updater');
|
2022-02-08 14:27:34 +00:00
|
|
|
const path = require('path');
|
|
|
|
const fs = require('fs');
|
2022-01-11 21:16:14 +00:00
|
|
|
const os = require('os');
|
2022-10-05 08:56:58 +00:00
|
|
|
const spawn = require('child_process').spawn;
|
|
|
|
|
2022-02-24 09:13:00 +00:00
|
|
|
const log = require('electron-log');
|
|
|
|
const mainLog = log.scope('main');
|
|
|
|
const daemonProcessLog = log.scope('freedata-daemon');
|
2022-03-24 19:49:13 +00:00
|
|
|
const mime = require('mime');
|
2022-11-08 13:54:27 +00:00
|
|
|
const net = require('net');
|
|
|
|
|
2022-03-24 19:49:13 +00:00
|
|
|
|
2022-02-24 09:13:00 +00:00
|
|
|
const sysInfo = log.scope('system information');
|
2022-03-03 18:57:40 +00:00
|
|
|
sysInfo.info("SYSTEM INFORMATION ----------------------------- ");
|
2022-02-24 09:13:00 +00:00
|
|
|
sysInfo.info("APP VERSION : " + app.getVersion());
|
|
|
|
sysInfo.info("PLATFORM : " + os.platform());
|
|
|
|
sysInfo.info("ARCHITECTURE: " + os.arch());
|
|
|
|
sysInfo.info("FREE MEMORY: " + os.freemem());
|
|
|
|
sysInfo.info("TOTAL MEMORY: " + os.totalmem());
|
|
|
|
sysInfo.info("LOAD AVG : " + os.loadavg());
|
|
|
|
sysInfo.info("RELEASE : " + os.release());
|
|
|
|
sysInfo.info("TYPE : " + os.type());
|
|
|
|
sysInfo.info("VERSION : " + os.version());
|
|
|
|
sysInfo.info("UPTIME : " + os.uptime());
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-09-13 16:27:50 +00:00
|
|
|
app.setName("FreeDATA");
|
2021-09-04 15:11:20 +00:00
|
|
|
|
2022-02-08 14:27:34 +00:00
|
|
|
var appDataFolder = process.env.APPDATA || (process.platform == 'darwin' ? process.env.HOME + '/Library/Application Support' : process.env.HOME + "/.config");
|
2021-09-13 16:27:50 +00:00
|
|
|
var configFolder = path.join(appDataFolder, "FreeDATA");
|
2022-02-08 14:27:34 +00:00
|
|
|
var configPath = path.join(configFolder, 'config.json');
|
2021-09-04 14:33:17 +00:00
|
|
|
|
2021-11-19 16:30:17 +00:00
|
|
|
// create config folder if not exists
|
2021-09-04 18:23:58 +00:00
|
|
|
if (!fs.existsSync(configFolder)) {
|
|
|
|
fs.mkdirSync(configFolder);
|
|
|
|
}
|
2021-09-04 14:33:17 +00:00
|
|
|
|
2022-03-03 18:57:40 +00:00
|
|
|
// create config file if not exists with defaults
|
|
|
|
const configDefaultSettings = '{\
|
|
|
|
"tnc_host": "127.0.0.1",\
|
|
|
|
"tnc_port": "3000",\
|
|
|
|
"daemon_host": "127.0.0.1",\
|
|
|
|
"daemon_port": "3001",\
|
|
|
|
"mycall": "AA0AA-0",\
|
|
|
|
"mygrid": "JN40aa",\
|
2022-09-23 09:17:59 +00:00
|
|
|
"radiocontrol" : "disabled",\
|
|
|
|
"hamlib_deviceid": "RIG_MODEL_DUMMY_NOVFO",\
|
|
|
|
"enable_hamlib_deviceport" : "False",\
|
|
|
|
"hamlib_deviceport": "/dev/ttyACM1",\
|
|
|
|
"enable_hamlib_stop_bits" : "False",\
|
|
|
|
"hamlib_stop_bits" : "1",\
|
|
|
|
"enable_hamlib_data_bits" : "False",\
|
|
|
|
"hamlib_data_bits" : "8",\
|
|
|
|
"enable_hamlib_handshake" : "False",\
|
|
|
|
"hamlib_handshake" : "None",\
|
|
|
|
"enable_hamlib_serialspeed" : "False",\
|
|
|
|
"hamlib_serialspeed" : "9600",\
|
|
|
|
"enable_hamlib_pttprotocol" : "False",\
|
2022-10-06 08:08:31 +00:00
|
|
|
"hamlib_dtrstate" : "OFF",\
|
|
|
|
"enable_hamlib_dtrstate" : "False",\
|
2022-09-23 09:17:59 +00:00
|
|
|
"hamlib_pttprotocol" : "USB",\
|
|
|
|
"enable_hamlib_pttport" : "False",\
|
|
|
|
"hamlib_pttport": "/dev/ttyACM1",\
|
2022-09-23 17:18:20 +00:00
|
|
|
"hamlib_dcd": "None",\
|
2022-09-23 09:17:59 +00:00
|
|
|
"hamlbib_serialspeed_ptt": "9600",\
|
|
|
|
"hamlib_rigctld_port" : "4532",\
|
|
|
|
"hamlib_rigctld_ip" : "127.0.0.1",\
|
|
|
|
"hamlib_rigctld_path" : "",\
|
2022-10-03 12:17:03 +00:00
|
|
|
"hamlib_rigctld_server_port" : "4532",\
|
2022-03-03 18:57:40 +00:00
|
|
|
"spectrum": "waterfall",\
|
|
|
|
"tnclocation": "localhost",\
|
|
|
|
"enable_scatter" : "False",\
|
|
|
|
"enable_fft" : "False",\
|
2022-03-31 10:45:44 +00:00
|
|
|
"enable_fsk" : "False",\
|
2022-05-28 12:08:33 +00:00
|
|
|
"low_bandwidth_mode" : "False",\
|
2022-03-03 18:57:40 +00:00
|
|
|
"theme" : "default",\
|
|
|
|
"screen_height" : 430,\
|
|
|
|
"screen_width" : 1050,\
|
|
|
|
"update_channel" : "latest",\
|
2022-03-10 18:45:37 +00:00
|
|
|
"beacon_interval" : 5,\
|
2022-03-19 11:42:10 +00:00
|
|
|
"received_files_folder" : "None",\
|
|
|
|
"tuning_range_fmin" : "-50.0",\
|
2022-04-18 15:17:53 +00:00
|
|
|
"tuning_range_fmax" : "50.0",\
|
2022-09-05 09:54:50 +00:00
|
|
|
"respond_to_cq" : "True",\
|
2022-11-05 21:27:33 +00:00
|
|
|
"rx_buffer_size" : "16", \
|
|
|
|
"enable_explorer" : "False" \
|
2022-03-03 18:57:40 +00:00
|
|
|
}';
|
|
|
|
|
2021-09-04 18:23:58 +00:00
|
|
|
if (!fs.existsSync(configPath)) {
|
2022-03-03 18:57:40 +00:00
|
|
|
fs.writeFileSync(configPath, configDefaultSettings)
|
2021-09-04 18:23:58 +00:00
|
|
|
}
|
|
|
|
|
2022-03-03 18:57:40 +00:00
|
|
|
// load settings
|
|
|
|
var config = require(configPath);
|
|
|
|
|
|
|
|
//config validation
|
|
|
|
// check running config against default config.
|
|
|
|
// if parameter not exists, add it to running config to prevent errors
|
|
|
|
sysInfo.info("CONFIG VALIDATION ----------------------------- ");
|
|
|
|
|
|
|
|
var parsedConfig = JSON.parse(configDefaultSettings);
|
|
|
|
for (key in parsedConfig) {
|
|
|
|
if (config.hasOwnProperty(key)) {
|
|
|
|
sysInfo.info("FOUND SETTTING [" + key + "]: " + config[key]);
|
|
|
|
} else {
|
|
|
|
sysInfo.error("MISSING SETTTING [" + key + "] : " + parsedConfig[key]);
|
|
|
|
config[key] = parsedConfig[key];
|
|
|
|
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sysInfo.info("------------------------------------------ ");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-09-10 15:59:33 +00:00
|
|
|
|
2022-03-10 18:45:37 +00:00
|
|
|
/*
|
2021-11-19 16:30:17 +00:00
|
|
|
var chatDB = path.join(configFolder, 'chatDB.json')
|
|
|
|
// create chat database file if not exists
|
2022-03-03 18:57:40 +00:00
|
|
|
const configContentChatDB = `
|
2021-11-19 16:30:17 +00:00
|
|
|
{ "chatDB" : [{
|
|
|
|
"id" : "00000000",
|
|
|
|
"timestamp" : 1234566,
|
|
|
|
"mycall" : "AA0AA",
|
|
|
|
"dxcall" : "AB0AB",
|
|
|
|
"dxgrid" : "JN1200",
|
|
|
|
"message" : "hallowelt"
|
|
|
|
}]
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
if (!fs.existsSync(chatDB)) {
|
2022-03-03 18:57:40 +00:00
|
|
|
fs.writeFileSync(chatDB, configContentChatDB);
|
2021-11-19 16:30:17 +00:00
|
|
|
}
|
2022-03-10 18:45:37 +00:00
|
|
|
*/
|
2021-11-19 16:30:17 +00:00
|
|
|
|
|
|
|
|
2021-09-10 15:59:33 +00:00
|
|
|
/*
|
|
|
|
// Creates receivedFiles folder if not exists
|
|
|
|
// https://stackoverflow.com/a/26227660
|
|
|
|
var appDataFolder = process.env.HOME
|
2021-09-13 16:27:50 +00:00
|
|
|
var applicationFolder = path.join(appDataFolder, "FreeDATA");
|
2021-09-10 15:59:33 +00:00
|
|
|
var receivedFilesFolder = path.join(applicationFolder, "receivedFiles");
|
|
|
|
|
|
|
|
// https://stackoverflow.com/a/13544465
|
|
|
|
fs.mkdir(receivedFilesFolder, {
|
|
|
|
recursive: true
|
|
|
|
}, function(err) {
|
|
|
|
console.log(err);
|
|
|
|
});
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-03-03 18:57:40 +00:00
|
|
|
|
2022-02-16 08:11:32 +00:00
|
|
|
|
2021-07-23 15:40:44 +00:00
|
|
|
|
2021-07-17 07:02:56 +00:00
|
|
|
let win = null;
|
|
|
|
let data = null;
|
2022-03-03 18:57:40 +00:00
|
|
|
let logViewer = null;
|
2021-09-04 14:33:17 +00:00
|
|
|
var daemonProcess = null;
|
|
|
|
|
2022-11-08 13:23:21 +00:00
|
|
|
|
|
|
|
// create a splash screen
|
|
|
|
function createSplashScreen(){
|
|
|
|
splashScreen = new BrowserWindow({
|
|
|
|
height: 250,
|
|
|
|
width: 250,
|
|
|
|
transparent: true,
|
|
|
|
frame: false,
|
|
|
|
alwaysOnTop: true
|
|
|
|
});
|
|
|
|
splashScreen.loadFile('src/splash.html');
|
|
|
|
splashScreen.center();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-07-24 07:06:22 +00:00
|
|
|
function createWindow() {
|
|
|
|
win = new BrowserWindow({
|
2022-02-10 14:05:04 +00:00
|
|
|
width: config.screen_width,
|
|
|
|
height: config.screen_height,
|
2022-11-08 13:23:21 +00:00
|
|
|
show: false,
|
2021-08-28 13:50:59 +00:00
|
|
|
autoHideMenuBar: true,
|
2022-02-25 11:54:31 +00:00
|
|
|
icon: 'src/img/icon.png',
|
2021-07-24 07:06:22 +00:00
|
|
|
webPreferences: {
|
|
|
|
//preload: path.join(__dirname, 'preload-main.js'),
|
2022-11-06 16:00:20 +00:00
|
|
|
backgroundThrottle: false,
|
2021-07-24 07:06:22 +00:00
|
|
|
preload: require.resolve('./preload-main.js'),
|
|
|
|
nodeIntegration: true,
|
|
|
|
contextIsolation: false,
|
2022-02-23 21:15:19 +00:00
|
|
|
enableRemoteModule: false,
|
2022-03-10 18:45:37 +00:00
|
|
|
sandbox: false
|
2022-02-23 21:15:19 +00:00
|
|
|
//https://stackoverflow.com/questions/53390798/opening-new-window-electron/53393655
|
|
|
|
//https://github.com/electron/remote
|
2021-07-24 07:06:22 +00:00
|
|
|
}
|
|
|
|
})
|
2021-08-28 13:50:59 +00:00
|
|
|
// hide menu bar
|
|
|
|
win.setMenuBarVisibility(false)
|
2021-09-04 18:23:58 +00:00
|
|
|
|
2021-07-24 07:06:22 +00:00
|
|
|
//open dev tools
|
2021-09-08 16:22:41 +00:00
|
|
|
/*win.webContents.openDevTools({
|
2021-07-24 07:06:22 +00:00
|
|
|
mode: 'undocked',
|
|
|
|
activate: true,
|
|
|
|
})
|
2021-09-05 15:30:46 +00:00
|
|
|
*/
|
2021-07-24 07:06:22 +00:00
|
|
|
win.loadFile('src/index.html')
|
2021-11-19 16:30:17 +00:00
|
|
|
|
|
|
|
chat = new BrowserWindow({
|
2022-03-29 20:24:35 +00:00
|
|
|
height: 600,
|
|
|
|
width: 1000,
|
2021-11-19 16:30:17 +00:00
|
|
|
show: false,
|
2022-03-29 20:24:35 +00:00
|
|
|
//parent: win,
|
2021-07-24 07:06:22 +00:00
|
|
|
webPreferences: {
|
2021-11-19 16:30:17 +00:00
|
|
|
preload: require.resolve('./preload-chat.js'),
|
2021-07-24 07:06:22 +00:00
|
|
|
nodeIntegration: true,
|
|
|
|
|
|
|
|
}
|
|
|
|
})
|
2021-11-19 16:30:17 +00:00
|
|
|
|
2022-02-08 14:27:34 +00:00
|
|
|
chat.loadFile('src/chat-module.html');
|
|
|
|
chat.setMenuBarVisibility(false);
|
2021-11-19 16:30:17 +00:00
|
|
|
|
2022-03-03 18:57:40 +00:00
|
|
|
|
|
|
|
logViewer = new BrowserWindow({
|
|
|
|
height: 900,
|
|
|
|
width: 600,
|
|
|
|
show: false,
|
2022-03-29 20:24:35 +00:00
|
|
|
//parent: win,
|
2022-03-03 18:57:40 +00:00
|
|
|
webPreferences: {
|
|
|
|
preload: require.resolve('./preload-log.js'),
|
|
|
|
nodeIntegration: true,
|
|
|
|
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
logViewer.loadFile('src/log-module.html');
|
|
|
|
logViewer.setMenuBarVisibility(false);
|
|
|
|
|
|
|
|
// Emitted when the window is closed.
|
|
|
|
logViewer.on('close', function(evt) {
|
2022-03-30 15:53:35 +00:00
|
|
|
if (logViewer !== null){
|
2022-03-03 18:57:40 +00:00
|
|
|
evt.preventDefault();
|
|
|
|
logViewer.hide();
|
2022-03-30 15:53:35 +00:00
|
|
|
} else {
|
|
|
|
this.close()
|
|
|
|
}
|
2022-03-03 18:57:40 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-07-17 07:02:56 +00:00
|
|
|
|
|
|
|
// Emitted when the window is closed.
|
2021-07-24 07:06:22 +00:00
|
|
|
win.on('closed', function() {
|
2022-03-31 09:53:57 +00:00
|
|
|
console.log("closing all windows.....")
|
|
|
|
/*
|
2021-07-17 07:02:56 +00:00
|
|
|
win = null;
|
2021-11-19 16:30:17 +00:00
|
|
|
chat = null;
|
2022-03-03 18:57:40 +00:00
|
|
|
logViewer = null;
|
2022-03-31 09:53:57 +00:00
|
|
|
*/
|
|
|
|
close_all();
|
|
|
|
|
2021-07-17 07:02:56 +00:00
|
|
|
})
|
2022-02-22 10:06:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
win.once('ready-to-show', () => {
|
2022-02-22 14:40:33 +00:00
|
|
|
|
2022-03-03 18:57:40 +00:00
|
|
|
log.transports.file.level = "debug"
|
|
|
|
autoUpdater.logger = log.scope('updater');
|
|
|
|
|
|
|
|
autoUpdater.channel = config.update_channel
|
|
|
|
|
2022-02-23 09:14:46 +00:00
|
|
|
autoUpdater.autoInstallOnAppQuit = false;
|
2022-02-22 14:40:33 +00:00
|
|
|
autoUpdater.autoDownload = true;
|
2022-02-22 10:06:22 +00:00
|
|
|
autoUpdater.checkForUpdatesAndNotify();
|
2022-02-23 21:15:19 +00:00
|
|
|
//autoUpdater.quitAndInstall();
|
2022-02-22 10:06:22 +00:00
|
|
|
});
|
2021-07-17 07:02:56 +00:00
|
|
|
|
2021-11-19 16:30:17 +00:00
|
|
|
|
|
|
|
chat.on('closed', function () {
|
2022-02-23 21:15:19 +00:00
|
|
|
|
2021-07-24 07:06:22 +00:00
|
|
|
})
|
2021-11-19 16:30:17 +00:00
|
|
|
|
2021-07-17 07:02:56 +00:00
|
|
|
|
2021-07-24 07:06:22 +00:00
|
|
|
// https://stackoverflow.com/questions/44258831/only-hide-the-window-when-closing-it-electron
|
2021-11-19 16:30:17 +00:00
|
|
|
chat.on('close', function(evt) {
|
2021-07-24 07:06:22 +00:00
|
|
|
evt.preventDefault();
|
2022-02-08 14:27:34 +00:00
|
|
|
chat.hide();
|
2021-07-24 07:06:22 +00:00
|
|
|
});
|
2021-11-19 16:30:17 +00:00
|
|
|
|
2021-07-17 07:02:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
app.whenReady().then(() => {
|
2022-11-08 13:23:21 +00:00
|
|
|
|
|
|
|
// show splash screen
|
|
|
|
createSplashScreen();
|
|
|
|
|
|
|
|
// create main window
|
2022-02-08 14:27:34 +00:00
|
|
|
createWindow();
|
2021-09-04 18:23:58 +00:00
|
|
|
|
2022-11-08 13:23:21 +00:00
|
|
|
// wait some time, then close splash screen and show main windows
|
|
|
|
setTimeout(function() {
|
|
|
|
splashScreen.close();
|
|
|
|
win.show();
|
|
|
|
}, 3000);
|
|
|
|
|
2022-01-11 21:16:14 +00:00
|
|
|
// start daemon by checking os
|
2022-02-24 09:13:00 +00:00
|
|
|
mainLog.info('Starting freedata-daemon binary');
|
2022-02-16 10:28:40 +00:00
|
|
|
|
2022-02-19 20:30:52 +00:00
|
|
|
if(os.platform()=='darwin'){
|
2022-10-05 08:56:58 +00:00
|
|
|
daemonProcess = spawn(path.join(process.resourcesPath, 'tnc', 'freedata-daemon'), [],
|
2022-02-21 16:25:33 +00:00
|
|
|
{
|
|
|
|
cwd: path.join(process.resourcesPath, 'tnc'),
|
|
|
|
});
|
2022-02-19 20:30:52 +00:00
|
|
|
}
|
|
|
|
|
2022-02-21 16:25:33 +00:00
|
|
|
/*
|
|
|
|
process.resourcesPath -->
|
|
|
|
/tmp/.mount_FreeDAUQYfKb/resources
|
|
|
|
|
|
|
|
__dirname -->
|
|
|
|
/tmp/.mount_FreeDAUQYfKb/resources/app.asar
|
|
|
|
*/
|
2022-02-19 19:45:57 +00:00
|
|
|
|
2022-02-16 10:28:40 +00:00
|
|
|
if(os.platform()=='linux'){
|
|
|
|
|
2022-02-24 09:13:00 +00:00
|
|
|
/*
|
2022-02-21 16:25:33 +00:00
|
|
|
var folder = path.join(process.resourcesPath, 'tnc');
|
|
|
|
//var folder = path.join(__dirname, 'extraResources', 'tnc');
|
|
|
|
console.log(folder);
|
|
|
|
fs.readdir(folder, (err, files) => {
|
|
|
|
console.log(files);
|
|
|
|
});
|
2022-02-24 09:13:00 +00:00
|
|
|
*/
|
|
|
|
|
2022-10-05 08:56:58 +00:00
|
|
|
daemonProcess = spawn(path.join(process.resourcesPath, 'tnc', 'freedata-daemon'), [],
|
2022-02-21 16:25:33 +00:00
|
|
|
{
|
|
|
|
cwd: path.join(process.resourcesPath, 'tnc'),
|
2022-02-24 09:13:00 +00:00
|
|
|
});
|
2022-01-11 21:16:14 +00:00
|
|
|
}
|
2022-02-16 10:28:40 +00:00
|
|
|
|
2022-01-11 21:16:14 +00:00
|
|
|
|
|
|
|
if(os.platform()=='win32' || os.platform()=='win64'){
|
2022-02-21 11:20:36 +00:00
|
|
|
// for windows the relative path via path.join(__dirname) is not needed for some reason
|
2022-02-21 17:59:03 +00:00
|
|
|
//daemonProcess = exec('\\tnc\\daemon.exe', [])
|
|
|
|
|
2022-10-05 08:56:58 +00:00
|
|
|
daemonProcess = spawn(path.join(process.resourcesPath, 'tnc', 'freedata-daemon.exe'), [],
|
2022-02-21 16:25:33 +00:00
|
|
|
{
|
|
|
|
cwd: path.join(process.resourcesPath, 'tnc'),
|
|
|
|
});
|
2022-02-21 17:59:03 +00:00
|
|
|
|
2022-02-21 11:20:36 +00:00
|
|
|
}
|
2022-02-16 08:11:32 +00:00
|
|
|
|
2022-02-21 11:20:36 +00:00
|
|
|
// return process messages
|
|
|
|
|
|
|
|
daemonProcess.on('error', (err) => {
|
2022-02-24 09:13:00 +00:00
|
|
|
daemonProcessLog.error(`error when starting daemon: ${err}`);
|
2022-02-21 11:20:36 +00:00
|
|
|
});
|
2022-02-16 09:11:09 +00:00
|
|
|
|
2022-02-21 11:20:36 +00:00
|
|
|
daemonProcess.on('message', (data) => {
|
2022-03-12 12:18:16 +00:00
|
|
|
daemonProcessLog.info(`${data}`);
|
2022-02-21 11:20:36 +00:00
|
|
|
});
|
2022-03-03 18:57:40 +00:00
|
|
|
|
2022-02-21 11:20:36 +00:00
|
|
|
daemonProcess.stdout.on('data', (data) => {
|
2022-03-12 12:18:16 +00:00
|
|
|
daemonProcessLog.info(`${data}`);
|
2022-02-21 11:20:36 +00:00
|
|
|
});
|
|
|
|
|
2022-03-12 12:18:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-02-21 11:20:36 +00:00
|
|
|
daemonProcess.stderr.on('data', (data) => {
|
2022-02-24 09:13:00 +00:00
|
|
|
daemonProcessLog.info(`${data}`);
|
2022-03-03 18:57:40 +00:00
|
|
|
|
|
|
|
let arg = {
|
|
|
|
entry: `${data}`
|
|
|
|
};
|
2022-03-11 11:52:05 +00:00
|
|
|
// send info to log only if log screen available
|
|
|
|
// it seems an error occurs when updating
|
|
|
|
if (logViewer !== null && logViewer !== ''){
|
2022-05-01 08:55:56 +00:00
|
|
|
try{
|
|
|
|
logViewer.webContents.send('action-update-log', arg);
|
|
|
|
} catch (e) {
|
|
|
|
// empty for keeping error stuff silent
|
|
|
|
// this is important to avoid error messages if we are going to close the app while
|
|
|
|
// an logging information will be pushed to the logger
|
|
|
|
}
|
2022-03-11 11:52:05 +00:00
|
|
|
}
|
2022-03-03 18:57:40 +00:00
|
|
|
|
2022-02-21 11:20:36 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
daemonProcess.on('close', (code) => {
|
2022-02-24 09:13:00 +00:00
|
|
|
daemonProcessLog.warn(`daemonProcess exited with code ${code}`);
|
2022-02-21 11:20:36 +00:00
|
|
|
});
|
|
|
|
|
2021-12-20 16:12:34 +00:00
|
|
|
|
|
|
|
|
2021-07-24 07:06:22 +00:00
|
|
|
app.on('activate', () => {
|
|
|
|
if (BrowserWindow.getAllWindows().length === 0) {
|
2022-02-08 14:27:34 +00:00
|
|
|
createWindow();
|
2021-07-24 07:06:22 +00:00
|
|
|
}
|
|
|
|
})
|
2021-07-17 07:02:56 +00:00
|
|
|
})
|
|
|
|
|
2022-02-24 09:13:00 +00:00
|
|
|
|
2022-03-31 09:53:57 +00:00
|
|
|
app.on('window-all-closed', () => {
|
|
|
|
close_all();
|
2022-02-24 09:13:00 +00:00
|
|
|
|
2021-07-17 07:02:56 +00:00
|
|
|
})
|
|
|
|
|
2021-07-19 19:01:38 +00:00
|
|
|
// IPC HANDLER
|
2021-11-19 16:30:17 +00:00
|
|
|
|
2022-09-23 17:29:04 +00:00
|
|
|
ipcMain.on('request-show-chat-window', () => {
|
2022-02-08 14:27:34 +00:00
|
|
|
chat.show();
|
2021-08-07 17:46:02 +00:00
|
|
|
});
|
2021-11-19 16:30:17 +00:00
|
|
|
|
|
|
|
|
2022-10-03 07:36:43 +00:00
|
|
|
ipcMain.on('request-update-tnc-state', (event, arg) => {
|
2021-07-17 07:02:56 +00:00
|
|
|
win.webContents.send('action-update-tnc-state', arg);
|
2021-08-07 17:46:02 +00:00
|
|
|
//data.webContents.send('action-update-tnc-state', arg);
|
2021-07-17 07:02:56 +00:00
|
|
|
});
|
|
|
|
|
2021-08-07 18:57:36 +00:00
|
|
|
/*
|
2021-07-23 15:40:44 +00:00
|
|
|
ipcMain.on('request-update-data-state', (event, arg) => {
|
|
|
|
//win.webContents.send('action-update-data-state', arg);
|
2021-08-07 17:46:02 +00:00
|
|
|
//data.webContents.send('action-update-data-state', arg);
|
2021-07-23 15:40:44 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
ipcMain.on('request-update-heard-stations', (event, arg) => {
|
2021-07-25 14:35:50 +00:00
|
|
|
win.webContents.send('action-update-heard-stations', arg);
|
2021-07-23 15:40:44 +00:00
|
|
|
});
|
2021-08-07 18:57:36 +00:00
|
|
|
*/
|
2022-10-03 07:36:43 +00:00
|
|
|
ipcMain.on('request-update-daemon-state', (event, arg) => {
|
2021-07-17 07:02:56 +00:00
|
|
|
win.webContents.send('action-update-daemon-state', arg);
|
|
|
|
});
|
|
|
|
|
2022-10-03 07:36:43 +00:00
|
|
|
ipcMain.on('request-update-hamlib-test', (event, arg) => {
|
2021-10-17 14:00:23 +00:00
|
|
|
win.webContents.send('action-update-hamlib-test', arg);
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-10-03 07:36:43 +00:00
|
|
|
ipcMain.on('request-update-tnc-connection', (event, arg) => {
|
2022-02-12 15:34:47 +00:00
|
|
|
win.webContents.send('action-update-tnc-connection', arg);
|
|
|
|
});
|
2021-10-17 14:00:23 +00:00
|
|
|
|
2022-10-03 07:36:43 +00:00
|
|
|
ipcMain.on('request-update-daemon-connection', (event, arg) => {
|
2021-07-17 07:02:56 +00:00
|
|
|
win.webContents.send('action-update-daemon-connection', arg);
|
|
|
|
});
|
|
|
|
|
2022-10-03 07:36:43 +00:00
|
|
|
ipcMain.on('run-tnc-command', (event, arg) => {
|
2021-09-04 18:23:58 +00:00
|
|
|
win.webContents.send('run-tnc-command', arg);
|
2021-07-19 19:01:38 +00:00
|
|
|
});
|
2021-08-16 18:04:03 +00:00
|
|
|
|
2022-10-03 07:36:43 +00:00
|
|
|
ipcMain.on('request-update-rx-buffer', (event, arg) => {
|
2021-09-04 18:23:58 +00:00
|
|
|
win.webContents.send('action-update-rx-buffer', arg);
|
2021-09-08 16:22:41 +00:00
|
|
|
});
|
2021-10-17 14:59:15 +00:00
|
|
|
|
2022-03-10 18:45:37 +00:00
|
|
|
/*
|
2021-10-17 15:22:07 +00:00
|
|
|
ipcMain.on('request-update-rx-msg-buffer', (event, arg) => {
|
2021-11-19 16:30:17 +00:00
|
|
|
chat.webContents.send('action-update-rx-msg-buffer', arg);
|
2021-10-17 14:59:15 +00:00
|
|
|
});
|
2022-03-10 18:45:37 +00:00
|
|
|
*/
|
2022-10-03 07:36:43 +00:00
|
|
|
ipcMain.on('request-new-msg-received', (event, arg) => {
|
2022-03-10 18:45:37 +00:00
|
|
|
chat.webContents.send('action-new-msg-received', arg);
|
|
|
|
});
|
2022-10-03 07:36:43 +00:00
|
|
|
ipcMain.on('request-update-transmission-status', (event, arg) => {
|
2022-03-14 19:21:15 +00:00
|
|
|
chat.webContents.send('action-update-transmission-status', arg);
|
|
|
|
});
|
2022-02-22 10:06:22 +00:00
|
|
|
|
2022-09-23 17:22:47 +00:00
|
|
|
ipcMain.on('request-open-tnc-log', () => {
|
2022-03-03 18:57:40 +00:00
|
|
|
logViewer.show();
|
|
|
|
});
|
|
|
|
|
2022-09-20 17:24:07 +00:00
|
|
|
//file selector
|
|
|
|
ipcMain.on('get-file-path',(event,data)=>{
|
|
|
|
dialog.showOpenDialog({defaultPath: path.join(__dirname, '../'),
|
|
|
|
buttonLabel: 'Select rigctld', properties: ['openFile']}).then(filePaths => {
|
|
|
|
win.webContents.send('return-file-paths', {path: filePaths,})
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2022-03-10 18:45:37 +00:00
|
|
|
//folder selector
|
|
|
|
ipcMain.on('get-folder-path',(event,data)=>{
|
2022-03-24 19:49:13 +00:00
|
|
|
dialog.showOpenDialog({defaultPath: path.join(__dirname, '../'),
|
2022-03-10 18:45:37 +00:00
|
|
|
buttonLabel: 'Select folder', properties: ['openDirectory']}).then(folderPaths => {
|
2022-03-24 19:49:13 +00:00
|
|
|
win.webContents.send('return-folder-paths', {path: folderPaths,})
|
|
|
|
|
2022-03-10 18:45:37 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
//open folder
|
|
|
|
ipcMain.on('open-folder',(event,data)=>{
|
|
|
|
shell.showItemInFolder(data.path)
|
|
|
|
});
|
|
|
|
|
2022-03-24 19:49:13 +00:00
|
|
|
//select file
|
|
|
|
ipcMain.on('select-file',(event,data)=>{
|
|
|
|
dialog.showOpenDialog({defaultPath: path.join(__dirname, '../'),
|
|
|
|
buttonLabel: 'Select file', properties: ['openFile']}).then(filepath => {
|
|
|
|
|
|
|
|
console.log(filepath.filePaths[0])
|
|
|
|
|
|
|
|
try {
|
2022-03-27 19:04:04 +00:00
|
|
|
//fs.readFile(filepath.filePaths[0], 'utf8', function (err, data) {
|
|
|
|
fs.readFile(filepath.filePaths[0], 'binary', function (err, data) {
|
|
|
|
|
|
|
|
console.log(data.length)
|
2022-03-24 19:49:13 +00:00
|
|
|
|
2022-03-27 19:04:04 +00:00
|
|
|
console.log(data)
|
2022-03-24 19:49:13 +00:00
|
|
|
|
|
|
|
var filename = path.basename(filepath.filePaths[0])
|
|
|
|
var mimeType = mime.getType(filename)
|
2022-06-09 12:54:42 +00:00
|
|
|
console.log(mimeType)
|
2022-06-09 19:42:20 +00:00
|
|
|
if (mimeType == '' || mimeType == null){
|
2022-06-09 12:54:42 +00:00
|
|
|
mimeType = 'plain/text'
|
|
|
|
}
|
2022-03-24 19:49:13 +00:00
|
|
|
chat.webContents.send('return-selected-files', {data : data, mime: mimeType, filename: filename})
|
|
|
|
})
|
|
|
|
|
|
|
|
} catch (err) {
|
|
|
|
console.log(err);
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
//save file to folder
|
|
|
|
ipcMain.on('save-file-to-folder',(event,data)=>{
|
2022-03-27 19:04:04 +00:00
|
|
|
|
|
|
|
console.log(data.file)
|
2022-03-24 19:49:13 +00:00
|
|
|
|
2022-03-27 19:04:04 +00:00
|
|
|
dialog.showSaveDialog({defaultPath: data.filename}).then(filepath => {
|
2022-03-10 18:45:37 +00:00
|
|
|
|
2022-03-24 19:49:13 +00:00
|
|
|
console.log(filepath.filePath)
|
2022-03-27 19:04:04 +00:00
|
|
|
console.log(data.file)
|
|
|
|
|
|
|
|
try {
|
2022-11-11 14:39:24 +00:00
|
|
|
|
2022-11-11 14:43:02 +00:00
|
|
|
let buffer = Buffer.from(data.file);
|
2022-03-27 19:04:04 +00:00
|
|
|
let arraybuffer = Uint8Array.from(buffer);
|
|
|
|
console.log(arraybuffer)
|
|
|
|
fs.writeFile(filepath.filePath, data.file, 'binary', function (err, data) {
|
|
|
|
//fs.writeFile(filepath.filePath, arraybuffer, function (err, data) {
|
|
|
|
//fs.writeFile(filepath.filePath, arraybuffer, 'binary', function(err) {
|
|
|
|
//fs.writeFile(filepath.filePath, new Uint8Array(Buffer.from(data.file)), function (err, data) {
|
|
|
|
//fs.writeFile(filepath.filePath, Buffer.from(data.file), function (err, data) {
|
|
|
|
})
|
|
|
|
} catch (err) {
|
|
|
|
console.log(err);
|
|
|
|
}
|
2022-03-24 19:49:13 +00:00
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
});
|
2022-02-22 10:06:22 +00:00
|
|
|
|
2022-04-24 13:34:59 +00:00
|
|
|
|
2022-06-07 08:08:15 +00:00
|
|
|
//tnc messages START --------------------------------------
|
|
|
|
|
|
|
|
// CQ TRANSMITTING
|
|
|
|
ipcMain.on('request-show-cq-toast-transmitting',(event,data)=>{
|
|
|
|
win.webContents.send('action-show-cq-toast-transmitting', data);
|
|
|
|
});
|
|
|
|
|
|
|
|
// CQ RECEIVED
|
|
|
|
ipcMain.on('request-show-cq-toast-received',(event,data)=>{
|
|
|
|
win.webContents.send('action-show-cq-toast-received', data);
|
|
|
|
});
|
|
|
|
|
|
|
|
// QRV TRANSMITTING
|
|
|
|
ipcMain.on('request-show-qrv-toast-transmitting',(event,data)=>{
|
|
|
|
win.webContents.send('action-show-qrv-toast-transmitting', data);
|
|
|
|
});
|
|
|
|
|
|
|
|
// QRV RECEIVED
|
|
|
|
ipcMain.on('request-show-qrv-toast-received',(event,data)=>{
|
|
|
|
win.webContents.send('action-show-qrv-toast-received', data);
|
|
|
|
});
|
|
|
|
|
|
|
|
// BEACON TRANSMITTING
|
|
|
|
ipcMain.on('request-show-beacon-toast-transmitting',(event,data)=>{
|
|
|
|
win.webContents.send('action-show-beacon-toast-transmitting', data);
|
|
|
|
});
|
|
|
|
|
|
|
|
// BEACON RECEIVED
|
|
|
|
ipcMain.on('request-show-beacon-toast-received',(event,data)=>{
|
|
|
|
win.webContents.send('action-show-beacon-toast-received', data);
|
|
|
|
});
|
|
|
|
|
|
|
|
// PING TRANSMITTING
|
|
|
|
ipcMain.on('request-show-ping-toast-transmitting',(event,data)=>{
|
|
|
|
win.webContents.send('action-show-ping-toast-transmitting', data);
|
|
|
|
});
|
|
|
|
|
|
|
|
// PING RECEIVED
|
|
|
|
ipcMain.on('request-show-ping-toast-received',(event,data)=>{
|
|
|
|
win.webContents.send('action-show-ping-toast-received', data);
|
|
|
|
});
|
|
|
|
|
|
|
|
// PING RECEIVED ACK
|
|
|
|
ipcMain.on('request-show-ping-toast-received-ack',(event,data)=>{
|
|
|
|
win.webContents.send('action-show-ping-toast-received-ack', data);
|
|
|
|
});
|
|
|
|
|
|
|
|
// ARQ DATA CHANNEL OPENING
|
|
|
|
ipcMain.on('request-show-arq-toast-datachannel-opening',(event,data)=>{
|
|
|
|
win.webContents.send('action-show-arq-toast-datachannel-opening', data);
|
|
|
|
});
|
|
|
|
|
2022-11-17 21:17:50 +00:00
|
|
|
// ARQ DATA CHANNEL WAITING
|
|
|
|
ipcMain.on('request-show-arq-toast-datachannel-waiting',(event,data)=>{
|
|
|
|
win.webContents.send('action-show-arq-toast-datachannel-waiting', data);
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2022-06-07 08:08:15 +00:00
|
|
|
// ARQ DATA CHANNEL OPEN
|
2022-06-09 12:14:31 +00:00
|
|
|
ipcMain.on('request-show-arq-toast-datachannel-opened',(event,data)=>{
|
|
|
|
win.webContents.send('action-show-arq-toast-datachannel-opened', data);
|
2022-06-07 08:08:15 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
// ARQ DATA RECEIVED OPENER
|
|
|
|
ipcMain.on('request-show-arq-toast-datachannel-received-opener',(event,data)=>{
|
|
|
|
win.webContents.send('action-show-arq-toast-datachannel-received-opener', data);
|
|
|
|
});
|
|
|
|
|
|
|
|
// ARQ TRANSMISSION FAILED
|
|
|
|
ipcMain.on('request-show-arq-toast-transmission-failed',(event,data)=>{
|
|
|
|
win.webContents.send('action-show-arq-toast-transmission-failed', data);
|
|
|
|
});
|
|
|
|
|
|
|
|
// ARQ TRANSMISSION RECEIVING
|
|
|
|
ipcMain.on('request-show-arq-toast-transmission-receiving',(event,data)=>{
|
|
|
|
win.webContents.send('action-show-arq-toast-transmission-receiving', data);
|
|
|
|
});
|
|
|
|
|
|
|
|
// ARQ TRANSMISSION RECEIVED
|
|
|
|
ipcMain.on('request-show-arq-toast-transmission-received',(event,data)=>{
|
|
|
|
win.webContents.send('action-show-arq-toast-transmission-received', data);
|
|
|
|
});
|
|
|
|
|
|
|
|
// ARQ TRANSMISSION TRANSMITTING
|
|
|
|
ipcMain.on('request-show-arq-toast-transmission-transmitting',(event,data)=>{
|
|
|
|
win.webContents.send('action-show-arq-toast-transmission-transmitting', data);
|
|
|
|
});
|
|
|
|
|
|
|
|
// ARQ TRANSMISSION TRANSMITTED
|
|
|
|
ipcMain.on('request-show-arq-toast-transmission-transmitted',(event,data)=>{
|
|
|
|
win.webContents.send('action-show-arq-toast-transmission-transmitted', data);
|
|
|
|
});
|
|
|
|
|
2022-06-15 08:51:19 +00:00
|
|
|
// ARQ SESSION CONNECTING
|
|
|
|
ipcMain.on('request-show-arq-toast-session-connecting',(event,data)=>{
|
|
|
|
win.webContents.send('action-show-arq-toast-session-connecting', data);
|
|
|
|
});
|
|
|
|
|
2022-11-17 23:03:18 +00:00
|
|
|
// ARQ SESSION WAITING
|
|
|
|
ipcMain.on('request-show-arq-toast-session-waiting',(event,data)=>{
|
|
|
|
win.webContents.send('action-show-arq-toast-session-waiting', data);
|
|
|
|
});
|
|
|
|
|
2022-06-15 08:51:19 +00:00
|
|
|
// ARQ SESSION CONNECTED
|
|
|
|
ipcMain.on('request-show-arq-toast-session-connected',(event,data)=>{
|
|
|
|
win.webContents.send('action-show-arq-toast-session-connected', data);
|
|
|
|
});
|
|
|
|
|
|
|
|
// ARQ SESSION CLOSE
|
|
|
|
ipcMain.on('request-show-arq-toast-session-close',(event,data)=>{
|
|
|
|
win.webContents.send('action-show-arq-toast-session-close', data);
|
|
|
|
});
|
|
|
|
|
|
|
|
// ARQ SESSION FAILED
|
|
|
|
ipcMain.on('request-show-arq-toast-session-failed',(event,data)=>{
|
|
|
|
win.webContents.send('action-show-arq-toast-session-failed', data);
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2022-06-07 08:08:15 +00:00
|
|
|
|
|
|
|
//tnc messages END --------------------------------------
|
|
|
|
|
2022-04-24 13:34:59 +00:00
|
|
|
//restart and install udpate
|
|
|
|
ipcMain.on('request-restart-and-install',(event,data)=>{
|
2022-04-30 10:27:14 +00:00
|
|
|
close_sub_processes()
|
2022-04-24 13:34:59 +00:00
|
|
|
autoUpdater.quitAndInstall();
|
|
|
|
});
|
|
|
|
|
2022-02-22 14:53:55 +00:00
|
|
|
// LISTENER FOR UPDATER EVENTS
|
2022-02-23 09:14:46 +00:00
|
|
|
autoUpdater.on('update-available', (info) => {
|
2022-02-24 09:13:00 +00:00
|
|
|
mainLog.info('update available');
|
|
|
|
|
2022-02-22 14:40:33 +00:00
|
|
|
let arg = {
|
2022-02-23 09:14:46 +00:00
|
|
|
status: "update-available",
|
|
|
|
info: info
|
2022-02-22 14:40:33 +00:00
|
|
|
};
|
|
|
|
win.webContents.send('action-updater', arg);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2022-02-23 09:14:46 +00:00
|
|
|
autoUpdater.on('update-not-available', (info) => {
|
2022-02-24 09:13:00 +00:00
|
|
|
mainLog.info('update not available');
|
2022-02-22 14:40:33 +00:00
|
|
|
let arg = {
|
2022-02-23 09:14:46 +00:00
|
|
|
status: "update-not-available",
|
|
|
|
info: info
|
2022-02-22 14:40:33 +00:00
|
|
|
};
|
|
|
|
win.webContents.send('action-updater', arg);
|
2022-02-22 10:06:22 +00:00
|
|
|
});
|
2022-02-22 14:40:33 +00:00
|
|
|
|
|
|
|
|
2022-03-03 18:57:40 +00:00
|
|
|
autoUpdater.on('update-downloaded', (info) => {
|
2022-02-24 09:13:00 +00:00
|
|
|
mainLog.info('update downloaded');
|
2022-02-22 14:40:33 +00:00
|
|
|
let arg = {
|
2022-03-03 18:57:40 +00:00
|
|
|
status: "update-downloaded",
|
|
|
|
info: info
|
2022-02-22 14:40:33 +00:00
|
|
|
};
|
|
|
|
win.webContents.send('action-updater', arg);
|
2022-02-23 09:14:46 +00:00
|
|
|
// we need to call this at this point.
|
|
|
|
// if an update is available and we are force closing the app
|
|
|
|
// the entire screen crashes...
|
2022-04-18 09:13:53 +00:00
|
|
|
//mainLog.info('quit application and install update');
|
|
|
|
//autoUpdater.quitAndInstall();
|
2022-02-23 09:14:46 +00:00
|
|
|
|
|
|
|
|
2022-02-22 14:40:33 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
autoUpdater.on('checking-for-update', () => {
|
2022-02-24 09:13:00 +00:00
|
|
|
mainLog.info('checking for update');
|
2022-02-22 14:40:33 +00:00
|
|
|
let arg = {
|
2022-02-22 20:05:48 +00:00
|
|
|
status: "checking-for-update",
|
|
|
|
version: app.getVersion()
|
2022-02-22 14:40:33 +00:00
|
|
|
};
|
|
|
|
win.webContents.send('action-updater', arg);
|
|
|
|
});
|
|
|
|
|
|
|
|
autoUpdater.on('download-progress', (progress) => {
|
|
|
|
let arg = {
|
|
|
|
status: "download-progress",
|
|
|
|
progress: progress
|
|
|
|
};
|
|
|
|
win.webContents.send('action-updater', arg);
|
|
|
|
});
|
|
|
|
|
2022-03-03 18:57:40 +00:00
|
|
|
autoUpdater.on('error', (error) => {
|
2022-02-24 09:13:00 +00:00
|
|
|
mainLog.info('update error');
|
2022-02-22 14:40:33 +00:00
|
|
|
let arg = {
|
|
|
|
status: "error",
|
2022-03-03 18:57:40 +00:00
|
|
|
progress: error
|
2022-02-22 14:40:33 +00:00
|
|
|
};
|
|
|
|
win.webContents.send('action-updater', arg);
|
2022-03-19 11:42:10 +00:00
|
|
|
mainLog.error("AUTO UPDATER : " + error);
|
2022-02-22 10:06:22 +00:00
|
|
|
});
|
|
|
|
|
2022-03-03 18:57:40 +00:00
|
|
|
|
2022-03-10 18:45:37 +00:00
|
|
|
|
2022-04-30 10:27:14 +00:00
|
|
|
function close_sub_processes(){
|
|
|
|
mainLog.warn('closing sub processes');
|
2022-03-31 09:53:57 +00:00
|
|
|
|
|
|
|
// closing the tnc binary if not closed when closing application and also our daemon which has been started by the gui
|
|
|
|
try {
|
|
|
|
daemonProcess.kill();
|
|
|
|
} catch (e) {
|
|
|
|
mainLog.error(e)
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-05-01 07:44:30 +00:00
|
|
|
mainLog.warn('closing tnc and daemon');
|
|
|
|
try {
|
2022-03-31 09:53:57 +00:00
|
|
|
|
2022-05-01 07:44:30 +00:00
|
|
|
if(os.platform()=='win32' || os.platform()=='win64'){
|
2022-10-05 08:56:58 +00:00
|
|
|
spawn('Taskkill', ['/IM', 'freedata-tnc.exe', '/F'])
|
|
|
|
spawn('Taskkill', ['/IM', 'freedata-daemon.exe', '/F'])
|
2022-05-01 07:44:30 +00:00
|
|
|
}
|
2022-03-31 09:53:57 +00:00
|
|
|
|
2022-05-01 07:44:30 +00:00
|
|
|
if(os.platform()=='linux'){
|
|
|
|
|
2022-10-05 08:56:58 +00:00
|
|
|
spawn('pkill', ['-9', 'freedata-tnc'])
|
|
|
|
spawn('pkill', ['-9', 'freedata-daemon'])
|
2022-05-01 07:44:30 +00:00
|
|
|
}
|
2022-03-31 09:53:57 +00:00
|
|
|
|
2022-05-01 07:44:30 +00:00
|
|
|
if(os.platform()=='darwin'){
|
2022-03-31 09:53:57 +00:00
|
|
|
|
2022-10-05 08:56:58 +00:00
|
|
|
spawn('pkill', ['-9', 'freedata-tnc'])
|
|
|
|
spawn('pkill', ['-9', 'freedata-daemon'])
|
2022-05-01 07:44:30 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
mainLog.error(e)
|
2022-03-31 09:53:57 +00:00
|
|
|
}
|
2022-04-24 13:34:59 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
function close_all() {
|
|
|
|
|
|
|
|
// function for closing the application with closing all used processes
|
|
|
|
|
2022-04-30 10:27:14 +00:00
|
|
|
close_sub_processes();
|
2022-04-24 13:34:59 +00:00
|
|
|
|
2022-03-31 09:53:57 +00:00
|
|
|
mainLog.warn('quitting app');
|
|
|
|
|
|
|
|
win.destroy();
|
|
|
|
chat.destroy();
|
|
|
|
logViewer.destroy();
|
|
|
|
|
|
|
|
app.quit();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-09-20 17:24:07 +00:00
|
|
|
// RUN RIGCTLD
|
2022-10-03 07:36:43 +00:00
|
|
|
ipcMain.on('request-start-rigctld',(event, data)=>{
|
2022-10-03 12:25:13 +00:00
|
|
|
|
|
|
|
try{
|
2022-11-17 21:17:50 +00:00
|
|
|
let rigctld_proc = spawn(data.path, data.parameters);
|
2022-11-17 23:23:13 +00:00
|
|
|
|
|
|
|
rigctld_proc.on('exit', function (code) {
|
|
|
|
console.log('rigctld process exited with code ' + code);
|
|
|
|
|
|
|
|
// if rigctld crashes, error code is -2
|
|
|
|
// then we are going to restart rigctld
|
|
|
|
// this "fixes" a problem with latest rigctld on raspberry pi
|
|
|
|
//if (code == -2){
|
|
|
|
// setTimeout(ipcRenderer.send('request-start-rigctld', data), 500);
|
|
|
|
//}
|
|
|
|
//let rigctld_proc = spawn(data.path, data.parameters);
|
|
|
|
});
|
2022-10-03 12:25:13 +00:00
|
|
|
} catch (e) {
|
|
|
|
console.log(e);
|
|
|
|
}
|
|
|
|
|
2022-09-23 17:22:47 +00:00
|
|
|
/*
|
2022-09-23 17:29:04 +00:00
|
|
|
const rigctld = exec(data.path, data.parameters);
|
2022-09-20 17:24:07 +00:00
|
|
|
rigctld.stdout.on("data", data => {
|
|
|
|
console.log(`stdout: ${data}`);
|
|
|
|
});
|
2022-09-23 17:22:47 +00:00
|
|
|
*/
|
|
|
|
|
2022-09-20 17:24:07 +00:00
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// STOP RIGCTLD
|
|
|
|
ipcMain.on('request-stop-rigctld',(event,data)=>{
|
|
|
|
mainLog.warn('closing rigctld');
|
|
|
|
try {
|
|
|
|
|
|
|
|
if(os.platform()=='win32' || os.platform()=='win64'){
|
2022-10-05 08:56:58 +00:00
|
|
|
spawn('Taskkill', ['/IM', 'rigctld.exe', '/F'])
|
2022-09-20 17:24:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(os.platform()=='linux'){
|
|
|
|
|
2022-10-05 08:56:58 +00:00
|
|
|
spawn('pkill', ['-9', 'rigctld'])
|
2022-09-23 12:06:13 +00:00
|
|
|
|
2022-09-20 17:24:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(os.platform()=='darwin'){
|
|
|
|
|
2022-10-05 08:56:58 +00:00
|
|
|
spawn('pkill', ['-9', 'rigctld'])
|
2022-09-20 17:24:07 +00:00
|
|
|
|
2022-09-23 12:06:13 +00:00
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
mainLog.error(e)
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-11-08 13:54:27 +00:00
|
|
|
// CHECK RIGCTLD CONNECTION
|
2022-11-18 13:47:31 +00:00
|
|
|
// create new socket so we are not reopening every time a new one
|
|
|
|
var rigctld_connection = new net.Socket();
|
|
|
|
var rigctld_connection_state = false;
|
2022-11-08 13:54:27 +00:00
|
|
|
ipcMain.on('request-check-rigctld',(event, data)=>{
|
|
|
|
|
|
|
|
try{
|
2022-11-08 08:36:06 +00:00
|
|
|
|
2022-10-05 08:56:58 +00:00
|
|
|
let Data = {
|
2022-11-08 13:54:27 +00:00
|
|
|
state: "unknown",
|
2022-10-05 08:56:58 +00:00
|
|
|
};
|
|
|
|
|
2022-11-18 13:47:31 +00:00
|
|
|
if(!rigctld_connection_state){
|
|
|
|
rigctld_connection = new net.Socket();
|
|
|
|
rigctld_connection.connect(data.port, data.ip)
|
|
|
|
}
|
2022-09-23 12:06:13 +00:00
|
|
|
|
2022-11-18 13:47:31 +00:00
|
|
|
// check if we have created a new socket object
|
|
|
|
if (typeof(rigctld_connection) != 'undefined') {
|
2022-11-08 18:53:14 +00:00
|
|
|
|
2022-11-18 13:47:31 +00:00
|
|
|
rigctld_connection.on('connect', function() {
|
|
|
|
rigctld_connection_state = true;
|
|
|
|
Data["state"] = "connection possible - (" + data.ip + ":" + data.port + ")";
|
2022-11-09 07:40:32 +00:00
|
|
|
if (win !== null && win !== ''){
|
|
|
|
win.webContents.send('action-check-rigctld', Data);
|
|
|
|
}
|
2022-11-08 13:54:27 +00:00
|
|
|
})
|
2022-09-23 12:06:13 +00:00
|
|
|
|
2022-11-18 13:47:31 +00:00
|
|
|
rigctld_connection.on('error', function() {
|
|
|
|
rigctld_connection_state = false;
|
|
|
|
Data["state"] = "unknown/stopped - (" + data.ip + ":" + data.port + ")";
|
2022-11-09 07:40:32 +00:00
|
|
|
if (win !== null && win !== ''){
|
|
|
|
win.webContents.send('action-check-rigctld', Data);
|
|
|
|
}
|
2022-10-05 08:56:58 +00:00
|
|
|
})
|
2022-11-08 13:54:27 +00:00
|
|
|
|
2022-11-18 13:47:31 +00:00
|
|
|
rigctld_connection.on('end', function() {
|
|
|
|
rigctld_connection_state = false;
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-11-08 13:54:27 +00:00
|
|
|
} catch(e) {
|
|
|
|
console.log(e)
|
2022-09-20 17:24:07 +00:00
|
|
|
}
|
2022-10-05 08:56:58 +00:00
|
|
|
|
2022-11-08 13:54:27 +00:00
|
|
|
});
|