Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge develop into experimental #8003

Merged
merged 53 commits into from Jan 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
06740e5
Translated using Weblate (Hindi)
qnixsynapse Nov 16, 2018
c15151a
Translated using Weblate (Hindi)
qnixsynapse Nov 16, 2018
d3496c0
Merge remote-tracking branch 'origin/develop' into develop
Nov 16, 2018
6804a00
Merge remote-tracking branch 'origin/develop' into develop
Nov 19, 2018
286c5e8
Merge remote-tracking branch 'origin/develop' into develop
Nov 21, 2018
819e6d9
Merge remote-tracking branch 'origin/develop' into develop
Nov 21, 2018
15b8d41
Merge remote-tracking branch 'origin/develop' into develop
Nov 21, 2018
9eaba3d
Merge remote-tracking branch 'origin/develop' into develop
Nov 22, 2018
496a5ba
Merge remote-tracking branch 'origin/develop' into develop
Nov 22, 2018
8cb8890
Merge remote-tracking branch 'origin/develop' into develop
Nov 22, 2018
dc92b12
Merge remote-tracking branch 'origin/develop' into develop
Nov 22, 2018
c3b05cb
Merge remote-tracking branch 'origin/develop' into develop
Nov 23, 2018
710e295
Add a function to send a rageshake from the console
turt2live Nov 27, 2018
ac34ca1
Appease the linter
turt2live Nov 27, 2018
373f850
Safely bind console.log and default withLogs to true
turt2live Nov 29, 2018
10671aa
Merge pull request #7755 from vector-im/travis/rageshake-console
turt2live Nov 29, 2018
844dbcf
Merge remote-tracking branch 'origin/develop' into develop
Nov 29, 2018
7247e97
Update to electron 3.0.10
dbkr Dec 5, 2018
0007e66
Merge remote-tracking branch 'origin/develop' into develop
Dec 5, 2018
69567f9
Merge pull request #7784 from RiotTranslateBot/weblate-riot-web-riot-web
dbkr Dec 5, 2018
5310b4c
js-sdk & react-sdk rc.1
dbkr Dec 6, 2018
6ba4714
v0.17.8-rc.1
dbkr Dec 6, 2018
8d9987a
Prepare changelog for v0.17.8-rc.1
dbkr Dec 6, 2018
88ff92a
v0.17.8-rc.1
dbkr Dec 6, 2018
10294ab
react-sdk rc.2
dbkr Dec 6, 2018
bf2d792
Revert electron app version bump
dbkr Dec 6, 2018
02eb8a2
Actually revert electron app version bump
dbkr Dec 6, 2018
74c81d6
v0.17.8-rc.1
dbkr Dec 6, 2018
b6493a2
v0.17.8-rc.1
dbkr Dec 6, 2018
a82f9d5
Released js-sdk & react-sdk
dbkr Dec 10, 2018
7c4f67b
v0.17.8
dbkr Dec 10, 2018
cb628d0
Prepare changelog for v0.17.8
dbkr Dec 10, 2018
c2038a5
v0.17.8
dbkr Dec 10, 2018
6ca0b3a
Update the tests to match https://github.com/matrix-org/matrix-react-…
richvdh Dec 11, 2018
df15529
Merge pull request #7834 from vector-im/rav/no_preserve_hs_url
bwindels Dec 11, 2018
17983c4
Link to CONTRIBUTING from JS SDK
jryans Dec 18, 2018
19f1489
Run the Desktop app in a sandbox
dbkr Dec 18, 2018
0c428ef
lint
dbkr Dec 18, 2018
60d3076
Update to new electron single instance API
dbkr Dec 18, 2018
0e58063
Update tests for new platform layout
dbkr Dec 18, 2018
5a54951
Merge pull request #7908 from vector-im/dbkr/electron_singleinstance_…
dbkr Dec 18, 2018
ff45dc6
Remove unused commented line
dbkr Dec 19, 2018
b35903b
Merge pull request #7907 from vector-im/dbkr/electron_sandbox
dbkr Dec 19, 2018
fc4e148
Electron: Load app from custom protocol
dbkr Dec 19, 2018
b6d70f4
Missing include
dbkr Dec 19, 2018
8cd37d2
Clarify line number instructions
jryans Dec 19, 2018
f7bdc93
Make clear that the Debian package is for desktop
remram44 Dec 19, 2018
6c6819f
Merge pull request #7919 from remram44/debian-pkg-is-electron
t3chguy Dec 19, 2018
7527bdd
Fix the IndexedDB worker
dbkr Dec 19, 2018
baf3df5
Merge pull request #7920 from vector-im/dbkr/fix_indexeddb_worker
dbkr Dec 20, 2018
751a1dc
Add tool to migrate logins between origins
dbkr Dec 21, 2018
62a49af
Only serve origin migrator whilst migrating
dbkr Dec 21, 2018
9e08551
Merge pull request #7943 from vector-im/dbkr/electron_custom_protocol
dbkr Jan 3, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 25 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,28 @@
Changes in [0.17.8](https://github.com/vector-im/riot-web/releases/tag/v0.17.8) (2018-12-10)
============================================================================================
[Full Changelog](https://github.com/vector-im/riot-web/compare/v0.17.8-rc.1...v0.17.8)

* No changes since rc.1

Changes in [0.17.8-rc.1](https://github.com/vector-im/riot-web/releases/tag/v0.17.8-rc.1) (2018-12-06)
======================================================================================================
[Full Changelog](https://github.com/vector-im/riot-web/compare/v0.17.7...v0.17.8-rc.1)

* Update from Weblate.
[\#7784](https://github.com/vector-im/riot-web/pull/7784)
* Add a function to send a rageshake from the console
[\#7755](https://github.com/vector-im/riot-web/pull/7755)
* Re-apply "Run lint on travis builds and use modern node versions"
[\#7738](https://github.com/vector-im/riot-web/pull/7738)
* Revert "Run lint on travis builds and use modern node versions"
[\#7737](https://github.com/vector-im/riot-web/pull/7737)
* Run lint on travis builds and use modern node versions
[\#7490](https://github.com/vector-im/riot-web/pull/7490)
* Fix missing js-sdk logging
[\#7736](https://github.com/vector-im/riot-web/pull/7736)
* Add $accent-color-50pct as a CSS variable to the Status theme
[\#7710](https://github.com/vector-im/riot-web/pull/7710)

Changes in [0.17.7](https://github.com/vector-im/riot-web/releases/tag/v0.17.7) (2018-11-22)
============================================================================================
[Full Changelog](https://github.com/vector-im/riot-web/compare/v0.17.6...v0.17.7)
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.rst
@@ -1,4 +1,4 @@
Contributing code to Riot
=========================

Riot follows the same pattern as https://github.com/matrix-org/synapse/blob/master/CONTRIBUTING.rst.
Riot follows the same pattern as https://github.com/matrix-org/matrix-js-sdk/blob/master/CONTRIBUTING.rst.
3 changes: 2 additions & 1 deletion README.md
Expand Up @@ -28,7 +28,8 @@ Note that Chrome does not allow microphone or webcam access for sites served
over http (except localhost), so for working VoIP you will need to serve Riot
over https.

### Installation Steps for Debian Stretch
### Desktop Installation for Debian Stretch

1. Add the repository to your sources.list using either of the following two options:
- Directly to sources.list: `echo "deb https://riot.im/packages/debian/ stretch main" | sudo tee -a /etc/apt/sources.list`
- As a separate entry in sources.list.d: `echo "deb https://riot.im/packages/debian/ stretch main" | sudo tee /etc/apt/sources.list.d/riot.list`
Expand Down
2 changes: 1 addition & 1 deletion electron_app/package.json
Expand Up @@ -2,7 +2,7 @@
"name": "riot-web",
"productName": "Riot",
"main": "src/electron-main.js",
"version": "0.17.7",
"version": "0.17.8",
"description": "A feature-rich client for Matrix.org",
"author": "New Vector Ltd.",
"dependencies": {
Expand Down
206 changes: 160 additions & 46 deletions electron_app/src/electron-main.js
Expand Up @@ -2,6 +2,7 @@
Copyright 2016 Aviral Dasgupta
Copyright 2016 OpenMarket Ltd
Copyright 2017 Michael Telatynski <7t3chguy@gmail.com>
Copyright 2018 New Vector Ltd

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -23,16 +24,23 @@ const checkSquirrelHooks = require('./squirrelhooks');
if (checkSquirrelHooks()) return;

const argv = require('minimist')(process.argv);
const {app, ipcMain, powerSaveBlocker, BrowserWindow, Menu} = require('electron');
const {app, ipcMain, powerSaveBlocker, BrowserWindow, Menu, autoUpdater, protocol} = require('electron');
const AutoLaunch = require('auto-launch');
const path = require('path');

const tray = require('./tray');
const vectorMenu = require('./vectormenu');
const webContentsHandler = require('./webcontents-handler');
const updater = require('./updater');
const { migrateFromOldOrigin } = require('./originMigrator');

const windowStateKeeper = require('electron-window-state');

// boolean flag set whilst we are doing one-time origin migration
// We only serve the origin migration script while we're actually
// migrating to mitigate any risk of it being used maliciously.
let migratingOrigin = false;

if (argv['profile']) {
app.setPath('userData', `${app.getPath('userData')}-${argv['profile']}`);
}
Expand Down Expand Up @@ -97,27 +105,75 @@ ipcMain.on('app_onAction', function(ev, payload) {
}
});

autoUpdater.on('update-downloaded', (ev, releaseNotes, releaseName, releaseDate, updateURL) => {
if (!mainWindow) return;
// forward to renderer
mainWindow.webContents.send('update-downloaded', {
releaseNotes,
releaseName,
releaseDate,
updateURL,
});
});

app.commandLine.appendSwitch('--enable-usermedia-screen-capturing');
ipcMain.on('ipcCall', async function(ev, payload) {
if (!mainWindow) return;

const shouldQuit = app.makeSingleInstance((commandLine, workingDirectory) => {
// If other instance launched with --hidden then skip showing window
if (commandLine.includes('--hidden')) return;
const args = payload.args || [];
let ret;

// Someone tried to run a second instance, we should focus our window.
if (mainWindow) {
if (!mainWindow.isVisible()) mainWindow.show();
if (mainWindow.isMinimized()) mainWindow.restore();
mainWindow.focus();
switch (payload.name) {
case 'getUpdateFeedUrl':
ret = autoUpdater.getFeedURL();
break;
case 'getAutoLaunchEnabled':
ret = launcher.isEnabled;
break;
case 'setAutoLaunchEnabled':
if (args[0]) {
launcher.enable();
} else {
launcher.disable();
}
break;
case 'getAppVersion':
ret = app.getVersion();
break;
case 'focusWindow':
if (mainWindow.isMinimized()) {
mainWindow.restore();
} else if (!mainWindow.isVisible()) {
mainWindow.show();
} else {
mainWindow.focus();
}
case 'origin_migrate':
migratingOrigin = true;
await migrateFromOldOrigin();
migratingOrigin = false;
break;
default:
mainWindow.webContents.send('ipcReply', {
id: payload.id,
error: "Unknown IPC Call: " + payload.name,
});
return;
}

mainWindow.webContents.send('ipcReply', {
id: payload.id,
reply: ret,
});
});

if (shouldQuit) {
app.commandLine.appendSwitch('--enable-usermedia-screen-capturing');

const gotLock = app.requestSingleInstanceLock();
if (!gotLock) {
console.log('Other instance detected: exiting');
app.exit();
}


const launcher = new AutoLaunch({
name: vectorConfig.brand || 'Riot',
isHidden: true,
Expand All @@ -126,39 +182,12 @@ const launcher = new AutoLaunch({
},
});

const settings = {
'auto-launch': {
get: launcher.isEnabled,
set: function(bool) {
if (bool) {
return launcher.enable();
} else {
return launcher.disable();
}
},
},
};

ipcMain.on('settings_get', async function(ev) {
const data = {};

try {
await Promise.all(Object.keys(settings).map(async function (setting) {
data[setting] = await settings[setting].get();
}));

ev.sender.send('settings', data);
} catch (e) {
console.error(e);
}
});

ipcMain.on('settings_set', function(ev, key, value) {
console.log(key, value);
if (settings[key] && settings[key].set) {
settings[key].set(value);
}
});
// Register the scheme the app is served from as 'standard'
// which allows things like relative URLs and IndexedDB to
// work.
// Also mark it as secure (ie. accessing resources from this
// protocol and HTTPS won't trigger mixed content warnings).
protocol.registerStandardSchemes(['vector'], {secure: true});

app.on('ready', () => {
if (argv['devtools']) {
Expand All @@ -175,6 +204,66 @@ app.on('ready', () => {
}
}

protocol.registerFileProtocol('vector', (request, callback) => {
if (request.method !== 'GET') {
callback({error: -322}); // METHOD_NOT_SUPPORTED from chromium/src/net/base/net_error_list.h
return null;
}

const parsedUrl = new URL(request.url);
if (parsedUrl.protocol !== 'vector:') {
callback({error: -302}); // UNKNOWN_URL_SCHEME
return;
}
if (parsedUrl.host !== 'vector') {
callback({error: -105}); // NAME_NOT_RESOLVED
return;
}

const target = parsedUrl.pathname.split('/');

// path starts with a '/'
if (target[0] !== '') {
callback({error: -6}); // FILE_NOT_FOUND
return;
}

if (target[target.length - 1] == '') {
target[target.length - 1] = 'index.html';
}

let baseDir;
// first part of the path determines where we serve from
if (migratingOrigin && target[1] === 'origin_migrator_dest') {
// the origin migrator destination page
// (only the destination script needs to come from the
// custom protocol: the source part is loaded from a
// file:// as that's the origin we're migrating from).
baseDir = __dirname + "/../../origin_migrator/dest";
} else if (target[1] === 'webapp') {
baseDir = __dirname + "/../../webapp";
} else {
callback({error: -6}); // FILE_NOT_FOUND
return;
}

// Normalise the base dir and the target path separately, then make sure
// the target path isn't trying to back out beyond its root
baseDir = path.normalize(baseDir);

const relTarget = path.normalize(path.join(...target.slice(2)));
if (relTarget.startsWith('..')) {
callback({error: -6}); // FILE_NOT_FOUND
return;
}
const absTarget = path.join(baseDir, relTarget);

callback({
path: absTarget,
});
}, (error) => {
if (error) console.error('Failed to register protocol')
});

if (vectorConfig['update_base_url']) {
console.log(`Starting auto update with base URL: ${vectorConfig['update_base_url']}`);
Expand All @@ -191,6 +280,7 @@ app.on('ready', () => {
defaultHeight: 768,
});

const preloadScript = path.normalize(`${__dirname}/preload.js`);
mainWindow = global.mainWindow = new BrowserWindow({
icon: iconPath,
show: false,
Expand All @@ -200,8 +290,20 @@ app.on('ready', () => {
y: mainWindowState.y,
width: mainWindowState.width,
height: mainWindowState.height,
webPreferences: {
preload: preloadScript,
nodeIntegration: false,
sandbox: true,
enableRemoteModule: false,
// We don't use this: it's useful for the preload script to
// share a context with the main page so we can give select
// objects to the main page. The sandbox option isolates the
// main page from the background script.
contextIsolation: false,
webgl: false,
},
});
mainWindow.loadURL(`file://${__dirname}/../../webapp/index.html`);
mainWindow.loadURL('vector://vector/webapp/');
Menu.setApplicationMenu(vectorMenu);

// explicitly hide because setApplicationMenu on Linux otherwise shows...
Expand Down Expand Up @@ -268,6 +370,18 @@ app.on('before-quit', () => {
}
});

app.on('second-instance', (ev, commandLine, workingDirectory) => {
// If other instance launched with --hidden then skip showing window
if (commandLine.includes('--hidden')) return;

// Someone tried to run a second instance, we should focus our window.
if (mainWindow) {
if (!mainWindow.isVisible()) mainWindow.show();
if (mainWindow.isMinimized()) mainWindow.restore();
mainWindow.focus();
}
});

// Set the App User Model ID to match what the squirrel
// installer uses for the shortcut icon.
// This makes notifications work on windows 8.1 (and is
Expand Down
62 changes: 62 additions & 0 deletions electron_app/src/originMigrator.js
@@ -0,0 +1,62 @@
/*
Copyright 2018 New Vector Ltd

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

const { BrowserWindow, ipcMain } = require('electron');
const path = require('path');

async function migrateFromOldOrigin() {
console.log("Attempting to migrate data between origins");

// We can use the same preload script: we just need ipcRenderer exposed
const preloadScript = path.normalize(`${__dirname}/preload.js`);
await new Promise(resolve => {
const migrateWindow = new BrowserWindow({
show: false,
webPreferences: {
preload: preloadScript,
nodeIntegration: false,
sandbox: true,
enableRemoteModule: false,
webgl: false,
},
});
ipcMain.on('origin_migration_complete', (e, success, sentSummary, storedSummary) => {
if (success) {
console.log("Origin migration completed successfully!");
} else {
console.error("Origin migration failed!");
}
console.error("Data sent", sentSummary);
console.error("Data stored", storedSummary);
migrateWindow.close();
resolve();
});
ipcMain.on('origin_migration_nodata', (e) => {
console.log("No session to migrate from old origin");
migrateWindow.close();
resolve();
});
// Normalise the path because in the distribution, __dirname will be inside the
// electron asar.
const sourcePagePath = path.normalize(__dirname + '/../../origin_migrator/source.html');
console.log("Loading path: " + sourcePagePath);
migrateWindow.loadURL('file://' + sourcePagePath);
});
}

module.exports = {
migrateFromOldOrigin,
};