-
-
\ No newline at end of file
diff --git a/js/basicAuth/index.js b/js/basicAuth/index.js
deleted file mode 100644
index 6c9a4168..00000000
--- a/js/basicAuth/index.js
+++ /dev/null
@@ -1,177 +0,0 @@
-'use strict';
-
-const electron = require('electron');
-const BrowserWindow = electron.BrowserWindow;
-const ipc = electron.ipcMain;
-const path = require('path');
-const fs = require('fs');
-const log = require('../log.js');
-const logLevels = require('../enums/logLevels.js');
-const { isMac } = require('../utils/misc');
-const { initCrashReporterMain, initCrashReporterRenderer } = require('../crashReporter.js');
-const i18n = require('../translation/i18n');
-
-let basicAuthWindow;
-
-const local = {};
-
-let windowConfig = {
- width: 360,
- height: isMac ? 270 : 295,
- show: false,
- modal: true,
- autoHideMenuBar: true,
- titleBarStyle: true,
- resizable: false,
- webPreferences: {
- preload: path.join(__dirname, 'renderer.js'),
- sandbox: true,
- nodeIntegration: false,
- devTools: false
- }
-};
-
-/**
- * method to get the HTML template path
- * @returns {string}
- */
-function getTemplatePath() {
- let templatePath = path.join(__dirname, 'basic-auth.html');
- try {
- fs.statSync(templatePath).isFile();
- } catch (err) {
- log.send(logLevels.ERROR, 'basic-auth: Could not find template ("' + templatePath + '").');
- }
- return 'file://' + templatePath;
-}
-
-/**
- * Opens the basic auth window for authentication
- * @param {String} windowName - name of the window upon which this window should show
- * @param {String} hostname - name of the website that requires authentication
- * @param {boolean} isValidCredentials - false if invalid username or password
- * @param {Function} clearSettings
- * @param {Function} callback
- */
-function openBasicAuthWindow(windowName, hostname, isValidCredentials, clearSettings, callback) {
-
- // Register callback function
- if (typeof callback === 'function') {
- local.authCallback = callback;
- }
- // Register close function
- if (typeof clearSettings === 'function') {
- local.clearSettings = clearSettings;
- }
-
- // This prevents creating multiple instances of the
- // basic auth window
- if (basicAuthWindow) {
- if (basicAuthWindow.isMinimized()) {
- basicAuthWindow.restore();
- }
- basicAuthWindow.focus();
- return;
- }
- let allWindows = BrowserWindow.getAllWindows();
- allWindows = allWindows.find((window) => { return window.winName === windowName });
-
- // if we couldn't find any window matching the window name
- // it will render as a new window
- if (allWindows) {
- windowConfig.parent = allWindows;
- }
-
- basicAuthWindow = new BrowserWindow(windowConfig);
- basicAuthWindow.setVisibleOnAllWorkspaces(true);
- basicAuthWindow.loadURL(getTemplatePath());
-
- // sets the AlwaysOnTop property for the basic auth window
- // if the main window's AlwaysOnTop is true
- let focusedWindow = BrowserWindow.getFocusedWindow();
- if (focusedWindow && focusedWindow.isAlwaysOnTop()) {
- basicAuthWindow.setAlwaysOnTop(true);
- }
-
- basicAuthWindow.once('ready-to-show', () => {
- basicAuthWindow.show();
- });
-
- basicAuthWindow.webContents.on('did-finish-load', () => {
- const basicAuthContent = i18n.getMessageFor('BasicAuth');
- basicAuthWindow.webContents.send('i18n-basic-auth', basicAuthContent);
- // initialize crash reporter
- initCrashReporterMain({ process: 'basic auth window' });
- initCrashReporterRenderer(basicAuthWindow, { process: 'render | basic auth window' });
- basicAuthWindow.webContents.send('hostname', hostname);
- basicAuthWindow.webContents.send('isValidCredentials', isValidCredentials);
- if (!isMac) {
- // prevents from displaying menu items when "alt" key is pressed
- basicAuthWindow.setMenu(null);
- }
- });
-
- basicAuthWindow.webContents.on('crashed', function (event, killed) {
-
- log.send(logLevels.INFO, `Basic Auth Window crashed! Killed? ${killed}`);
-
- if (killed) {
- return;
- }
-
- const options = {
- type: 'error',
- title: i18n.getMessageFor('Renderer Process Crashed'),
- message: i18n.getMessageFor('Oops! Looks like we have had a crash.'),
- buttons: ['Close']
- };
-
- electron.dialog.showMessageBox(options, function () {
- closeAuthWindow(true);
- });
- });
-
- basicAuthWindow.on('close', () => {
- destroyWindow();
- });
-
- basicAuthWindow.on('closed', () => {
- destroyWindow();
- });
-}
-
-ipc.on('login', (event, args) => {
- if (typeof args === 'object' && typeof local.authCallback === 'function') {
- local.authCallback(args.username, args.password);
- closeAuthWindow(false);
- }
-});
-
-ipc.on('close-basic-auth', () => {
- closeAuthWindow(true);
-});
-
-/**
- * Destroys a window
- */
-function destroyWindow() {
- basicAuthWindow = null;
-}
-
-/**
- * Method to close the auth window
- * @param {boolean} clearSettings - Whether to clear the auth settings
- */
-function closeAuthWindow(clearSettings) {
- if (clearSettings && typeof local.clearSettings === 'function') {
- local.clearSettings();
- }
-
- if (basicAuthWindow) {
- basicAuthWindow.close();
- }
-}
-
-module.exports = {
- openBasicAuthWindow: openBasicAuthWindow
-};
diff --git a/js/basicAuth/renderer.js b/js/basicAuth/renderer.js
deleted file mode 100644
index 6b4fff0f..00000000
--- a/js/basicAuth/renderer.js
+++ /dev/null
@@ -1,83 +0,0 @@
-'use strict';
-const { ipcRenderer, crashReporter } = require('electron');
-
-renderDom();
-
-/**
- * Method that renders application data
- */
-function renderDom() {
- document.addEventListener('DOMContentLoaded', function () {
- loadContent();
- });
-}
-
-function loadContent() {
- let basicAuth = document.getElementById('basicAuth');
- let cancel = document.getElementById('cancel');
-
- if (basicAuth) {
- basicAuth.onsubmit = (e) => {
- e.preventDefault();
- submitForm();
- };
- }
-
- if (cancel) {
- cancel.addEventListener('click', () => {
- ipcRenderer.send('close-basic-auth');
- });
- }
-}
-
-/**
- * Method that gets invoked on submitting the form
- */
-function submitForm() {
- let username = document.getElementById('username').value;
- let password = document.getElementById('password').value;
-
- if (username && password) {
- ipcRenderer.send('login', { username, password });
- }
-}
-
-/**
- * Updates the hosts name
- */
-ipcRenderer.on('hostname', (event, host) => {
- let hostname = document.getElementById('hostname');
-
- if (hostname){
- hostname.innerHTML = host || 'unknown';
- }
-});
-
-/**
- * Triggered if user credentials are invalid
- */
-ipcRenderer.on('isValidCredentials', (event, isValidCredentials) => {
- let credentialsError = document.getElementById('credentialsError');
-
- if (credentialsError){
- credentialsError.style.display = isValidCredentials ? 'none' : 'block'
- }
-});
-
-ipcRenderer.on('register-crash-reporter', (event, arg) => {
- if (arg && typeof arg === 'object') {
- crashReporter.start(arg);
- }
-});
-
-ipcRenderer.on('i18n-basic-auth', (event, content) => {
- if (content && typeof content === 'object') {
- const i18nNodes = document.querySelectorAll('[data-i18n-text]');
-
- for (let node of i18nNodes) {
- if (node.attributes['data-i18n-text'] && node.attributes['data-i18n-text'].value) {
- node.innerText = content[node.attributes['data-i18n-text'].value] || node.attributes['data-i18n-text'].value;
- }
- }
- }
-});
\ No newline at end of file
diff --git a/js/bringToFront.js b/js/bringToFront.js
deleted file mode 100644
index 5912273e..00000000
--- a/js/bringToFront.js
+++ /dev/null
@@ -1,31 +0,0 @@
-'use strict';
-
-const windowMgr = require('./windowMgr.js');
-const { getConfigField } = require('./config.js');
-const log = require('./log.js');
-const logLevels = require('./enums/logLevels.js');
-
-/**
- * Method that checks if user has enabled the bring to front feature
- * if so then activates the main window
- * @param {String} windowName - Name of the window to activate
- * @param {String} reason - The reason for which the window is to be activated
- */
-function bringToFront(windowName, reason) {
-
- getConfigField('bringToFront')
- .then((bringToFrontSetting) => {
- if (typeof bringToFrontSetting === 'boolean' && bringToFrontSetting) {
- log.send(logLevels.INFO, 'Window has been activated for: ' + reason);
- windowMgr.activate(windowName || 'main', false);
- }
- })
- .catch((error) => {
- log.send(logLevels.ERROR, 'Could not read bringToFront field from config error= ' + error);
- });
-}
-
-
-module.exports = {
- bringToFront: bringToFront
-};
\ No newline at end of file
diff --git a/js/cacheHandler/index.js b/js/cacheHandler/index.js
deleted file mode 100644
index f883b8d1..00000000
--- a/js/cacheHandler/index.js
+++ /dev/null
@@ -1,39 +0,0 @@
-const fs = require('fs');
-const nodePath = require('path');
-const electron = require('electron');
-
-const log = require('../log.js');
-const logLevels = require('../enums/logLevels.js');
-
-const cacheCheckFilename = 'CacheCheck';
-const cacheCheckFilePath = nodePath.join(electron.app.getPath('userData'), cacheCheckFilename);
-
-function handleCacheFailureCheckOnStartup() {
-
- return new Promise((resolve) => {
-
- if (fs.existsSync(cacheCheckFilePath)) {
- log.send(logLevels.INFO, `Cache check file exists, so not clearing cache!`);
- fs.unlinkSync(cacheCheckFilePath);
- resolve();
- } else {
- log.send(logLevels.INFO, `Cache check file does not exist, we are clearing the cache!`);
- electron.session.defaultSession.clearCache(() => {
- log.send(logLevels.INFO, `Cleared cache!`);
- resolve();
- });
- }
-
- });
-
-}
-
-function handleCacheFailureCheckOnExit() {
- log.send(logLevels.INFO, `Clean exit! Creating cache check file!`);
- fs.writeFileSync(cacheCheckFilePath, "");
-}
-
-module.exports = {
- handleCacheFailureCheckOnStartup: handleCacheFailureCheckOnStartup,
- handleCacheFailureCheckOnExit: handleCacheFailureCheckOnExit
-};
diff --git a/js/config.js b/js/config.js
deleted file mode 100644
index d445ce41..00000000
--- a/js/config.js
+++ /dev/null
@@ -1,420 +0,0 @@
-'use strict';
-
-const electron = require('electron');
-const app = electron.app;
-const path = require('path');
-const fs = require('fs');
-const omit = require('lodash.omit');
-const pick = require('lodash.pick');
-const difference = require('lodash.difference');
-
-const isDevEnv = require('./utils/misc.js').isDevEnv;
-const isMac = require('./utils/misc.js').isMac;
-const getRegistry = require('./utils/getRegistry.js');
-const log = require('./log.js');
-const logLevels = require('./enums/logLevels.js');
-const { buildNumber } = require('../package.json');
-
-const configFileName = 'Symphony.config';
-
-// cached config when first reading files. initially undefined and will be
-// updated when read from disk.
-let userConfig;
-let globalConfig;
-
-let ignoreSettings = [
- 'minimizeOnClose',
- 'launchOnStartup',
- 'alwaysOnTop',
- 'url',
- 'memoryRefresh',
- 'bringToFront',
- 'isCustomTitleBar'
-];
-
-/**
- * Tries to read given field from user config file, if field doesn't exist
- * then tries reading from global config. User config is stord in directory:
- * app.getPath('userData') and file called Symphony.config. Global config is
- * stored in file Symphony.config in directory where executable gets installed.
- *
- * Config is a flat key/value file.
- * e.g. { url: 'https://my.symphony.com', }
- *
- * @param {String} fieldName Name of field to try fetching
- * @return {Promise} Returns promise that will succeed with field
- * value if found in either user or global config. Otherwise will fail promise.
- */
-function getConfigField(fieldName) {
- return getUserConfigField(fieldName)
- .then((value) => {
- // got value from user config
- return value;
- }, () => {
- // failed to get value from user config, so try global config
- return getGlobalConfigField(fieldName);
- });
-}
-
-/**
- * Gets a specific user config value for a field
- * @param fieldName
- * @returns {Promise}
- */
-function getUserConfigField(fieldName) {
- return readUserConfig().then((config) => {
- if (typeof fieldName === 'string' && fieldName in config) {
- return config[fieldName];
- }
-
- throw new Error('field does not exist in user config: ' + fieldName);
- });
-}
-
-/**
- * Reads the user config file and returns all the attributes
- * @param customConfigPath
- * @returns {Promise}
- */
-function readUserConfig(customConfigPath) {
-
- return new Promise((resolve, reject) => {
-
- if (userConfig) {
- resolve(userConfig);
- return;
- }
-
- let configPath = customConfigPath;
-
- if (!configPath) {
- configPath = path.join(app.getPath('userData'), configFileName);
- }
-
- log.send(logLevels.INFO, `config path ${configPath}`);
-
- fs.readFile(configPath, 'utf8', (err, data) => {
-
- if (err) {
- log.send(logLevels.INFO, `cannot open user config file ${configPath}, error is ${err}`);
- reject(new Error(`cannot open user config file ${configPath}, error is ${err}`));
- return;
- }
-
- try {
- // data is the contents of the text file we just read
- userConfig = JSON.parse(data);
- resolve(userConfig);
- } catch (e) {
- log.send(logLevels.INFO, `cannot parse user config data ${data}, error is ${e}`);
- reject(new Error(`cannot parse user config data ${data}, error is ${e}`));
- }
-
- });
- });
-}
-
-/**
- * Gets a specific global config value for a field
- * @param fieldName
- * @returns {Promise}
- */
-function getGlobalConfigField(fieldName) {
- return readGlobalConfig().then((config) => {
- if (typeof fieldName === 'string' && fieldName in config) {
- return config[fieldName];
- }
-
- throw new Error('field does not exist in global config: ' + fieldName);
- });
-}
-
-/**
- * reads global configuration file: config/Symphony.config. this file is
- * hold items (such as the start url) that are intended to be used as
- * global (or default) values for all users running this app. for production
- * this file is located relative to the executable - it is placed there by
- * the installer. this makes the file easily modifable by admin (or person who
- * installed app). for dev env, the file is read directly from packed asar file.
- */
-function readGlobalConfig() {
- return new Promise((resolve, reject) => {
- if (globalConfig) {
- resolve(globalConfig);
- return;
- }
-
- let configPath;
- let globalConfigFileName = path.join('config', configFileName);
- if (isDevEnv) {
- // for dev env, get config file from asar
- configPath = path.join(app.getAppPath(), globalConfigFileName);
- } else {
- // for non-dev, config file is placed by installer relative to exe.
- // this is so the config can be easily be changed post install.
- let execPath = path.dirname(app.getPath('exe'));
- // for mac exec is stored in subdir, for linux/windows config
- // dir is in the same location.
- configPath = path.join(execPath, isMac ? '..' : '', globalConfigFileName);
- }
-
- fs.readFile(configPath, 'utf8', (err, data) => {
- if (err) {
- reject(new Error('cannot open global config file: ' + configPath + ', error: ' + err));
- } else {
- try {
- // data is the contents of the text file we just read
- globalConfig = JSON.parse(data);
- } catch (e) {
- reject(new Error('can not parse config file data: ' + data + ', error: ' + err));
- }
- getRegistry('PodUrl')
- .then((url) => {
- globalConfig.url = url;
- resolve(globalConfig);
- }).catch(() => {
- resolve(globalConfig);
- });
- }
- });
- });
-}
-
-/**
- * Updates user config with given field with new value
- * @param {String} fieldName Name of field in config to be added/changed.
- * @param {Object} newValue Object to replace given value
- * @return {Promise} Promise that resolves/rejects when file write is complete.
- */
-function updateConfigField(fieldName, newValue) {
- return readUserConfig()
- .then((config) => {
- return saveUserConfig(fieldName, newValue, config);
- }, () => {
- // in case config doesn't exist, can't read or is corrupted.
- // add configBuildNumber - just in case in future we need to provide
- // upgrade capabilities.
- return saveUserConfig(fieldName, newValue, {
- configBuildNumber: buildNumber || '0',
- });
- });
-}
-
-/**
- * Saves an updated value to the user config
- * @param fieldName
- * @param newValue
- * @param oldConfig
- * @returns {Promise}
- */
-function saveUserConfig(fieldName, newValue, oldConfig) {
- return new Promise((resolve, reject) => {
- let configPath = path.join(app.getPath('userData'), configFileName);
-
- if (!oldConfig || !fieldName) {
- reject(new Error('can not save config, invalid input'));
- return;
- }
-
- // clone and set new value
- let newConfig = Object.assign({}, oldConfig);
- newConfig[fieldName] = newValue;
-
- let jsonNewConfig = JSON.stringify(newConfig, null, ' ');
-
- fs.writeFile(configPath, jsonNewConfig, 'utf8', (err) => {
- if (err) {
- reject(err);
- } else {
- userConfig = newConfig;
- resolve(newConfig);
- }
- });
- });
-}
-
-/**
- * Updates the existing user config settings by removing
- * 'minimizeOnClose', 'launchOnStartup', 'url' and 'alwaysOnTop'
- * @param {Object} oldUserConfig the old user config object
- */
-function updateUserConfig(oldUserConfig) {
-
- return new Promise((resolve, reject) => {
-
- // create a new object from the old user config
- // by ommitting the user related settings from
- // the old user config
- log.send(logLevels.INFO, `old user config string ${JSON.stringify(oldUserConfig)}`);
- let newUserConfig = omit(oldUserConfig, ignoreSettings);
- let newUserConfigString = JSON.stringify(newUserConfig, null, 2);
-
- log.send(logLevels.INFO, `new config string ${newUserConfigString}`);
-
- // get the user config path
- let userConfigFile;
- userConfigFile = path.join(app.getPath('userData'), configFileName);
-
- if (!userConfigFile) {
- reject(new Error(`user config file doesn't exist`));
- return;
- }
-
- // write the new user config changes to the user config file
- fs.writeFile(userConfigFile, newUserConfigString, 'utf-8', (err) => {
- if (err) {
- reject(new Error(`Failed to update user config error: ${err}`));
- return;
- }
- userConfig = newUserConfig;
- resolve();
- });
- });
-
-}
-
-/**
- * Manipulates user config on first time launch
- * @returns {Promise}
- */
-function updateUserConfigOnLaunch(resolve, reject) {
- // we get the user config path using electron
- const userConfigFile = path.join(app.getPath('userData'), configFileName);
-
- // In case the file exists, we remove it so that all the
- // values are fetched from the global config
- // https://perzoinc.atlassian.net/browse/ELECTRON-126
- return readUserConfig(userConfigFile).then((data) => {
- // Add build number info to the user config data
- const updatedData = Object.assign(data || {}, { configBuildNumber: buildNumber || '0' });
-
- updateUserConfig(updatedData)
- .then(resolve)
- .catch(reject);
- }).catch((err) => {
- return reject(err);
- });
-
-}
-
-/**
- * Method that tries to grab multiple config field from user config
- * if field doesn't exist tries reading from global config
- *
- * @param {Array} fieldNames - array of config filed names
- * @returns {Promise} - object all the config data from user and global config
- */
-function getMultipleConfigField(fieldNames) {
- return new Promise((resolve, reject) => {
- let userConfigData;
-
- if (!fieldNames && fieldNames.length < 0) {
- reject(new Error('cannot read config file, invalid fields'));
- return;
- }
-
- // reads user config data
- readUserConfig().then((config) => {
- userConfigData = pick(config, fieldNames);
- let userConfigKeys = userConfigData ? Object.keys(userConfigData) : undefined;
-
- /**
- * Condition to validate data from user config,
- * if all the required fields are not present
- * this tries to fetch the remaining fields from global config
- */
- if (!userConfigKeys || userConfigKeys.length < fieldNames.length) {
-
- // remainingConfig - config field that are not present in the user config
- let remainingConfig = difference(fieldNames, userConfigKeys);
-
- if (remainingConfig && Object.keys(remainingConfig).length > 0) {
- readGlobalConfig().then((globalConfigData) => {
- // assigns the remaining fields from global config to the user config
- userConfigData = Object.assign(userConfigData, pick(globalConfigData, remainingConfig));
- resolve(userConfigData);
- }).catch((err) => {
- reject(err);
- });
- }
-
- } else {
- resolve(userConfigData);
- }
- }).catch(() => {
- // This reads global config if there was any
- // error while reading user config
- readGlobalConfig().then((config) => {
- userConfigData = pick(config, fieldNames);
- resolve(userConfigData);
- }).catch((err) => {
- reject(err);
- });
- });
- });
-}
-
-
-/**
- * Clears the cached config
- */
-function clearCachedConfigs() {
- userConfig = null;
- globalConfig = null;
-}
-
-function readConfigFileSync() {
-
- let configPath;
- let globalConfigFileName = path.join('config', configFileName);
- if (isDevEnv) {
- // for dev env, get config file from asar
- configPath = path.join(app.getAppPath(), globalConfigFileName);
- } else {
- // for non-dev, config file is placed by installer relative to exe.
- // this is so the config can be easily be changed post install.
- let execPath = path.dirname(app.getPath('exe'));
- // for mac exec is stored in subdir, for linux/windows config
- // dir is in the same location.
- configPath = path.join(execPath, isMac ? '..' : '', globalConfigFileName);
- }
-
- let data = fs.readFileSync(configPath);
-
- try {
- return JSON.parse(data);
- } catch (err) {
- log.send(logLevels.ERROR, 'config: parsing config failed: ' + err);
- }
-
- return null;
-
-}
-
-const readConfigFromFile = (key) => {
- let data = readConfigFileSync();
- return data[key];
-}
-
-module.exports = {
-
- configFileName,
-
- getConfigField,
-
- updateConfigField,
- updateUserConfigOnLaunch,
-
- getMultipleConfigField,
-
- // items below here are only exported for testing, do NOT use!
- saveUserConfig,
- clearCachedConfigs,
-
- readConfigFileSync,
- readConfigFromFile,
-
- // use only if you specifically need to read global config fields
- getGlobalConfigField,
- getUserConfigField
-};
diff --git a/js/crashReporter.js b/js/crashReporter.js
deleted file mode 100644
index d1147ff6..00000000
--- a/js/crashReporter.js
+++ /dev/null
@@ -1,85 +0,0 @@
-const { crashReporter } = require('electron');
-const { getMultipleConfigField } = require('./config.js');
-
-const log = require('./log.js');
-const logLevels = require('./enums/logLevels.js');
-
-const configFields = ['url', 'crashReporter'];
-let crashReporterData;
-
-/**
- * Method that returns all the required field for crash reporter
- *
- * @param extras {object}
- * @return {Promise}
- */
-function getCrashReporterConfig(extras) {
- return new Promise((resolve, reject) => {
-
- if (crashReporterData && crashReporterData.companyName) {
- crashReporterData.extra = Object.assign(crashReporterData.extra, extras);
- resolve(crashReporterData);
- return;
- }
-
- getMultipleConfigField(configFields)
- .then((data) => {
-
- if (!data && !data.crashReporter && !data.crashReporter.companyName) {
- reject(new Error('Company name cannot be empty'));
- return;
- }
-
- crashReporterData = {
- companyName: data.crashReporter.companyName,
- submitURL: data.crashReporter.submitURL,
- uploadToServer: data.crashReporter.uploadToServer,
- extra: Object.assign(
- {podUrl: data.url},
- extras
- )
- };
- resolve(crashReporterData);
- })
- .catch((err) => log.send(
- logLevels.ERROR,
- 'Unable to initialize crash reporter failed to read config file. Error is -> ' + err
- ));
- })
-}
-
-function initCrashReporterMain(extras) {
- getCrashReporterConfig(extras).then((mainCrashReporterData) => {
- try {
- crashReporter.start(mainCrashReporterData);
- } catch (err) {
- log.send(logLevels.ERROR, 'Failed to start crash reporter main process. Error is -> ' + err);
- }
- }).catch((err) => log.send(
- logLevels.ERROR,
- 'Unable to initialize crash reporter for main process. Error is -> ' + err
- ));
-}
-
-
-/**
- * Method to initialize crash reporter for renderer process
- *
- * @param browserWindow {Electron.BrowserWindow}
- * @param extras {Object}
- */
-function initCrashReporterRenderer(browserWindow, extras) {
- if (browserWindow && browserWindow.webContents && !browserWindow.isDestroyed()) {
- getCrashReporterConfig(extras).then((rendererCrashReporterData) => {
- browserWindow.webContents.send('register-crash-reporter', rendererCrashReporterData);
- }).catch((err) => log.send(
- logLevels.ERROR,
- 'Unable to initialize crash reporter for renderer process. Error is -> ' + err
- ));
- }
-}
-
-module.exports = {
- initCrashReporterMain,
- initCrashReporterRenderer,
-};
\ No newline at end of file
diff --git a/js/cryptoLib.js b/js/cryptoLib.js
deleted file mode 100644
index 6cc9f673..00000000
--- a/js/cryptoLib.js
+++ /dev/null
@@ -1,132 +0,0 @@
-const electron = require('electron');
-const app = electron.app;
-const ffi = require('ffi');
-const ref = require('ref');
-const path = require('path');
-const execPath = path.dirname(app.getPath('exe'));
-
-const log = require('./log.js');
-const logLevels = require('./enums/logLevels.js');
-const { isMac, isDevEnv } = require('../js/utils/misc');
-
-const TAG_LENGTH = 16;
-const arch = process.arch === 'ia32';
-const winLibraryPath = isDevEnv ? path.join(__dirname, '..', 'library') : path.join(execPath, 'library');
-const macLibraryPath = isDevEnv ? path.join(__dirname, '..', 'library') : path.join(execPath, '..', 'library');
-
-const cryptoLibPath = isMac ?
- path.join(macLibraryPath, 'cryptoLib.dylib') :
- (arch ? path.join(winLibraryPath, 'libsymphonysearch-x86.dll') : path.join(winLibraryPath, 'libsymphonysearch-x64.dll'));
-
-const library = new ffi.Library((cryptoLibPath), {
-
- AESEncryptGCM: [ref.types.int32, [
- ref.refType(ref.types.uchar),
- ref.types.int32,
- ref.refType(ref.types.uchar),
- ref.types.int32,
- ref.refType(ref.types.uchar),
- ref.refType(ref.types.uchar),
- ref.types.uint32,
- ref.refType(ref.types.uchar),
- ref.refType(ref.types.uchar),
- ref.types.uint32,
- ]],
-
- AESDecryptGCM: [ref.types.int32, [
- ref.refType(ref.types.uchar),
- ref.types.int32,
- ref.refType(ref.types.uchar),
- ref.types.int32,
- ref.refType(ref.types.uchar),
- ref.types.uint32,
- ref.refType(ref.types.uchar),
- ref.refType(ref.types.uchar),
- ref.types.uint32,
- ref.refType(ref.types.uchar),
- ]],
-
- getVersion: [ref.types.CString, []],
-});
-
-/**
- * Method to decrypt content
- * @param Base64IV
- * @param Base64AAD
- * @param Base64Key
- * @param Base64In
- * @return {*}
- * @constructor
- */
-const AESGCMEncrypt = function (Base64IV, Base64AAD, Base64Key, Base64In) {
- return EncryptDecrypt('AESGCMEncrypt', Base64IV, Base64AAD, Base64Key, Base64In);
-};
-
-/**
- * Method to decrypt content
- * @param Base64IV
- * @param Base64AAD
- * @param Base64Key
- * @param Base64In
- * @return {*}
- * @constructor
- */
-const AESGCMDecrypt = function (Base64IV, Base64AAD, Base64Key, Base64In) {
- return EncryptDecrypt('AESGCMDecrypt', Base64IV, Base64AAD, Base64Key, Base64In);
-};
-
-/**
- * Encrypt / Decrypt
- * @param name {String} - Method name
- * @param Base64IV {String} base64
- * @param Base64AAD {String} base64
- * @param Base64Key {String} base64
- * @param Base64In {String} base64
- * @return {*}
- * @constructor
- */
-const EncryptDecrypt = function (name, Base64IV, Base64AAD, Base64Key, Base64In) {
- let base64In = Base64In;
-
- if (!base64In) {
- base64In = "";
- }
-
- const IV = Buffer.from(Base64IV, 'base64');
- const AAD = Buffer.from(Base64AAD, 'base64');
- const Key = Buffer.from(Base64Key, 'base64');
- const In = Buffer.from(base64In, 'base64');
-
- if (name === 'AESGCMEncrypt') {
- const OutPtr = Buffer.alloc(In.length);
- const Tag = Buffer.alloc(TAG_LENGTH);
-
- const resultCode = library.AESEncryptGCM(In, In.length, AAD, AAD.length, Key, IV, IV.length, OutPtr, Tag, TAG_LENGTH);
-
- if (resultCode < 0) {
- log.send(logLevels.ERROR, `AESEncryptGCM, Failed to encrypt with exit code ${resultCode}`);
- }
- const bufferArray = [OutPtr, Tag];
- return Buffer.concat(bufferArray).toString('base64');
- }
-
- if (name === 'AESGCMDecrypt') {
- const CipherTextLen = In.length - TAG_LENGTH;
- const Tag = Buffer.from(In.slice(In.length - 16, In.length));
- const OutPtr = Buffer.alloc(In.length - TAG_LENGTH);
-
- const resultCode = library.AESDecryptGCM(In, CipherTextLen, AAD, AAD.length, Tag, TAG_LENGTH, Key, IV, IV.length, OutPtr);
-
- if (resultCode < 0) {
- log.send(logLevels.ERROR, `AESDecryptGCM, Failed to decrypt with exit code ${resultCode}`);
- }
- return OutPtr.toString('base64');
- }
-
- return null;
-};
-
-module.exports = {
- AESGCMEncrypt: AESGCMEncrypt,
- AESGCMDecrypt: AESGCMDecrypt,
-};
diff --git a/js/desktopCapturer/getSource.js b/js/desktopCapturer/getSource.js
deleted file mode 100644
index 1c43e167..00000000
--- a/js/desktopCapturer/getSource.js
+++ /dev/null
@@ -1,161 +0,0 @@
-'use strict';
-
-// This code provides equivalent of desktopCapturer.getSources that works in
-// a sandbox renderer. see: https://electron.atom.io/docs/api/desktop-capturer/
-//
-// The code here is not entirely kosher/stable as it is using private ipc
-// events. The code was take directly from electron.asar file provided in
-// prebuilt node module. Note: the slight difference here is the thumbnail
-// returns a base64 encoded image rather than a electron nativeImage.
-//
-// Until electron provides access to desktopCapturer in a sandboxed
-// renderer process, this will have to do. See github issue posted here to
-// electron: https://github.com/electron/electron/issues/9312
-
-const { ipcRenderer, remote, desktopCapturer } = require('electron');
-const apiEnums = require('../enums/api.js');
-const apiCmds = apiEnums.cmds;
-const apiName = apiEnums.apiName;
-const { isWindowsOS } = require('../utils/misc');
-const USER_CANCELLED = 'User Cancelled';
-
-let nextId = 0;
-let includes = [].includes;
-let screenShareArgv;
-let isScreenShareEnabled = false;
-let dialogContent;
-
-function getNextId() {
- return ++nextId;
-}
-
-/**
- * Checks if the options and their types are valid
- * @param options |options.type| can not be empty and has to include 'window' or 'screen'.
- * @returns {boolean}
- */
-function isValid(options) {
- return ((options !== null ? options.types : undefined) !== null) && Array.isArray(options.types);
-}
-
-/**
- * Gets the sources for capturing screens / windows
- * @param options
- * @param callback
- * @returns {*}
- */
-function getSource(options, callback) {
- let captureScreen, captureWindow, id;
- let sourceTypes = [];
- if (!isValid(options)) {
- callback(new Error('Invalid options'));
- return;
- }
- captureWindow = includes.call(options.types, 'window');
- captureScreen = includes.call(options.types, 'screen');
-
- let updatedOptions = options;
- if (!updatedOptions.thumbnailSize) {
- updatedOptions.thumbnailSize = {
- width: 150,
- height: 150
- };
- }
-
- if (isWindowsOS && captureWindow) {
- /**
- * Sets the captureWindow to false if Desktop composition
- * is disabled otherwise true
- *
- * Setting captureWindow to false returns only screen sources
- * @type {boolean}
- */
- captureWindow = remote.systemPreferences.isAeroGlassEnabled();
- }
-
- if (captureWindow) {
- sourceTypes.push('window');
- }
- if (captureScreen) {
- sourceTypes.push('screen');
- }
-
- // displays a dialog if media permissions are disable
- if (!isScreenShareEnabled) {
- let focusedWindow = remote.BrowserWindow.getFocusedWindow();
- if (focusedWindow && !focusedWindow.isDestroyed()) {
- remote.dialog.showMessageBox(focusedWindow, dialogContent ||
- {
- type: 'error',
- title: 'Permission Denied!',
- message: 'Your administrator has disabled screen share. Please contact your admin for help'
- });
- callback(new Error('Permission Denied'));
- return;
- }
- }
-
- id = getNextId();
- desktopCapturer.getSources({ types: sourceTypes, thumbnailSize: updatedOptions.thumbnailSize }, (event, sources) => {
-
- if (screenShareArgv) {
- const title = screenShareArgv.substr(screenShareArgv.indexOf('=') + 1);
- const filteredSource = sources.filter(source => source.name === title);
-
- if (Array.isArray(filteredSource) && filteredSource.length > 0) {
- return callback(null, filteredSource[0]);
- }
-
- if (typeof filteredSource === 'object' && filteredSource.name) {
- return callback(null, filteredSource);
- }
-
- if (sources.length > 0) {
- return callback(null, sources[0]);
- }
-
- }
-
- const updatedSources = sources.map(source => {
- return Object.assign({}, source, {
- thumbnail: source.thumbnail.toDataURL()
- });
- });
-
- ipcRenderer.send(apiName, {
- cmd: apiCmds.openScreenPickerWindow,
- sources: updatedSources,
- id: id
- });
-
- function successCallback(e, source) {
- // Cleaning up the event listener to prevent memory leaks
- if (!source) {
- ipcRenderer.removeListener('start-share' + id, func);
- return callback(new Error(USER_CANCELLED));
- }
- return callback(null, source);
- }
-
- const func = successCallback.bind(this);
- ipcRenderer.once('start-share' + id, func);
- return null;
- });
-}
-
-// event that updates screen share argv
-ipcRenderer.once('screen-share-argv', (event, arg) => {
- if (typeof arg === 'string') {
- screenShareArgv = arg;
- }
-});
-
-// event that updates screen share permission
-ipcRenderer.on('is-screen-share-enabled', (event, screenShare, content) => {
- dialogContent = content;
- if (typeof screenShare === 'boolean' && screenShare) {
- isScreenShareEnabled = true;
- }
-});
-
-module.exports = getSource;
\ No newline at end of file
diff --git a/js/desktopCapturer/getSources.js b/js/desktopCapturer/getSources.js
deleted file mode 100644
index 9d90c3de..00000000
--- a/js/desktopCapturer/getSources.js
+++ /dev/null
@@ -1,146 +0,0 @@
-'use strict';
-
-// This code provides equivalent of desktopCapturer.getSources that works in
-// a sandbox renderer. see: https://electron.atom.io/docs/api/desktop-capturer/
-//
-// The code here is not entirely kosher/stable as it is using private ipc
-// events. The code was take directly from electron.asar file provided in
-// prebuilt node module. Note: the slight difference here is the thumbnail
-// returns a base64 encoded image rather than a electron nativeImage.
-//
-// Until electron provides access to desktopCapturer in a sandboxed
-// renderer process, this will have to do. See github issue posted here to
-// electron: https://github.com/electron/electron/issues/9312
-
-const { remote, desktopCapturer, ipcRenderer } = require('electron');
-const { isWindowsOS } = require('../utils/misc');
-
-let includes = [].includes;
-let screenShareArgv;
-let isScreenShareEnabled = false;
-let dialogContent;
-
-/**
- * Checks if the options and their types are valid
- * @param options |options.type| can not be empty and has to include 'window' or 'screen'.
- * @returns {boolean}
- */
-function isValid(options) {
- return ((options !== null ? options.types : undefined) !== null) && Array.isArray(options.types);
-}
-
-/**
- * Gets the sources for capturing screens / windows
- * @param options
- * @param callback
- * @returns {*}
- */
-function getSources(options, callback) {
- let captureScreen, captureWindow;
- let sourceTypes = [];
- if (!isValid(options)) {
- callback(new Error('Invalid options'));
- return;
- }
- captureWindow = includes.call(options.types, 'window');
- captureScreen = includes.call(options.types, 'screen');
-
- let updatedOptions = options;
- if (!updatedOptions.thumbnailSize) {
- updatedOptions.thumbnailSize = {
- width: 150,
- height: 150
- };
- }
-
- if (isWindowsOS && captureWindow) {
- /**
- * Sets the captureWindow to false if Desktop composition
- * is disabled otherwise true
- *
- * Setting captureWindow to false returns only screen sources
- * @type {boolean}
- */
- captureWindow = remote.systemPreferences.isAeroGlassEnabled();
- }
- if (captureWindow) {
- sourceTypes.push('window');
- }
- if (captureScreen) {
- sourceTypes.push('screen');
- }
-
- // displays a dialog if media permissions are disable
- if (!isScreenShareEnabled) {
- let focusedWindow = remote.BrowserWindow.getFocusedWindow();
- if (focusedWindow && !focusedWindow.isDestroyed()) {
- remote.dialog.showMessageBox(focusedWindow, dialogContent ||
- {
- type: 'error',
- title: 'Permission Denied!',
- message: 'Your administrator has disabled screen share. Please contact your admin for help'
- });
- callback(new Error('Permission Denied'));
- return;
- }
- }
-
- desktopCapturer.getSources({ types: sourceTypes, thumbnailSize: updatedOptions.thumbnailSize }, (event, sources) => {
-
- if (screenShareArgv) {
- const title = screenShareArgv.substr(screenShareArgv.indexOf('=') + 1);
- const filteredSource = sources.filter(source => source.name === title);
-
- if (Array.isArray(filteredSource) && filteredSource.length > 0) {
- return callback(null, filteredSource[0]);
- }
-
- if (typeof filteredSource === 'object' && filteredSource.name) {
- return callback(null, filteredSource);
- }
-
- if (sources.length > 0) {
- return callback(null, sources[0]);
- }
-
- }
-
- let source;
- return callback(null, (function() {
- let i, len, results;
- results = [];
- for (i = 0, len = sources.length; i < len; i++) {
- source = sources[i];
- results.push({
- id: source.id,
- name: source.name,
- thumbnail: source.thumbnail.toDataURL()
- });
- }
-
- return results;
-
- }()));
- });
-}
-
-// event that updates screen share argv
-ipcRenderer.once('screen-share-argv', (event, arg) => {
- if (typeof arg === 'string') {
- screenShareArgv = arg;
- }
-});
-
-// event that updates screen share permission
-ipcRenderer.on('is-screen-share-enabled', (event, screenShare, content) => {
- dialogContent = content;
- if (typeof screenShare === 'boolean' && screenShare) {
- isScreenShareEnabled = true;
- }
-});
-
-/**
- * @deprecated instead use getSource
- * @type {getSources}
- */
-module.exports = getSources;
\ No newline at end of file
diff --git a/js/desktopCapturer/index.js b/js/desktopCapturer/index.js
deleted file mode 100644
index fa4fa516..00000000
--- a/js/desktopCapturer/index.js
+++ /dev/null
@@ -1,174 +0,0 @@
-'use strict';
-
-const electron = require('electron');
-const BrowserWindow = electron.BrowserWindow;
-const ipc = electron.ipcMain;
-const path = require('path');
-const fs = require('fs');
-const log = require('../log.js');
-const logLevels = require('../enums/logLevels.js');
-const { isMac, isWindowsOS } = require('./../utils/misc.js');
-const { initCrashReporterMain, initCrashReporterRenderer } = require('../crashReporter.js');
-const i18n = require('../translation/i18n');
-
-let screenPickerWindow;
-let preloadWindow;
-let eventId;
-
-let windowConfig = {
- width: 580,
- height: isMac ? 519 : 523,
- show: false,
- modal: true,
- frame: false,
- autoHideMenuBar: true,
- resizable: false,
- alwaysOnTop: true,
- webPreferences: {
- preload: path.join(__dirname, 'renderer.js'),
- sandbox: true,
- nodeIntegration: false,
- devTools: false
- }
-};
-
-/**
- * method to get the HTML template path
- * @returns {string}
- */
-function getTemplatePath() {
- let templatePath = path.join(__dirname, 'screen-picker.html');
- try {
- fs.statSync(templatePath).isFile();
- } catch (err) {
- log.send(logLevels.ERROR, 'screen-picker: Could not find template ("' + templatePath + '").');
- }
- return 'file://' + templatePath;
-}
-
-/**
- * Creates the screen picker window
- * @param eventSender {RTCRtpSender} - event sender window object
- * @param sources {Array} - list of object which has screens and applications
- * @param id {Number} - event emitter id
- */
-function openScreenPickerWindow(eventSender, sources, id) {
-
- // prevent a new window from being opened if there is an
- // existing window / there is no event sender
- if (!eventSender || screenPickerWindow) {
- return;
- }
-
- // Screen picker will always be placed on top of the focused window
- const focusedWindow = BrowserWindow.getFocusedWindow();
-
- // As screen picker is an independent window this will make sure
- // it will open screen picker window center of the focused window
- if (focusedWindow) {
- const { x, y, width, height } = focusedWindow.getBounds();
-
- if (x !== undefined && y !== undefined) {
- const windowWidth = Math.round(width * 0.5);
- const windowHeight = Math.round(height * 0.5);
-
- // Calculating the center of the parent window
- // to place the configuration window
- const centerX = x + width / 2.0;
- const centerY = y + height / 2.0;
- windowConfig.x = Math.round(centerX - (windowWidth / 2.0));
- windowConfig.y = Math.round(centerY - (windowHeight / 2.0));
- }
-
- if (isWindowsOS) {
- windowConfig.parent = focusedWindow;
- }
- }
-
- // Store the window ref to send event
- preloadWindow = eventSender;
- eventId = id;
-
- screenPickerWindow = new BrowserWindow(windowConfig);
- screenPickerWindow.setVisibleOnAllWorkspaces(true);
- screenPickerWindow.loadURL(getTemplatePath());
-
- screenPickerWindow.once('ready-to-show', () => {
- screenPickerWindow.show();
- });
-
- screenPickerWindow.webContents.on('did-finish-load', () => {
- const screenPickerContent = i18n.getMessageFor('ScreenPicker');
- screenPickerWindow.webContents.send('i18n-screen-picker', screenPickerContent);
- // initialize crash reporter
- initCrashReporterMain({ process: 'desktop capture window' });
- initCrashReporterRenderer(screenPickerWindow, { process: 'render | desktop capture window' });
- screenPickerWindow.webContents.send('desktop-capturer-sources', sources, isWindowsOS);
- });
-
- screenPickerWindow.webContents.on('crashed', function (event, killed) {
-
- log.send(logLevels.INFO, `Screen Picker Window crashed! Killed? ${killed}`);
-
- if (killed) {
- return;
- }
-
- const options = {
- type: 'error',
- title: i18n.getMessageFor('Renderer Process Crashed'),
- message: i18n.getMessageFor('Oops! Looks like we have had a crash.'),
- buttons: ['Close']
- };
-
- electron.dialog.showMessageBox(options, function () {
- if (screenPickerWindow && !screenPickerWindow.isDestroyed()) {
- screenPickerWindow.close();
- }
- });
- });
-
- screenPickerWindow.on('close', () => {
- destroyWindow();
- });
-
- screenPickerWindow.on('closed', () => {
- destroyWindow();
- });
-
-}
-
-/**
- * Destroys a window
- */
-function destroyWindow() {
- // sending null will clean up the event listener
- startScreenShare(null);
- screenPickerWindow = null;
-}
-
-/**
- * Sends an event to a specific with the selected source
- * @param source {Object} - User selected source
- */
-function startScreenShare(source) {
- if (preloadWindow && !preloadWindow.isDestroyed()) {
- preloadWindow.send('start-share' + eventId, source);
- }
-}
-
-// Emitted when user has selected a source and press the share button
-ipc.on('share-selected-source', (event, source) => {
- startScreenShare(source);
-});
-
-// Emitted when user closes the screen picker window
-ipc.on('close-screen-picker', () => {
- if (screenPickerWindow && !screenPickerWindow.isDestroyed()) {
- screenPickerWindow.close();
- }
-});
-
-module.exports = {
- openScreenPickerWindow
-};
diff --git a/js/desktopCapturer/renderer.js b/js/desktopCapturer/renderer.js
deleted file mode 100644
index a2e3c789..00000000
--- a/js/desktopCapturer/renderer.js
+++ /dev/null
@@ -1,319 +0,0 @@
-'use strict';
-const { ipcRenderer, crashReporter } = require('electron');
-
-const screenRegExp = new RegExp(/^Screen \d+$/gmi);
-
-// All the required Keyboard keyCode events
-const keyCodeEnum = Object.freeze({
- pageDown: 34,
- rightArrow: 39,
- pageUp: 33,
- leftArrow: 37,
- homeKey: 36,
- upArrow: 38,
- endKey: 35,
- arrowDown: 40,
- enterKey: 13,
- escapeKey: 27
-});
-
-let availableSources;
-let selectedSource;
-let currentIndex = -1;
-let localizedContent;
-
-document.addEventListener('DOMContentLoaded', () => {
- renderDom();
-});
-
-/**
- * Method that renders application data
- */
-function renderDom() {
- const applicationTab = document.getElementById('application-tab');
- const screenTab = document.getElementById('screen-tab');
- const share = document.getElementById('share');
- const cancel = document.getElementById('cancel');
- const xButton = document.getElementById('x-button');
-
- // Event listeners
- xButton.addEventListener('click', () => {
- closeScreenPickerWindow();
- }, false);
-
- share.addEventListener('click', () => {
- startShare();
- }, false);
-
- cancel.addEventListener('click', () => {
- closeScreenPickerWindow();
- }, false);
-
- screenTab.addEventListener('click', () => {
- updateShareButtonText(localizedContent && localizedContent[ 'Select Screen' ] ?
- localizedContent[ 'Select Screen' ] :
- 'Select Screen');
- }, false);
-
- applicationTab.addEventListener('click', () => {
- updateShareButtonText(localizedContent && localizedContent[ 'Select Application' ] ?
- localizedContent[ 'Select Application' ] :
- 'Select Application');
- }, false);
-
- document.addEventListener('keyup', handleKeyUpPress.bind(this), true);
-
-}
-
-/**
- * Event emitted by main process with a list of available
- * Screens and Applications
- */
-ipcRenderer.on('desktop-capturer-sources', (event, sources, isWindowsOS) => {
-
- if (!Array.isArray(sources) && typeof isWindowsOS !== 'boolean') {
- return;
- }
- availableSources = sources;
-
- if (isWindowsOS) {
- document.body.classList.add('window-border');
- }
-
- const screenContent = document.getElementById('screen-contents');
- const applicationContent = document.getElementById('application-contents');
- const applicationTab = document.getElementById('applications');
- const screenTab = document.getElementById('screens');
-
- let hasScreens = false;
- let hasApplications = false;
-
- for (let source of sources) {
- screenRegExp.lastIndex = 0;
- if (source.display_id !== "") {
- source.fileName = 'fullscreen';
- if (source.name === 'Entire screen') {
- const screenName = localizedContent['Entire screen'] || 'Entire screen';
- screenContent.appendChild(createItem(source, screenName));
- } else {
- const screenName = localizedContent['Screen {number}'] || 'Screen {number}';
- const screenNumber = source.name.substr(7, source.name.length);
- const localisedScreenString = screenName.replace('{number}', screenNumber);
- screenContent.appendChild(createItem(source, localisedScreenString));
- }
- hasScreens = true;
- } else {
- source.fileName = null;
- applicationContent.appendChild(createItem(source, source.name));
- hasApplications = true;
- }
- }
-
- if (!hasScreens && !hasApplications) {
- const errorContent = document.getElementById('error-content');
- const mainContent = document.getElementById('main-content');
-
- errorContent.style.display = 'block';
- mainContent.style.display = 'none';
- }
-
- if (hasApplications) {
- applicationTab.classList.remove('hidden');
- }
-
- if (hasScreens) {
- screenTab.classList.remove('hidden');
- }
-});
-
-function startShare() {
- if (selectedSource && selectedSource.id) {
- ipcRenderer.send('share-selected-source', selectedSource);
- closeScreenPickerWindow();
- }
-}
-
-/**
- * Creates DOM elements and injects data
- * @param source Screen source
- * @param name Name of the source
- * @returns {HTMLDivElement}
- */
-function createItem(source, name) {
- const itemContainer = document.createElement("div");
- const sectionBox = document.createElement("div");
- const imageTag = document.createElement("img");
- const titleContainer = document.createElement("div");
-
- // Added class names to the dom elements
- itemContainer.classList.add('item-container');
- sectionBox.classList.add('screen-section-box');
- imageTag.classList.add('img-wrapper');
- titleContainer.classList.add('screen-source-title');
-
- // Inject data to the dom element
- imageTag.src = source.thumbnail;
- titleContainer.innerText = name;
-
- sectionBox.appendChild(imageTag);
- itemContainer.id = source.id;
- itemContainer.appendChild(sectionBox);
- itemContainer.appendChild(titleContainer);
-
- itemContainer.addEventListener('click', updateUI.bind(this, source, itemContainer), false);
-
- return itemContainer;
-}
-
-/**
- * When ever user select a source store it and update the UI
- * @param source
- * @param itemContainer
- */
-function updateUI(source, itemContainer) {
- selectedSource = source;
-
- let shareButton = document.getElementById('share');
- shareButton.className = 'share-button';
-
- highlightSelectedSource();
- itemContainer.classList.add('selected');
- shareButton.innerText = localizedContent && localizedContent.Share ? localizedContent.Share : 'Share';
-}
-
-/**
- * Loops through the items and removes
- * the selected class property
- */
-function highlightSelectedSource() {
- let items = document.getElementsByClassName('item-container');
- for (const item of items) {
- item.classList.remove('selected');
- }
-}
-
-/**
- * Method that updates the share button
- * text based on the content type
- * @param text
- */
-function updateShareButtonText(text) {
- let shareButton = document.getElementById('share');
-
- if (shareButton && shareButton.classList[0] === 'share-button-disable') {
- shareButton.innerText = text;
- }
-}
-
-/**
- * Method handles used key up event
- * @param e
- */
-function handleKeyUpPress(e) {
- const keyCode = e.keyCode || e.which;
-
- switch (keyCode) {
- case keyCodeEnum.pageDown:
- case keyCodeEnum.rightArrow:
- updateSelectedSource(1);
- break;
- case keyCodeEnum.pageUp:
- case keyCodeEnum.leftArrow:
- updateSelectedSource(-1);
- break;
- case keyCodeEnum.homeKey:
- if (currentIndex !== 0) {
- updateSelectedSource(0);
- }
- break;
- case keyCodeEnum.upArrow:
- updateSelectedSource(-2);
- break;
- case keyCodeEnum.endKey:
- if (currentIndex !== availableSources.length - 1) {
- updateSelectedSource(availableSources.length - 1);
- }
- break;
- case keyCodeEnum.arrowDown:
- updateSelectedSource(2);
- break;
- case keyCodeEnum.enterKey:
- startShare();
- break;
- case keyCodeEnum.escapeKey:
- closeScreenPickerWindow();
- break;
- default:
- break;
- }
-}
-
-/**
- * Updates UI based on the key press
- * @param index
- */
-function updateSelectedSource(index) {
-
- let selectedElement = document.getElementsByClassName('selected')[0];
- if (selectedElement) {
- currentIndex = availableSources.findIndex((source) => {
- return source.id === selectedElement.id
- });
- }
-
- // Find the next item to be selected
- let nextIndex = (currentIndex + index + availableSources.length) % availableSources.length;
- if (availableSources[nextIndex] && availableSources[nextIndex].id) {
- let item = document.getElementById(availableSources[nextIndex] ? availableSources[nextIndex].id : "");
-
- if (item) {
- // Method that stores and update the selected source
- updateUI(availableSources[nextIndex], item);
- }
- }
-}
-
-/**
- * Closes the screen picker window
- */
-function closeScreenPickerWindow() {
- document.removeEventListener('keyUp', handleKeyUpPress.bind(this), true);
- ipcRenderer.send('close-screen-picker');
-}
-
-ipcRenderer.on('register-crash-reporter', (event, arg) => {
- if (arg && typeof arg === 'object') {
- crashReporter.start(arg);
- }
-});
-
-ipcRenderer.on('i18n-screen-picker', (event, content) => {
- localizedContent = content;
- if (content && typeof content === 'object') {
- const i18nNodes = document.querySelectorAll('[data-i18n-text]');
-
- for (let node of i18nNodes) {
- if (node.attributes['data-i18n-text'] && node.attributes['data-i18n-text'].value) {
- node.innerText = content[node.attributes['data-i18n-text'].value] || node.attributes['data-i18n-text'].value;
- }
- }
- }
-});
-
-
-// note: this is a workaround until
-// https://github.com/electron/electron/issues/8841
-// is fixed on the electron. where 'will-navigate'
-// is never fired in sandbox mode
-//
-// This is required in order to prevent from loading
-// dropped content
-window.addEventListener('drop', function(e) {
- e.preventDefault();
- e.stopPropagation();
-});
-
-window.addEventListener('dragover', function(e) {
- e.preventDefault();
- e.stopPropagation();
-});
\ No newline at end of file
diff --git a/js/desktopCapturer/screen-picker.html b/js/desktopCapturer/screen-picker.html
deleted file mode 100644
index bbeede3b..00000000
--- a/js/desktopCapturer/screen-picker.html
+++ /dev/null
@@ -1,246 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/js/dialogs/showBasicAuth.js b/js/dialogs/showBasicAuth.js
deleted file mode 100644
index d91cb105..00000000
--- a/js/dialogs/showBasicAuth.js
+++ /dev/null
@@ -1,46 +0,0 @@
-'use strict';
-
-const electron = require('electron');
-
-const basicAuth = require('../basicAuth');
-let currentAuthURL;
-let tries = 0;
-
-/**
- * Having a proxy or hosts that requires authentication will allow user to
- * enter their credentials 'username' & 'password'
- */
-electron.app.on('login', (event, webContents, request, authInfo, callback) => {
-
- event.preventDefault();
-
- // This check is to determine whether the request is for the same
- // host if so then increase the login tries from which we can
- // display invalid credentials
- if (currentAuthURL !== request.url) {
- currentAuthURL = request.url;
- } else {
- tries++
- }
-
- // name of the host to display
- let hostname = authInfo.host || authInfo.realm;
- let browserWin = electron.BrowserWindow.fromWebContents(webContents);
- let windowName = browserWin.winName || '';
-
- /**
- * Method that resets currentAuthURL and tries
- * if user closes the auth window
- */
- function clearSettings() {
- callback();
- currentAuthURL = '';
- tries = 0;
- }
-
- /**
- * Opens an electron modal window in which
- * user can enter credentials fot the host
- */
- basicAuth.openBasicAuthWindow(windowName, hostname, tries === 0, clearSettings, callback);
-});
diff --git a/js/dialogs/showCertError.js b/js/dialogs/showCertError.js
deleted file mode 100644
index 914cab19..00000000
--- a/js/dialogs/showCertError.js
+++ /dev/null
@@ -1,48 +0,0 @@
-'use strict';
-
-const electron = require('electron');
-
-const log = require('../log.js');
-const logLevels = require('../enums/logLevels.js');
-const i18n = require('../translation/i18n');
-
-let ignoreAllCertErrors = false;
-
-/**
- * If certificate error occurs allow user to deny or allow particular certificate
- * error. If user selects 'Ignore All', then all subsequent certificate errors
- * will ignored during this session.
- *
- * Note: the dialog is synchronous so further processing is blocked until
- * user provides a response.
- */
-electron.app.on('certificate-error', function(event, webContents, url, error,
- certificate, callback) {
-
- if (ignoreAllCertErrors) {
- event.preventDefault();
- callback(true);
- return;
- }
-
- log.send(logLevels.WARNING, 'Certificate error: ' + error + ' for url: ' + url);
-
- const browserWin = electron.BrowserWindow.fromWebContents(webContents);
- const buttonId = electron.dialog.showMessageBox(browserWin, {
- type: 'warning',
- buttons: [ 'Allow', 'Deny', 'Ignore All' ],
- defaultId: 1,
- cancelId: 1,
- noLink: true,
- title: i18n.getMessageFor('Certificate Error'),
- message: i18n.getMessageFor('Certificate Error') + `: ${error}\nURL: ${url}`,
- });
-
- event.preventDefault();
-
- if (buttonId === 2) {
- ignoreAllCertErrors = true;
- }
-
- callback(buttonId !== 1);
-});
diff --git a/js/dialogs/showLoadError.js b/js/dialogs/showLoadError.js
deleted file mode 100644
index 0fede3ad..00000000
--- a/js/dialogs/showLoadError.js
+++ /dev/null
@@ -1,67 +0,0 @@
-'use strict';
-
-const electron = require('electron');
-
-const log = require('../log.js');
-const logLevels = require('../enums/logLevels.js');
-const i18n = require('../translation/i18n');
-
-/**
- * Show dialog pinned to given window when loading error occurs
- * @param {BrowserWindow} win Window to host dialog
- * @param {String} url Url that failed
- * @param {String} errorDesc Description of error
- * @param {Number} errorCode Error code
- * @param {function} retryCallback Callback when user clicks reload
- * @param {Boolean} showDialog Indicates if a dialog need to be show to a user
- */
-function showLoadFailure(win, url, errorDesc, errorCode, retryCallback, showDialog) {
- let msg;
- if (url) {
- msg = i18n.getMessageFor('Error loading URL') + `:\n${url}`;
- } else {
- msg = i18n.getMessageFor('Error loading window');
- }
- if (errorDesc) {
- msg += '\n\n' + errorDesc;
- }
- if (errorCode) {
- msg += '\n\nError Code: ' + errorCode;
- }
-
- if (showDialog) {
- electron.dialog.showMessageBox(win, {
- type: 'error',
- buttons: [i18n.getMessageFor('Reload'), i18n.getMessageFor('Ignore')],
- defaultId: 0,
- cancelId: 1,
- noLink: true,
- title: i18n.getMessageFor('Loading Error'),
- message: msg
- }, response);
- }
-
- log.send(logLevels.WARNING, 'Load failure msg: ' + errorDesc +
- ' errorCode: ' + errorCode + ' for url:' + url);
-
- // async handle of user input
- function response(buttonId) {
- // retry if hitting butotn index 0 (i.e., reload)
- if (buttonId === 0 && typeof retryCallback === 'function') {
- retryCallback();
- }
- }
-}
-
-/**
- * Show message indicating network connectivity has been lost.
- * @param {BrowserWindow} win Window to host dialog
- * @param {String} url Url that failed
- * @param {function} retryCallback Callback when user clicks reload
- */
-function showNetworkConnectivityError(win, url, retryCallback) {
- let errorDesc = i18n.getMessageFor('Network connectivity has been lost. Check your internet connection.');
- showLoadFailure(win, url, errorDesc, 0, retryCallback, true);
-}
-
-module.exports = { showLoadFailure, showNetworkConnectivityError };
\ No newline at end of file
diff --git a/js/downloadManager/index.js b/js/downloadManager/index.js
deleted file mode 100644
index 1f2b32f8..00000000
--- a/js/downloadManager/index.js
+++ /dev/null
@@ -1,253 +0,0 @@
-'use strict';
-
-const { ipcRenderer, remote } = require('electron');
-
-const local = {
- ipcRenderer: ipcRenderer,
- downloadItems: []
-};
-
-let showInFolderText = 'Show in Folder';
-let openText = 'Open';
-let downloadedText = 'Downloaded';
-let fileNotFoundTitle = 'File not Found';
-let fileNotFoundMessage = 'The file you are trying to open cannot be found in the specified path.';
-
-// listen for file download complete event
-local.ipcRenderer.on('downloadCompleted', (event, arg) => {
- createDOM(arg);
-});
-
-// listen for file download progress event
-local.ipcRenderer.on('downloadProgress', () => {
- initiate();
-});
-
-// listen for locale change and update
-local.ipcRenderer.on('locale-changed', (event, data) => {
-
- if (data && typeof data === 'object') {
-
- if (data.downloadManager) {
- openText = data.downloadManager.Open;
- downloadedText = data.downloadManager.Downloaded;
-
- showInFolderText = data.downloadManager['Show in Folder'];
- fileNotFoundTitle = data.downloadManager['File not Found'];
- fileNotFoundMessage = data.downloadManager['The file you are trying to open cannot be found in the specified path.'];
- }
-
- }
-
-});
-
-/**
- * Open file in default app.
- * @param id
- */
-function openFile(id) {
- let fileIndex = local.downloadItems.findIndex((item) => {
- return item._id === id;
- });
- if (fileIndex !== -1) {
- let openResponse = remote.shell.openExternal(`file:///${local.downloadItems[fileIndex].savedPath}`);
- let focusedWindow = remote.BrowserWindow.getFocusedWindow();
- if (!openResponse && focusedWindow && !focusedWindow.isDestroyed()) {
- remote.dialog.showMessageBox(focusedWindow, {type: 'error', title: fileNotFoundTitle, message: fileNotFoundMessage});
- }
- }
-}
-
-/**
- * Show downloaded file in explorer or finder.
- * @param id
- */
-function showInFinder(id) {
- let showFileIndex = local.downloadItems.findIndex((item) => {
- return item._id === id;
- });
- if (showFileIndex !== -1) {
- let showResponse = remote.shell.showItemInFolder(local.downloadItems[showFileIndex].savedPath);
- let focusedWindow = remote.BrowserWindow.getFocusedWindow();
- if (!showResponse && focusedWindow && !focusedWindow.isDestroyed()) {
- remote.dialog.showMessageBox(focusedWindow, {type: 'error', title: fileNotFoundTitle, message: fileNotFoundMessage});
- }
- }
-}
-
-/**
- * Create the document object model
- * @param arg
- */
-function createDOM(arg) {
-
- if (arg && arg._id) {
- let fileDisplayName = getFileDisplayName(arg.fileName);
- let downloadItemKey = arg._id;
-
- local.downloadItems.push(arg);
-
- let ul = document.getElementById('download-main');
- if (ul) {
- let li = document.createElement('li');
- li.id = downloadItemKey;
- li.classList.add('download-element');
- ul.insertBefore(li, ul.childNodes[0]);
-
- let itemDiv = document.createElement('div');
- itemDiv.classList.add('download-item');
- itemDiv.id = 'dl-item';
- li.appendChild(itemDiv);
- let openMainFile = document.getElementById('dl-item');
- openMainFile.addEventListener('click', () => {
- let id = openMainFile.parentNode.id;
- openFile(id);
- });
-
- let fileDetails = document.createElement('div');
- fileDetails.classList.add('file');
- itemDiv.appendChild(fileDetails);
-
- let downProgress = document.createElement('div');
- downProgress.id = 'download-progress';
- downProgress.classList.add('download-complete');
- downProgress.classList.add('flash');
- setTimeout(() => {
- downProgress.classList.remove('flash');
- }, 4000);
- fileDetails.appendChild(downProgress);
-
- let fileIcon = document.createElement('span');
- fileIcon.classList.add('tempo-icon');
- fileIcon.classList.add('tempo-icon--download');
- fileIcon.classList.add('download-complete-color');
- setTimeout(() => {
- fileIcon.classList.remove('download-complete-color');
- fileIcon.classList.remove('tempo-icon--download');
- fileIcon.classList.add('tempo-icon--document');
- }, 4000);
- downProgress.appendChild(fileIcon);
-
- let fileNameDiv = document.createElement('div');
- fileNameDiv.classList.add('downloaded-filename');
- itemDiv.appendChild(fileNameDiv);
-
- let h2FileName = document.createElement('h2');
- h2FileName.classList.add('text-cutoff');
- h2FileName.innerHTML = fileDisplayName;
- h2FileName.title = fileDisplayName;
- fileNameDiv.appendChild(h2FileName);
-
- let fileProgressTitle = document.createElement('span');
- fileProgressTitle.id = 'per';
- fileProgressTitle.innerHTML = `${arg.total} ${downloadedText}`;
- fileNameDiv.appendChild(fileProgressTitle);
-
- let caret = document.createElement('div');
- caret.id = 'menu';
- caret.classList.add('caret');
- caret.classList.add('tempo-icon');
- caret.classList.add('tempo-icon--dropdown');
- li.appendChild(caret);
-
- let actionMenu = document.createElement('div');
- actionMenu.id = 'download-action-menu';
- actionMenu.classList.add('download-action-menu');
- caret.appendChild(actionMenu);
-
- let caretUL = document.createElement('ul');
- caretUL.id = downloadItemKey;
- actionMenu.appendChild(caretUL);
-
- let caretLiOpen = document.createElement('li');
- caretLiOpen.id = 'download-open';
- caretLiOpen.innerHTML = openText;
- caretUL.appendChild(caretLiOpen);
- let openFileDocument = document.getElementById('download-open');
- openFileDocument.addEventListener('click', () => {
- let id = openFileDocument.parentNode.id;
- openFile(id);
- });
-
- let caretLiShow = document.createElement('li');
- caretLiShow.id = 'download-show-in-folder';
- caretLiShow.innerHTML = showInFolderText;
- caretUL.appendChild(caretLiShow);
- let showInFinderDocument = document.getElementById('download-show-in-folder');
- showInFinderDocument.addEventListener('click', () => {
- let id = showInFinderDocument.parentNode.id;
- showInFinder(id);
- });
- }
- }
-}
-
-/**
- * Initiate the download manager
- */
-function initiate() {
- let mainFooter = document.getElementById('footer');
- let mainDownloadDiv = document.getElementById('download-manager-footer');
-
- if (mainDownloadDiv) {
-
- mainFooter.classList.remove('hidden');
-
- let ulFind = document.getElementById('download-main');
-
- if (!ulFind) {
- let uList = document.createElement('ul');
- uList.id = 'download-main';
- mainDownloadDiv.appendChild(uList);
- }
-
- let closeSpanFind = document.getElementById('close-download-bar');
-
- if (!closeSpanFind) {
- let closeSpan = document.createElement('span');
- closeSpan.id = 'close-download-bar';
- closeSpan.classList.add('close-download-bar');
- closeSpan.classList.add('tempo-icon');
- closeSpan.classList.add('tempo-icon--close');
- mainDownloadDiv.appendChild(closeSpan);
- }
-
- let closeDownloadManager = document.getElementById('close-download-bar');
- if (closeDownloadManager) {
- closeDownloadManager.addEventListener('click', () => {
- local.downloadItems = [];
- document.getElementById('footer').classList.add('hidden');
- document.getElementById('download-main').innerHTML = '';
- });
- }
- }
-}
-
-/**
- * Return a file display name for the download item
- */
-function getFileDisplayName(fileName) {
- let fileList = local.downloadItems;
- let fileNameCount = 0;
- let fileDisplayName = fileName;
-
- /* Check if a file with the same name exists
- * (akin to the user downloading a file with the same name again)
- * in the download bar
- */
- for (let i = 0; i < fileList.length; i++) {
- if (fileName === fileList[i].fileName) {
- fileNameCount++;
- }
- }
-
- /* If it exists, add a count to the name like how Chrome does */
- if (fileNameCount) {
- let extLastIndex = fileDisplayName.lastIndexOf('.');
- let fileCount = ' (' + fileNameCount + ')';
-
- fileDisplayName = fileDisplayName.slice(0, extLastIndex) + fileCount + fileDisplayName.slice(extLastIndex);
- }
-
- return fileDisplayName;
-}
\ No newline at end of file
diff --git a/js/enums/api.js b/js/enums/api.js
deleted file mode 100644
index 0376da2f..00000000
--- a/js/enums/api.js
+++ /dev/null
@@ -1,36 +0,0 @@
-'use strict';
-
-let keyMirror = require('keymirror');
-
-/**
- * Set of APIs exposed to the remote object
- * @type {Object}
- */
-const cmds = keyMirror({
- isOnline: null,
- registerLogger: null,
- setBadgeCount: null,
- badgeDataUrl: null,
- activate: null,
- registerBoundsChange: null,
- registerProtocolHandler: null,
- registerActivityDetection: null,
- showNotificationSettings: null,
- sanitize: null,
- bringToFront: null,
- openScreenPickerWindow: null,
- popupMenu: null,
- optimizeMemoryConsumption: null,
- optimizeMemoryRegister: null,
- setIsInMeeting: null,
- setLocale: null,
- keyPress: null,
- openScreenSharingIndicator: null,
- cancelNetworkStatusCheck: null,
- quitWindow: null,
-});
-
-module.exports = {
- cmds: cmds,
- apiName: 'symphony-api'
-};
diff --git a/js/enums/logLevels.js b/js/enums/logLevels.js
deleted file mode 100644
index 087d538e..00000000
--- a/js/enums/logLevels.js
+++ /dev/null
@@ -1,16 +0,0 @@
-'use strict';
-
-let keyMirror = require('keymirror');
-
-/**
- * The different log levels
- * @type {Object}
- */
-module.exports = keyMirror({
- ERROR: null,
- CONFLICT: null,
- WARN: null,
- ACTION: null,
- INFO: null,
- DEBUG: null
-});
diff --git a/js/enums/titleBarStyles.js b/js/enums/titleBarStyles.js
deleted file mode 100644
index a1c49ff3..00000000
--- a/js/enums/titleBarStyles.js
+++ /dev/null
@@ -1,12 +0,0 @@
-'use strict';
-
-let keyMirror = require('keymirror');
-
-/**
- * The different title bar styles
- * @type {Object}
- */
-module.exports = keyMirror({
- CUSTOM: null,
- NATIVE: null,
-});
diff --git a/js/eventEmitter.js b/js/eventEmitter.js
deleted file mode 100644
index 3e34f3d5..00000000
--- a/js/eventEmitter.js
+++ /dev/null
@@ -1,10 +0,0 @@
-'use strict';
-
-const EventEmitter = require('events').EventEmitter;
-const eventEmitter = new EventEmitter();
-
-// These method should only be used in main process
-module.exports = {
- emit: eventEmitter.emit,
- on: eventEmitter.on
-};
\ No newline at end of file
diff --git a/js/log.js b/js/log.js
deleted file mode 100644
index e1e1f382..00000000
--- a/js/log.js
+++ /dev/null
@@ -1,168 +0,0 @@
-'use strict';
-
-const fs = require('fs');
-const util = require('util');
-
-const { app } = require('electron');
-const path = require('path');
-const getCmdLineArg = require('./utils/getCmdLineArg.js');
-const logLevels = require('./enums/logLevels.js');
-
-const MAX_LOG_QUEUE_LENGTH = 100;
-
-let electronLog;
-
-class Logger {
-
- constructor() {
- // browser window that has registered a logger
- this.logWindow = null;
-
- // holds log messages received before logger has been registered.
- this.logQueue = [];
-
- // Initializes the local logger
- if (!process.env.ELECTRON_QA) {
- initializeLocalLogger();
- }
- }
-
- /**
- * Send log messages from main process to logger hosted by
- * renderer process. Allows main process to use logger
- * provided by JS.
- * @param {enum} level enum from ./enums/LogLevel.js
- * @param {string} details msg to be logged
- */
- send(level, details) {
- if (!level || !details) {
- return;
- }
-
- if (!process.env.ELECTRON_QA) {
- logLocally(level, details);
- }
-
- let logMsg = {
- level: level,
- details: details,
- startTime: Date.now()
- };
-
- if (this.logWindow) {
- this.logWindow.send('log', {
- msgs: [ logMsg ]
- });
- } else {
- // store log msgs for later when (if) we get logger registered
- this.logQueue.push(logMsg);
- // don't store more than 100 msgs. keep most recent log msgs.
- if (this.logQueue.length > MAX_LOG_QUEUE_LENGTH) {
- this.logQueue.shift();
- }
- }
- }
-
- /**
- * Sets a window instance for the remote object
- * @param win
- */
- setLogWindow(win) {
- this.logWindow = win;
-
- if (this.logWindow) {
- let logMsg = {};
-
- if (Array.isArray(this.logQueue)) {
- logMsg.msgs = this.logQueue;
- }
-
- // configure desired log level and send pending log msgs
- let logLevel = getCmdLineArg(process.argv, '--logLevel=', false);
- if (logLevel) {
- let level = logLevel.split('=')[1];
- if (level) {
- logMsg.logLevel = level;
- }
- }
-
- if (getCmdLineArg(process.argv, '--enableConsoleLogging', false)) {
- logMsg.showInConsole = true;
- }
-
- if (Object.keys(logMsg).length) {
- this.logWindow.send('log', logMsg);
- }
-
- this.logQueue = [];
- }
- }
-}
-
-let loggerInstance = new Logger();
-
-/**
- * Initializes the electron logger for local logging
- */
-function initializeLocalLogger() {
-
- // If the user has specified a custom log path use it.
- let customLogPathArg = getCmdLineArg(process.argv, '--logPath=', false);
- let customLogsFolder = customLogPathArg && customLogPathArg.substring(customLogPathArg.indexOf('=') + 1);
-
- if (customLogsFolder && fs.existsSync(customLogsFolder)) {
- app.setPath('logs', customLogsFolder);
- }
- // eslint-disable-next-line global-require
- electronLog = require('electron-log');
- const logPath = app.getPath('logs');
- cleanupOldLogs(logPath);
- electronLog.transports.file.file = path.join(logPath, `app_${Date.now()}.log`);
- electronLog.transports.file.level = 'debug';
- electronLog.transports.file.format = '{y}-{m}-{d} {h}:{i}:{s}:{ms} {z} | {level} | {text}';
- electronLog.transports.file.appName = 'Symphony';
-}
-
-/**
- * Cleans up old log files in the given path
- * @param {String} logPath Path of the log files
- */
-function cleanupOldLogs(logPath) {
- let files = fs.readdirSync(logPath);
- const deleteTimeStamp = new Date().getTime() + (10 * 24 * 60 * 60 * 1000);
- files.forEach((file) => {
- if (file === '.DS_Store' || file === 'app.log') {
- return;
- }
- const filePath = path.join(logPath, file);
- const stat = fs.statSync(filePath);
- const fileTimestamp = new Date(util.inspect(stat.mtime)).getTime();
- if (fileTimestamp > deleteTimeStamp) {
- fs.unlinkSync(filePath);
- }
- });
-}
-
-/**
- * Logs locally using the electron-logger
- * @param level
- * @param message
- */
-function logLocally(level, message) {
- switch (level) {
- case logLevels.ERROR: electronLog.error(message); break;
- case logLevels.CONFLICT: electronLog.error(message); break;
- case logLevels.WARN: electronLog.warn(message); break;
- case logLevels.ACTION: electronLog.warn(message); break;
- case logLevels.INFO: electronLog.info(message); break;
- case logLevels.DEBUG: electronLog.debug(message); break;
- default: electronLog.debug(message);
- }
-}
-
-// Logger class is only exposed for testing purposes.
-module.exports = {
- Logger: Logger,
- send: loggerInstance.send.bind(loggerInstance),
- setLogWindow: loggerInstance.setLogWindow.bind(loggerInstance)
-};
diff --git a/js/main.js b/js/main.js
deleted file mode 100644
index e2d9d930..00000000
--- a/js/main.js
+++ /dev/null
@@ -1,479 +0,0 @@
-'use strict';
-
-// Third Party Dependencies
-const electron = require('electron');
-const app = electron.app;
-const crashReporter = electron.crashReporter;
-const nodeURL = require('url');
-const shellPath = require('shell-path');
-const urlParser = require('url');
-const nodePath = require('path');
-require('electron-dl')();
-
-const { version, clientVersion, buildNumber } = require('../package.json');
-const log = require('./log.js');
-const logLevels = require('./enums/logLevels.js');
-
-log.send(logLevels.INFO, `-----------------Starting the app with version ${version}-----------------`);
-
-// Local Dependencies
-require('./stats');
-const { getConfigField, readConfigFileSync, updateUserConfigOnLaunch, getUserConfigField } = require('./config.js');
-const protocolHandler = require('./protocolHandler');
-const { setCheckboxValues } = require('./menus/menuTemplate.js');
-const autoLaunch = require('./autoLaunch');
-const { handleCacheFailureCheckOnStartup, handleCacheFailureCheckOnExit} = require('./cacheHandler');
-
-const { isMac, isDevEnv } = require('./utils/misc.js');
-const getCmdLineArg = require('./utils/getCmdLineArg.js');
-
-//setting the env path child_process issue https://github.com/electron/electron/issues/7688
-shellPath()
- .then((path) => {
- process.env.PATH = path
- })
- .catch(() => {
- process.env.PATH = [
- './node_modules/.bin',
- '/usr/local/bin',
- process.env.PATH
- ].join(':');
- });
-
-// used to check if a url was opened when the app was already open
-let isAppAlreadyOpen = false;
-
-require('./mainApiMgr.js');
-
-// monitor memory of main process
-require('./memoryMonitor.js');
-
-// adds 'symphony' as a protocol in the system.
-// plist file in macOS and registry entries on windows
-app.setAsDefaultProtocolClient('symphony');
-
-const windowMgr = require('./windowMgr.js');
-const i18n = require('./translation/i18n');
-let ContextMenuBuilder;
-
-getConfigField('url')
- .then(initializeCrashReporter)
- .catch(app.quit);
-
-function initializeCrashReporter(podUrl) {
-
- getConfigField('crashReporter')
- .then((crashReporterConfig) => {
- crashReporter.start({ companyName: crashReporterConfig.companyName, submitURL: crashReporterConfig.submitURL, uploadToServer: crashReporterConfig.uploadToServer, extra: { 'process': 'main', podUrl: podUrl } });
- log.send(logLevels.INFO, 'initialized crash reporter on the main process!');
- })
- .catch((err) => {
- log.send(logLevels.ERROR, 'Unable to initialize crash reporter in the main process. Error is -> ' + err);
- });
-
-}
-
-const allowMultiInstance = getCmdLineArg(process.argv, '--multiInstance', true) || isDevEnv;
-
-if (!allowMultiInstance) {
- const gotTheLock = app.requestSingleInstanceLock();
-
- // quit if another instance is already running, ignore for dev env or if app was started with multiInstance flag
- if (!gotTheLock) {
- app.quit()
- } else {
- app.on('second-instance', (event, argv) => {
- // Someone tried to run a second instance, we should focus our window.
- log.send(logLevels.INFO, `Second instance created with args ${argv}`);
- let mainWin = windowMgr.getMainWindow();
- if (mainWin) {
- isAppAlreadyOpen = true;
- if (mainWin.isMinimized()) {
- mainWin.restore();
- }
- mainWin.focus();
- }
- processProtocolAction(argv);
- });
- }
-} else {
- app.releaseSingleInstanceLock();
-}
-
-/**
- * Sets chrome authentication flags in electron
- */
-function setChromeFlags() {
-
- // Read the config parameters synchronously
- let config = readConfigFileSync();
-
- // If we cannot find any config, just skip setting any flags
- if (config && config.customFlags) {
-
- if (config.customFlags.authServerWhitelist && config.customFlags.authServerWhitelist !== "") {
- app.commandLine.appendSwitch('auth-server-whitelist', config.customFlags.authServerWhitelist);
- }
-
- if (config.customFlags.authNegotiateDelegateWhitelist && config.customFlags.authNegotiateDelegateWhitelist !== "") {
- app.commandLine.appendSwitch('auth-negotiate-delegate-whitelist', config.customFlags.authNegotiateDelegateWhitelist);
- }
-
- if (config.customFlags.disableGpu) {
- app.commandLine.appendSwitch("disable-gpu", true);
- app.commandLine.appendSwitch("disable-gpu-compositing", true);
- app.commandLine.appendSwitch("disable-d3d11", true);
- }
-
- }
-
- app.commandLine.appendSwitch("disable-background-timer-throttling", true);
-
- setChromeFlagsFromCommandLine();
-
-}
-
-/**
- * Parse arguments from command line
- * and set as chrome flags if applicable
- */
-function setChromeFlagsFromCommandLine() {
-
- // Special args that need to be excluded as part of the chrome command line switch
- let specialArgs = ['--url', '--multiInstance', '--userDataPath=', 'symphony://', '--inspect-brk', '--inspect'];
-
- const cmdArgs = process.argv;
- cmdArgs.forEach((arg) => {
- // We need to check if the argument key matches the one
- // in the special args array and return if it does match
- const argSplit = arg.split('=');
- const argKey = argSplit[0];
- const argValue = argSplit[1] && arg.substring(arg.indexOf('=')+1);
- if (arg.startsWith('--') && specialArgs.includes(argKey)) {
- return;
- }
-
- // All the chrome flags starts with --
- // So, any other arg (like 'electron' or '.')
- // need to be skipped
- if (arg.startsWith('--')) {
- // Since chrome takes values after an equals
- // We split the arg and set it either as
- // just a key, or as a key-value pair
- if (argKey && argValue) {
- app.commandLine.appendSwitch(argKey.substr(2), argValue);
- } else {
- app.commandLine.appendSwitch(argKey);
- }
- log.send(logLevels.INFO, `Appended chrome command line switch ${argKey} with value ${argValue}`);
- }
-
- });
-}
-
-// Set the chrome flags
-setChromeFlags();
-
-/**
- * This method will be called when Electron has finished
- * initialization and is ready to create browser windows.
- * Some APIs can only be used after this event occurs.
- */
-app.on('ready', () => {
- log.send(logLevels.INFO, `App is ready, proceeding to load the POD`);
- handlePowerEvents();
- handleCacheFailureCheckOnStartup()
- .then(() => {
- initiateApp();
- })
- .catch((err) => {
- log.send(logLevels.INFO, `Couldn't clear cache and refresh -> ${err}`);
- initiateApp();
- });
-
- function initiateApp() {
- checkFirstTimeLaunch()
- .then(readConfigThenOpenMainWindow)
- .catch(readConfigThenOpenMainWindow);
-
- }
-});
-
-/**
- * Is triggered when all the windows are closed
- * In which case we quit the app
- */
-app.on('window-all-closed', function () {
- log.send(logLevels.INFO, `All windows closed, quitting the app`);
- app.quit();
-});
-
-app.on('quit', function () {
- log.send(logLevels.INFO, `-----------------Quitting the app-----------------`);
- handleCacheFailureCheckOnExit();
-});
-
-/**
- * Is triggered when the app is up & running
- */
-app.on('activate', function () {
- log.send(logLevels.INFO, `SDA is activated again`);
- if (windowMgr.isMainWindow(null)) {
- log.send(logLevels.INFO, `Main window instance is null, creating new instance`);
- setupThenOpenMainWindow();
- } else {
- log.send(logLevels.INFO, `Main window instance is available, showing it`);
- windowMgr.showMainWindow();
- }
-});
-
-if (isMac) {
- // Sets application version info that will be displayed in about app panel
- app.setAboutPanelOptions({ applicationVersion: `${clientVersion}-${version}`, version: buildNumber });
-}
-
-/**
- * This event is emitted only on macOS
- * at this moment, support for windows
- * is in pipeline (https://github.com/electron/electron/pull/8052)
- */
-app.on('open-url', function (event, url) {
- log.send(logLevels.INFO, `Open URL event triggered with url ${JSON.stringify(url)}`);
- handleProtocolAction(url);
-});
-
-app.on('web-contents-created', function (event, webContents) {
- onWebContent(webContents);
-});
-
-function onWebContent(webContents) {
-
- if (!ContextMenuBuilder) {
- // eslint-disable-next-line global-require
- ContextMenuBuilder = require('electron-spellchecker').ContextMenuBuilder;
- }
-
- const spellchecker = windowMgr.getSpellchecker();
- spellchecker.initializeSpellChecker();
- spellchecker.updateContextMenuLocale(i18n.getMessageFor('ContextMenu'));
- const contextMenuBuilder = new ContextMenuBuilder(spellchecker.spellCheckHandler, webContents, false, spellchecker.processMenu.bind(spellchecker));
- contextMenuBuilder.setAlternateStringFormatter(spellchecker.getStringTable(i18n.getMessageFor('ContextMenu')));
- let currentLocale = i18n.getLanguage();
-
- const contextMenuListener = (event, info) => {
- log.send(logLevels.INFO, `Context menu event triggered for web contents with info ${JSON.stringify(info)}`);
- if (currentLocale !== i18n.getLanguage()) {
- contextMenuBuilder.setAlternateStringFormatter(spellchecker.getStringTable(i18n.getMessageFor('ContextMenu')));
- spellchecker.updateContextMenuLocale(i18n.getMessageFor('ContextMenu'));
- currentLocale = i18n.getLanguage();
- }
- contextMenuBuilder.showPopupMenu(info);
- };
-
- webContents.on('context-menu', contextMenuListener);
-
- webContents.once('destroyed', () => {
- webContents.removeListener('context-menu', contextMenuListener);
- });
-}
-
-/**
- * Reads the config fields that are required for the menu items
- * then opens the main window
- *
- * This is a workaround for the issue where the menu template was returned
- * even before the config data was populated
- * https://perzoinc.atlassian.net/browse/ELECTRON-154
- */
-function readConfigThenOpenMainWindow() {
- setCheckboxValues()
- .then(setupThenOpenMainWindow)
- .catch(setupThenOpenMainWindow)
-}
-
-/**
- * Sets up the app (to handle various things like config changes, protocol handling etc.)
- * and opens the main window
- */
-function setupThenOpenMainWindow() {
-
- processProtocolAction(process.argv);
-
- isAppAlreadyOpen = true;
- getUrlAndCreateMainWindow();
-
- // Allows a developer to set custom user data path from command line when
- // launching the app. Mostly used for running automation tests with
- // multiple instances
- let customDataArg = getCmdLineArg(process.argv, '--userDataPath=', false);
- let customDataFolder = customDataArg && customDataArg.substring(customDataArg.indexOf('=') + 1);
-
- if (customDataArg && customDataFolder) {
- app.setPath('userData', customDataFolder);
- }
-
- // Event that fixes the remote desktop issue in Windows
- // by repositioning the browser window
- electron.screen.on('display-removed', windowMgr.verifyDisplays);
-
-}
-
-function checkFirstTimeLaunch() {
- return new Promise((resolve, reject) => {
- getUserConfigField('configBuildNumber')
- .then((configBuildNumber) => {
- const execPath = nodePath.dirname(app.getPath('exe'));
- const shouldUpdateUserConfig = execPath.indexOf('AppData\\Local\\Programs') !== -1 || isMac;
-
- if (configBuildNumber && typeof configBuildNumber === 'string' && configBuildNumber !== buildNumber) {
- return setupFirstTimeLaunch(resolve, reject, shouldUpdateUserConfig);
- }
- log.send(logLevels.INFO, `not a first-time launch as
- configBuildNumber: ${configBuildNumber} installerBuildNumber: ${buildNumber} shouldUpdateUserConfig: ${shouldUpdateUserConfig}`);
- return resolve();
- })
- .catch((e) => {
- log.send(logLevels.ERROR, `Error reading configVersion error: ${e}`);
- return setupFirstTimeLaunch(resolve, reject, true);
- });
- });
-}
-
-/**
- * Setup and update user config
- * on first time launch or if the latest app version
- *
- * @return {Promise}
- */
-function setupFirstTimeLaunch(resolve, reject, shouldUpdateUserConfig) {
- log.send(logLevels.INFO, 'setting first time launch config');
- getConfigField('launchOnStartup')
- .then(setStartup)
- .then(() => {
- if (shouldUpdateUserConfig) {
- log.send(logLevels.INFO, `Resetting user config data? ${shouldUpdateUserConfig}`);
- return updateUserConfigOnLaunch(resolve, reject);
- }
- return resolve();
- })
- .catch(reject);
-}
-
-/**
- * Sets Symphony on startup
- * @param lStartup
- * @returns {Promise}
- */
-function setStartup(lStartup) {
- log.send(logLevels.INFO, `launch on startup parameter value is ${lStartup}`);
- return new Promise((resolve) => {
- let launchOnStartup = (String(lStartup) === 'true');
- log.send(logLevels.INFO, `launchOnStartup value is ${launchOnStartup}`);
- if (launchOnStartup) {
- log.send(logLevels.INFO, `enabling launch on startup`);
- autoLaunch.enable();
- return resolve();
- }
- autoLaunch.disable();
- return resolve();
- });
-}
-
-/**
- * Checks for the url argument, processes it
- * and creates the main window
- */
-function getUrlAndCreateMainWindow() {
- // allow passing url argument
- let url = getCmdLineArg(process.argv, '--url=', false);
- if (url) {
- windowMgr.createMainWindow(url.substr(6));
- return;
- }
-
- getConfigField('url')
- .then(createWin).catch(function (err) {
- log.send(logLevels.ERROR, `unable to create main window -> ${err}`);
- app.quit();
- });
-}
-
-/**
- * Creates a window
- * @param urlFromConfig
- */
-function createWin(urlFromConfig) {
- // add https protocol if none found.
- let parsedUrl = nodeURL.parse(urlFromConfig);
-
- if (!parsedUrl.protocol || parsedUrl.protocol !== 'https') {
- parsedUrl.protocol = 'https:';
- parsedUrl.slashes = true
- }
- let url = nodeURL.format(parsedUrl);
-
- windowMgr.createMainWindow(url);
-}
-
-/**
- * processes protocol action for windows clients
- * @param argv {Array} an array of command line arguments
- */
-function processProtocolAction(argv) {
-
- // In case of windows, we need to handle protocol handler
- // manually because electron doesn't emit
- // 'open-url' event on windows
- if (!(process.platform === 'win32')) {
- return;
- }
-
- let protocolUri = getCmdLineArg(argv, 'symphony://', false);
- log.send(logLevels.INFO, `Trying to process a protocol action for uri ${protocolUri}`);
-
- if (protocolUri) {
- const parsedURL = urlParser.parse(protocolUri);
- if (!parsedURL.protocol || !parsedURL.slashes) {
- return;
- }
- log.send(logLevels.INFO, `Parsing protocol url successful for ${parsedURL}`);
- handleProtocolAction(protocolUri);
- }
-}
-
-/**
- * Handles a protocol action based on the current state of the app
- * @param uri
- */
-function handleProtocolAction(uri) {
- if (!isAppAlreadyOpen) {
- log.send(logLevels.INFO, `App started by protocol url ${uri}. We are caching this to be processed later!`);
- // app is opened by the protocol url, cache the protocol url to be used later
- protocolHandler.setProtocolUrl(uri);
- } else {
- // This is needed for mac OS as it brings pop-outs to foreground
- // (if it has been previously focused) instead of main window
- if (isMac) {
- const mainWindow = windowMgr.getMainWindow();
- if (mainWindow && !mainWindow.isDestroyed()) {
- windowMgr.activate(mainWindow.winName);
- }
- }
- // app is already open, so, just trigger the protocol action method
- log.send(logLevels.INFO, `App opened by protocol url ${uri}`);
- protocolHandler.processProtocolAction(uri);
- }
-}
-
-const handlePowerEvents = () => {
-
- const events = [
- 'suspend', 'resume', 'on-ac', 'on-battery', 'shutdown', 'lock-screen', 'unlock-screen'
- ];
-
- events.forEach((appEvent) => {
- electron.powerMonitor.on(appEvent, () => {
- log.send(logLevels.INFO, `Power Monitor Event Occurred: ${appEvent}`)
- });
- });
-};
diff --git a/js/mainApiMgr.js b/js/mainApiMgr.js
deleted file mode 100644
index 07f666fa..00000000
--- a/js/mainApiMgr.js
+++ /dev/null
@@ -1,210 +0,0 @@
-'use strict';
-
-/**
- * This module runs in the main process and handles api calls
- * from the renderer process.
- */
-const electron = require('electron');
-const app = electron.app;
-
-const windowMgr = require('./windowMgr.js');
-const log = require('./log.js');
-const logLevels = require('./enums/logLevels');
-const activityDetection = require('./activityDetection');
-const badgeCount = require('./badgeCount.js');
-const protocolHandler = require('./protocolHandler');
-const configureNotification = require('./notify/settings/configure-notification-position');
-const { bringToFront } = require('./bringToFront.js');
-const eventEmitter = require('./eventEmitter');
-const { isMac } = require('./utils/misc');
-const { openScreenPickerWindow } = require('./desktopCapturer');
-const { openScreenSharingIndicator } = require('./screenSharingIndicator');
-const { setPreloadMemoryInfo, setIsInMeeting, setPreloadWindow } = require('./memoryMonitor');
-
-const apiEnums = require('./enums/api.js');
-const apiCmds = apiEnums.cmds;
-const apiName = apiEnums.apiName;
-
-// can be overridden for testing
-let checkValidWindow = true;
-
-/**
- * Ensure events comes from a window that we have created.
- * @param {EventEmitter} event node emitter event to be tested
- * @return {Boolean} returns true if exists otherwise false
- */
-function isValidWindow(event) {
- if (!checkValidWindow) {
- return true;
- }
- let result = false;
- if (event && event.sender) {
- // validate that event sender is from window we created
- const browserWin = electron.BrowserWindow.fromWebContents(event.sender);
- const winKey = event.sender.browserWindowOptions &&
- event.sender.browserWindowOptions.winKey;
-
- result = windowMgr.hasWindow(browserWin, winKey);
- }
-
- if (!result) {
- log.send(logLevels.WARN, 'invalid window try to perform action, ignoring action');
- }
-
- return result;
-}
-
-/**
- * Method that is invoked when the application is reloaded/navigated
- * window.addEventListener('beforeunload')
- * @param windowName
- */
-function sanitize(windowName) {
- // To make sure the reload event is from the main window
- if (windowMgr.getMainWindow() && windowName === windowMgr.getMainWindow().winName) {
- // reset the badge count whenever an user refreshes the electron client
- badgeCount.show(0);
-
- // Terminates the screen snippet process on reload
- if (!isMac) {
- eventEmitter.emit('killScreenSnippet');
- }
- // Closes all the child windows
- windowMgr.cleanUpChildWindows();
- }
-}
-
-/**
- * Handle API related ipc messages from renderers. Only messages from windows
- * we have created are allowed.
- */
-electron.ipcMain.on(apiName, (event, arg) => {
-
- if (!isValidWindow(event)) {
- return;
- }
-
- if (!arg) {
- return;
- }
-
- switch(arg.cmd) {
- case apiCmds.isOnline:
- if (typeof arg.isOnline === 'boolean') {
- windowMgr.setIsOnline(arg.isOnline);
- }
- break;
- case apiCmds.setBadgeCount:
- if (typeof arg.count === 'number') {
- badgeCount.show(arg.count);
- }
- break;
- case apiCmds.registerProtocolHandler:
- protocolHandler.setProtocolWindow(event.sender);
- protocolHandler.checkProtocolAction();
- break;
- case apiCmds.badgeDataUrl:
- if (typeof arg.dataUrl === 'string' && typeof arg.count === 'number') {
- badgeCount.setDataUrl(arg.dataUrl, arg.count);
- }
- break;
- case apiCmds.activate:
- if (typeof arg.windowName === 'string') {
- windowMgr.activate(arg.windowName);
- }
- break;
- case apiCmds.registerBoundsChange:
- windowMgr.setBoundsChangeWindow(event.sender);
- break;
- case apiCmds.registerLogger:
- // renderer window that has a registered logger from JS.
- log.setLogWindow(event.sender);
- break;
- case apiCmds.registerActivityDetection:
- if (typeof arg.period === 'number') {
- // renderer window that has a registered activity detection from JS.
- activityDetection.setActivityWindow(arg.period, event.sender);
- }
- break;
- case apiCmds.showNotificationSettings:
- if (typeof arg.windowName === 'string') {
- configureNotification.openConfigurationWindow(arg.windowName);
- }
- break;
- case apiCmds.sanitize:
- if (typeof arg.windowName === 'string') {
- sanitize(arg.windowName);
- }
- break;
- case apiCmds.bringToFront:
- // validates the user bring to front config and activates the wrapper
- if (typeof arg.reason === 'string' && arg.reason === 'notification') {
- bringToFront(arg.windowName, arg.reason);
- }
- break;
- case apiCmds.openScreenPickerWindow:
- if (Array.isArray(arg.sources) && typeof arg.id === 'number') {
- openScreenPickerWindow(event.sender, arg.sources, arg.id);
- }
- break;
- case apiCmds.popupMenu: {
- let browserWin = electron.BrowserWindow.fromWebContents(event.sender);
- if (browserWin && !browserWin.isDestroyed()) {
- windowMgr.getMenu().popup(browserWin, {x: 20, y: 15, async: true});
- }
- break;
- }
- case apiCmds.optimizeMemoryConsumption:
- if (typeof arg.activeRequests === 'number') {
- log.send(logLevels.INFO, 'Received active network request from renderer processes');
- setPreloadMemoryInfo(arg.activeRequests);
- }
- break;
- case apiCmds.optimizeMemoryRegister:
- setPreloadWindow(event.sender);
- break;
- case apiCmds.setIsInMeeting:
- if (typeof arg.isInMeeting === 'boolean') {
- setIsInMeeting(arg.isInMeeting);
- }
- break;
- case apiCmds.setLocale:
- if (typeof arg.locale === 'string') {
- let browserWin = electron.BrowserWindow.fromWebContents(event.sender);
- windowMgr.setLocale(browserWin, { language: arg.locale });
- }
- break;
- case apiCmds.keyPress:
- if (typeof arg.keyCode === 'number') {
- windowMgr.handleKeyPress(arg.keyCode);
- }
- break;
- case apiCmds.isMisspelled:
- if (typeof arg.text === 'string') {
- /* eslint-disable no-param-reassign */
- event.returnValue = windowMgr.isMisspelled(arg.text);
- /* eslint-enable no-param-reassign */
- }
- break;
- case apiCmds.openScreenSharingIndicator:
- if (typeof arg.displayId === 'string' && typeof arg.id === 'number') {
- openScreenSharingIndicator(event.sender, arg.displayId, arg.id);
- }
- break;
- case apiCmds.cancelNetworkStatusCheck:
- windowMgr.cancelNetworkStatusCheck();
- break;
- case apiCmds.quitWindow:
- app.quit();
- break;
- default:
- }
-
-});
-
-// expose these methods primarily for testing...
-module.exports = {
- shouldCheckValidWindow: function(shouldCheck) {
- checkValidWindow = shouldCheck;
- }
-};
\ No newline at end of file
diff --git a/js/memoryMonitor.js b/js/memoryMonitor.js
deleted file mode 100644
index d479648c..00000000
--- a/js/memoryMonitor.js
+++ /dev/null
@@ -1,143 +0,0 @@
-'use strict';
-const electron = require('electron');
-const app = electron.app;
-const log = require('./log.js');
-const logLevels = require('./enums/logLevels.js');
-const { getMainWindow, setIsAutoReload, getIsOnline } = require('./windowMgr');
-const { getConfigField } = require('./config');
-
-const memoryRefreshThreshold = 60 * 60 * 1000;
-const maxIdleTime = 4 * 60 * 60 * 1000;
-const memoryRefreshInterval = 60 * 60 * 1000;
-const cpuUsageThreshold = 5;
-
-let isInMeeting = false;
-let canReload = true;
-let preloadMemory;
-let preloadWindow;
-
-// once a minute
-setInterval(gatherMemory, 1000 * 60);
-
-/**
- * Gathers system memory and logs it to the remote system
- */
-function gatherMemory() {
- let appMetrics = app.getAppMetrics();
- log.send(logLevels.INFO, `Current App Metrics -> ${JSON.stringify(appMetrics)}`);
-}
-
-/**
- * Method that checks memory usage every minute
- * and verify if the user in inactive if so it reloads the
- * application to free up some memory consumption
- */
-function optimizeMemory() {
-
- if (!preloadMemory.cpuUsage) {
- log.send(logLevels.INFO, `cpu usage not available`);
- return;
- }
-
- const cpuUsagePercentage = preloadMemory.cpuUsage.percentCPUUsage;
- const activeNetworkRequest = preloadMemory.activeRequests === 0;
-
- electron.powerMonitor.querySystemIdleTime((time) => {
- const idleTime = time * 1000;
- if (cpuUsagePercentage <= cpuUsageThreshold
- && !isInMeeting
- && getIsOnline()
- && canReload
- && idleTime > maxIdleTime
- && activeNetworkRequest
- ) {
- getConfigField('memoryRefresh')
- .then((enabled) => {
- if (enabled) {
- const mainWindow = getMainWindow();
-
- if (mainWindow && !mainWindow.isDestroyed()) {
- setIsAutoReload(true);
- log.send(logLevels.INFO, `Reloading the app to optimize memory usage as
- memory consumption is no longer detectable
- CPU usage percentage was ${preloadMemory.cpuUsage.percentCPUUsage}
- user was in a meeting? ${isInMeeting}
- pending network request on the client was ${preloadMemory.activeRequests}
- is network online? ${getIsOnline()}`);
- mainWindow.reload();
-
- // do not refresh for another 1hrs
- canReload = false;
- setTimeout(() => {
- canReload = true;
- }, memoryRefreshThreshold);
- }
- } else {
- log.send(logLevels.INFO, `Memory refresh not enabled by the user so Not Reloading the app`);
- }
- });
- } else {
- log.send(logLevels.INFO, `Not Reloading the app as
- application was refreshed less than a hour ago? ${canReload ? 'no' : 'yes'}
- memory consumption is no longer detectable
- CPU usage percentage was ${preloadMemory.cpuUsage.percentCPUUsage}
- user was in a meeting? ${isInMeeting}
- pending network request on the client was ${preloadMemory.activeRequests}
- is network online? ${getIsOnline()}`);
- }
- });
-}
-
-/**
- * Sets the current user meeting status
- * @param meetingStatus - Whether user is in an active meeting
- */
-function setIsInMeeting(meetingStatus) {
- isInMeeting = meetingStatus;
-}
-
-/**
- * Sets preload memory info and calls optimize memory func
- *
- * @param activeRequests - pending active network requests on the client
- */
-function setPreloadMemoryInfo(activeRequests) {
- log.send(logLevels.INFO, 'Memory info received from preload process now running optimize memory logic');
- const cpuUsage = process.getCPUUsage();
- preloadMemory = { cpuUsage, activeRequests };
- optimizeMemory();
-}
-
-/**
- * Sets the preload window
- *
- * @param win - preload window
- */
-function setPreloadWindow(win) {
- log.send(logLevels.INFO, 'Preload window registered');
- preloadWindow = win;
-}
-
-/**
- * Request memory info from the registered preload window
- * which invokes the optimize memory func
- */
-function requestMemoryInfo() {
- if (preloadWindow) {
- log.send(logLevels.INFO, 'Requesting memory information from the preload script');
- preloadWindow.send('memory-info-request');
- }
-}
-
-/**
- * Requests memory info from the renderer every 4 hrs
- */
-setInterval(() => {
- requestMemoryInfo();
-}, memoryRefreshInterval);
-
-module.exports = {
- setIsInMeeting,
- setPreloadMemoryInfo,
- setPreloadWindow,
-};
\ No newline at end of file
diff --git a/js/menus/menuTemplate.js b/js/menus/menuTemplate.js
deleted file mode 100644
index 97a6d9fc..00000000
--- a/js/menus/menuTemplate.js
+++ /dev/null
@@ -1,582 +0,0 @@
-'use strict';
-
-const fs = require('fs');
-const electron = require('electron');
-
-const { updateConfigField, getMultipleConfigField, readConfigFromFile } = require('../config.js');
-const { isMac, isWindowsOS } = require('../utils/misc.js');
-const archiveHandler = require('../utils/archiveHandler');
-const log = require('../log.js');
-const logLevels = require('../enums/logLevels.js');
-const eventEmitter = require('../eventEmitter');
-const aboutApp = require('../aboutApp');
-const moreInfo = require('../moreInfo');
-const titleBarStyles = require('../enums/titleBarStyles');
-const i18n = require('../translation/i18n');
-const autoLaunch = require('../autoLaunch');
-
-const configFields = [
- 'minimizeOnClose',
- 'launchOnStartup',
- 'alwaysOnTop',
- 'notificationSettings',
- 'bringToFront',
- 'memoryRefresh',
- 'isCustomTitleBar'
-];
-
-let minimizeOnClose = false;
-let launchOnStartup = false;
-let isAlwaysOnTop = false;
-let bringToFront = false;
-let memoryRefresh = false;
-let titleBarStyle = titleBarStyles.CUSTOM;
-
-const windowsAccelerator = Object.assign({
- undo: 'Ctrl+Z',
- redo: 'Ctrl+Y',
- cut: 'Ctrl+X',
- copy: 'Ctrl+C',
- paste: 'Ctrl+V',
- pasteandmatchstyle: 'Ctrl+Shift+V',
- selectall: 'Ctrl+A',
- resetzoom: 'Ctrl+0',
- zoomin: 'Ctrl+Shift+Plus',
- zoomout: 'Ctrl+-',
- togglefullscreen: 'F11',
- minimize: 'Ctrl+M',
- close: 'Ctrl+W',
-});
-
-function getTemplate(app) {
-
- const template = [{
- label: i18n.getMessageFor('Edit'),
- submenu: [
- buildMenuItem('undo', i18n.getMessageFor('Undo')),
- buildMenuItem('redo', i18n.getMessageFor('Redo')),
- { type: 'separator' },
- buildMenuItem('cut', i18n.getMessageFor('Cut')),
- buildMenuItem('copy', i18n.getMessageFor('Copy')),
- buildMenuItem('paste', i18n.getMessageFor('Paste')),
- buildMenuItem('pasteandmatchstyle', i18n.getMessageFor('Paste and Match Style')),
- buildMenuItem('delete', i18n.getMessageFor('Delete')),
- buildMenuItem('selectall', i18n.getMessageFor('Select All'))
- ]
- },
- {
- label: i18n.getMessageFor('View'),
- submenu: [{
- label: i18n.getMessageFor('Reload'),
- accelerator: 'CmdOrCtrl+R',
- click(item, focusedWindow) {
- if (focusedWindow) {
- focusedWindow.reload();
- }
- }
- },
- { type: 'separator' },
- buildMenuItem('resetzoom', i18n.getMessageFor('Actual Size')),
- buildMenuItem('zoomin', i18n.getMessageFor('Zoom In')),
- buildMenuItem('zoomout', i18n.getMessageFor('Zoom Out')),
- { type: 'separator' },
- buildMenuItem('togglefullscreen', i18n.getMessageFor('Toggle Full Screen')),
- ]
- },
- {
- role: 'window',
- label: i18n.getMessageFor('Window'),
- submenu: [
- buildMenuItem('minimize', i18n.getMessageFor('Minimize')),
- buildMenuItem('close', i18n.getMessageFor('Close')),
- ]
- },
- {
- role: 'help',
- label: i18n.getMessageFor('Help'),
- submenu:
- [
- {
- label: i18n.getMessageFor('Symphony Help'),
- click() {
- let helpUrl = i18n.getMessageFor('Help Url');
- electron.shell.openExternal(helpUrl);
- }
- },
- {
- label: i18n.getMessageFor('Learn More'),
- click() {
- let symUrl = i18n.getMessageFor('Symphony Url');
- electron.shell.openExternal(symUrl);
- }
- },
- {
- label: i18n.getMessageFor('Troubleshooting'),
- submenu: [
- {
- label: isMac ? i18n.getMessageFor('Show Logs in Finder') : i18n.getMessageFor('Show Logs in Explorer'),
- click(item, focusedWindow) {
-
- const FILE_EXTENSIONS = ['.log'];
- const MAC_LOGS_PATH = '/Library/Logs/Symphony/';
- const WINDOWS_LOGS_PATH = '\\AppData\\Roaming\\Symphony\\logs';
-
- let logsPath = isMac ? MAC_LOGS_PATH : WINDOWS_LOGS_PATH;
- let source = electron.app.getPath('home') + logsPath;
-
- if (!fs.existsSync(source) && focusedWindow && !focusedWindow.isDestroyed()) {
- electron.dialog.showMessageBox(focusedWindow, {
- type: 'error',
- title: i18n.getMessageFor('Failed!'),
- message: i18n.getMessageFor('No logs are available to share')
- });
- return;
- }
-
- let destPath = isMac ? '/logs_symphony_' : '\\logs_symphony_';
- let timestamp = new Date().getTime();
-
- let destination = electron.app.getPath('downloads') + destPath + timestamp + '.zip';
-
- archiveHandler.generateArchiveForDirectory(source, destination, FILE_EXTENSIONS)
- .then(() => {
- electron.shell.showItemInFolder(destination);
- })
- .catch((err) => {
- if (focusedWindow && !focusedWindow.isDestroyed()) {
- electron.dialog.showMessageBox(focusedWindow, {
- type: 'error',
- title: i18n.getMessageFor('Failed!'),
- message: i18n.getMessageFor('Unable to generate logs due to ') + err
- });
- }
- });
-
- }
- },
- {
- label: isMac ? i18n.getMessageFor('Show crash dump in Finder') : i18n.getMessageFor('Show crash dump in Explorer'),
- click(item, focusedWindow) {
- const FILE_EXTENSIONS = isMac ? ['.dmp'] : ['.dmp', '.txt'];
- const crashesDirectory = electron.crashReporter.getCrashesDirectory();
- let source = isMac ? crashesDirectory + '/completed' : crashesDirectory;
-
- // TODO: Add support to get diagnostic reports from ~/Library/Logs/DiagnosticReports
- if (!fs.existsSync(source) || fs.readdirSync(source).length === 0 && focusedWindow && !focusedWindow.isDestroyed()) {
- electron.dialog.showMessageBox(focusedWindow, {
- type: 'error',
- title: i18n.getMessageFor('Failed!'),
- message: i18n.getMessageFor('No crashes available to share')
- });
- return;
- }
-
- let destPath = isMac ? '/crashes_symphony_' : '\\crashes_symphony_';
- let timestamp = new Date().getTime();
-
- let destination = electron.app.getPath('downloads') + destPath + timestamp + '.zip';
-
- archiveHandler.generateArchiveForDirectory(source, destination, FILE_EXTENSIONS)
- .then(() => {
- electron.shell.showItemInFolder(destination);
- })
- .catch((err) => {
- if (focusedWindow && !focusedWindow.isDestroyed()) {
- electron.dialog.showMessageBox(focusedWindow, {
- type: 'error',
- title: i18n.getMessageFor('Failed!'),
- message: i18n.getMessageFor('Unable to generate crash reports due to ') + err
- });
- }
- });
- }
- },
- {
- label: i18n.getMessageFor('Toggle Developer Tools'),
- accelerator: isMac ? 'Alt+Command+I' : 'Ctrl+Shift+I',
- click(item, focusedWindow) {
- let devToolsEnabled = readConfigFromFile('devToolsEnabled');
- if (focusedWindow && !focusedWindow.isDestroyed()) {
- if (devToolsEnabled) {
- focusedWindow.webContents.toggleDevTools();
- } else {
- log.send(logLevels.INFO, `dev tools disabled for ${focusedWindow.winName} window`);
- electron.dialog.showMessageBox(focusedWindow, {
- type: 'warning',
- buttons: ['Ok'],
- title: i18n.getMessageFor('Dev Tools disabled'),
- message: i18n.getMessageFor('Dev Tools has been disabled! Please contact your system administrator to enable it!'),
- });
- }
- }
- }
- },
- {
- label: i18n.getMessageFor('More Information'),
- click(item, focusedWindow) {
- let windowName = focusedWindow ? focusedWindow.name : '';
- moreInfo.openMoreInfoWindow(windowName);
- }
- }
- ]
- }
- ]
- }
- ];
-
- if (isMac && template[0].label !== app.getName()) {
- template.unshift({
- label: app.getName(),
- submenu: [{
- role: 'about',
- label: i18n.getMessageFor('About Symphony')
- },
- {
- type: 'separator'
- },
- {
- role: 'services',
- label: i18n.getMessageFor('Services'),
- submenu: []
- },
- {
- type: 'separator'
- },
- {
- role: 'hide',
- label: i18n.getMessageFor('Hide Symphony')
- },
- {
- role: 'hideothers',
- label: i18n.getMessageFor('Hide Others')
- },
- {
- role: 'unhide',
- label: i18n.getMessageFor('Show All')
- },
- {
- type: 'separator'
- },
- {
- role: 'quit',
- label: i18n.getMessageFor('Quit Symphony')
- }
- ]
- });
- // Edit menu.
- template[1].submenu.push({
- type: 'separator'
- }, {
- label: i18n.getMessageFor('Speech'),
- submenu: [{
- role: 'startspeaking',
- label: i18n.getMessageFor('Start Speaking')
- },
- {
- role: 'stopspeaking',
- label: i18n.getMessageFor('Stop Speaking')
- }
- ]
- });
- // Window menu.
- template[3].submenu = [{
- accelerator: 'CmdOrCtrl+W',
- role: 'close',
- label: i18n.getMessageFor('Close')
- },
- {
- accelerator: 'CmdOrCtrl+M',
- role: 'minimize',
- label: i18n.getMessageFor('Minimize')
- },
- {
- role: 'zoom',
- label: i18n.getMessageFor('Zoom')
- },
- {
- type: 'separator'
- },
- {
- role: 'front',
- label: i18n.getMessageFor('Bring All to Front')
- }
- ];
- }
-
- let index = 2;
- if (isMac && template[0].label !== app.getName()) {
- index = 3;
- }
-
- template[index].submenu.push({
- type: 'separator'
- });
-
- // Window menu -> launchOnStartup.
- template[index].submenu.push({
- label: i18n.getMessageFor('Auto Launch On Startup'),
- type: 'checkbox',
- checked: launchOnStartup,
- click: function (item, focusedWindow) {
- if (item.checked) {
- autoLaunch.enable()
- .catch(function (err) {
- let title = 'Error setting AutoLaunch configuration';
- log.send(logLevels.ERROR, 'MenuTemplate: ' + title + ': auto launch error ' + err);
- if (focusedWindow && !focusedWindow.isDestroyed()) {
- electron.dialog.showMessageBox(focusedWindow, {
- type: 'error',
- title: i18n.getMessageFor(title),
- message: i18n.getMessageFor(title) + ': ' + err
- });
- }
- });
- } else {
- autoLaunch.disable()
- .catch(function (err) {
- let title = 'Error setting AutoLaunch configuration';
- log.send(logLevels.ERROR, 'MenuTemplate: ' + title + ': auto launch error ' + err);
- if (focusedWindow && !focusedWindow.isDestroyed()) {
- electron.dialog.showMessageBox(focusedWindow, {
- type: 'error',
- title: i18n.getMessageFor(title),
- message: i18n.getMessageFor(title) + ': ' + err
- });
- }
- });
- }
- launchOnStartup = item.checked;
- updateConfigField('launchOnStartup', launchOnStartup);
- }
- });
-
- // Window menu -> alwaysOnTop.
- template[index].submenu.push({
- label: i18n.getMessageFor('Always on Top'),
- type: 'checkbox',
- checked: isAlwaysOnTop,
- click: (item) => {
- isAlwaysOnTop = item.checked;
- eventEmitter.emit('isAlwaysOnTop', {
- isAlwaysOnTop,
- shouldActivateMainWindow: true
- });
- updateConfigField('alwaysOnTop', isAlwaysOnTop);
- }
- });
-
- // Window menu -> minimizeOnClose.
- // ToDo: Add behavior on Close.
- template[index].submenu.push({
- label: i18n.getMessageFor('Minimize on Close'),
- type: 'checkbox',
- checked: minimizeOnClose,
- click: function (item) {
- minimizeOnClose = item.checked;
- updateConfigField('minimizeOnClose', minimizeOnClose);
- }
- });
-
- // Window menu -> bringToFront
- template[index].submenu.push({
- label: isWindowsOS ? i18n.getMessageFor('Flash Notification in Taskbar') : i18n.getMessageFor('Bring to Front on Notifications'),
- type: 'checkbox',
- checked: bringToFront,
- click: function (item) {
- bringToFront = item.checked;
- updateConfigField('bringToFront', bringToFront);
- }
- });
-
- // Window/View menu -> separator
- template[index].submenu.push({
- type: 'separator',
- });
-
- // Window - View menu -> memoryRefresh
- template[index].submenu.push({
- label: i18n.getMessageFor('Refresh app when idle'),
- type: 'checkbox',
- checked: memoryRefresh,
- click: function (item) {
- memoryRefresh = item.checked;
- updateConfigField('memoryRefresh', memoryRefresh);
- }
- });
-
- // Window - View menu -> Clear Cache
- template[index].submenu.push({
- label: i18n.getMessageFor('Clear cache and Reload'),
- click: function (item, focusedWindow) {
- if (focusedWindow && !focusedWindow.isDestroyed()) {
- electron.session.defaultSession.clearCache(() => {
- focusedWindow.reload();
- });
- }
- }
- });
-
- if (!isMac) {
- /* eslint-disable no-param-reassign */
- template[index].submenu.push({
- label: titleBarStyle === titleBarStyles.NATIVE ?
- i18n.getMessageFor('Enable Hamburger menu') :
- i18n.getMessageFor('Disable Hamburger menu'),
- click: function () {
- const isNativeStyle = titleBarStyle === titleBarStyles.NATIVE;
-
- titleBarStyle = isNativeStyle ? titleBarStyles.NATIVE : titleBarStyles.CUSTOM;
- titleBarActions(app, isNativeStyle);
- }
- }, {
- type: 'separator'
- });
- /* eslint-enable no-param-reassign */
-
- template[index].submenu.push({
- label: i18n.getMessageFor('Quit Symphony'),
- click: function () {
- app.quit();
- }
- });
-
- // This adds About Symphony under help menu for windows
- template[3].submenu.push({
- label: i18n.getMessageFor('About Symphony'),
- click(menuItem, focusedWindow) {
- let windowName = focusedWindow ? focusedWindow.winName : '';
- aboutApp.openAboutWindow(windowName);
- }
- });
- }
-
- return template;
-}
-
-/**
- * Sets the checkbox values for different menu items
- * based on configuration
- */
-function setCheckboxValues() {
- return new Promise((resolve) => {
- /**
- * Method that reads multiple config fields
- */
- getMultipleConfigField(configFields)
- .then(function (configData) {
- for (let key in configData) {
- if (configData.hasOwnProperty(key)) { // eslint-disable-line no-prototype-builtins
- switch (key) {
- case 'minimizeOnClose':
- minimizeOnClose = configData[key];
- break;
- case 'launchOnStartup':
- launchOnStartup = configData[key];
- break;
- case 'alwaysOnTop':
- isAlwaysOnTop = configData[key];
- eventEmitter.emit('isAlwaysOnTop', {
- isAlwaysOnTop: configData[key],
- shouldActivateMainWindow: true
- });
- break;
- case 'notificationSettings':
- eventEmitter.emit('notificationSettings', configData[key]);
- break;
- case 'bringToFront':
- bringToFront = configData[key];
- break;
- case 'isCustomTitleBar':
- titleBarStyle = configData[key] ? titleBarStyles.CUSTOM : titleBarStyles.NATIVE;
- break;
- case 'memoryRefresh':
- memoryRefresh = configData[key];
- break;
- default:
- break;
- }
- }
- }
- return resolve();
- })
- .catch((err) => {
- let title = 'Error loading configuration';
- log.send(logLevels.ERROR, 'MenuTemplate: error reading configuration fields, error: ' + err);
- if (electron.BrowserWindow.getFocusedWindow() && !electron.BrowserWindow.getFocusedWindow().isDestroyed()) {
- electron.dialog.showMessageBox(electron.BrowserWindow.getFocusedWindow(), {
- type: 'error',
- title: i18n.getMessageFor(title),
- message: i18n.getMessageFor(title) + ': ' + err
- });
- }
- return resolve();
- });
- });
-}
-
-/**
- * Sets respective accelerators w.r.t roles for the menu template
- *
- * @param role {String} The action of the menu item
- * @param label {String} Menu item name
- * @return {Object}
- * @return {Object}.role The action of the menu item
- * @return {Object}.accelerator keyboard shortcuts and modifiers
- */
-function buildMenuItem(role, label) {
-
- if (isMac) {
- return label ? { role: role, label: label } : { role: role }
- }
-
- if (isWindowsOS) {
- return label ? { role: role, label: label, accelerator: windowsAccelerator[role] || '', registerAccelerator: true }
- : { role: role, accelerator: windowsAccelerator[role] || '', registerAccelerator: true }
- }
-
- return label ? { role: role, label: label } : { role: role }
-}
-
-function getMinimizeOnClose() {
- return minimizeOnClose;
-}
-
-function getTitleBarStyle() {
- return titleBarStyle;
-}
-
-/**
- * Displays an option to the user whether
- * to relaunch application
- *
- * @param app
- * @param isNativeStyle
- */
-function titleBarActions(app, isNativeStyle) {
- const options = {
- type: 'question',
- title: i18n.getMessageFor('Relaunch Application'),
- message: i18n.getMessageFor('Updating Title bar style requires Symphony to relaunch.'),
- detail: i18n.getMessageFor('Note: When Hamburger menu is disabled, you can trigger the main menu by pressing the Alt key.'),
- buttons: [i18n.getMessageFor('Relaunch'), i18n.getMessageFor('Cancel')],
- cancelId: 1
- };
- electron.dialog.showMessageBox(electron.BrowserWindow.getFocusedWindow(), options, function (index) {
- if (index === 0) {
- updateConfigField('isCustomTitleBar', !!isNativeStyle)
- .then(() => {
- app.relaunch();
- app.exit();
- }).catch((e) => {
- log.send(logLevels.ERROR, `Unable to disable / enable hamburger menu due to error: ${e}`);
- });
- }
- });
-}
-
-module.exports = {
- getTemplate: getTemplate,
- getMinimizeOnClose: getMinimizeOnClose,
- setCheckboxValues: setCheckboxValues,
- getTitleBarStyle: getTitleBarStyle
-};
diff --git a/js/moreInfo/index.js b/js/moreInfo/index.js
deleted file mode 100644
index 970de4c9..00000000
--- a/js/moreInfo/index.js
+++ /dev/null
@@ -1,141 +0,0 @@
-'use strict';
-
-const electron = require('electron');
-const BrowserWindow = electron.BrowserWindow;
-const path = require('path');
-const fs = require('fs');
-const log = require('../log.js');
-const logLevels = require('../enums/logLevels.js');
-const { version, clientVersion, buildNumber } = require('../../package.json');
-const { initCrashReporterMain, initCrashReporterRenderer } = require('../crashReporter.js');
-const i18n = require('../translation/i18n');
-const { isMac } = require('../utils/misc');
-
-let moreInfoWindow;
-
-let windowConfig = {
- width: 800,
- height: 600,
- show: false,
- modal: true,
- autoHideMenuBar: true,
- titleBarStyle: true,
- resizable: false,
- fullscreenable: false,
- webPreferences: {
- preload: path.join(__dirname, 'renderer.js'),
- sandbox: true,
- nodeIntegration: false,
- devTools: false
- }
-};
-
-/**
- * method to get the HTML template path
- * @returns {string}
- */
-function getTemplatePath() {
- let templatePath = path.join(__dirname, 'more-info.html');
- try {
- fs.statSync(templatePath).isFile();
- } catch (err) {
- log.send(logLevels.ERROR, 'more-info: Could not find template ("' + templatePath + '").');
- }
- return 'file://' + templatePath;
-}
-
-/**
- * Opens the about application window for a specific window
- * @param {String} windowName - name of the window upon
- * which this window should show
- */
-function openMoreInfoWindow(windowName) {
-
- // This prevents creating multiple instances of the
- // about window
- if (moreInfoWindow) {
- if (moreInfoWindow.isMinimized()) {
- moreInfoWindow.restore();
- }
- moreInfoWindow.focus();
- return;
- }
- let allWindows = BrowserWindow.getAllWindows();
- allWindows = allWindows.find((window) => { return window.winName === windowName });
-
- // if we couldn't find any window matching the window name
- // it will render as a new window
- if (allWindows) {
- windowConfig.parent = allWindows;
- }
-
- moreInfoWindow = new BrowserWindow(windowConfig);
- moreInfoWindow.setVisibleOnAllWorkspaces(true);
- moreInfoWindow.loadURL(getTemplatePath());
-
- // sets the AlwaysOnTop property for the about window
- // if the main window's AlwaysOnTop is true
- let focusedWindow = BrowserWindow.getFocusedWindow();
- if (focusedWindow && focusedWindow.isAlwaysOnTop()) {
- moreInfoWindow.setAlwaysOnTop(true);
- }
-
- moreInfoWindow.once('ready-to-show', () => {
- moreInfoWindow.show();
- });
-
- moreInfoWindow.webContents.on('did-finish-load', () => {
- const moreInfoContext = i18n.getMessageFor('MoreInfo');
- moreInfoWindow.webContents.send('i18n-more-info', moreInfoContext);
- // initialize crash reporter
- initCrashReporterMain({ process: 'more info window' });
- initCrashReporterRenderer(moreInfoWindow, { process: 'render | more info window' });
- moreInfoWindow.webContents.send('versionInfo', { version, clientVersion, buildNumber });
- if (!isMac) {
- // prevents from displaying menu items when "alt" key is pressed
- moreInfoWindow.setMenu(null);
- }
- });
-
- moreInfoWindow.webContents.on('crashed', function (event, killed) {
-
- log.send(logLevels.INFO, `More Info Window crashed! Killed? ${killed}`);
-
- if (killed) {
- return;
- }
-
- const options = {
- type: 'error',
- title: i18n.getMessageFor('Renderer Process Crashed'),
- message: i18n.getMessageFor('Oops! Looks like we have had a crash.'),
- buttons: ['Close']
- };
-
- electron.dialog.showMessageBox(options, function () {
- if (moreInfoWindow && !moreInfoWindow.isDestroyed()) {
- moreInfoWindow.close();
- }
- });
- });
-
- moreInfoWindow.on('close', () => {
- destroyWindow();
- });
-
- moreInfoWindow.on('closed', () => {
- destroyWindow();
- });
-}
-
-/**
- * Destroys a window
- */
-function destroyWindow() {
- moreInfoWindow = null;
-}
-
-
-module.exports = {
- openMoreInfoWindow: openMoreInfoWindow
-};
diff --git a/js/moreInfo/more-info.html b/js/moreInfo/more-info.html
deleted file mode 100644
index 1c70d49c..00000000
--- a/js/moreInfo/more-info.html
+++ /dev/null
@@ -1,45 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/js/moreInfo/renderer.js b/js/moreInfo/renderer.js
deleted file mode 100644
index 4b89da64..00000000
--- a/js/moreInfo/renderer.js
+++ /dev/null
@@ -1,66 +0,0 @@
-'use strict';
-const { ipcRenderer, crashReporter } = require('electron');
-
-renderDom();
-
-/**
- * Method that renders application data
- */
-function renderDom() {
- document.addEventListener('DOMContentLoaded', function () {
- const electronV = document.getElementById('electron');
- const chromiumV = document.getElementById('chromium');
- const v8V = document.getElementById('v8');
- const nodeV = document.getElementById('node');
- const opensslV = document.getElementById('openssl');
- const zlibV = document.getElementById('zlib');
- const uvV = document.getElementById('uv');
- const aresV = document.getElementById('ares');
- const httpparserV = document.getElementById('httpparser');
-
- electronV.innerHTML = `Electron ${process.versions.electron}`;
- chromiumV.innerHTML = `Chromium ${process.versions.chrome}`;
- v8V.innerHTML = `V8 ${process.versions.v8}`;
- nodeV.innerHTML = `Node ${process.versions.node}`;
- opensslV.innerHTML = `OpenSSL ${process.versions.openssl}`;
- zlibV.innerHTML = `ZLib ${process.versions.zlib}`;
- uvV.innerHTML = `UV ${process.versions.uv}`;
- aresV.innerHTML = `Ares ${process.versions.ares}`;
- httpparserV.innerHTML = `HTTP Parser ${process.versions.http_parser}`;
- });
-}
-
-ipcRenderer.on('register-crash-reporter', (event, arg) => {
- if (arg && typeof arg === 'object') {
- crashReporter.start(arg);
- }
-});
-
-ipcRenderer.on('i18n-more-info', (event, content) => {
- if (content && typeof content === 'object') {
- const i18nNodes = document.querySelectorAll('[data-i18n-text]');
-
- for (let node of i18nNodes) {
- if (node.attributes['data-i18n-text'] && node.attributes['data-i18n-text'].value) {
- node.innerText = content[node.attributes['data-i18n-text'].value] || node.attributes['data-i18n-text'].value;
- }
- }
- }
-});
-
-// note: this is a workaround until
-// https://github.com/electron/electron/issues/8841
-// is fixed on the electron. where 'will-navigate'
-// is never fired in sandbox mode
-//
-// This is required in order to prevent from loading
-// dropped content
-window.addEventListener('drop', function(e) {
- e.preventDefault();
- e.stopPropagation();
-});
-
-window.addEventListener('dragover', function(e) {
- e.preventDefault();
- e.stopPropagation();
-});
\ No newline at end of file
diff --git a/js/networkError/contents.js b/js/networkError/contents.js
deleted file mode 100644
index d285b28f..00000000
--- a/js/networkError/contents.js
+++ /dev/null
@@ -1,126 +0,0 @@
-const errorContent = (data) => {
- return (`
-
-
-
-
-
-
-
${data["Problem connecting to Symphony"] || "Problem connecting to Symphony"}
-
- ${data["Looks like you are not connected to the Internet. We'll try to reconnect automatically."]
- || "Looks like you are not connected to the Internet. We'll try to reconnect automatically."}
-