Skip to content

Commit

Permalink
Merge pull request #88 from Microsoft/eanders-MS
Browse files Browse the repository at this point in the history
Eanders ms
  • Loading branch information
eanders-ms authored Jan 27, 2017
2 parents c0a963d + 68506a3 commit 50132ad
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 6 deletions.
9 changes: 9 additions & 0 deletions src/client/emulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,13 @@ export class Emulator {
};
request(options);
}

public static quitAndInstall() {
const settings = getSettings();
let options: request.OptionsWithUrl = {
url: `${this.serviceUrl}/emulator/system/quitAndInstall`,
method: "POST"
};
request(options);
}
}
9 changes: 4 additions & 5 deletions src/client/hyperlinkHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

import { shell, remote } from 'electron';
import { shell } from 'electron';
import * as URL from 'url';
import * as QueryString from 'querystring';
import { InspectorActions, AddressBarActions } from './reducers';
import { getSettings, selectedActivity$, deselectActivity } from './settings';
import { Settings as ServerSettings } from '../types/serverSettingsTypes';
import { Emulator } from './emulator';
import * as log from './log';


Expand Down Expand Up @@ -116,9 +117,7 @@ function navigateCommandUrl(params: string[]) {
return;
const json = decodeURIComponent(params['args']);
const args = JSON.parse(json);
if (args.cmd === 'autoUpdater.quitAndInstall') {
if (remote.autoUpdater) {
remote.autoUpdater.quitAndInstall();
}
if (args === 'autoUpdater.quitAndInstall') {
Emulator.quitAndInstall();
}
}
14 changes: 14 additions & 0 deletions src/server/controllers/emulator/emulatorController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

import * as Restify from 'restify';
import * as HttpStatus from "http-status-codes";
import { autoUpdater } from 'electron';
import { getSettings, getStore } from '../../settings';
import { emulator } from '../../emulator';
import { RestServer } from '../../restServer';
Expand Down Expand Up @@ -68,6 +69,7 @@ export class EmulatorController {
server.router.post('/emulator/:conversationId/typing', this.typing);
server.router.post('/emulator/:conversationId/ping', this.ping);
server.router.del('/emulator/:conversationId/userdata', this.deleteUserData);
server.router.post('/emulator/system/quitAndInstall', this.quitAndInstall);
}

static getUsers = (req: Restify.Request, res: Restify.Response, next: Restify.Next): any => {
Expand Down Expand Up @@ -168,4 +170,16 @@ export class EmulatorController {
ResponseTypes.sendErrorResponse(req, res, next, err);
}
}

static quitAndInstall = (req: Restify.Request, res: Restify.Response, next: Restify.Next): any => {
try {
if (autoUpdater) {
autoUpdater.quitAndInstall();
}
res.send(HttpStatus.OK);
res.end();
} catch (err) {
ResponseTypes.sendErrorResponse(req, res, next, err);
}
}
}
2 changes: 1 addition & 1 deletion src/server/emulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class Emulator {
// Note: We're intentionally sending and ISettings here, not a Settings. This
// is why we're getting the value from getStore().getState().
Electron.ipcMain.on('clientStarted', () => {
// DISABLED: Use chrome's proxy settings for all outgoing requests
// Use system proxy settings for outgoing requests
const session = Electron.session.defaultSession;
this.proxyAgent = new ElectronProxyAgent(session);
http.globalAgent = this.proxyAgent;
Expand Down

0 comments on commit 50132ad

Please sign in to comment.