2019-01-04 03:27:12 +01:00
|
|
|
import { shell } from 'electron';
|
2019-04-18 18:03:17 +01:00
|
|
|
let electronSocket;
|
2017-10-21 04:37:01 +02:00
|
|
|
|
2018-09-26 01:31:53 +02:00
|
|
|
export = (socket: SocketIO.Socket) => {
|
2019-04-18 18:03:17 +01:00
|
|
|
electronSocket = socket;
|
2017-10-21 04:37:01 +02:00
|
|
|
socket.on('shell-showItemInFolder', (fullPath) => {
|
|
|
|
|
const success = shell.showItemInFolder(fullPath);
|
|
|
|
|
|
2019-04-18 18:03:17 +01:00
|
|
|
electronSocket.emit('shell-showItemInFolderCompleted', success);
|
2017-10-21 04:37:01 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
socket.on('shell-openItem', (fullPath) => {
|
|
|
|
|
const success = shell.openItem(fullPath);
|
|
|
|
|
|
2019-04-18 18:03:17 +01:00
|
|
|
electronSocket.emit('shell-openItemCompleted', success);
|
2017-10-21 04:37:01 +02:00
|
|
|
});
|
|
|
|
|
|
2019-05-16 03:13:35 +02:00
|
|
|
socket.on('shell-openExternal', (url, options) => {
|
|
|
|
|
let success = true;
|
2017-10-21 04:37:01 +02:00
|
|
|
|
2019-05-16 03:13:35 +02:00
|
|
|
if (options) {
|
|
|
|
|
shell.openExternal(url, options).catch((error) => {
|
|
|
|
|
success = false;
|
2019-04-18 18:03:17 +01:00
|
|
|
electronSocket.emit('shell-openExternalCallback', [url, error]);
|
2017-10-21 04:37:01 +02:00
|
|
|
});
|
|
|
|
|
} else {
|
2019-05-16 03:13:35 +02:00
|
|
|
shell.openExternal(url).catch((error) => {
|
|
|
|
|
success = false;
|
|
|
|
|
electronSocket.emit('shell-openExternalCallback', [url, error]);
|
|
|
|
|
});
|
2017-10-21 04:37:01 +02:00
|
|
|
}
|
|
|
|
|
|
2019-04-18 18:03:17 +01:00
|
|
|
electronSocket.emit('shell-openExternalCompleted', success);
|
2017-10-21 04:37:01 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
socket.on('shell-moveItemToTrash', (fullPath) => {
|
|
|
|
|
const success = shell.moveItemToTrash(fullPath);
|
|
|
|
|
|
2019-04-18 18:03:17 +01:00
|
|
|
electronSocket.emit('shell-moveItemToTrashCompleted', success);
|
2017-10-21 04:37:01 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
socket.on('shell-beep', () => {
|
|
|
|
|
shell.beep();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
socket.on('shell-writeShortcutLink', (shortcutPath, operation, options) => {
|
|
|
|
|
const success = shell.writeShortcutLink(shortcutPath, operation, options);
|
|
|
|
|
|
2019-04-18 18:03:17 +01:00
|
|
|
electronSocket.emit('shell-writeShortcutLinkCompleted', success);
|
2017-10-21 04:37:01 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
socket.on('shell-readShortcutLink', (shortcutPath) => {
|
|
|
|
|
const shortcutDetails = shell.readShortcutLink(shortcutPath);
|
|
|
|
|
|
2019-04-18 18:03:17 +01:00
|
|
|
electronSocket.emit('shell-readShortcutLinkCompleted', shortcutDetails);
|
2017-10-21 04:37:01 +02:00
|
|
|
});
|
2019-01-04 03:27:12 +01:00
|
|
|
};
|