2018-07-21 19:00:08 +00:00
|
|
|
/* eslint-disable no-console */
|
|
|
|
|
2017-09-25 22:00:19 +00:00
|
|
|
const path = require('path');
|
|
|
|
const url = require('url');
|
2017-10-13 23:49:16 +00:00
|
|
|
const os = require('os');
|
2020-02-21 23:40:04 +00:00
|
|
|
const fs = require('fs-extra');
|
2018-08-28 21:53:05 +00:00
|
|
|
const crypto = require('crypto');
|
2019-05-16 22:32:11 +00:00
|
|
|
const qs = require('qs');
|
2020-02-21 23:40:04 +00:00
|
|
|
const normalizePath = require('normalize-path');
|
|
|
|
const fg = require('fast-glob');
|
|
|
|
const PQueue = require('p-queue').default;
|
2017-09-25 22:00:19 +00:00
|
|
|
|
2017-10-18 18:57:48 +00:00
|
|
|
const _ = require('lodash');
|
2018-06-14 20:39:44 +00:00
|
|
|
const pify = require('pify');
|
Beta versions support: SxS support, in-app env/instance display (#1606)
* Script for beta config; unique data dir, in-app env/type display
To release a beta build, increment the version and add -beta-N to the
end, then go through all the standard release activities.
The prepare-build npm script then updates key bits of the package.json
to ensure that the beta build can be installed alongside a production
build. This includes a new name ('Signal Beta') and a different location
for application data.
Note: Beta builds can be installed alongside production builds.
As part of this, a couple new bits of data are shown across the app:
- Environment (development or test, not shown if production)
- App Instance (disabled in production; used for multiple accounts)
These are shown in:
- The window title - both environment and app instance. You can tell
beta builds because the app name, preceding these data bits, is
different.
- The about window - both environment and app instance. You can tell
beta builds from the version number.
- The header added to the debug log - just environment. The version
number will tell us if it's a beta build, and app instance isn't
helpful.
* Turn on single-window mode in non-production modes
Because it's really frightening when you see 'unable to read from db'
errors in the console.
* aply.sh: More instructions for initial setup and testing
* Gruntfile: Get consistent with use of package.json datas
* Linux: manually update desktop keys, since macros not available
2017-10-30 20:57:13 +00:00
|
|
|
const electron = require('electron');
|
2017-09-25 22:00:19 +00:00
|
|
|
|
2018-08-16 17:07:38 +00:00
|
|
|
const packageJson = require('./package.json');
|
|
|
|
const GlobalErrors = require('./app/global_errors');
|
2020-03-20 21:00:11 +00:00
|
|
|
const { setup: setupSpellChecker } = require('./app/spell_check');
|
2018-06-14 20:39:44 +00:00
|
|
|
|
2018-08-16 17:07:38 +00:00
|
|
|
GlobalErrors.addHandler();
|
|
|
|
|
2020-02-21 23:40:04 +00:00
|
|
|
// Set umask early on in the process lifecycle to ensure file permissions are
|
|
|
|
// set such that only we have read access to our files
|
|
|
|
process.umask(0o077);
|
|
|
|
|
2018-08-16 17:07:38 +00:00
|
|
|
const getRealPath = pify(fs.realpath);
|
2018-05-23 23:26:40 +00:00
|
|
|
const {
|
|
|
|
app,
|
2018-05-24 19:13:16 +00:00
|
|
|
BrowserWindow,
|
2019-12-17 20:25:57 +00:00
|
|
|
dialog,
|
2018-05-23 23:26:40 +00:00
|
|
|
ipcMain: ipc,
|
2018-05-24 19:13:16 +00:00
|
|
|
Menu,
|
2018-05-23 23:26:40 +00:00
|
|
|
protocol: electronProtocol,
|
2018-05-24 19:13:16 +00:00
|
|
|
session,
|
|
|
|
shell,
|
2018-05-23 23:26:40 +00:00
|
|
|
} = electron;
|
2017-03-02 22:04:38 +00:00
|
|
|
|
2018-03-02 19:43:03 +00:00
|
|
|
const appUserModelId = `org.whispersystems.${packageJson.name}`;
|
2018-04-27 21:25:04 +00:00
|
|
|
console.log('Set Windows Application User Model ID (AUMID)', {
|
|
|
|
appUserModelId,
|
|
|
|
});
|
2018-03-02 19:43:03 +00:00
|
|
|
app.setAppUserModelId(appUserModelId);
|
2017-03-30 19:01:30 +00:00
|
|
|
|
2020-03-19 17:57:50 +00:00
|
|
|
// We don't navigate, but this is the way of the future
|
|
|
|
// https://github.com/electron/electron/issues/18397
|
|
|
|
app.allowRendererProcessReuse = true;
|
|
|
|
|
2017-06-22 01:04:19 +00:00
|
|
|
// Keep a global reference of the window object, if you don't, the window will
|
Beta versions support: SxS support, in-app env/instance display (#1606)
* Script for beta config; unique data dir, in-app env/type display
To release a beta build, increment the version and add -beta-N to the
end, then go through all the standard release activities.
The prepare-build npm script then updates key bits of the package.json
to ensure that the beta build can be installed alongside a production
build. This includes a new name ('Signal Beta') and a different location
for application data.
Note: Beta builds can be installed alongside production builds.
As part of this, a couple new bits of data are shown across the app:
- Environment (development or test, not shown if production)
- App Instance (disabled in production; used for multiple accounts)
These are shown in:
- The window title - both environment and app instance. You can tell
beta builds because the app name, preceding these data bits, is
different.
- The about window - both environment and app instance. You can tell
beta builds from the version number.
- The header added to the debug log - just environment. The version
number will tell us if it's a beta build, and app instance isn't
helpful.
* Turn on single-window mode in non-production modes
Because it's really frightening when you see 'unable to read from db'
errors in the console.
* aply.sh: More instructions for initial setup and testing
* Gruntfile: Get consistent with use of package.json datas
* Linux: manually update desktop keys, since macros not available
2017-10-30 20:57:13 +00:00
|
|
|
// be closed automatically when the JavaScript object is garbage collected.
|
2017-06-22 01:28:07 +00:00
|
|
|
let mainWindow;
|
2020-04-06 23:45:39 +00:00
|
|
|
let mainWindowCreated = false;
|
2020-03-25 23:45:37 +00:00
|
|
|
let loadingWindow;
|
2017-04-13 19:10:42 +00:00
|
|
|
|
2017-11-21 23:23:18 +00:00
|
|
|
function getMainWindow() {
|
|
|
|
return mainWindow;
|
|
|
|
}
|
|
|
|
|
2017-11-27 22:48:09 +00:00
|
|
|
// Tray icon and related objects
|
|
|
|
let tray = null;
|
New design for import/install, 'light' import (#2053)
- A new design for the import flow. It features:
- Icons at the top of every screen
- Gray background, blue buttons, thinner text
- Simpler copy
- A new design for the install flow. It features:
- Immediate entry into the QR code screen
- Animated dots to show that we're loading the QR code from the server
- Fewer screens: 1) QR 2) device name 3) sync-in-progress
- When not set up, the app opens directly into the install screen, which has been streamlined. The `--import` command-line argument will cause the app to open directly into the import flow.
- Support for two different flavors of builds - the normal build will open into the standard registration flow, and the import flavor will be exactly the same except during setup it will open directly into the import flow.
- A new design for the (dev-only) standalone registration view
- When these install sequences are active, the OS File menu has entries to allow you to switch the method of setup you'd like to use. These go away as soon as the first step is taken in any of these flows.
- The device name (chosen on initial setup) is now shown in the settings panel
- At the end of a light import, we hand off to the normal device link screen, starting at the QR code. On a full import, we remove the sensitive encryption information in the export to prevent conflicts on multiple imports.
- `Whisper.Backup.exportToDirectory()` takes an options object so you can tell it to do a light export.
- `Whisper.Backup.importFromDirectory()` takes an options object so you can force it to load only the light components found on disk. It also returns an object so you can tell whether a given import was a full import or light import.
- On start of import, we build a list of all the ids present in the messages, conversations, and groups stores in IndexedDB. This can take some time if a lot of data is in the database already, but it makes the subsequent deduplicated import very fast.
- Disappearing messages are now excluded when exporting
- Remove some TODOs in the tests
2018-02-22 18:40:32 +00:00
|
|
|
const startInTray = process.argv.some(arg => arg === '--start-in-tray');
|
2018-04-27 21:25:04 +00:00
|
|
|
const usingTrayIcon =
|
|
|
|
startInTray || process.argv.some(arg => arg === '--use-tray-icon');
|
2019-10-15 21:00:10 +00:00
|
|
|
|
|
|
|
const disableFlashFrame = process.argv.some(
|
|
|
|
arg => arg === '--disable-flash-frame'
|
|
|
|
);
|
2017-11-27 22:48:09 +00:00
|
|
|
|
2018-01-08 21:19:25 +00:00
|
|
|
const config = require('./app/config');
|
2017-06-22 01:04:19 +00:00
|
|
|
|
2018-08-16 17:07:38 +00:00
|
|
|
// Very important to put before the single instance check, since it is based on the
|
|
|
|
// userData directory.
|
|
|
|
const userConfig = require('./app/user_config');
|
|
|
|
|
2018-04-27 21:25:04 +00:00
|
|
|
const importMode =
|
|
|
|
process.argv.some(arg => arg === '--import') || config.get('import');
|
New design for import/install, 'light' import (#2053)
- A new design for the import flow. It features:
- Icons at the top of every screen
- Gray background, blue buttons, thinner text
- Simpler copy
- A new design for the install flow. It features:
- Immediate entry into the QR code screen
- Animated dots to show that we're loading the QR code from the server
- Fewer screens: 1) QR 2) device name 3) sync-in-progress
- When not set up, the app opens directly into the install screen, which has been streamlined. The `--import` command-line argument will cause the app to open directly into the import flow.
- Support for two different flavors of builds - the normal build will open into the standard registration flow, and the import flavor will be exactly the same except during setup it will open directly into the import flow.
- A new design for the (dev-only) standalone registration view
- When these install sequences are active, the OS File menu has entries to allow you to switch the method of setup you'd like to use. These go away as soon as the first step is taken in any of these flows.
- The device name (chosen on initial setup) is now shown in the settings panel
- At the end of a light import, we hand off to the normal device link screen, starting at the QR code. On a full import, we remove the sensitive encryption information in the export to prevent conflicts on multiple imports.
- `Whisper.Backup.exportToDirectory()` takes an options object so you can tell it to do a light export.
- `Whisper.Backup.importFromDirectory()` takes an options object so you can force it to load only the light components found on disk. It also returns an object so you can tell whether a given import was a full import or light import.
- On start of import, we build a list of all the ids present in the messages, conversations, and groups stores in IndexedDB. This can take some time if a lot of data is in the database already, but it makes the subsequent deduplicated import very fast.
- Disappearing messages are now excluded when exporting
- Remove some TODOs in the tests
2018-02-22 18:40:32 +00:00
|
|
|
|
2020-03-05 21:14:58 +00:00
|
|
|
const development =
|
|
|
|
config.environment === 'development' || config.environment === 'staging';
|
New design for import/install, 'light' import (#2053)
- A new design for the import flow. It features:
- Icons at the top of every screen
- Gray background, blue buttons, thinner text
- Simpler copy
- A new design for the install flow. It features:
- Immediate entry into the QR code screen
- Animated dots to show that we're loading the QR code from the server
- Fewer screens: 1) QR 2) device name 3) sync-in-progress
- When not set up, the app opens directly into the install screen, which has been streamlined. The `--import` command-line argument will cause the app to open directly into the import flow.
- Support for two different flavors of builds - the normal build will open into the standard registration flow, and the import flavor will be exactly the same except during setup it will open directly into the import flow.
- A new design for the (dev-only) standalone registration view
- When these install sequences are active, the OS File menu has entries to allow you to switch the method of setup you'd like to use. These go away as soon as the first step is taken in any of these flows.
- The device name (chosen on initial setup) is now shown in the settings panel
- At the end of a light import, we hand off to the normal device link screen, starting at the QR code. On a full import, we remove the sensitive encryption information in the export to prevent conflicts on multiple imports.
- `Whisper.Backup.exportToDirectory()` takes an options object so you can tell it to do a light export.
- `Whisper.Backup.importFromDirectory()` takes an options object so you can force it to load only the light components found on disk. It also returns an object so you can tell whether a given import was a full import or light import.
- On start of import, we build a list of all the ids present in the messages, conversations, and groups stores in IndexedDB. This can take some time if a lot of data is in the database already, but it makes the subsequent deduplicated import very fast.
- Disappearing messages are now excluded when exporting
- Remove some TODOs in the tests
2018-02-22 18:40:32 +00:00
|
|
|
|
2018-08-16 17:07:38 +00:00
|
|
|
// We generally want to pull in our own modules after this point, after the user
|
|
|
|
// data directory has been set.
|
|
|
|
const attachments = require('./app/attachments');
|
|
|
|
const attachmentChannel = require('./app/attachment_channel');
|
2019-03-28 17:09:26 +00:00
|
|
|
const updater = require('./ts/updater/index');
|
2018-08-16 17:07:38 +00:00
|
|
|
const createTrayIcon = require('./app/tray_icon');
|
2018-07-21 16:37:39 +00:00
|
|
|
const dockIcon = require('./app/dock_icon');
|
2018-08-28 21:53:05 +00:00
|
|
|
const ephemeralConfig = require('./app/ephemeral_config');
|
2018-08-16 17:07:38 +00:00
|
|
|
const logging = require('./app/logging');
|
2020-04-01 18:59:11 +00:00
|
|
|
const sql = require('./ts/sql/Server').default;
|
2018-08-16 17:07:38 +00:00
|
|
|
const sqlChannels = require('./app/sql_channel');
|
|
|
|
const windowState = require('./app/window_state');
|
|
|
|
const { createTemplate } = require('./app/menu');
|
|
|
|
const {
|
|
|
|
installFileHandler,
|
|
|
|
installWebHandler,
|
|
|
|
} = require('./app/protocol_filter');
|
|
|
|
const { installPermissionsHandler } = require('./app/permissions');
|
Beta versions support: SxS support, in-app env/instance display (#1606)
* Script for beta config; unique data dir, in-app env/type display
To release a beta build, increment the version and add -beta-N to the
end, then go through all the standard release activities.
The prepare-build npm script then updates key bits of the package.json
to ensure that the beta build can be installed alongside a production
build. This includes a new name ('Signal Beta') and a different location
for application data.
Note: Beta builds can be installed alongside production builds.
As part of this, a couple new bits of data are shown across the app:
- Environment (development or test, not shown if production)
- App Instance (disabled in production; used for multiple accounts)
These are shown in:
- The window title - both environment and app instance. You can tell
beta builds because the app name, preceding these data bits, is
different.
- The about window - both environment and app instance. You can tell
beta builds from the version number.
- The header added to the debug log - just environment. The version
number will tell us if it's a beta build, and app instance isn't
helpful.
* Turn on single-window mode in non-production modes
Because it's really frightening when you see 'unable to read from db'
errors in the console.
* aply.sh: More instructions for initial setup and testing
* Gruntfile: Get consistent with use of package.json datas
* Linux: manually update desktop keys, since macros not available
2017-10-30 20:57:13 +00:00
|
|
|
|
2020-03-20 21:00:11 +00:00
|
|
|
let appStartInitialSpellcheckSetting = true;
|
|
|
|
|
|
|
|
async function getSpellCheckSetting() {
|
|
|
|
const json = await sql.getItemById('spell-check');
|
|
|
|
|
|
|
|
// Default to `true` if setting doesn't exist yet
|
|
|
|
if (!json) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return json.value;
|
|
|
|
}
|
|
|
|
|
2017-12-14 20:27:52 +00:00
|
|
|
function showWindow() {
|
2018-01-04 02:18:13 +00:00
|
|
|
if (!mainWindow) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-12-14 20:27:52 +00:00
|
|
|
// Using focus() instead of show() seems to be important on Windows when our window
|
|
|
|
// has been docked using Aero Snap/Snap Assist. A full .show() call here will cause
|
|
|
|
// the window to reposition:
|
2018-01-30 22:22:51 +00:00
|
|
|
// https://github.com/signalapp/Signal-Desktop/issues/1429
|
2017-12-14 20:27:52 +00:00
|
|
|
if (mainWindow.isVisible()) {
|
|
|
|
mainWindow.focus();
|
|
|
|
} else {
|
|
|
|
mainWindow.show();
|
|
|
|
}
|
|
|
|
|
|
|
|
// toggle the visibility of the show/hide tray icon menu entries
|
|
|
|
if (tray) {
|
|
|
|
tray.updateContextMenu();
|
|
|
|
}
|
2018-07-21 16:37:39 +00:00
|
|
|
|
|
|
|
// show the app on the Dock in case it was hidden before
|
|
|
|
dockIcon.show();
|
2017-12-14 20:27:52 +00:00
|
|
|
}
|
|
|
|
|
Beta versions support: SxS support, in-app env/instance display (#1606)
* Script for beta config; unique data dir, in-app env/type display
To release a beta build, increment the version and add -beta-N to the
end, then go through all the standard release activities.
The prepare-build npm script then updates key bits of the package.json
to ensure that the beta build can be installed alongside a production
build. This includes a new name ('Signal Beta') and a different location
for application data.
Note: Beta builds can be installed alongside production builds.
As part of this, a couple new bits of data are shown across the app:
- Environment (development or test, not shown if production)
- App Instance (disabled in production; used for multiple accounts)
These are shown in:
- The window title - both environment and app instance. You can tell
beta builds because the app name, preceding these data bits, is
different.
- The about window - both environment and app instance. You can tell
beta builds from the version number.
- The header added to the debug log - just environment. The version
number will tell us if it's a beta build, and app instance isn't
helpful.
* Turn on single-window mode in non-production modes
Because it's really frightening when you see 'unable to read from db'
errors in the console.
* aply.sh: More instructions for initial setup and testing
* Gruntfile: Get consistent with use of package.json datas
* Linux: manually update desktop keys, since macros not available
2017-10-30 20:57:13 +00:00
|
|
|
if (!process.mas) {
|
2017-04-26 03:16:51 +00:00
|
|
|
console.log('making app single instance');
|
2019-02-21 22:41:17 +00:00
|
|
|
const gotLock = app.requestSingleInstanceLock();
|
|
|
|
if (!gotLock) {
|
Beta versions support: SxS support, in-app env/instance display (#1606)
* Script for beta config; unique data dir, in-app env/type display
To release a beta build, increment the version and add -beta-N to the
end, then go through all the standard release activities.
The prepare-build npm script then updates key bits of the package.json
to ensure that the beta build can be installed alongside a production
build. This includes a new name ('Signal Beta') and a different location
for application data.
Note: Beta builds can be installed alongside production builds.
As part of this, a couple new bits of data are shown across the app:
- Environment (development or test, not shown if production)
- App Instance (disabled in production; used for multiple accounts)
These are shown in:
- The window title - both environment and app instance. You can tell
beta builds because the app name, preceding these data bits, is
different.
- The about window - both environment and app instance. You can tell
beta builds from the version number.
- The header added to the debug log - just environment. The version
number will tell us if it's a beta build, and app instance isn't
helpful.
* Turn on single-window mode in non-production modes
Because it's really frightening when you see 'unable to read from db'
errors in the console.
* aply.sh: More instructions for initial setup and testing
* Gruntfile: Get consistent with use of package.json datas
* Linux: manually update desktop keys, since macros not available
2017-10-30 20:57:13 +00:00
|
|
|
console.log('quitting; we are the second instance');
|
2018-01-30 18:55:49 +00:00
|
|
|
app.exit();
|
2019-02-21 22:41:17 +00:00
|
|
|
} else {
|
2019-12-18 19:21:35 +00:00
|
|
|
app.on('second-instance', (e, argv) => {
|
2019-02-21 22:41:17 +00:00
|
|
|
// Someone tried to run a second instance, we should focus our window
|
|
|
|
if (mainWindow) {
|
|
|
|
if (mainWindow.isMinimized()) {
|
|
|
|
mainWindow.restore();
|
|
|
|
}
|
|
|
|
|
|
|
|
showWindow();
|
|
|
|
}
|
2019-12-18 19:21:35 +00:00
|
|
|
// Are they trying to open a sgnl link?
|
|
|
|
const incomingUrl = getIncomingUrl(argv);
|
|
|
|
if (incomingUrl) {
|
|
|
|
handleSgnlLink(incomingUrl);
|
|
|
|
}
|
|
|
|
// Handled
|
2019-02-21 22:41:17 +00:00
|
|
|
return true;
|
|
|
|
});
|
2017-04-25 00:26:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-28 21:53:05 +00:00
|
|
|
const windowFromUserConfig = userConfig.get('window');
|
|
|
|
const windowFromEphemeral = ephemeralConfig.get('window');
|
|
|
|
let windowConfig = windowFromEphemeral || windowFromUserConfig;
|
|
|
|
if (windowFromUserConfig) {
|
|
|
|
userConfig.set('window', null);
|
|
|
|
ephemeralConfig.set('window', windowConfig);
|
|
|
|
}
|
|
|
|
|
2017-07-20 17:18:50 +00:00
|
|
|
const loadLocale = require('./app/locale').load;
|
2017-09-25 22:00:19 +00:00
|
|
|
|
2018-01-08 21:19:25 +00:00
|
|
|
// Both of these will be set after app fires the 'ready' event
|
|
|
|
let logger;
|
2017-07-20 17:18:50 +00:00
|
|
|
let locale;
|
2017-06-09 19:37:01 +00:00
|
|
|
|
2018-07-13 15:57:30 +00:00
|
|
|
function prepareURL(pathSegments, moreKeys) {
|
2019-12-17 20:25:57 +00:00
|
|
|
const parsed = url.parse(path.join(...pathSegments));
|
|
|
|
|
2017-10-13 23:49:16 +00:00
|
|
|
return url.format({
|
2019-12-17 20:25:57 +00:00
|
|
|
...parsed,
|
|
|
|
protocol: parsed.protocol || 'file:',
|
2017-10-13 23:49:16 +00:00
|
|
|
slashes: true,
|
|
|
|
query: {
|
Beta versions support: SxS support, in-app env/instance display (#1606)
* Script for beta config; unique data dir, in-app env/type display
To release a beta build, increment the version and add -beta-N to the
end, then go through all the standard release activities.
The prepare-build npm script then updates key bits of the package.json
to ensure that the beta build can be installed alongside a production
build. This includes a new name ('Signal Beta') and a different location
for application data.
Note: Beta builds can be installed alongside production builds.
As part of this, a couple new bits of data are shown across the app:
- Environment (development or test, not shown if production)
- App Instance (disabled in production; used for multiple accounts)
These are shown in:
- The window title - both environment and app instance. You can tell
beta builds because the app name, preceding these data bits, is
different.
- The about window - both environment and app instance. You can tell
beta builds from the version number.
- The header added to the debug log - just environment. The version
number will tell us if it's a beta build, and app instance isn't
helpful.
* Turn on single-window mode in non-production modes
Because it's really frightening when you see 'unable to read from db'
errors in the console.
* aply.sh: More instructions for initial setup and testing
* Gruntfile: Get consistent with use of package.json datas
* Linux: manually update desktop keys, since macros not available
2017-10-30 20:57:13 +00:00
|
|
|
name: packageJson.productName,
|
2017-10-13 23:49:16 +00:00
|
|
|
locale: locale.name,
|
|
|
|
version: app.getVersion(),
|
|
|
|
buildExpiration: config.get('buildExpiration'),
|
|
|
|
serverUrl: config.get('serverUrl'),
|
|
|
|
cdnUrl: config.get('cdnUrl'),
|
2018-05-26 01:01:56 +00:00
|
|
|
certificateAuthority: config.get('certificateAuthority'),
|
2017-10-13 23:49:16 +00:00
|
|
|
environment: config.environment,
|
|
|
|
node_version: process.versions.node,
|
|
|
|
hostname: os.hostname(),
|
Beta versions support: SxS support, in-app env/instance display (#1606)
* Script for beta config; unique data dir, in-app env/type display
To release a beta build, increment the version and add -beta-N to the
end, then go through all the standard release activities.
The prepare-build npm script then updates key bits of the package.json
to ensure that the beta build can be installed alongside a production
build. This includes a new name ('Signal Beta') and a different location
for application data.
Note: Beta builds can be installed alongside production builds.
As part of this, a couple new bits of data are shown across the app:
- Environment (development or test, not shown if production)
- App Instance (disabled in production; used for multiple accounts)
These are shown in:
- The window title - both environment and app instance. You can tell
beta builds because the app name, preceding these data bits, is
different.
- The about window - both environment and app instance. You can tell
beta builds from the version number.
- The header added to the debug log - just environment. The version
number will tell us if it's a beta build, and app instance isn't
helpful.
* Turn on single-window mode in non-production modes
Because it's really frightening when you see 'unable to read from db'
errors in the console.
* aply.sh: More instructions for initial setup and testing
* Gruntfile: Get consistent with use of package.json datas
* Linux: manually update desktop keys, since macros not available
2017-10-30 20:57:13 +00:00
|
|
|
appInstance: process.env.NODE_APP_INSTANCE,
|
2017-12-08 18:38:01 +00:00
|
|
|
proxyUrl: process.env.HTTPS_PROXY || process.env.https_proxy,
|
2019-01-16 03:03:56 +00:00
|
|
|
contentProxyUrl: config.contentProxyUrl,
|
New design for import/install, 'light' import (#2053)
- A new design for the import flow. It features:
- Icons at the top of every screen
- Gray background, blue buttons, thinner text
- Simpler copy
- A new design for the install flow. It features:
- Immediate entry into the QR code screen
- Animated dots to show that we're loading the QR code from the server
- Fewer screens: 1) QR 2) device name 3) sync-in-progress
- When not set up, the app opens directly into the install screen, which has been streamlined. The `--import` command-line argument will cause the app to open directly into the import flow.
- Support for two different flavors of builds - the normal build will open into the standard registration flow, and the import flavor will be exactly the same except during setup it will open directly into the import flow.
- A new design for the (dev-only) standalone registration view
- When these install sequences are active, the OS File menu has entries to allow you to switch the method of setup you'd like to use. These go away as soon as the first step is taken in any of these flows.
- The device name (chosen on initial setup) is now shown in the settings panel
- At the end of a light import, we hand off to the normal device link screen, starting at the QR code. On a full import, we remove the sensitive encryption information in the export to prevent conflicts on multiple imports.
- `Whisper.Backup.exportToDirectory()` takes an options object so you can tell it to do a light export.
- `Whisper.Backup.importFromDirectory()` takes an options object so you can force it to load only the light components found on disk. It also returns an object so you can tell whether a given import was a full import or light import.
- On start of import, we build a list of all the ids present in the messages, conversations, and groups stores in IndexedDB. This can take some time if a lot of data is in the database already, but it makes the subsequent deduplicated import very fast.
- Disappearing messages are now excluded when exporting
- Remove some TODOs in the tests
2018-02-22 18:40:32 +00:00
|
|
|
importMode: importMode ? true : undefined, // for stringify()
|
2020-04-15 23:12:28 +00:00
|
|
|
serverPublicParams: config.get('serverPublicParams'),
|
2018-10-18 01:01:21 +00:00
|
|
|
serverTrustRoot: config.get('serverTrustRoot'),
|
2020-03-20 21:00:11 +00:00
|
|
|
appStartInitialSpellcheckSetting,
|
2018-07-13 15:57:30 +00:00
|
|
|
...moreKeys,
|
2018-01-08 21:19:25 +00:00
|
|
|
},
|
|
|
|
});
|
2017-10-13 23:49:16 +00:00
|
|
|
}
|
|
|
|
|
2019-12-03 20:02:50 +00:00
|
|
|
async function handleUrl(event, target) {
|
2017-10-13 23:49:16 +00:00
|
|
|
event.preventDefault();
|
2019-12-17 20:25:57 +00:00
|
|
|
const { protocol, hostname } = url.parse(target);
|
|
|
|
const isDevServer = config.enableHttp && hostname === 'localhost';
|
|
|
|
// We only want to specially handle urls that aren't requesting the dev server
|
|
|
|
if ((protocol === 'http:' || protocol === 'https:') && !isDevServer) {
|
2019-12-03 20:02:50 +00:00
|
|
|
try {
|
|
|
|
await shell.openExternal(target);
|
|
|
|
} catch (error) {
|
|
|
|
console.log(`Failed to open url: ${error.stack}`);
|
|
|
|
}
|
2017-10-13 23:49:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-21 21:48:05 +00:00
|
|
|
function handleCommonWindowEvents(window) {
|
2018-01-08 21:19:25 +00:00
|
|
|
window.webContents.on('will-navigate', handleUrl);
|
2017-10-13 23:49:16 +00:00
|
|
|
window.webContents.on('new-window', handleUrl);
|
2020-01-21 21:48:05 +00:00
|
|
|
window.webContents.on('preload-error', (event, preloadPath, error) => {
|
|
|
|
console.error(`Preload error in ${preloadPath}: `, error.message);
|
|
|
|
});
|
2017-10-13 23:49:16 +00:00
|
|
|
}
|
|
|
|
|
2017-11-30 19:58:00 +00:00
|
|
|
const DEFAULT_WIDTH = 800;
|
|
|
|
const DEFAULT_HEIGHT = 610;
|
2020-01-17 17:49:01 +00:00
|
|
|
const MIN_WIDTH = 680;
|
2019-06-27 20:38:58 +00:00
|
|
|
const MIN_HEIGHT = 550;
|
2017-11-30 19:58:00 +00:00
|
|
|
const BOUNDS_BUFFER = 100;
|
|
|
|
|
|
|
|
function isVisible(window, bounds) {
|
|
|
|
const boundsX = _.get(bounds, 'x') || 0;
|
|
|
|
const boundsY = _.get(bounds, 'y') || 0;
|
|
|
|
const boundsWidth = _.get(bounds, 'width') || DEFAULT_WIDTH;
|
|
|
|
const boundsHeight = _.get(bounds, 'height') || DEFAULT_HEIGHT;
|
|
|
|
|
|
|
|
// requiring BOUNDS_BUFFER pixels on the left or right side
|
2018-04-27 21:25:04 +00:00
|
|
|
const rightSideClearOfLeftBound =
|
|
|
|
window.x + window.width >= boundsX + BOUNDS_BUFFER;
|
|
|
|
const leftSideClearOfRightBound =
|
|
|
|
window.x <= boundsX + boundsWidth - BOUNDS_BUFFER;
|
2017-11-30 19:58:00 +00:00
|
|
|
|
|
|
|
// top can't be offscreen, and must show at least BOUNDS_BUFFER pixels at bottom
|
|
|
|
const topClearOfUpperBound = window.y >= boundsY;
|
2018-04-27 21:25:04 +00:00
|
|
|
const topClearOfLowerBound =
|
|
|
|
window.y <= boundsY + boundsHeight - BOUNDS_BUFFER;
|
2017-11-30 19:58:00 +00:00
|
|
|
|
2018-04-27 21:25:04 +00:00
|
|
|
return (
|
|
|
|
rightSideClearOfLeftBound &&
|
Auto-orient image attachments based on EXIF metadata
As described in #998, images are sometimes displayed with an incorrect
orientation. This is because cameras often write files in the native sensor byte
order and attach the `Orientation` EXIF metadata to tell end-user devices how to
display the images based on the original author’s capture orientation.
Electron/Chromium (and therefore Signal Desktop) currently doesn’t support
applying this metadata for `<img>` tags, e.g. CSS `image-orientation: from-
image`. As a workaround, this change uses the `loadImage` library with the
`orientation: true` flag to auto-orient images ~~before display~~ upon receipt
and before sending.
**Changes**
- [x] ~~Auto-orient images during display in message list view~~
- [x] Ensure image is not displayed until loaded (to prevent layout reflow) .
- [x] Auto-orient images upon receipt and before storing in IndexedDB
(~~or preserve original data until Chromium offers native fix?~~)
- [x] Auto-orient images in compose area preview.
- [x] ~~Auto-orient images in lightbox view~~
- [x] Auto-orient images before sending / storage.
- [x] Add EditorConfig for sharing code styles across editors.
- [x] Fix ESLint ignore file.
- [x] Change `function-paren-newline` ESLint rule from
`consistent` to `multiline`.
- [x] Add `operator-linebreak` ESLint rule for consistency.
- [x] Added `blob-util` dependency for converting between array buffers,
blobs, etc.
- [x] Extracted `createMessageHandler` to consolidate logic for
`onMessageReceived` and `onSentMessage`.
- [x] Introduce `async` / `await` to simplify async coding (restore control flow
for branching, loops, and exceptions).
- [x] Introduce `window.Signal` namespace for exposing ES2015+ CommonJS modules.
- [x] Introduce rudimentary `Message` and `Attachment` types to begin defining a
schema and versioning. This will allow us to track which changes, e.g.
auto-orient JPEGs, per message / attachment as well as which fields
are stored.
- [x] Renamed `window.dataURLtoBlob` to `window.dataURLToBlobSync` to both fix
the strange `camelCase` as well as to highlight that this operation is
synchronous and therefore blocks the user thread.
- [x] Normalize all JPEG MIME types to `image/jpeg`, eliminating the
invalid `image/jpg`.
- [x] Add `npm run test-modules` command for testing non-browser specific
CommonJS modules.
- **Stretch Goals**
- [ ] ~~Restrict `autoOrientImage` to `Blob` to narrow API interface.~~ Do
this once we use PureScript.
- [ ] ~~Return non-JPEGs as no-op from `autoOrientImage`.~~ Skipping
`autoOrientImage` for non-JPEGs altogether.
- [ ] Retroactively auto-orient existing JPEG image attachments in the
background.
---
Fixes #998
---
- **Blog:** EXIF Orientation Handling Is a Ghetto:
https://www.daveperrett.com/articles/2012/07/28/exif-orientation-handling-is-a-ghetto/
- **Chromium Bug:** EXIF orientation is ignored:
https://bugs.chromium.org/p/chromium/issues/detail?id=56845
- **Chromium Bug:** Support for the CSS image-orientation CSS property:
https://bugs.chromium.org/p/chromium/issues/detail?id=158753
---
commit ce5090b473a2448229dc38e4c3f15d7ad0137714
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Fri Feb 16 10:35:36 2018 -0500
Inline message descriptors
commit 329036e59c138c1e950ec7c654eebd7d87076de5
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Thu Feb 15 17:34:40 2018 -0500
Clarify order of operations
Semantically, it makes more sense to do `getFile` before `clearForm`
even though it seems to work either way.
commit f9d4cfb2ba0d8aa308b0923bbe6066ea34cb97bd
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Thu Feb 15 17:18:26 2018 -0500
Simplify `operator-linebreak` configuration
Enabling `before` caused more code changes and it turns out our previous
configuration is already the default.
commit db588997acdd90ed2ad829174ecbba744383c78b
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Thu Feb 15 17:15:59 2018 -0500
Remove obsolete TODO
commit 799c8817633f6afa0b731fc3b5434e463bd850e3
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Thu Feb 15 17:12:18 2018 -0500
Enable ESLint `function-paren-newline` `multiline`
Per discussion.
commit b660b6bc8ef41df7601a411213d6cda80821df87
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Thu Feb 15 17:10:48 2018 -0500
Use `messageDescriptor.id` not `source`
commit 5e7309d176f4a7e97d3dc4c738e6b0ccd4792871
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Wed Feb 14 16:29:01 2018 -0500
Remove unnecessary `eslint-env`
commit 393b3da55eabd7413596c86cc3971b063a0efe31
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Wed Feb 14 16:19:17 2018 -0500
Refactor `onSentMessage` and `onMessageReceived`
Since they are so similar, we create the handlers using new
`createMessageHandler` function. This allows us to ensure both synced and
received messages go through schema upgrade pipeline.
commit b3db0bf179c9a5bea96480cde28c6fa7193ac117
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Wed Feb 14 16:18:21 2018 -0500
Add `Message` descriptor functions
commit 8febf125b1b42fe4ae1888dd50fcee2749dc1ff0
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Wed Feb 14 14:46:56 2018 -0500
Fix typo
commit 98d951ef77bd578b313a4ff4b496b793e82e88d5
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Wed Feb 14 12:22:39 2018 -0500
Remove `promises` reference
commit a0e9559ed5bed947dabf28cb672e63d39948d854
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Wed Feb 14 12:22:13 2018 -0500
Fix `AttachmentView::mediaType` fall-through
commit 67be916a83951b8a1f9b22efe78a6da6b1825f38
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Wed Feb 14 12:03:41 2018 -0500
Remove minor TODOs
commit 0af186e118256b62905de38487ffacc41693ff47
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Wed Feb 14 11:44:41 2018 -0500
Enable ESLint for `js/views/attachment_view.js`
commit 28a2dc5b8a28e1a087924fdc7275bf7d9a577b92
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Wed Feb 14 11:44:12 2018 -0500
Remove dynamic type checks
commit f4ce36fcfc2737de32d911cd6103f889097813f6
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Wed Feb 14 11:27:56 2018 -0500
Rename `process` to `upgradeSchema`
- `Message.process` -> `Message.upgradeSchema`
- `Attachment.process` -> `Attachment.upgradeSchema`
- `Attachment::processVersion` -> `Attachment::schemaVersion`
Document version history.
commit 41b92c0a31050ba05ddb1c43171d651f3568b9ac
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Wed Feb 14 11:11:50 2018 -0500
Add `operator-linebreak` ESLint rule
Based on the following discussion:
https://github.com/signalapp/Signal-Desktop/pull/2040#discussion_r168029106
commit 462defbe55879060fe25bc69103d4429bae2b2f6
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Wed Feb 14 11:01:30 2018 -0500
Add missing `await` for `ConversationController.getOrCreateAndWait`
Tested this by setting `if` condition to `true` and confirming it works.
It turns rotating a profile key is more involved and might require
registering a new account according to Matthew.
commit c08058ee4b883b3e23a40683de802ac81ed74874
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Tue Feb 13 16:32:24 2018 -0500
Convert `FileList` to `Array`
commit 70a6c4201925f57be1f94d9da3547fdefc7bbb53
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Tue Feb 13 15:46:34 2018 -0500
:art: Fix lint errors
commit 2ca7cdbc31d4120d6c6a838a6dcf43bc209d9788
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Tue Feb 13 15:07:09 2018 -0500
Skip `autoOrientImage` for non-JPEG images
commit 58eac383013c16ca363a4ed33dca5c7ba61284e5
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Tue Feb 13 14:55:35 2018 -0500
Move new-style modules to `window.Signal` namespace
commit 02c9328877dce289d6116a18b1c223891bd3cd0b
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Tue Feb 13 14:35:23 2018 -0500
Extract `npm run test-modules` command
commit 2c708eb94fba468b81ea9427734896114f5a7807
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Tue Feb 13 13:25:51 2018 -0500
Extract `Message.process`
commit 4a2e52f68a77536a0fa04aa3c29ad3e541a8fa7e
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Tue Feb 13 13:25:12 2018 -0500
Fix EditorConfig
commit a346bab5db082720f5d47363f06301380e870425
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Tue Feb 13 13:13:02 2018 -0500
Remove `vim` directives on ESLint-ed files
commit 7ec885c6359e495b407d5bc3eac9431d47c37fc6
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Tue Feb 13 13:08:24 2018 -0500
Remove CSP whitelisting of `blob:`
We no longer use `autoOrientImage` using blob URLs. Bring this back if we
decide to auto-orient legacy attachments.
commit 879b6f58f4a3f4a9ed6915af6b1be46c1e90e0ca
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Tue Feb 13 12:57:05 2018 -0500
Use `Message` type to determine send function
Throws on invalid message type.
commit 5203d945c98fd2562ae4e22c5c9838d27dec305b
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Tue Feb 13 12:56:48 2018 -0500
Whitelist `Whisper` global
commit 8ad0b066a3690d3382b86bf6ac00c03df7d1e20b
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Tue Feb 13 12:56:32 2018 -0500
Add `Whisper.Types` namespace
This avoids namespace collision for `Whisper.Message`.
commit 785a949fce2656ca7dcaf0869d6b9e0648114e80
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Tue Feb 13 12:55:43 2018 -0500
Add `Message` type
commit 674a7357abf0dcc365455695d56c0479998ebf27
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Tue Feb 13 12:35:23 2018 -0500
Run ESLint on `Conversation::sendMessage`
commit cd985aa700caa80946245b17ea1b856449f152a0
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Tue Feb 13 12:34:38 2018 -0500
Document type signature of `FileInputView::readFile`
commit d70d70e52c49588a1dc9833dfe5dd7128e13607f
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Tue Feb 13 12:31:16 2018 -0500
Move attachment processing closer to sending
This helps ensure processing happens uniformly, regardless of which code
paths are taken to send an attachment.
commit 532ac3e273a26b97f831247f9ee3412621b5c112
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Tue Feb 13 12:22:29 2018 -0500
Process attachment before it’s sent
Picked this place since it already had various async steps, similar to
`onMessageReceived` for the incoming `Attachment.process`.
Could we try have this live closer to where we store it in IndexedDB, e.g.
`Conversation::sendMessage`?
commit a4582ae2fb6e1d3487131ba1f8fa6a00170cb32c
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Tue Feb 13 12:21:42 2018 -0500
Refactor `getFile` and `getFiles`
Lint them using ESLint.
commit 07e9114e65046d791fc4f6ed90d6e2e938ad559d
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Tue Feb 13 11:37:31 2018 -0500
Document incoming and outgoing attachments fields
Note how outgoing message attachments only have 4 fields. This presumably
means the others are not used in our code and could be discarded for
simplicity.
commit fdc3ef289d6ec1be344a12d496839d5ba747bb6a
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Tue Feb 13 11:36:21 2018 -0500
Highlight that `dataURLToBlob` is synchronous
commit b9c6bf600fcecedfd649ef2ae3c8629cced4e45a
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Tue Feb 13 11:35:49 2018 -0500
Add EditorConfig configuration
commit e56101e229d56810c8e31ad7289043a152c6c449
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Tue Feb 13 11:34:23 2018 -0500
Replace custom with `blob-util` functions
IMPORTANT: All of them are async so we need to use `await`, otherwise we get
strange or silent errors.
commit f95150f6a9569fabcb31f3acd9f6b7bf50b5d145
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Tue Feb 13 11:17:30 2018 -0500
Revert "Replace custom functions with `blob-util`"
This reverts commit 8a81e9c01bfe80c0e1bf76737092206c06949512.
commit 33860d93f3d30ec55c32f3f4a58729df2eb43f0d
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Tue Feb 13 11:13:02 2018 -0500
Revert "Replace `blueimp-canvas-to-blob` with `blob-util`"
This reverts commit 31b3e853e4afc78fe80995921aa4152d9f6e4783.
commit 7a0ba6fed622d76a3c39c7f03de541a7edb5b8dd
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Tue Feb 13 11:12:58 2018 -0500
Replace `blueimp-canvas-to-blob` with `blob-util`
commit 47a5f2bfd8b3f546e27e8d2b7e1969755d825a66
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Tue Feb 13 10:55:34 2018 -0500
Replace custom functions with `blob-util`
commit 1cfa0efdb4fb1265369e2bf243c21f04f044fa01
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Tue Feb 13 10:47:02 2018 -0500
Add `blob-util` dependency
commit 9ac26be1bd783cd5070d886de107dd3ad9c91ad1
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Tue Feb 13 10:46:44 2018 -0500
Document why we drop original image data during auto-orient
commit 4136d6c382b99f41760a4da519d0db537fa7de8d
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Tue Feb 13 10:46:27 2018 -0500
Extract `DEFAULT_JPEG_QUALITY`
commit 4a7156327eb5f94dba80cb300b344ac591226b0e
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Tue Feb 13 10:37:11 2018 -0500
Drop support for invalid `image/jpg` MIME type
commit 69fe96581f25413194032232f1bf704312e4754c
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Tue Feb 13 09:54:30 2018 -0500
Document `window.onInvalidStateError` global
commit a48ba1c77458da38583ee9cd488f70a59f6ee0fd
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Tue Feb 13 09:54:04 2018 -0500
Selectively run ESLint on `js/background.js`
Enabling ESLint on a per function basis allows us to incrementally improve
the codebase without requiring large and potentially risky refactorings.
commit e6d1cf826befc17ad4ec72fda8e761701665635e
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Tue Feb 13 09:16:23 2018 -0500
Move async attachment processing to `onMessageReceived`
We previously processed attachments in `handleDataMessage` which is mostly a
synchronous function, except for the saving of the model. Moving the
processing into the already async `onMessageReceived` improves code clarity.
commit be6ca2a9aae5b59c360817deb1e18d39d705755e
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Tue Feb 13 09:14:49 2018 -0500
Document import of ES2015+ modules
commit eaaf7c41608fb988b8f4bbaa933cff110115610e
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Tue Feb 13 09:14:29 2018 -0500
:art: Fix lint error
commit a25b0e2e3d0f72c6a7bf0a15683f02450d5209ee
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Tue Feb 13 09:13:57 2018 -0500
:art: Organize `require`s
commit e0cc3d8fab6529d01b388acddf8605908c3d236b
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Tue Feb 13 09:07:17 2018 -0500
Implement attachment process version
Instead of keeping track of last normalization (processing) date, we now
keep track of an internal processing version that will help us understand
what kind of processing has already been completed for a given attachment.
This will let us retroactively upgrade existing attachments.
As we add more processing steps, we can build a processing pipeline that can
convert any attachment processing version into a higher one,
e.g. 4 -> 5 -> 6 -> 7.
commit ad9083d0fdb880bc518e02251e51a39f7e1c585f
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Tue Feb 13 08:50:31 2018 -0500
Ignore ES2015+ files during JSCS linting
commit 96641205f734927aaebc2342d977c555799c3e3b
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Tue Feb 13 08:48:07 2018 -0500
Improve ESLint ignore rules
Apparently, using unqualified `/**` patterns prevents `!` include patterns.
Using qualified glob patterns, e.g. `js/models/**/*.js`, lets us work
around this.
commit 255e0ab15bd1a0ca8ca5746e42d23977c8765d01
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Tue Feb 13 08:44:59 2018 -0500
:abc: ESLint ignored files
commit ebcb70258a26f234bd602072ac7c0a1913128132
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Tue Feb 13 08:35:47 2018 -0500
Whitelist `browser` environment for ESLint
commit 3eaace6f3a21421c5aaaaf01592408c7ed83ecd3
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Tue Feb 13 08:35:05 2018 -0500
Use `MIME` module
commit ba2cf7770e614415733414a2dcc48f110b929892
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Tue Feb 13 08:32:54 2018 -0500
:art: Fix lint errors
commit 65acc86e8580e88f7a6611eb4b8fa5d7291f7a3f
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Tue Feb 13 08:30:42 2018 -0500
Add ES2015+ files to JSHint ignored list
commit 8b6494ae6c9247acdfa059a9b361ec5ffcdb39f0
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Tue Feb 13 08:29:20 2018 -0500
Document potentially unexpected `autoScale` behavior
commit 8b4c69b2002d1777d3621be10f92cbf432f9d4d6
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Tue Feb 13 08:26:47 2018 -0500
Test CommonJS modules separately
Not sure how to test them as part of Grunt `unit-tests` task as
`test/index.html` doesn’t allow for inclusion of CommonJS modules that use
`require`. The tests are silently skipped.
commit 213400e4b2bba3efee856a25b40e269221c3c39d
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Tue Feb 13 08:24:27 2018 -0500
Add `MIME` type module
commit 37a726e4fb4b3ed65914463122a5662847b5adee
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Mon Feb 12 20:18:05 2018 -0500
Return proper `Error` from `blobArrayToBuffer`
commit 164752db5612220e4dcf58d57bcd682cb489a399
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Mon Feb 12 20:15:41 2018 -0500
:art: Fix ESLint errors
commit d498dd79a067c75098dd3179814c914780e5cb4f
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Mon Feb 12 20:14:33 2018 -0500
Update `Attachment` type field definitions
commit 141155a1533ff8fb616b70ea313432781bbebffd
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Mon Feb 12 20:12:50 2018 -0500
Move `blueimp-canvas-to-blob` from Bower to npm
commit 7ccb833e5d286ddd6235d3e491c62ac1e4544510
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Mon Feb 12 16:33:50 2018 -0500
:art: Clarify data flow
commit e7da41591fde5a830467bebf1b6f51c1f7293e74
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Mon Feb 12 16:31:21 2018 -0500
Use `blobUrl` for consistency
commit 523a80eefe0e2858aa1fb2bb9539ec44da502963
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Mon Feb 12 16:28:06 2018 -0500
Remove just-in-time image auto-orient for lightbox
We can bring this back if our users would like auto-orient for old
attachments.
commit 0739feae9c47dd523c10740d6cdf746d539f270c
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Mon Feb 12 16:27:21 2018 -0500
Remove just-in-time auto-orient of message attachments
We can bring this back if our users would like auto-orient for old
attachments. But better yet, we might implement this as database migration.
commit ed43c66f92830ee233d5a94d0545eea4da43894d
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Mon Feb 12 16:26:24 2018 -0500
Auto-orient JPEG attachments upon receipt
commit e2eb8e36b017b048d57602fca14e45d657e0e1a1
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Mon Feb 12 16:25:26 2018 -0500
Expose `Attachment` type through `Whisper.Attachment`
commit 9638fbc987b84f143ca34211dc4666d96248ea2f
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Mon Feb 12 16:23:39 2018 -0500
Use `contentType` from `model`
commit 032c0ced46c3876cb9474b26f9d53d6f1c6b16a0
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Mon Feb 12 16:23:04 2018 -0500
Return `Error` object for `autoOrientImage` failures
commit ff04bad8510c4b21aef350bed2b1887d0e055b98
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Mon Feb 12 16:22:32 2018 -0500
Add `options` for `autoOrientImage` output type / quality
commit 87745b5586d1e182b51c9f9bc5e4eaf6dbc16722
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Mon Feb 12 16:18:46 2018 -0500
Add `Attachment` type
Defines various functions on attachments, e.g. normalization
(auto-orient JPEGs, etc.)
commit de27fdc10a53bc8882a9c978e82265db9ac6d6f5
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Mon Feb 12 16:16:34 2018 -0500
Add `yarn grunt` shortcut
This allows us to use local `grunt-cli` for `grunt dev`.
commit 59974db5a5da0d8f4cdc8ce5c4e3c974ecd5e754
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Mon Feb 12 10:10:11 2018 -0500
Improve readability
commit b5ba96f1e6f40f2e1fa77490c583217768e1f412
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Mon Feb 12 10:08:12 2018 -0500
Use `snake_case` for module names
Prevents problems across case-sensitive and case-insensitive file systems.
We can work around this in the future using a lint rule such as
`eslint-plugin-require-path-exists`.
See discussion:
https://github.com/signalapp/Signal-Desktop/pull/2040#discussion_r167365931
commit 48c5d3155c96ef628b00d99b52975e580d1d5501
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Mon Feb 12 10:05:44 2018 -0500
:art: Use destructuring
commit 4822f49f22382a99ebf142b337375f7c25251d76
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Fri Feb 9 17:41:40 2018 -0500
Auto-orient images in lightbox view
commit 7317110809677dddbbef3fadbf912cdba1c010bf
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Fri Feb 9 17:40:14 2018 -0500
Document magic number for escape key
commit c790d07389a7d0bbf5298de83dbcfa8be1e7696b
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Fri Feb 9 17:38:35 2018 -0500
Make second `View` argument an `options` object
commit fbe010bb63d0088af9dfe11f153437fab34247e0
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Fri Feb 9 17:27:40 2018 -0500
Allow `loadImage` to fetch `blob://` URLs
commit ec35710d002b019a273eeb48f94dcaf2babe5d96
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Fri Feb 9 16:57:48 2018 -0500
:art: Shorten `autoOrientImage` import
commit d07433e3cf316c6a143a0c9393ba26df9e3af17b
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Fri Feb 9 16:57:19 2018 -0500
Make `autoOrientImage` module standalone
commit c285bf5e33cdf10e0ef71e72cd6f55aef0df96ef
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Fri Feb 9 16:55:44 2018 -0500
Replace `loadImage` with `autoOrientImage`
commit 44318549235af01fd061c25f557c93fd21cebb7a
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Fri Feb 9 16:53:23 2018 -0500
Add `autoOrientImage` module
This module exposes `loadImage` with a `Promise` based interface and pre-
populates `orientation: true` option to auto-orient input. Returns data URL
as string.
The module uses a named export as refactoring references of modules with
`default` (`module.exports`) export references can be error-prone.
See: https://basarat.gitbooks.io/typescript/docs/tips/defaultIsBad.html
commit c77063afc6366fe49615052796fe46f9b369de39
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Fri Feb 9 16:44:30 2018 -0500
Auto-orient preview images
See: #998
commit 06dba5eb8f662c11af3a9ba8395bb453ab2e5f8d
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Fri Feb 9 16:43:23 2018 -0500
TODO: Use native `Canvas::toBlob`
One challenge is that `Canvas::toBlob` is async whereas
`dataURLtoBlob` is sync.
commit b15c304a3125dd023fd90990e6225a7303f3596f
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Fri Feb 9 16:42:45 2018 -0500
Make `null` check strict
Appeases JSHint. ESLint has a nice `smart` option for `eqeqeq` rule:
https://eslint.org/docs/rules/eqeqeq#smart
commit ea70b92d9b18201758e11fdc25b09afc97b50055
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Fri Feb 9 15:23:58 2018 -0500
Use `Canvas::toDataURL` to preserve `ImageView` logic
This way, all the other code paths remain untouched in case we want to
remove the auto-orient code once Chrome supports the `image-orientation`
CSS property.
See:
- #998
- https://developer.mozilla.org/en-US/docs/Web/CSS/image-orientation
commit 62fd744f9f27d951573a68d2cdfe7ba2a3784b41
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Fri Feb 9 14:38:04 2018 -0500
Use CSS to constrain auto-oriented images
commit f4d3392687168c237441b29140c7968b49dbef9e
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Fri Feb 9 14:35:02 2018 -0500
Replace `ImageView` `el` with auto-oriented `canvas`
See: #998
commit 1602d7f610e4993ad1291f88197f9ead1e25e776
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Fri Feb 9 14:25:48 2018 -0500
Pass `Blob` to `View` (for `ImageView`)
This allows us to do JPEG auto-orientation based on EXIF metadata.
commit e6a414f2b2a80da1137b839b348a38510efd04bb
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Fri Feb 9 14:25:12 2018 -0500
:hocho: Remove newline
commit 5f0d9570d7862fc428ff89c2ecfd332a744537e5
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Fri Feb 9 11:17:02 2018 -0500
Expose `blueimp-load-image` as `window.loadImage`
commit 1e1c62fe2f6a76dbcf1998dd468c26187c9871dc
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Fri Feb 9 11:16:46 2018 -0500
Add `blueimp-load-image` npm dependency
commit ad17fa8a68a21ca5ddec336801b8568009bef3d4
Author: Daniel Gasienica <daniel@gasienica.ch>
Date: Fri Feb 9 11:14:40 2018 -0500
Remove `blueimp-load-image` Bower dependency
2018-02-21 15:26:59 +00:00
|
|
|
leftSideClearOfRightBound &&
|
|
|
|
topClearOfUpperBound &&
|
2018-04-27 21:25:04 +00:00
|
|
|
topClearOfLowerBound
|
|
|
|
);
|
2017-11-30 19:58:00 +00:00
|
|
|
}
|
|
|
|
|
2020-03-20 21:00:11 +00:00
|
|
|
async function createWindow() {
|
2018-01-08 21:19:25 +00:00
|
|
|
const { screen } = electron;
|
2018-04-27 21:25:04 +00:00
|
|
|
const windowOptions = Object.assign(
|
|
|
|
{
|
|
|
|
show: !startInTray, // allow to start minimised in tray
|
|
|
|
width: DEFAULT_WIDTH,
|
|
|
|
height: DEFAULT_HEIGHT,
|
|
|
|
minWidth: MIN_WIDTH,
|
|
|
|
minHeight: MIN_HEIGHT,
|
|
|
|
autoHideMenuBar: false,
|
2019-02-05 17:25:05 +00:00
|
|
|
backgroundColor:
|
|
|
|
config.environment === 'test' || config.environment === 'test-lib'
|
|
|
|
? '#ffffff' // Tests should always be rendered on a white background
|
2020-03-05 21:24:51 +00:00
|
|
|
: '#3a76f0',
|
2018-04-27 21:25:04 +00:00
|
|
|
webPreferences: {
|
|
|
|
nodeIntegration: false,
|
2018-05-19 00:52:20 +00:00
|
|
|
nodeIntegrationInWorker: false,
|
2019-02-21 22:41:17 +00:00
|
|
|
contextIsolation: false,
|
2018-04-27 21:25:04 +00:00
|
|
|
preload: path.join(__dirname, 'preload.js'),
|
2018-05-23 22:54:10 +00:00
|
|
|
nativeWindowOpen: true,
|
2020-03-20 21:00:11 +00:00
|
|
|
spellcheck: await getSpellCheckSetting(),
|
2018-04-27 21:25:04 +00:00
|
|
|
},
|
|
|
|
icon: path.join(__dirname, 'images', 'icon_256.png'),
|
2017-11-09 01:33:20 +00:00
|
|
|
},
|
2019-11-14 22:01:52 +00:00
|
|
|
_.pick(windowConfig, ['autoHideMenuBar', 'width', 'height', 'x', 'y'])
|
2018-04-27 21:25:04 +00:00
|
|
|
);
|
2017-11-30 19:58:00 +00:00
|
|
|
|
|
|
|
if (!_.isNumber(windowOptions.width) || windowOptions.width < MIN_WIDTH) {
|
|
|
|
windowOptions.width = DEFAULT_WIDTH;
|
|
|
|
}
|
|
|
|
if (!_.isNumber(windowOptions.height) || windowOptions.height < MIN_HEIGHT) {
|
|
|
|
windowOptions.height = DEFAULT_HEIGHT;
|
|
|
|
}
|
|
|
|
if (!_.isBoolean(windowOptions.autoHideMenuBar)) {
|
|
|
|
delete windowOptions.autoHideMenuBar;
|
|
|
|
}
|
|
|
|
|
2018-04-27 21:25:04 +00:00
|
|
|
const visibleOnAnyScreen = _.some(screen.getAllDisplays(), display => {
|
2017-11-30 19:58:00 +00:00
|
|
|
if (!_.isNumber(windowOptions.x) || !_.isNumber(windowOptions.y)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return isVisible(windowOptions, _.get(display, 'bounds'));
|
|
|
|
});
|
|
|
|
if (!visibleOnAnyScreen) {
|
|
|
|
console.log('Location reset needed');
|
|
|
|
delete windowOptions.x;
|
|
|
|
delete windowOptions.y;
|
|
|
|
}
|
2017-05-19 23:49:31 +00:00
|
|
|
|
2018-04-27 21:25:04 +00:00
|
|
|
logger.info(
|
|
|
|
'Initializing BrowserWindow config: %s',
|
|
|
|
JSON.stringify(windowOptions)
|
|
|
|
);
|
2017-10-03 18:07:40 +00:00
|
|
|
|
2017-05-19 23:49:31 +00:00
|
|
|
// Create the browser window.
|
|
|
|
mainWindow = new BrowserWindow(windowOptions);
|
2020-04-06 23:45:39 +00:00
|
|
|
mainWindowCreated = true;
|
2020-03-20 21:00:11 +00:00
|
|
|
setupSpellChecker(mainWindow, locale.messages);
|
2020-03-04 02:10:12 +00:00
|
|
|
if (!usingTrayIcon && windowConfig && windowConfig.maximized) {
|
2019-09-16 21:18:39 +00:00
|
|
|
mainWindow.maximize();
|
|
|
|
}
|
2020-03-04 02:10:12 +00:00
|
|
|
if (!usingTrayIcon && windowConfig && windowConfig.fullscreen) {
|
2019-11-14 22:01:52 +00:00
|
|
|
mainWindow.setFullScreen(true);
|
|
|
|
}
|
2017-05-19 23:49:31 +00:00
|
|
|
|
|
|
|
function captureAndSaveWindowStats() {
|
2018-02-21 22:18:04 +00:00
|
|
|
if (!mainWindow) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-05-19 23:49:31 +00:00
|
|
|
const size = mainWindow.getSize();
|
|
|
|
const position = mainWindow.getPosition();
|
|
|
|
|
|
|
|
// so if we need to recreate the window, we have the most recent settings
|
|
|
|
windowConfig = {
|
|
|
|
maximized: mainWindow.isMaximized(),
|
2020-03-19 17:57:50 +00:00
|
|
|
autoHideMenuBar: mainWindow.autoHideMenuBar,
|
2019-11-14 22:01:52 +00:00
|
|
|
fullscreen: mainWindow.isFullScreen(),
|
2017-05-19 23:49:31 +00:00
|
|
|
width: size[0],
|
|
|
|
height: size[1],
|
|
|
|
x: position[0],
|
2018-01-08 21:19:25 +00:00
|
|
|
y: position[1],
|
2017-05-19 23:49:31 +00:00
|
|
|
};
|
|
|
|
|
2018-04-27 21:25:04 +00:00
|
|
|
logger.info(
|
|
|
|
'Updating BrowserWindow config: %s',
|
|
|
|
JSON.stringify(windowConfig)
|
|
|
|
);
|
2018-08-28 21:53:05 +00:00
|
|
|
ephemeralConfig.set('window', windowConfig);
|
2017-05-19 23:49:31 +00:00
|
|
|
}
|
|
|
|
|
2017-10-18 18:57:48 +00:00
|
|
|
const debouncedCaptureStats = _.debounce(captureAndSaveWindowStats, 500);
|
|
|
|
mainWindow.on('resize', debouncedCaptureStats);
|
|
|
|
mainWindow.on('move', debouncedCaptureStats);
|
2017-04-25 00:14:38 +00:00
|
|
|
|
2017-06-22 01:04:19 +00:00
|
|
|
if (config.environment === 'test') {
|
2017-05-15 21:47:45 +00:00
|
|
|
mainWindow.loadURL(prepareURL([__dirname, 'test', 'index.html']));
|
2017-12-01 21:35:39 +00:00
|
|
|
} else if (config.environment === 'test-lib') {
|
2018-04-27 21:25:04 +00:00
|
|
|
mainWindow.loadURL(
|
|
|
|
prepareURL([__dirname, 'libtextsecure', 'test', 'index.html'])
|
|
|
|
);
|
2017-05-15 21:47:45 +00:00
|
|
|
} else {
|
|
|
|
mainWindow.loadURL(prepareURL([__dirname, 'background.html']));
|
|
|
|
}
|
2017-03-02 22:04:38 +00:00
|
|
|
|
2017-05-16 16:11:58 +00:00
|
|
|
if (config.get('openDevTools')) {
|
2017-04-05 18:42:30 +00:00
|
|
|
// Open the DevTools.
|
2018-01-08 21:19:25 +00:00
|
|
|
mainWindow.webContents.openDevTools();
|
2017-04-05 18:42:30 +00:00
|
|
|
}
|
2017-03-02 22:04:38 +00:00
|
|
|
|
2020-01-21 21:48:05 +00:00
|
|
|
handleCommonWindowEvents(mainWindow);
|
2017-06-22 01:04:19 +00:00
|
|
|
|
2017-04-22 22:58:50 +00:00
|
|
|
// Emitted when the window is about to be closed.
|
2018-11-05 19:06:12 +00:00
|
|
|
// Note: We do most of our shutdown logic here because all windows are closed by
|
|
|
|
// Electron before the app quits.
|
|
|
|
mainWindow.on('close', async e => {
|
|
|
|
console.log('close event', {
|
|
|
|
readyForShutdown: mainWindow ? mainWindow.readyForShutdown : null,
|
|
|
|
shouldQuit: windowState.shouldQuit(),
|
|
|
|
});
|
2017-11-27 22:48:09 +00:00
|
|
|
// If the application is terminating, just do the default
|
2018-04-27 21:25:04 +00:00
|
|
|
if (
|
|
|
|
config.environment === 'test' ||
|
2018-11-05 19:06:12 +00:00
|
|
|
config.environment === 'test-lib' ||
|
|
|
|
(mainWindow.readyForShutdown && windowState.shouldQuit())
|
2018-04-27 21:25:04 +00:00
|
|
|
) {
|
2017-11-27 22:48:09 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-11-05 19:06:12 +00:00
|
|
|
// Prevent the shutdown
|
|
|
|
e.preventDefault();
|
|
|
|
mainWindow.hide();
|
|
|
|
|
2017-11-27 22:48:09 +00:00
|
|
|
// On Mac, or on other platforms when the tray icon is in use, the window
|
|
|
|
// should be only hidden, not closed, when the user clicks the close button
|
2018-11-05 19:06:12 +00:00
|
|
|
if (
|
|
|
|
!windowState.shouldQuit() &&
|
|
|
|
(usingTrayIcon || process.platform === 'darwin')
|
|
|
|
) {
|
2017-11-27 22:48:09 +00:00
|
|
|
// toggle the visibility of the show/hide tray icon menu entries
|
|
|
|
if (tray) {
|
|
|
|
tray.updateContextMenu();
|
|
|
|
}
|
2018-11-05 19:06:12 +00:00
|
|
|
|
2018-07-21 16:37:39 +00:00
|
|
|
// hide the app from the Dock on macOS if the tray icon is enabled
|
|
|
|
if (usingTrayIcon) {
|
|
|
|
dockIcon.hide();
|
|
|
|
}
|
|
|
|
|
2018-11-05 19:06:12 +00:00
|
|
|
return;
|
2017-04-22 22:58:50 +00:00
|
|
|
}
|
2018-11-05 19:06:12 +00:00
|
|
|
|
|
|
|
await requestShutdown();
|
2019-02-07 19:39:16 +00:00
|
|
|
if (mainWindow) {
|
|
|
|
mainWindow.readyForShutdown = true;
|
|
|
|
}
|
2018-11-05 19:06:12 +00:00
|
|
|
app.quit();
|
2017-04-22 22:58:50 +00:00
|
|
|
});
|
2017-06-22 01:04:19 +00:00
|
|
|
|
2017-03-02 22:04:38 +00:00
|
|
|
// Emitted when the window is closed.
|
2018-01-08 21:19:25 +00:00
|
|
|
mainWindow.on('closed', () => {
|
2017-03-02 22:04:38 +00:00
|
|
|
// Dereference the window object, usually you would store windows
|
|
|
|
// in an array if your app supports multi windows, this is the time
|
|
|
|
// when you should delete the corresponding element.
|
2018-01-08 21:19:25 +00:00
|
|
|
mainWindow = null;
|
2017-04-28 01:03:22 +00:00
|
|
|
});
|
2017-03-02 22:04:38 +00:00
|
|
|
}
|
|
|
|
|
2019-03-28 17:09:26 +00:00
|
|
|
ipc.on('show-window', () => {
|
|
|
|
showWindow();
|
|
|
|
});
|
|
|
|
|
2019-10-03 19:07:35 +00:00
|
|
|
let isReadyForUpdates = false;
|
|
|
|
async function readyForUpdates() {
|
|
|
|
if (isReadyForUpdates) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
isReadyForUpdates = true;
|
|
|
|
|
2019-05-16 22:32:11 +00:00
|
|
|
// First, install requested sticker pack
|
2019-12-18 19:21:35 +00:00
|
|
|
const incomingUrl = getIncomingUrl(process.argv);
|
|
|
|
if (incomingUrl) {
|
|
|
|
handleSgnlLink(incomingUrl);
|
2019-03-28 17:09:26 +00:00
|
|
|
}
|
|
|
|
|
2019-05-16 22:32:11 +00:00
|
|
|
// Second, start checking for app updates
|
2019-03-28 17:09:26 +00:00
|
|
|
try {
|
2020-02-13 18:14:08 +00:00
|
|
|
await updater.start(getMainWindow, locale, logger);
|
2019-03-28 17:09:26 +00:00
|
|
|
} catch (error) {
|
|
|
|
logger.error(
|
|
|
|
'Error starting update checks:',
|
|
|
|
error && error.stack ? error.stack : error
|
|
|
|
);
|
|
|
|
}
|
2019-10-03 19:07:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ipc.once('ready-for-updates', readyForUpdates);
|
|
|
|
|
|
|
|
const TEN_MINUTES = 10 * 60 * 1000;
|
|
|
|
setTimeout(readyForUpdates, TEN_MINUTES);
|
2019-03-28 17:09:26 +00:00
|
|
|
|
2017-10-13 23:49:16 +00:00
|
|
|
function openReleaseNotes() {
|
2018-04-27 21:25:04 +00:00
|
|
|
shell.openExternal(
|
|
|
|
`https://github.com/signalapp/Signal-Desktop/releases/tag/v${app.getVersion()}`
|
|
|
|
);
|
2017-10-13 23:49:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function openNewBugForm() {
|
2018-01-30 22:22:51 +00:00
|
|
|
shell.openExternal('https://github.com/signalapp/Signal-Desktop/issues/new');
|
2017-10-13 23:49:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function openSupportPage() {
|
2018-04-27 21:25:04 +00:00
|
|
|
shell.openExternal(
|
|
|
|
'https://support.signal.org/hc/en-us/categories/202319038-Desktop'
|
|
|
|
);
|
2017-10-13 23:49:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function openForums() {
|
2018-02-28 20:50:56 +00:00
|
|
|
shell.openExternal('https://community.signalusers.org/');
|
2017-10-13 23:49:16 +00:00
|
|
|
}
|
|
|
|
|
2019-11-07 21:36:16 +00:00
|
|
|
function showKeyboardShortcuts() {
|
|
|
|
if (mainWindow) {
|
|
|
|
mainWindow.webContents.send('show-keyboard-shortcuts');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
New design for import/install, 'light' import (#2053)
- A new design for the import flow. It features:
- Icons at the top of every screen
- Gray background, blue buttons, thinner text
- Simpler copy
- A new design for the install flow. It features:
- Immediate entry into the QR code screen
- Animated dots to show that we're loading the QR code from the server
- Fewer screens: 1) QR 2) device name 3) sync-in-progress
- When not set up, the app opens directly into the install screen, which has been streamlined. The `--import` command-line argument will cause the app to open directly into the import flow.
- Support for two different flavors of builds - the normal build will open into the standard registration flow, and the import flavor will be exactly the same except during setup it will open directly into the import flow.
- A new design for the (dev-only) standalone registration view
- When these install sequences are active, the OS File menu has entries to allow you to switch the method of setup you'd like to use. These go away as soon as the first step is taken in any of these flows.
- The device name (chosen on initial setup) is now shown in the settings panel
- At the end of a light import, we hand off to the normal device link screen, starting at the QR code. On a full import, we remove the sensitive encryption information in the export to prevent conflicts on multiple imports.
- `Whisper.Backup.exportToDirectory()` takes an options object so you can tell it to do a light export.
- `Whisper.Backup.importFromDirectory()` takes an options object so you can force it to load only the light components found on disk. It also returns an object so you can tell whether a given import was a full import or light import.
- On start of import, we build a list of all the ids present in the messages, conversations, and groups stores in IndexedDB. This can take some time if a lot of data is in the database already, but it makes the subsequent deduplicated import very fast.
- Disappearing messages are now excluded when exporting
- Remove some TODOs in the tests
2018-02-22 18:40:32 +00:00
|
|
|
function setupAsNewDevice() {
|
|
|
|
if (mainWindow) {
|
|
|
|
mainWindow.webContents.send('set-up-as-new-device');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function setupAsStandalone() {
|
|
|
|
if (mainWindow) {
|
|
|
|
mainWindow.webContents.send('set-up-as-standalone');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-13 23:49:16 +00:00
|
|
|
let aboutWindow;
|
|
|
|
function showAbout() {
|
|
|
|
if (aboutWindow) {
|
|
|
|
aboutWindow.show();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const options = {
|
|
|
|
width: 500,
|
|
|
|
height: 400,
|
|
|
|
resizable: false,
|
|
|
|
title: locale.messages.aboutSignalDesktop.message,
|
|
|
|
autoHideMenuBar: true,
|
2020-03-05 21:24:51 +00:00
|
|
|
backgroundColor: '#3a76f0',
|
2017-10-13 23:49:16 +00:00
|
|
|
show: false,
|
|
|
|
webPreferences: {
|
|
|
|
nodeIntegration: false,
|
2018-05-19 00:52:20 +00:00
|
|
|
nodeIntegrationInWorker: false,
|
2019-02-21 22:41:17 +00:00
|
|
|
contextIsolation: false,
|
2018-06-02 00:43:01 +00:00
|
|
|
preload: path.join(__dirname, 'about_preload.js'),
|
2018-05-23 22:54:10 +00:00
|
|
|
nativeWindowOpen: true,
|
2017-11-21 23:23:18 +00:00
|
|
|
},
|
|
|
|
parent: mainWindow,
|
2017-10-13 23:49:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
aboutWindow = new BrowserWindow(options);
|
|
|
|
|
2020-01-21 21:48:05 +00:00
|
|
|
handleCommonWindowEvents(aboutWindow);
|
2017-10-13 23:49:16 +00:00
|
|
|
|
|
|
|
aboutWindow.loadURL(prepareURL([__dirname, 'about.html']));
|
|
|
|
|
2018-01-08 21:19:25 +00:00
|
|
|
aboutWindow.on('closed', () => {
|
2017-10-13 23:49:16 +00:00
|
|
|
aboutWindow = null;
|
|
|
|
});
|
|
|
|
|
2018-01-08 21:19:25 +00:00
|
|
|
aboutWindow.once('ready-to-show', () => {
|
2017-10-13 23:49:16 +00:00
|
|
|
aboutWindow.show();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-07-03 22:33:50 +00:00
|
|
|
let settingsWindow;
|
2020-03-20 21:00:11 +00:00
|
|
|
function showSettingsWindow() {
|
2018-07-03 22:33:50 +00:00
|
|
|
if (settingsWindow) {
|
|
|
|
settingsWindow.show();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!mainWindow) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-10-17 18:22:07 +00:00
|
|
|
addDarkOverlay();
|
|
|
|
|
2018-07-03 22:33:50 +00:00
|
|
|
const size = mainWindow.getSize();
|
|
|
|
const options = {
|
|
|
|
width: Math.min(500, size[0]),
|
|
|
|
height: Math.max(size[1] - 100, MIN_HEIGHT),
|
2020-01-15 17:55:15 +00:00
|
|
|
frame: false,
|
2018-07-03 22:33:50 +00:00
|
|
|
resizable: false,
|
|
|
|
title: locale.messages.signalDesktopPreferences.message,
|
|
|
|
autoHideMenuBar: true,
|
2020-03-05 21:24:51 +00:00
|
|
|
backgroundColor: '#3a76f0',
|
2018-07-03 22:33:50 +00:00
|
|
|
show: false,
|
|
|
|
modal: true,
|
|
|
|
webPreferences: {
|
|
|
|
nodeIntegration: false,
|
|
|
|
nodeIntegrationInWorker: false,
|
2019-02-21 22:41:17 +00:00
|
|
|
contextIsolation: false,
|
2018-07-03 22:33:50 +00:00
|
|
|
preload: path.join(__dirname, 'settings_preload.js'),
|
|
|
|
nativeWindowOpen: true,
|
|
|
|
},
|
|
|
|
parent: mainWindow,
|
|
|
|
};
|
|
|
|
|
|
|
|
settingsWindow = new BrowserWindow(options);
|
|
|
|
|
2020-01-21 21:48:05 +00:00
|
|
|
handleCommonWindowEvents(settingsWindow);
|
2018-07-03 22:33:50 +00:00
|
|
|
|
2019-05-16 22:32:38 +00:00
|
|
|
settingsWindow.loadURL(prepareURL([__dirname, 'settings.html']));
|
2018-07-03 22:33:50 +00:00
|
|
|
|
|
|
|
settingsWindow.on('closed', () => {
|
|
|
|
removeDarkOverlay();
|
|
|
|
settingsWindow = null;
|
|
|
|
});
|
|
|
|
|
|
|
|
settingsWindow.once('ready-to-show', () => {
|
|
|
|
settingsWindow.show();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-12-17 20:25:57 +00:00
|
|
|
async function getIsLinked() {
|
|
|
|
try {
|
|
|
|
const number = await sql.getItemById('number_id');
|
|
|
|
const password = await sql.getItemById('password');
|
|
|
|
return Boolean(number && password);
|
|
|
|
} catch (e) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let stickerCreatorWindow;
|
|
|
|
async function showStickerCreator() {
|
2020-01-08 17:44:54 +00:00
|
|
|
if (!(await getIsLinked())) {
|
2019-12-17 20:25:57 +00:00
|
|
|
const { message } = locale.messages[
|
|
|
|
'StickerCreator--Authentication--error'
|
|
|
|
];
|
|
|
|
|
|
|
|
dialog.showMessageBox({
|
|
|
|
type: 'warning',
|
|
|
|
message,
|
|
|
|
});
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (stickerCreatorWindow) {
|
|
|
|
stickerCreatorWindow.show();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const { x = 0, y = 0 } = windowConfig || {};
|
|
|
|
|
|
|
|
const options = {
|
|
|
|
x: x + 100,
|
|
|
|
y: y + 100,
|
|
|
|
width: 800,
|
|
|
|
minWidth: 800,
|
|
|
|
height: 650,
|
|
|
|
title: locale.messages.signalDesktopStickerCreator,
|
|
|
|
autoHideMenuBar: true,
|
2020-03-05 21:24:51 +00:00
|
|
|
backgroundColor: '#3a76f0',
|
2019-12-17 20:25:57 +00:00
|
|
|
show: false,
|
|
|
|
webPreferences: {
|
|
|
|
nodeIntegration: false,
|
|
|
|
nodeIntegrationInWorker: false,
|
|
|
|
contextIsolation: false,
|
|
|
|
preload: path.join(__dirname, 'sticker-creator/preload.js'),
|
|
|
|
nativeWindowOpen: true,
|
2020-03-20 21:00:11 +00:00
|
|
|
spellcheck: await getSpellCheckSetting(),
|
2019-12-17 20:25:57 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
stickerCreatorWindow = new BrowserWindow(options);
|
2020-03-20 21:00:11 +00:00
|
|
|
setupSpellChecker(stickerCreatorWindow, locale.messages);
|
2019-12-17 20:25:57 +00:00
|
|
|
|
2020-01-21 21:48:05 +00:00
|
|
|
handleCommonWindowEvents(stickerCreatorWindow);
|
2019-12-17 20:25:57 +00:00
|
|
|
|
|
|
|
const appUrl = config.enableHttp
|
|
|
|
? prepareURL(['http://localhost:6380/sticker-creator/dist/index.html'])
|
|
|
|
: prepareURL([__dirname, 'sticker-creator/dist/index.html']);
|
|
|
|
|
|
|
|
stickerCreatorWindow.loadURL(appUrl);
|
|
|
|
|
|
|
|
stickerCreatorWindow.on('closed', () => {
|
|
|
|
stickerCreatorWindow = null;
|
|
|
|
});
|
|
|
|
|
|
|
|
stickerCreatorWindow.once('ready-to-show', () => {
|
|
|
|
stickerCreatorWindow.show();
|
|
|
|
|
|
|
|
if (config.get('openDevTools')) {
|
|
|
|
// Open the DevTools.
|
|
|
|
stickerCreatorWindow.webContents.openDevTools();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-07-03 22:33:50 +00:00
|
|
|
let debugLogWindow;
|
2018-07-13 15:57:30 +00:00
|
|
|
async function showDebugLogWindow() {
|
2018-07-03 22:33:50 +00:00
|
|
|
if (debugLogWindow) {
|
|
|
|
debugLogWindow.show();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-07-13 15:57:30 +00:00
|
|
|
const theme = await pify(getDataFromMainWindow)('theme-setting');
|
2018-07-03 22:33:50 +00:00
|
|
|
const size = mainWindow.getSize();
|
|
|
|
const options = {
|
|
|
|
width: Math.max(size[0] - 100, MIN_WIDTH),
|
|
|
|
height: Math.max(size[1] - 100, MIN_HEIGHT),
|
|
|
|
resizable: false,
|
2019-10-04 18:06:17 +00:00
|
|
|
title: locale.messages.debugLog.message,
|
2018-07-03 22:33:50 +00:00
|
|
|
autoHideMenuBar: true,
|
2020-03-05 21:24:51 +00:00
|
|
|
backgroundColor: '#3a76f0',
|
2018-07-03 22:33:50 +00:00
|
|
|
show: false,
|
|
|
|
modal: true,
|
|
|
|
webPreferences: {
|
|
|
|
nodeIntegration: false,
|
|
|
|
nodeIntegrationInWorker: false,
|
2019-02-21 22:41:17 +00:00
|
|
|
contextIsolation: false,
|
2018-07-03 22:33:50 +00:00
|
|
|
preload: path.join(__dirname, 'debug_log_preload.js'),
|
|
|
|
nativeWindowOpen: true,
|
|
|
|
},
|
|
|
|
parent: mainWindow,
|
|
|
|
};
|
|
|
|
|
|
|
|
debugLogWindow = new BrowserWindow(options);
|
|
|
|
|
2020-01-21 21:48:05 +00:00
|
|
|
handleCommonWindowEvents(debugLogWindow);
|
2018-07-03 22:33:50 +00:00
|
|
|
|
2018-07-13 15:57:30 +00:00
|
|
|
debugLogWindow.loadURL(prepareURL([__dirname, 'debug_log.html'], { theme }));
|
2018-07-03 22:33:50 +00:00
|
|
|
|
|
|
|
debugLogWindow.on('closed', () => {
|
|
|
|
removeDarkOverlay();
|
|
|
|
debugLogWindow = null;
|
|
|
|
});
|
|
|
|
|
|
|
|
debugLogWindow.once('ready-to-show', () => {
|
|
|
|
addDarkOverlay();
|
|
|
|
debugLogWindow.show();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
let permissionsPopupWindow;
|
2018-07-13 15:57:30 +00:00
|
|
|
async function showPermissionsPopupWindow() {
|
2018-07-03 22:33:50 +00:00
|
|
|
if (permissionsPopupWindow) {
|
|
|
|
permissionsPopupWindow.show();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!mainWindow) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-07-13 15:57:30 +00:00
|
|
|
const theme = await pify(getDataFromMainWindow)('theme-setting');
|
2018-07-03 22:33:50 +00:00
|
|
|
const size = mainWindow.getSize();
|
|
|
|
const options = {
|
|
|
|
width: Math.min(400, size[0]),
|
|
|
|
height: Math.min(150, size[1]),
|
|
|
|
resizable: false,
|
2019-10-04 18:06:17 +00:00
|
|
|
title: locale.messages.allowAccess.message,
|
2018-07-03 22:33:50 +00:00
|
|
|
autoHideMenuBar: true,
|
2020-03-05 21:24:51 +00:00
|
|
|
backgroundColor: '#3a76f0',
|
2018-07-03 22:33:50 +00:00
|
|
|
show: false,
|
|
|
|
modal: true,
|
|
|
|
webPreferences: {
|
|
|
|
nodeIntegration: false,
|
|
|
|
nodeIntegrationInWorker: false,
|
2019-02-21 22:41:17 +00:00
|
|
|
contextIsolation: false,
|
2018-07-03 22:33:50 +00:00
|
|
|
preload: path.join(__dirname, 'permissions_popup_preload.js'),
|
|
|
|
nativeWindowOpen: true,
|
|
|
|
},
|
|
|
|
parent: mainWindow,
|
|
|
|
};
|
|
|
|
|
|
|
|
permissionsPopupWindow = new BrowserWindow(options);
|
|
|
|
|
2020-01-21 21:48:05 +00:00
|
|
|
handleCommonWindowEvents(permissionsPopupWindow);
|
2018-07-03 22:33:50 +00:00
|
|
|
|
|
|
|
permissionsPopupWindow.loadURL(
|
2018-07-13 15:57:30 +00:00
|
|
|
prepareURL([__dirname, 'permissions_popup.html'], { theme })
|
2018-07-03 22:33:50 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
permissionsPopupWindow.on('closed', () => {
|
|
|
|
removeDarkOverlay();
|
|
|
|
permissionsPopupWindow = null;
|
|
|
|
});
|
|
|
|
|
|
|
|
permissionsPopupWindow.once('ready-to-show', () => {
|
|
|
|
addDarkOverlay();
|
|
|
|
permissionsPopupWindow.show();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-03-02 22:04:38 +00:00
|
|
|
// 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.
|
2017-11-02 15:13:41 +00:00
|
|
|
let ready = false;
|
2018-06-14 20:39:44 +00:00
|
|
|
app.on('ready', async () => {
|
|
|
|
const userDataPath = await getRealPath(app.getPath('userData'));
|
|
|
|
const installPath = await getRealPath(app.getAppPath());
|
2018-05-23 23:26:40 +00:00
|
|
|
|
|
|
|
if (process.env.NODE_ENV !== 'test' && process.env.NODE_ENV !== 'test-lib') {
|
|
|
|
installFileHandler({
|
|
|
|
protocol: electronProtocol,
|
|
|
|
userDataPath,
|
|
|
|
installPath,
|
2018-05-25 21:11:26 +00:00
|
|
|
isWindows: process.platform === 'win32',
|
2018-05-23 23:26:40 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
installWebHandler({
|
2019-12-17 20:25:57 +00:00
|
|
|
enableHttp: config.enableHttp,
|
2018-05-23 23:26:40 +00:00
|
|
|
protocol: electronProtocol,
|
|
|
|
});
|
|
|
|
|
2018-07-03 22:33:50 +00:00
|
|
|
installPermissionsHandler({ session, userConfig });
|
2018-05-24 19:13:16 +00:00
|
|
|
|
2019-02-21 19:40:05 +00:00
|
|
|
await logging.initialize();
|
2019-01-22 17:47:19 +00:00
|
|
|
logger = logging.getLogger();
|
|
|
|
logger.info('app ready');
|
2019-03-28 17:09:26 +00:00
|
|
|
logger.info(`starting version ${packageJson.version}`);
|
2019-01-22 17:47:19 +00:00
|
|
|
|
2018-07-27 01:13:56 +00:00
|
|
|
if (!locale) {
|
|
|
|
const appLocale = process.env.NODE_ENV === 'test' ? 'en' : app.getLocale();
|
|
|
|
locale = loadLocale({ appLocale, logger });
|
|
|
|
}
|
2017-03-30 18:43:58 +00:00
|
|
|
|
2019-02-20 01:32:44 +00:00
|
|
|
GlobalErrors.updateLocale(locale.messages);
|
|
|
|
|
2018-08-28 21:53:05 +00:00
|
|
|
let key = userConfig.get('key');
|
|
|
|
if (!key) {
|
|
|
|
console.log(
|
|
|
|
'key/initialize: Generating new encryption key, since we did not find it on disk'
|
|
|
|
);
|
|
|
|
// https://www.zetetic.net/sqlcipher/sqlcipher-api/#key
|
|
|
|
key = crypto.randomBytes(32).toString('hex');
|
|
|
|
userConfig.set('key', key);
|
|
|
|
}
|
2020-03-25 23:45:37 +00:00
|
|
|
const sqlInitPromise = sql.initialize({
|
2019-02-20 01:32:44 +00:00
|
|
|
configDir: userDataPath,
|
|
|
|
key,
|
|
|
|
messages: locale.messages,
|
|
|
|
});
|
2020-03-25 23:45:37 +00:00
|
|
|
|
|
|
|
// If the sql initialization takes more than three seconds to complete, we
|
|
|
|
// want to notify the user that things are happening
|
|
|
|
const timeout = new Promise(resolve => setTimeout(resolve, 3000, 'timeout'));
|
|
|
|
// eslint-disable-next-line more/no-then
|
|
|
|
Promise.race([sqlInitPromise, timeout]).then(maybeTimeout => {
|
|
|
|
if (maybeTimeout !== 'timeout') {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
console.log(
|
|
|
|
'sql.initialize is taking more than three seconds; showing loading dialog'
|
|
|
|
);
|
|
|
|
|
|
|
|
loadingWindow = new BrowserWindow({
|
|
|
|
show: false,
|
|
|
|
width: 300,
|
|
|
|
height: 265,
|
|
|
|
resizable: false,
|
|
|
|
frame: false,
|
|
|
|
backgroundColor: '#3a76f0',
|
|
|
|
webPreferences: {
|
|
|
|
nodeIntegration: false,
|
|
|
|
preload: path.join(__dirname, 'loading_preload.js'),
|
|
|
|
},
|
|
|
|
icon: path.join(__dirname, 'images', 'icon_256.png'),
|
|
|
|
});
|
|
|
|
|
|
|
|
loadingWindow.once('ready-to-show', async () => {
|
|
|
|
loadingWindow.show();
|
|
|
|
// Wait for sql initialization to complete
|
|
|
|
await sqlInitPromise;
|
|
|
|
loadingWindow.destroy();
|
|
|
|
loadingWindow = null;
|
|
|
|
});
|
|
|
|
|
|
|
|
loadingWindow.loadURL(prepareURL([__dirname, 'loading.html']));
|
|
|
|
});
|
|
|
|
|
|
|
|
const success = await sqlInitPromise;
|
|
|
|
|
2019-02-20 01:32:44 +00:00
|
|
|
if (!success) {
|
|
|
|
console.log('sql.initialize was unsuccessful; returning early');
|
|
|
|
return;
|
|
|
|
}
|
2020-03-20 21:00:11 +00:00
|
|
|
// eslint-disable-next-line more/no-then
|
|
|
|
appStartInitialSpellcheckSetting = await getSpellCheckSetting();
|
2018-08-16 17:07:38 +00:00
|
|
|
await sqlChannels.initialize();
|
2017-06-22 01:04:19 +00:00
|
|
|
|
2018-11-12 22:13:16 +00:00
|
|
|
try {
|
|
|
|
const IDB_KEY = 'indexeddb-delete-needed';
|
|
|
|
const item = await sql.getItemById(IDB_KEY);
|
|
|
|
if (item && item.value) {
|
|
|
|
await sql.removeIndexedDBFiles();
|
|
|
|
await sql.removeItemById(IDB_KEY);
|
|
|
|
}
|
|
|
|
} catch (error) {
|
|
|
|
console.log(
|
|
|
|
'(ready event handler) error deleting IndexedDB:',
|
|
|
|
error && error.stack ? error.stack : error
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2018-08-08 17:00:33 +00:00
|
|
|
async function cleanupOrphanedAttachments() {
|
|
|
|
const allAttachments = await attachments.getAllAttachments(userDataPath);
|
|
|
|
const orphanedAttachments = await sql.removeKnownAttachments(
|
|
|
|
allAttachments
|
|
|
|
);
|
|
|
|
await attachments.deleteAll({
|
|
|
|
userDataPath,
|
|
|
|
attachments: orphanedAttachments,
|
|
|
|
});
|
2019-05-16 22:32:11 +00:00
|
|
|
|
|
|
|
const allStickers = await attachments.getAllStickers(userDataPath);
|
|
|
|
const orphanedStickers = await sql.removeKnownStickers(allStickers);
|
|
|
|
await attachments.deleteAllStickers({
|
|
|
|
userDataPath,
|
|
|
|
stickers: orphanedStickers,
|
|
|
|
});
|
2019-08-07 00:40:25 +00:00
|
|
|
|
|
|
|
const allDraftAttachments = await attachments.getAllDraftAttachments(
|
|
|
|
userDataPath
|
|
|
|
);
|
|
|
|
const orphanedDraftAttachments = await sql.removeKnownDraftAttachments(
|
|
|
|
allDraftAttachments
|
|
|
|
);
|
|
|
|
await attachments.deleteAllDraftAttachments({
|
|
|
|
userDataPath,
|
|
|
|
stickers: orphanedDraftAttachments,
|
|
|
|
});
|
2018-08-08 17:00:33 +00:00
|
|
|
}
|
|
|
|
|
2019-05-24 01:27:42 +00:00
|
|
|
try {
|
|
|
|
await attachments.clearTempPath(userDataPath);
|
|
|
|
} catch (error) {
|
|
|
|
logger.error(
|
|
|
|
'main/ready: Error deleting temp dir:',
|
|
|
|
error && error.stack ? error.stack : error
|
|
|
|
);
|
|
|
|
}
|
2018-08-08 17:00:33 +00:00
|
|
|
await attachmentChannel.initialize({
|
|
|
|
configDir: userDataPath,
|
|
|
|
cleanupOrphanedAttachments,
|
|
|
|
});
|
2018-08-06 23:18:58 +00:00
|
|
|
|
2018-07-27 01:13:56 +00:00
|
|
|
ready = true;
|
|
|
|
|
2020-03-26 19:24:40 +00:00
|
|
|
await createWindow();
|
2018-07-27 01:13:56 +00:00
|
|
|
if (usingTrayIcon) {
|
|
|
|
tray = createTrayIcon(getMainWindow, locale.messages);
|
|
|
|
}
|
|
|
|
|
|
|
|
setupMenu();
|
2020-02-21 23:40:04 +00:00
|
|
|
|
|
|
|
ensureFilePermissions(['config.json', 'sql/db.sqlite']);
|
2018-01-08 21:19:25 +00:00
|
|
|
});
|
|
|
|
|
New design for import/install, 'light' import (#2053)
- A new design for the import flow. It features:
- Icons at the top of every screen
- Gray background, blue buttons, thinner text
- Simpler copy
- A new design for the install flow. It features:
- Immediate entry into the QR code screen
- Animated dots to show that we're loading the QR code from the server
- Fewer screens: 1) QR 2) device name 3) sync-in-progress
- When not set up, the app opens directly into the install screen, which has been streamlined. The `--import` command-line argument will cause the app to open directly into the import flow.
- Support for two different flavors of builds - the normal build will open into the standard registration flow, and the import flavor will be exactly the same except during setup it will open directly into the import flow.
- A new design for the (dev-only) standalone registration view
- When these install sequences are active, the OS File menu has entries to allow you to switch the method of setup you'd like to use. These go away as soon as the first step is taken in any of these flows.
- The device name (chosen on initial setup) is now shown in the settings panel
- At the end of a light import, we hand off to the normal device link screen, starting at the QR code. On a full import, we remove the sensitive encryption information in the export to prevent conflicts on multiple imports.
- `Whisper.Backup.exportToDirectory()` takes an options object so you can tell it to do a light export.
- `Whisper.Backup.importFromDirectory()` takes an options object so you can force it to load only the light components found on disk. It also returns an object so you can tell whether a given import was a full import or light import.
- On start of import, we build a list of all the ids present in the messages, conversations, and groups stores in IndexedDB. This can take some time if a lot of data is in the database already, but it makes the subsequent deduplicated import very fast.
- Disappearing messages are now excluded when exporting
- Remove some TODOs in the tests
2018-02-22 18:40:32 +00:00
|
|
|
function setupMenu(options) {
|
2018-03-02 20:59:39 +00:00
|
|
|
const { platform } = process;
|
2019-12-17 20:25:57 +00:00
|
|
|
const menuOptions = {
|
|
|
|
...options,
|
New design for import/install, 'light' import (#2053)
- A new design for the import flow. It features:
- Icons at the top of every screen
- Gray background, blue buttons, thinner text
- Simpler copy
- A new design for the install flow. It features:
- Immediate entry into the QR code screen
- Animated dots to show that we're loading the QR code from the server
- Fewer screens: 1) QR 2) device name 3) sync-in-progress
- When not set up, the app opens directly into the install screen, which has been streamlined. The `--import` command-line argument will cause the app to open directly into the import flow.
- Support for two different flavors of builds - the normal build will open into the standard registration flow, and the import flavor will be exactly the same except during setup it will open directly into the import flow.
- A new design for the (dev-only) standalone registration view
- When these install sequences are active, the OS File menu has entries to allow you to switch the method of setup you'd like to use. These go away as soon as the first step is taken in any of these flows.
- The device name (chosen on initial setup) is now shown in the settings panel
- At the end of a light import, we hand off to the normal device link screen, starting at the QR code. On a full import, we remove the sensitive encryption information in the export to prevent conflicts on multiple imports.
- `Whisper.Backup.exportToDirectory()` takes an options object so you can tell it to do a light export.
- `Whisper.Backup.importFromDirectory()` takes an options object so you can force it to load only the light components found on disk. It also returns an object so you can tell whether a given import was a full import or light import.
- On start of import, we build a list of all the ids present in the messages, conversations, and groups stores in IndexedDB. This can take some time if a lot of data is in the database already, but it makes the subsequent deduplicated import very fast.
- Disappearing messages are now excluded when exporting
- Remove some TODOs in the tests
2018-02-22 18:40:32 +00:00
|
|
|
development,
|
2018-07-03 22:33:50 +00:00
|
|
|
showDebugLog: showDebugLogWindow,
|
2019-11-07 21:36:16 +00:00
|
|
|
showKeyboardShortcuts,
|
New design for import/install, 'light' import (#2053)
- A new design for the import flow. It features:
- Icons at the top of every screen
- Gray background, blue buttons, thinner text
- Simpler copy
- A new design for the install flow. It features:
- Immediate entry into the QR code screen
- Animated dots to show that we're loading the QR code from the server
- Fewer screens: 1) QR 2) device name 3) sync-in-progress
- When not set up, the app opens directly into the install screen, which has been streamlined. The `--import` command-line argument will cause the app to open directly into the import flow.
- Support for two different flavors of builds - the normal build will open into the standard registration flow, and the import flavor will be exactly the same except during setup it will open directly into the import flow.
- A new design for the (dev-only) standalone registration view
- When these install sequences are active, the OS File menu has entries to allow you to switch the method of setup you'd like to use. These go away as soon as the first step is taken in any of these flows.
- The device name (chosen on initial setup) is now shown in the settings panel
- At the end of a light import, we hand off to the normal device link screen, starting at the QR code. On a full import, we remove the sensitive encryption information in the export to prevent conflicts on multiple imports.
- `Whisper.Backup.exportToDirectory()` takes an options object so you can tell it to do a light export.
- `Whisper.Backup.importFromDirectory()` takes an options object so you can force it to load only the light components found on disk. It also returns an object so you can tell whether a given import was a full import or light import.
- On start of import, we build a list of all the ids present in the messages, conversations, and groups stores in IndexedDB. This can take some time if a lot of data is in the database already, but it makes the subsequent deduplicated import very fast.
- Disappearing messages are now excluded when exporting
- Remove some TODOs in the tests
2018-02-22 18:40:32 +00:00
|
|
|
showWindow,
|
|
|
|
showAbout,
|
2018-07-03 22:33:50 +00:00
|
|
|
showSettings: showSettingsWindow,
|
2019-12-17 20:25:57 +00:00
|
|
|
showStickerCreator,
|
New design for import/install, 'light' import (#2053)
- A new design for the import flow. It features:
- Icons at the top of every screen
- Gray background, blue buttons, thinner text
- Simpler copy
- A new design for the install flow. It features:
- Immediate entry into the QR code screen
- Animated dots to show that we're loading the QR code from the server
- Fewer screens: 1) QR 2) device name 3) sync-in-progress
- When not set up, the app opens directly into the install screen, which has been streamlined. The `--import` command-line argument will cause the app to open directly into the import flow.
- Support for two different flavors of builds - the normal build will open into the standard registration flow, and the import flavor will be exactly the same except during setup it will open directly into the import flow.
- A new design for the (dev-only) standalone registration view
- When these install sequences are active, the OS File menu has entries to allow you to switch the method of setup you'd like to use. These go away as soon as the first step is taken in any of these flows.
- The device name (chosen on initial setup) is now shown in the settings panel
- At the end of a light import, we hand off to the normal device link screen, starting at the QR code. On a full import, we remove the sensitive encryption information in the export to prevent conflicts on multiple imports.
- `Whisper.Backup.exportToDirectory()` takes an options object so you can tell it to do a light export.
- `Whisper.Backup.importFromDirectory()` takes an options object so you can force it to load only the light components found on disk. It also returns an object so you can tell whether a given import was a full import or light import.
- On start of import, we build a list of all the ids present in the messages, conversations, and groups stores in IndexedDB. This can take some time if a lot of data is in the database already, but it makes the subsequent deduplicated import very fast.
- Disappearing messages are now excluded when exporting
- Remove some TODOs in the tests
2018-02-22 18:40:32 +00:00
|
|
|
openReleaseNotes,
|
|
|
|
openNewBugForm,
|
|
|
|
openSupportPage,
|
|
|
|
openForums,
|
2018-03-02 20:59:39 +00:00
|
|
|
platform,
|
New design for import/install, 'light' import (#2053)
- A new design for the import flow. It features:
- Icons at the top of every screen
- Gray background, blue buttons, thinner text
- Simpler copy
- A new design for the install flow. It features:
- Immediate entry into the QR code screen
- Animated dots to show that we're loading the QR code from the server
- Fewer screens: 1) QR 2) device name 3) sync-in-progress
- When not set up, the app opens directly into the install screen, which has been streamlined. The `--import` command-line argument will cause the app to open directly into the import flow.
- Support for two different flavors of builds - the normal build will open into the standard registration flow, and the import flavor will be exactly the same except during setup it will open directly into the import flow.
- A new design for the (dev-only) standalone registration view
- When these install sequences are active, the OS File menu has entries to allow you to switch the method of setup you'd like to use. These go away as soon as the first step is taken in any of these flows.
- The device name (chosen on initial setup) is now shown in the settings panel
- At the end of a light import, we hand off to the normal device link screen, starting at the QR code. On a full import, we remove the sensitive encryption information in the export to prevent conflicts on multiple imports.
- `Whisper.Backup.exportToDirectory()` takes an options object so you can tell it to do a light export.
- `Whisper.Backup.importFromDirectory()` takes an options object so you can force it to load only the light components found on disk. It also returns an object so you can tell whether a given import was a full import or light import.
- On start of import, we build a list of all the ids present in the messages, conversations, and groups stores in IndexedDB. This can take some time if a lot of data is in the database already, but it makes the subsequent deduplicated import very fast.
- Disappearing messages are now excluded when exporting
- Remove some TODOs in the tests
2018-02-22 18:40:32 +00:00
|
|
|
setupAsNewDevice,
|
|
|
|
setupAsStandalone,
|
2019-12-17 20:25:57 +00:00
|
|
|
};
|
New design for import/install, 'light' import (#2053)
- A new design for the import flow. It features:
- Icons at the top of every screen
- Gray background, blue buttons, thinner text
- Simpler copy
- A new design for the install flow. It features:
- Immediate entry into the QR code screen
- Animated dots to show that we're loading the QR code from the server
- Fewer screens: 1) QR 2) device name 3) sync-in-progress
- When not set up, the app opens directly into the install screen, which has been streamlined. The `--import` command-line argument will cause the app to open directly into the import flow.
- Support for two different flavors of builds - the normal build will open into the standard registration flow, and the import flavor will be exactly the same except during setup it will open directly into the import flow.
- A new design for the (dev-only) standalone registration view
- When these install sequences are active, the OS File menu has entries to allow you to switch the method of setup you'd like to use. These go away as soon as the first step is taken in any of these flows.
- The device name (chosen on initial setup) is now shown in the settings panel
- At the end of a light import, we hand off to the normal device link screen, starting at the QR code. On a full import, we remove the sensitive encryption information in the export to prevent conflicts on multiple imports.
- `Whisper.Backup.exportToDirectory()` takes an options object so you can tell it to do a light export.
- `Whisper.Backup.importFromDirectory()` takes an options object so you can force it to load only the light components found on disk. It also returns an object so you can tell whether a given import was a full import or light import.
- On start of import, we build a list of all the ids present in the messages, conversations, and groups stores in IndexedDB. This can take some time if a lot of data is in the database already, but it makes the subsequent deduplicated import very fast.
- Disappearing messages are now excluded when exporting
- Remove some TODOs in the tests
2018-02-22 18:40:32 +00:00
|
|
|
const template = createTemplate(menuOptions, locale.messages);
|
|
|
|
const menu = Menu.buildFromTemplate(template);
|
|
|
|
Menu.setApplicationMenu(menu);
|
|
|
|
}
|
|
|
|
|
2018-11-05 19:06:12 +00:00
|
|
|
async function requestShutdown() {
|
|
|
|
if (!mainWindow || !mainWindow.webContents) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
console.log('requestShutdown: Requesting close of mainWindow...');
|
|
|
|
const request = new Promise((resolve, reject) => {
|
|
|
|
ipc.once('now-ready-for-shutdown', (_event, error) => {
|
|
|
|
console.log('requestShutdown: Response received');
|
|
|
|
|
|
|
|
if (error) {
|
|
|
|
return reject(error);
|
|
|
|
}
|
|
|
|
|
|
|
|
return resolve();
|
|
|
|
});
|
|
|
|
mainWindow.webContents.send('get-ready-for-shutdown');
|
|
|
|
|
|
|
|
// We'll wait two minutes, then force the app to go down. This can happen if someone
|
|
|
|
// exits the app before we've set everything up in preload() (so the browser isn't
|
|
|
|
// yet listening for these events), or if there are a whole lot of stacked-up tasks.
|
|
|
|
// Note: two minutes is also our timeout for SQL tasks in data.js in the browser.
|
|
|
|
setTimeout(() => {
|
|
|
|
console.log(
|
|
|
|
'requestShutdown: Response never received; forcing shutdown.'
|
|
|
|
);
|
|
|
|
resolve();
|
|
|
|
}, 2 * 60 * 1000);
|
|
|
|
});
|
|
|
|
|
|
|
|
try {
|
|
|
|
await request;
|
|
|
|
} catch (error) {
|
|
|
|
console.log(
|
|
|
|
'requestShutdown error:',
|
|
|
|
error && error.stack ? error.stack : error
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-08 21:19:25 +00:00
|
|
|
app.on('before-quit', () => {
|
2018-11-05 19:06:12 +00:00
|
|
|
console.log('before-quit event', {
|
|
|
|
readyForShutdown: mainWindow ? mainWindow.readyForShutdown : null,
|
|
|
|
shouldQuit: windowState.shouldQuit(),
|
|
|
|
});
|
2019-02-20 01:32:44 +00:00
|
|
|
|
2017-06-22 00:26:05 +00:00
|
|
|
windowState.markShouldQuit();
|
2017-04-22 22:58:50 +00:00
|
|
|
});
|
2017-06-22 00:26:05 +00:00
|
|
|
|
2017-03-02 22:04:38 +00:00
|
|
|
// Quit when all windows are closed.
|
2018-01-08 21:19:25 +00:00
|
|
|
app.on('window-all-closed', () => {
|
2020-04-06 23:45:39 +00:00
|
|
|
console.log('main process handling window-all-closed');
|
2017-03-02 22:04:38 +00:00
|
|
|
// On OS X it is common for applications and their menu bar
|
|
|
|
// to stay active until the user quits explicitly with Cmd + Q
|
2020-04-06 23:45:39 +00:00
|
|
|
const shouldAutoClose =
|
2018-04-27 21:25:04 +00:00
|
|
|
process.platform !== 'darwin' ||
|
|
|
|
config.environment === 'test' ||
|
2020-04-06 23:45:39 +00:00
|
|
|
config.environment === 'test-lib';
|
|
|
|
|
|
|
|
// Only automatically quit if the main window has been created
|
|
|
|
// This is necessary because `window-all-closed` can be triggered by the
|
|
|
|
// "optimizing application" window closing
|
|
|
|
if (shouldAutoClose && mainWindowCreated) {
|
2018-01-08 21:19:25 +00:00
|
|
|
app.quit();
|
2017-03-02 22:04:38 +00:00
|
|
|
}
|
2018-01-08 21:19:25 +00:00
|
|
|
});
|
2017-03-02 22:04:38 +00:00
|
|
|
|
2018-01-08 21:19:25 +00:00
|
|
|
app.on('activate', () => {
|
2017-11-02 15:13:41 +00:00
|
|
|
if (!ready) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-03-02 22:04:38 +00:00
|
|
|
// On OS X it's common to re-create a window in the app when the
|
|
|
|
// dock icon is clicked and there are no other windows open.
|
2017-09-07 01:21:38 +00:00
|
|
|
if (mainWindow) {
|
2017-04-22 22:58:50 +00:00
|
|
|
mainWindow.show();
|
2017-09-07 01:21:38 +00:00
|
|
|
} else {
|
|
|
|
createWindow();
|
2017-03-02 22:04:38 +00:00
|
|
|
}
|
2018-01-08 21:19:25 +00:00
|
|
|
});
|
2017-04-25 00:00:17 +00:00
|
|
|
|
2018-05-23 19:29:32 +00:00
|
|
|
// Defense in depth. We never intend to open webviews or windows. Prevent it completely.
|
|
|
|
app.on('web-contents-created', (createEvent, contents) => {
|
|
|
|
contents.on('will-attach-webview', attachEvent => {
|
2018-03-14 21:23:24 +00:00
|
|
|
attachEvent.preventDefault();
|
|
|
|
});
|
2018-05-23 19:29:32 +00:00
|
|
|
contents.on('new-window', newEvent => {
|
|
|
|
newEvent.preventDefault();
|
|
|
|
});
|
2018-03-14 21:23:24 +00:00
|
|
|
});
|
|
|
|
|
2019-05-16 22:32:11 +00:00
|
|
|
app.setAsDefaultProtocolClient('sgnl');
|
2019-12-18 19:21:35 +00:00
|
|
|
app.on('will-finish-launching', () => {
|
|
|
|
// open-url must be set from within will-finish-launching for macOS
|
|
|
|
// https://stackoverflow.com/a/43949291
|
|
|
|
app.on('open-url', (event, incomingUrl) => {
|
|
|
|
event.preventDefault();
|
|
|
|
handleSgnlLink(incomingUrl);
|
|
|
|
});
|
2019-05-16 22:32:11 +00:00
|
|
|
});
|
|
|
|
|
2018-01-08 21:19:25 +00:00
|
|
|
ipc.on('set-badge-count', (event, count) => {
|
2020-03-19 17:57:50 +00:00
|
|
|
app.badgeCount = count;
|
2017-04-25 00:00:17 +00:00
|
|
|
});
|
2017-06-22 01:04:19 +00:00
|
|
|
|
New design for import/install, 'light' import (#2053)
- A new design for the import flow. It features:
- Icons at the top of every screen
- Gray background, blue buttons, thinner text
- Simpler copy
- A new design for the install flow. It features:
- Immediate entry into the QR code screen
- Animated dots to show that we're loading the QR code from the server
- Fewer screens: 1) QR 2) device name 3) sync-in-progress
- When not set up, the app opens directly into the install screen, which has been streamlined. The `--import` command-line argument will cause the app to open directly into the import flow.
- Support for two different flavors of builds - the normal build will open into the standard registration flow, and the import flavor will be exactly the same except during setup it will open directly into the import flow.
- A new design for the (dev-only) standalone registration view
- When these install sequences are active, the OS File menu has entries to allow you to switch the method of setup you'd like to use. These go away as soon as the first step is taken in any of these flows.
- The device name (chosen on initial setup) is now shown in the settings panel
- At the end of a light import, we hand off to the normal device link screen, starting at the QR code. On a full import, we remove the sensitive encryption information in the export to prevent conflicts on multiple imports.
- `Whisper.Backup.exportToDirectory()` takes an options object so you can tell it to do a light export.
- `Whisper.Backup.importFromDirectory()` takes an options object so you can force it to load only the light components found on disk. It also returns an object so you can tell whether a given import was a full import or light import.
- On start of import, we build a list of all the ids present in the messages, conversations, and groups stores in IndexedDB. This can take some time if a lot of data is in the database already, but it makes the subsequent deduplicated import very fast.
- Disappearing messages are now excluded when exporting
- Remove some TODOs in the tests
2018-02-22 18:40:32 +00:00
|
|
|
ipc.on('remove-setup-menu-items', () => {
|
|
|
|
setupMenu();
|
|
|
|
});
|
|
|
|
|
|
|
|
ipc.on('add-setup-menu-items', () => {
|
|
|
|
setupMenu({
|
|
|
|
includeSetup: true,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-09-06 20:04:31 +00:00
|
|
|
ipc.on('draw-attention', () => {
|
2019-10-10 18:51:16 +00:00
|
|
|
if (!mainWindow) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (disableFlashFrame) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (process.platform === 'win32' || process.platform === 'linux') {
|
2019-09-06 20:04:31 +00:00
|
|
|
mainWindow.flashFrame(true);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-01-08 21:19:25 +00:00
|
|
|
ipc.on('restart', () => {
|
2017-05-07 21:39:43 +00:00
|
|
|
app.relaunch();
|
|
|
|
app.quit();
|
|
|
|
});
|
2017-10-13 18:39:18 +00:00
|
|
|
|
2018-01-08 21:19:25 +00:00
|
|
|
ipc.on('set-auto-hide-menu-bar', (event, autoHide) => {
|
2017-11-30 19:58:00 +00:00
|
|
|
if (mainWindow) {
|
2020-03-19 17:57:50 +00:00
|
|
|
mainWindow.autoHideMenuBar = autoHide;
|
2017-11-30 19:58:00 +00:00
|
|
|
}
|
2017-10-13 18:39:18 +00:00
|
|
|
});
|
|
|
|
|
2018-01-08 21:19:25 +00:00
|
|
|
ipc.on('set-menu-bar-visibility', (event, visibility) => {
|
2017-11-30 19:58:00 +00:00
|
|
|
if (mainWindow) {
|
|
|
|
mainWindow.setMenuBarVisibility(visibility);
|
|
|
|
}
|
2017-10-13 18:39:18 +00:00
|
|
|
});
|
2017-11-21 23:23:18 +00:00
|
|
|
|
2018-01-08 21:19:25 +00:00
|
|
|
ipc.on('close-about', () => {
|
2017-11-21 23:23:18 +00:00
|
|
|
if (aboutWindow) {
|
|
|
|
aboutWindow.close();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-01-17 23:27:58 +00:00
|
|
|
ipc.on('update-tray-icon', (event, unreadCount) => {
|
|
|
|
if (tray) {
|
|
|
|
tray.updateIcon(unreadCount);
|
|
|
|
}
|
|
|
|
});
|
2018-07-03 22:33:50 +00:00
|
|
|
|
|
|
|
// Debug Log-related IPC calls
|
|
|
|
|
|
|
|
ipc.on('show-debug-log', showDebugLogWindow);
|
|
|
|
ipc.on('close-debug-log', () => {
|
|
|
|
if (debugLogWindow) {
|
|
|
|
debugLogWindow.close();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// Permissions Popup-related IPC calls
|
|
|
|
|
|
|
|
ipc.on('show-permissions-popup', showPermissionsPopupWindow);
|
|
|
|
ipc.on('close-permissions-popup', () => {
|
|
|
|
if (permissionsPopupWindow) {
|
|
|
|
permissionsPopupWindow.close();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// Settings-related IPC calls
|
|
|
|
|
|
|
|
function addDarkOverlay() {
|
|
|
|
if (mainWindow && mainWindow.webContents) {
|
|
|
|
mainWindow.webContents.send('add-dark-overlay');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function removeDarkOverlay() {
|
|
|
|
if (mainWindow && mainWindow.webContents) {
|
|
|
|
mainWindow.webContents.send('remove-dark-overlay');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ipc.on('show-settings', showSettingsWindow);
|
|
|
|
ipc.on('close-settings', () => {
|
|
|
|
if (settingsWindow) {
|
|
|
|
settingsWindow.close();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
installSettingsGetter('device-name');
|
|
|
|
|
|
|
|
installSettingsGetter('theme-setting');
|
|
|
|
installSettingsSetter('theme-setting');
|
|
|
|
installSettingsGetter('hide-menu-bar');
|
|
|
|
installSettingsSetter('hide-menu-bar');
|
|
|
|
|
|
|
|
installSettingsGetter('notification-setting');
|
|
|
|
installSettingsSetter('notification-setting');
|
|
|
|
installSettingsGetter('audio-notification');
|
|
|
|
installSettingsSetter('audio-notification');
|
|
|
|
|
2018-07-19 01:46:12 +00:00
|
|
|
installSettingsGetter('spell-check');
|
|
|
|
installSettingsSetter('spell-check');
|
|
|
|
|
2018-07-03 22:33:50 +00:00
|
|
|
// This one is different because its single source of truth is userConfig, not IndexedDB
|
|
|
|
ipc.on('get-media-permissions', event => {
|
|
|
|
event.sender.send(
|
|
|
|
'get-success-media-permissions',
|
|
|
|
null,
|
|
|
|
userConfig.get('mediaPermissions') || false
|
|
|
|
);
|
|
|
|
});
|
|
|
|
ipc.on('set-media-permissions', (event, value) => {
|
|
|
|
userConfig.set('mediaPermissions', value);
|
|
|
|
|
|
|
|
// We reinstall permissions handler to ensure that a revoked permission takes effect
|
|
|
|
installPermissionsHandler({ session, userConfig });
|
|
|
|
|
|
|
|
event.sender.send('set-success-media-permissions', null);
|
|
|
|
});
|
|
|
|
|
|
|
|
installSettingsGetter('is-primary');
|
|
|
|
installSettingsGetter('sync-request');
|
|
|
|
installSettingsGetter('sync-time');
|
|
|
|
installSettingsSetter('sync-time');
|
|
|
|
|
|
|
|
ipc.on('delete-all-data', () => {
|
|
|
|
if (mainWindow && mainWindow.webContents) {
|
|
|
|
mainWindow.webContents.send('delete-all-data');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-10-04 18:06:17 +00:00
|
|
|
ipc.on('get-built-in-images', async () => {
|
|
|
|
try {
|
|
|
|
const images = await attachments.getBuiltInImages();
|
|
|
|
mainWindow.webContents.send('get-success-built-in-images', null, images);
|
|
|
|
} catch (error) {
|
|
|
|
if (mainWindow && mainWindow.webContents) {
|
|
|
|
mainWindow.webContents.send('get-success-built-in-images', error.message);
|
|
|
|
} else {
|
|
|
|
console.error('Error handling get-built-in-images:', error.stack);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2020-03-25 23:45:37 +00:00
|
|
|
// Ingested in preload.js via a sendSync call
|
|
|
|
ipc.on('locale-data', event => {
|
|
|
|
// eslint-disable-next-line no-param-reassign
|
|
|
|
event.returnValue = locale.messages;
|
|
|
|
});
|
|
|
|
|
2018-07-13 15:57:30 +00:00
|
|
|
function getDataFromMainWindow(name, callback) {
|
|
|
|
ipc.once(`get-success-${name}`, (_event, error, value) =>
|
|
|
|
callback(error, value)
|
|
|
|
);
|
|
|
|
mainWindow.webContents.send(`get-${name}`);
|
|
|
|
}
|
|
|
|
|
2018-07-03 22:33:50 +00:00
|
|
|
function installSettingsGetter(name) {
|
|
|
|
ipc.on(`get-${name}`, event => {
|
|
|
|
if (mainWindow && mainWindow.webContents) {
|
2018-12-10 21:48:51 +00:00
|
|
|
getDataFromMainWindow(name, (error, value) => {
|
|
|
|
const contents = event.sender;
|
|
|
|
if (contents.isDestroyed()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
contents.send(`get-success-${name}`, error, value);
|
|
|
|
});
|
2018-07-03 22:33:50 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function installSettingsSetter(name) {
|
|
|
|
ipc.on(`set-${name}`, (event, value) => {
|
|
|
|
if (mainWindow && mainWindow.webContents) {
|
2018-12-10 21:48:51 +00:00
|
|
|
ipc.once(`set-success-${name}`, (_event, error) => {
|
|
|
|
const contents = event.sender;
|
|
|
|
if (contents.isDestroyed()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
contents.send(`set-success-${name}`, error);
|
|
|
|
});
|
2018-07-03 22:33:50 +00:00
|
|
|
mainWindow.webContents.send(`set-${name}`, value);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2019-05-16 22:32:11 +00:00
|
|
|
|
2019-12-18 19:21:35 +00:00
|
|
|
function getIncomingUrl(argv) {
|
|
|
|
return argv.find(arg => arg.startsWith('sgnl://'));
|
|
|
|
}
|
|
|
|
|
2019-05-16 22:32:11 +00:00
|
|
|
function handleSgnlLink(incomingUrl) {
|
|
|
|
const { host: command, query } = url.parse(incomingUrl);
|
|
|
|
const args = qs.parse(query);
|
|
|
|
if (command === 'addstickers' && mainWindow && mainWindow.webContents) {
|
2019-12-18 19:21:35 +00:00
|
|
|
console.log('Opening sticker pack from sgnl protocol link');
|
2019-05-16 22:32:11 +00:00
|
|
|
const { pack_id: packId, pack_key: packKeyHex } = args;
|
|
|
|
const packKey = Buffer.from(packKeyHex, 'hex').toString('base64');
|
2019-05-24 01:27:42 +00:00
|
|
|
mainWindow.webContents.send('show-sticker-pack', { packId, packKey });
|
2019-05-16 22:32:11 +00:00
|
|
|
} else {
|
|
|
|
console.error('Unhandled sgnl link');
|
|
|
|
}
|
|
|
|
}
|
2019-12-17 20:25:57 +00:00
|
|
|
|
|
|
|
ipc.on('install-sticker-pack', (_event, packId, packKeyHex) => {
|
|
|
|
const packKey = Buffer.from(packKeyHex, 'hex').toString('base64');
|
|
|
|
mainWindow.webContents.send('install-sticker-pack', { packId, packKey });
|
|
|
|
});
|
2020-02-21 23:40:04 +00:00
|
|
|
|
|
|
|
ipc.on('ensure-file-permissions', async event => {
|
|
|
|
await ensureFilePermissions();
|
|
|
|
event.reply('ensure-file-permissions-done');
|
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Ensure files in the user's data directory have the proper permissions.
|
|
|
|
* Optionally takes an array of file paths to exclusively affect.
|
|
|
|
*
|
|
|
|
* @param {string[]} [onlyFiles] - Only ensure permissions on these given files
|
|
|
|
*/
|
|
|
|
async function ensureFilePermissions(onlyFiles) {
|
|
|
|
console.log('Begin ensuring permissions');
|
|
|
|
|
|
|
|
const start = Date.now();
|
|
|
|
const userDataPath = await getRealPath(app.getPath('userData'));
|
|
|
|
// fast-glob uses `/` for all platforms
|
|
|
|
const userDataGlob = normalizePath(path.join(userDataPath, '**', '*'));
|
|
|
|
|
|
|
|
// Determine files to touch
|
|
|
|
const files = onlyFiles
|
|
|
|
? onlyFiles.map(f => path.join(userDataPath, f))
|
|
|
|
: await fg(userDataGlob, {
|
|
|
|
markDirectories: true,
|
|
|
|
onlyFiles: false,
|
|
|
|
ignore: ['**/Singleton*'],
|
|
|
|
});
|
|
|
|
|
|
|
|
console.log(`Ensuring file permissions for ${files.length} files`);
|
|
|
|
|
|
|
|
// Touch each file in a queue
|
|
|
|
const q = new PQueue({ concurrency: 5 });
|
|
|
|
q.addAll(
|
|
|
|
files.map(f => async () => {
|
|
|
|
const isDir = f.endsWith('/');
|
|
|
|
try {
|
|
|
|
await fs.chmod(path.normalize(f), isDir ? 0o700 : 0o600);
|
|
|
|
} catch (error) {
|
|
|
|
console.error('ensureFilePermissions: Error from chmod', error.message);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
|
|
|
await q.onEmpty();
|
|
|
|
|
|
|
|
console.log(`Finish ensuring permissions in ${Date.now() - start}ms`);
|
|
|
|
}
|