Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var ipc = require('ipc');
// Listen for auto updates
ipc.on('notify', function (message) {
if (message === 'window:update-available') {
Session.set('updateAvailable', true);
}
if (message === 'application:quit') {
VirtualBox.saveVMState('boot2docker-vm', function (err) {
if (err) {
console.log(err);
}
});
}
});
var ipc = require('ipc');
// Listen for auto updates
ipc.on('notify', function (message) {
if (message === 'window:update-available') {
Session.set('updateAvailable', true);
}
if (message === 'application:quit') {
VirtualBox.saveVMState('boot2docker-vm', function (err) {
if (err) {
console.log(err);
}
});
}
});
function createMainWindow () {
const win = new BrowserWindow({
width: 1280,
height: 768,
resizable: true,
title: options.page_title
})
// Set the download directory to being off of the user's home folder
var tilde_downloads = path.join(app.getHomeDir(), 'Downloads')
win.webContents.session.setDownloadPath(tilde_downloads)
// Allow for messages to be sent from client
ipc.on('asynchronous-message', sendPath('async'))
ipc.on('synchronous-message', sendPath('sync'))
win.webContents.on('did-finish-load', function (webContents) {
var page_title = webContents.sender.getTitle()
var index_path
var home_btn_css
var home_btn_js
if (page_title != 'Aufbau home') {
// Add css
home_btn_css = fs.readFileSync(path.join(__dirname, 'home-btn.css'), 'utf-8')
webContents.sender.insertCSS(home_btn_css)
// Add home button
index_path = path.join(__dirname, 'www', 'index.html')
home_btn_js = fs.readFileSync(path.join(__dirname, 'home-btn.jst'), 'utf-8').replace('{{index_path}}', index_path)
webContents.sender.executeJavaScript(home_btn_js)
function createMainWindow () {
const win = new BrowserWindow({
width: 1280,
height: 768,
resizable: true,
title: options.page_title
})
// Set the download directory to being off of the user's home folder
var tilde_downloads = path.join(app.getHomeDir(), 'Downloads')
win.webContents.session.setDownloadPath(tilde_downloads)
// Allow for messages to be sent from client
ipc.on('asynchronous-message', sendPath('async'))
ipc.on('synchronous-message', sendPath('sync'))
win.webContents.on('did-finish-load', function (webContents) {
var page_title = webContents.sender.getTitle()
var index_path
var home_btn_css
var home_btn_js
if (page_title != 'Aufbau home') {
// Add css
home_btn_css = fs.readFileSync(path.join(__dirname, 'home-btn.css'), 'utf-8')
webContents.sender.insertCSS(home_btn_css)
// Add home button
index_path = path.join(__dirname, 'www', 'index.html')
home_btn_js = fs.readFileSync(path.join(__dirname, 'home-btn.jst'), 'utf-8').replace('{{index_path}}', index_path)
webContents.sender.executeJavaScript(home_btn_js)
export function connect() {
// For desktop mode only
if (!__WEB__) {
require('ipc').on('log', function (msg) {
logger.debug(msg);
});
require('ipc').on('playPauseToggle', function () {
logger.debug("received message: playPauseToggle");
if (store.player) {
store.player.togglePlayPause();
}
});
require('ipc').on('idle', function (idleOutput) {
// logger.debug("received idle: " + idleOutput);
const idleSeconds = parseInt(idleOutput);
if (idleSeconds > 180 && store.player && store.player.isPlaying) {
logger.debug("idle too long - pausing song");
store.player.pause();
}
});
// TODO: replace/remove
//const ipcRenderer = require('electron').ipcRenderer;
//observeStore(state => ({
// currentSong: state.currentSongAsync.data,
// artistImage: state.currentArtistImage
//}), data => {
continue;
}
var b5index = 'x' + str.charCodeAt(i).toString(16).toUpperCase() +
str.charCodeAt(i+1).toString(16).toUpperCase();
if (b2u_table[b5index]) {
data += b2u_table[b5index];
++i;
} else { // Not a big5 char
data += str.charAt(i);
}
}
return data;
}
});
ipc.send('connect', this.url);
ipc.on('data', pcman.receive.bind(pcman));
document.title = this.url;
document.addEventListener('focus', this.set_focus, false);
this.set_focus();
this.resize();
}
set_focus(e) {
export function connect() {
// For desktop mode only
if (!__WEB__) {
require('ipc').on('log', function (msg) {
logger.debug(msg);
});
require('ipc').on('playPauseToggle', function () {
logger.debug("received message: playPauseToggle");
if (store.player) {
store.player.togglePlayPause();
}
});
require('ipc').on('idle', function (idleOutput) {
// logger.debug("received idle: " + idleOutput);
const idleSeconds = parseInt(idleOutput);
if (idleSeconds > 180 && store.player && store.player.isPlaying) {
logger.debug("idle too long - pausing song");
menu.on('ready', function ready() {
var canQuit = false;
menu.app.on('will-quit', function tryQuit(e) {
if (canQuit) return true;
menu.window = undefined;
e.preventDefault();
});
ipc.on('terminate', function terminate(e) {
canQuit = true;
menu.app.terminate();
});
ipc.on('open-dir', function openDir(e) {
shell.showItemInFolder(path.join(conf.exec.cwd, 'config.json'));
});
var conf = loadConfig();
function loadConfig() {
var dir = path.join(menu.app.getPath('userData'), 'data');
var configFile = dir + '/config.json';
var conf, data;
function IpcClient () {
this.callbacks = [];
this.windowId = remote.getCurrentWindow().id;
var that = this,
runCallback = function (key, value, id, windowId) {
if (typeof id !== "undefined" && typeof that.callbacks[id] === "function" && windowId === that.windowId) {
var callback = that.callbacks[id];
callback(value);
}
};
ipc.on("get-reply", runCallback);
ipc.on("set-reply", runCallback);
ipc.on("trigger-reply", runCallback);
}