Fix for #2588 + Unused files cleanup.
Ylian Saint-Hilaire committed
May 5, 2021 at 10:40 UTC
bc72a553e24ef594eb4ac6390f60b5260ad0485c
5 files changed
+14
-1719
translate/translate.js
-4
@@ -36,8 +36,6 @@ var meshCentralSourceFiles = [
36
"../views/message2.handlebars",
37
"../views/messenger.handlebars",
38
"../views/player.handlebars",
39
- "../views/desktop.handlebars",
40
- "../views/terminal.handlebars",
39
"../views/sharing.handlebars",
40
"../views/mstsc.handlebars",
41
"../views/ssh.handlebars",
@@ -75,8 +73,6 @@ var minifyMeshCentralSourceFiles = [
73
"../views/message2.handlebars",
74
"../views/messenger.handlebars",
75
"../views/player.handlebars",
78
- "../views/desktop.handlebars",
79
- "../views/terminal.handlebars",
76
"../views/sharing.handlebars",
77
"../views/mstsc.handlebars",
78
"../views/ssh.handlebars",
views/desktop.handlebars
deleted
-1180
@@ -1,1180 +0,0 @@
1
-<!DOCTYPE html>
2
-<html lang="en" dir="ltr" xmlns="http://www.w3.org/1999/xhtml">
3
-<head>
4
- <meta http-equiv="X-UA-Compatible" content="IE=edge" />
5
- <meta content="text/html;charset=utf-8" http-equiv="Content-Type" />
6
- <meta name="viewport" content="user-scalable=1.0,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0" />
7
- <meta name="apple-mobile-web-app-capable" content="yes" />
8
- <meta name="format-detection" content="telephone=no" />
9
- <meta name="robots" content="noindex,nofollow">
10
- <link type="text/css" href="styles/style.css" media="screen" rel="stylesheet" title="CSS" />
11
- <link rel="apple-touch-icon" href="/favicon-303x303.png" />
12
- <script type="text/javascript" src="scripts/common-0.0.1{{min}}.js"></script>
13
- <script type="text/javascript" src="scripts/amt-redir-ws-0.1.0{{{min}}}.js"></script>
14
- <script type="text/javascript" src="scripts/amt-wsman-ws-0.2.0{{{min}}}.js"></script>
15
- <script type="text/javascript" src="scripts/agent-redir-ws-0.1.1{{{min}}}.js"></script>
16
- <script type="text/javascript" src="scripts/agent-redir-rtc-0.1.0{{{min}}}.js"></script>
17
- <script type="text/javascript" src="scripts/agent-desktop-0.0.2{{min}}.js"></script>
18
- <script type="text/javascript" src="scripts/amt-desktop-0.0.2{{min}}.js"></script>
19
- <script type="text/javascript" src="scripts/amt-terminal-0.0.2{{min}}.js"></script>
20
- <script type="text/javascript" src="scripts/zlib{{min}}.js"></script>
21
- <script type="text/javascript" src="scripts/zlib-inflate{{min}}.js"></script>
22
- <script type="text/javascript" src="scripts/zlib-adler32{{min}}.js"></script>
23
- <script type="text/javascript" src="scripts/zlib-crc32{{min}}.js"></script>
24
- <script keeplink=1 type="text/javascript" src="scripts/filesaver.min.js"></script>
25
- <title>{{{title}}}</title>
26
-</head>
27
-<body style="overflow:hidden;background-color:black">
28
- <div id=p11 class="noselect" style="overflow:hidden">
29
- <div id=deskarea0>
30
- <div id=deskarea1 class="areaHead">
31
- <div class="toright2">
32
- <span id="p11power"></span>
33
- <div class='deskareaicon' title="Toggle View Mode" onclick="toggleAspectRatio(1)">⇲</div>
34
- <div class='deskareaicon' title="Rotate Left" onclick="drotate(-1)">↺</div>
35
- <div class='deskareaicon' title="Rotate Right" onclick="drotate(1)">↻</div>
36
- <input id="deskActionsSettings" type="button" value="Settings..." title="Edit remote desktop settings" onkeypress="return false" onkeydown="return false" onclick="showDesktopSettings()" class="mR" />
37
- <div id="desktopCustomUiButtons" style="float:left"></div>
38
- </div>
39
- <div>
40
- <div id="idx_deskFullBtn2" onclick=deskToggleFull(event)> ✖</div>
41
- <input type="button" id="autoconnectbutton1" value="AutoConnect" onclick=autoConnectDesktop(event) onkeypress="return false" onkeydown="return false" style="display:none" />
42
- <span id=connectbutton1span><input type=button id=connectbutton1 cmenu="deskConnectButton" value="Connect" onclick=connectDesktop(event,3) onkeypress="return false" onkeydown="return false" disabled="disabled" /></span>
43
- <span id=connectbutton1hspan> <input type=button id=connectbutton1h value="HW Connect" title="Connect using Intel AMT hardware KVM" onclick=connectDesktop(event,2) onkeypress="return false" onkeydown="return false" disabled="disabled" /></span>
44
- <span id=disconnectbutton1span> <input type=button id=disconnectbutton1 value="Disconnect" onclick=connectDesktop(event,0) onkeypress="return false" onkeydown="return false" /></span>
45
- <span id="deskstatus">Disconnected</span><span id="deskmetadata"></span>
46
- </div>
47
- </div>
48
- <div id=deskarea3x style="max-height:calc(100vh - 52px);height:calc(100vh - 52px);">
49
- <div id=DeskFocus oncontextmenu="return false" onmousedown=dmousedown(event) onmouseup=dmouseup(event) onmousemove=dmousemove(event)></div>
50
- <div id=DeskParent>
51
- <canvas id=Desk width=640 height=480 oncontextmenu="return false" onmousedown=dmousedown(event) onmouseup=dmouseup(event) onmousemove=dmousemove(event) onmousewheel=dmousewheel(event)></canvas>
52
- </div>
53
- <div id=p11DeskConsoleMsg style="display:none;cursor:pointer;position:absolute;left:30px;top:17px;color:yellow;background-color:rgba(0,0,0,0.6);padding:10px;border-radius:5px" onclick=clearConsoleMsg()></div>
54
- </div>
55
- <div id=deskarea4 class="areaFoot">
56
- <div class="toright2">
57
- <span id="DeskLatency" title="Desktop Session Latency"></span>
58
- <span id="DeskTimer" style="display:none" title="Session time"></span>
59
- <select id=termdisplays style="display:none" onchange=deskSetDisplay(event) onkeypress="return false" onkeydown="return false"></select>
60
- <span id=DeskSaveImageButton title="Save a screenshot of the remote desktop"><img src='images/icon-camera.png' onclick=deskSaveImage() height=16 width=16 style=padding-top:2px /></span>
61
- </div>
62
- <div style="height:22px">
63
- <select id="deskkeys">
64
- <option value=10>Ctrl+Alt+Del</option>
65
- <option value=5>Win</option>
66
- <option value=0>Win+Down</option>
67
- <option value=1>Win+Up</option>
68
- <option value=2>Win+L</option>
69
- <option value=3>Win+M</option>
70
- <option value=4>Shift+Win+M</option>
71
- <option value=6>Win+R</option>
72
- <option value=7>Alt-F4</option>
73
- <option value=8>Ctrl-W</option>
74
- <option value=9>Alt-Tab</option>
75
- <option value=11>Win+Left</option>
76
- <option value=12>Win+Right</option>
77
- </select>
78
- <input id="DeskWD" type=button value="Send" onkeypress="return false" onkeydown="return false" onclick="deskSendKeys()" />
79
- <input id="DeskClip" style="" type="button" value="Clipboard" onkeypress="return false" onkeydown="return false" onclick="showDeskClip()" />
80
- <input id="DeskType" style="" type="button" value="Type" onkeypress="return false" onkeydown="return false" onclick="showDeskType()" />
81
- <label><span id="DeskControlSpan" title="Toggle mouse and keyboard input"><input id="DeskControl" type="checkbox" onkeypress="return false" onkeydown="return false" onclick="toggleKvmControl()" />Input</span></label>
82
- </div>
83
- </div>
84
- </div>
85
- <div id=dialog class="noselect" style="display:none">
86
- <div id=dialogHeader>
87
- <div tabindex=0 id=id_dialogclose onclick=setDialogMode() onkeypress="if (event.key == 'Enter') setDialogMode()">✖</div>
88
- <div id=id_dialogtitle></div>
89
- </div>
90
- <div id=dialogBody>
91
- <div id=dialog1>
92
- <div id=id_dialogMessage style=""></div>
93
- </div>
94
- <div id=dialog2 style="">
95
- <div id=id_dialogOptions></div>
96
- </div>
97
- <div id=dialog7 style="">
98
- <div id="d7meshkvm">
99
- <h4>Agent Remote Desktop</h4>
100
- <div>
101
- <div>Quality</div>
102
- <select id="d7bitmapquality" dir="rtl"></select>
103
- </div>
104
- <div>
105
- <div>Scaling</div>
106
- <select id="d7bitmapscaling" style="" dir="rtl">
107
- <option selected=selected value=1024>100%</option>
108
- <option value=896>87.5%</option>
109
- <option value=768>75%</option>
110
- <option value=640>62.5%</option>
111
- <option value=512>50%</option>
112
- <option value=384>37.5%</option>
113
- <option value=256>25%</option>
114
- <option value=128>12.5%</option>
115
- </select>
116
- </div>
117
- <div>
118
- <div>Frame rate</div>
119
- <select id="d7framelimiter" dir="rtl">
120
- <option selected=selected value=50>Fast</option>
121
- <option value=100>Medium</option>
122
- <option value=400>Slow</option>
123
- <option value=1000>Very slow</option>
124
- </select>
125
- </div>
126
- </div>
127
- <div id="d7amtkvm">
128
- <h4>Intel® AMT Hardware KVM</h4>
129
- <div>
130
- <div>Image Encoding</div>
131
- <select id="d7desktopmode">
132
- <option value="1">RLE8, Fastest</option>
133
- <option value="2">RLE16, Recommended</option>
134
- <option value="3">RAW8, Slow</option>
135
- <option value="4">RAW16, Very Slow</option>
136
- </select>
137
- </div>
138
- <div>
139
- <div>Other Settings</div>
140
- <div id="d7otherset" style="display:block">
141
- <label style="display:block"><input type="checkbox" id="d7showfocus" />Show Focus Tool</label>
142
- <label style="display:block"><input type="checkbox" id="d7showcursor" />Show Local Mouse Cursor</label>
143
- <label style="display:block"><input type="checkbox" id="d7localKeyMap" />Local Keyboard Map</label>
144
- </div>
145
- </div>
146
- </div>
147
- </div>
148
- </div>
149
- <div id="idx_dlgButtonBar">
150
- <input id="idx_dlgCancelButton" type="button" value="Cancel" style="" onclick="dialogclose(0)">
151
- <input id="idx_dlgOkButton" type="button" value="OK" style="" onclick="dialogclose(1)">
152
- <div><input id="idx_dlgDeleteButton" type="button" value="Delete" style="display:none" onclick="dialogclose(2)"></div>
153
- </div>
154
- </div>
155
- </div>
156
- <script>
157
- var sessionActivity = null;
158
- var desktop = null;
159
- var agentPresent = true;
160
- var intelAmtPresent = false;
161
- var deskAspectRatio = 0;
162
- var desktopsettings = { encoding: 2, showfocus: false, showmouse: true, showcad: true, quality: 40, scaling: 1024, framerate: 100, localkeymap: false };
163
- var p11DeskConsoleMsgTimer = null;
164
- var serverPublicNamePort = '{{{serverDnsName}}}:{{{serverPublicPort}}}';
165
- var domain = '{{{domain}}}';
166
- var domainUrl = '{{{domainurl}}}';
167
- var authCookie = '{{{authCookie}}}';
168
- var viewOnly = parseInt('{{{viewOnly}}}');
169
- var urlargs = parseUriArgs();
170
- var debugmode = urlargs.debug;
171
- var attemptWebRTC = false;
172
- var updateSessionTimer = null;
173
- var StatusStrs = ["Disconnected", "Connecting...", "Setup...", "Connected", "Intel® AMT Connected"];
174
- var webPageFullScreen = false;
175
- var expire = '{{{expire}}}';
176
- if (expire != '') { QH('p11power', printFlexDateTime(new Date(parseInt(expire)))); }
177
-
178
- function start() {
179
- window.onresize = deskAdjust;
180
- document.onkeypress = ondockeypress;
181
- document.onkeydown = ondockeydown;
182
- document.onkeyup = ondockeyup;
183
- setupDesktop();
184
-
185
- // View only mode
186
- if (viewOnly == 1) {
187
- QV('deskkeys', false);
188
- QV('DeskWD', false);
189
- QV('DeskClip', false);
190
- QV('DeskType', false);
191
- QV('DeskControlSpan', false);
192
- }
193
- }
194
-
195
- function isInputAllowed() { return (viewOnly != 1) && (Q('DeskControl').checked == true); }
196
- function clearConsoleMsg() { QH('p11DeskConsoleMsg', ''); }
197
-
198
- // Toggle the web page to full screen
199
- function toggleAspectRatio(toggle) {
200
- if (toggle === 1) { deskAspectRatio = ((deskAspectRatio + 1) % 3); }
201
- deskAdjust();
202
- }
203
-
204
- function deskAdjust() {
205
- var parentH = Q('DeskParent').clientHeight, parentW = Q('DeskParent').clientWidth;
206
- var deskH = Q('Desk').height, deskW = Q('Desk').width;
207
-
208
- if (deskAspectRatio == 2) {
209
- // Scale mode
210
- QS('Desk')['margin-top'] = null;
211
- QS('Desk').height = '100%';
212
- QS('Desk').width = '100%';
213
- QS('DeskParent').overflow = 'hidden';
214
- } else if (deskAspectRatio == 1) {
215
- // Zoomed mode
216
- QS('Desk')['margin-top'] = '0px';
217
- //QS('Desk')['margin-left'] = '0px';
218
- QS('Desk').height = deskH + 'px';
219
- QS('Desk').width = deskW + 'px';
220
- QS('DeskParent').overflow = 'scroll';
221
- } else {
222
- // Fixed aspect ratio
223
- if ((parentH / parentW) > (deskH / deskW)) {
224
- var hNew = ((deskH * parentW) / deskW) + 'px';
225
- //if (webPageFullScreen || fullscreen) {
226
- //QS('deskarea3x').height = null;
227
- //} else {
228
- // QS('deskarea3x').height = hNew;
229
- //QS('deskarea3x').height = null;
230
- //}
231
- QS('Desk').height = hNew;
232
- QS('Desk').width = '100%';
233
- } else {
234
- var wNew = ((deskW * parentH) / deskH) + 'px';
235
- //if (webPageFullScreen || fullscreen) {
236
- //QS('Desk').height = null;
237
- //} else {
238
- QS('Desk').height = '100%';
239
- //}
240
- QS('Desk').width = wNew;
241
- }
242
- QS('Desk')['margin-top'] = null;
243
- QS('DeskParent').overflow = 'hidden';
244
- }
245
- }
246
-
247
- //
248
- // DESKTOP
249
- //
250
-
251
- function setupDesktop() {
252
- // Setup the remote desktop
253
- if (desktop != null) { desktop.Stop(); desktop = null; }
254
-
255
- // If the device desktop is already connected in multi-desktop, use that.
256
- if (desktop == null) {
257
- // Device is not already connected, just setup a blank canvas
258
- QH('DeskParent', '<canvas id=Desk oncontextmenu="return false" onmousedown=dmousedown(event) onmouseup=dmouseup(event) onmousemove=dmousemove(event)></canvas>');
259
-
260
- // Setup the mouse wheel
261
- Q('Desk').addEventListener('DOMMouseScroll', function (e) { return dmousewheel(e); });
262
- Q('Desk').addEventListener('mousewheel', function (e) { return dmousewheel(e); });
263
- }
264
- updateDesktopButtons();
265
- deskAdjust();
266
- updateMetadata(desktop, 'deskmetadata');
267
- }
268
-
269
- // Show and enable the right buttons
270
- function updateDesktopButtons() {
271
- var deskState = 0;
272
- if (desktop != null) { deskState = desktop.State; }
273
-
274
- // Show the right buttons
275
- QV('disconnectbutton1span', (deskState != 0));
276
- QV('connectbutton1span', (deskState == 0) && (agentPresent));
277
- QV('connectbutton1hspan', (deskState == 0) && (intelAmtPresent));
278
-
279
- // Show the right settings
280
- QV('d7meshkvm', agentPresent && ((deskState == 0) || (desktop.contype == 1)));
281
- QV('d7amtkvm', intelAmtPresent && ((deskState == 0) || (desktop.contype == 2)));
282
-
283
- // Enable buttons
284
- QE('connectbutton1', agentPresent);
285
- QE('connectbutton1h', intelAmtPresent);
286
- //QV('DeskClip', agentPresent && ((desktop == null) || (desktop.contype != 2))); // Clipboard not supported on macOS
287
- QV('DeskClip', false); // Clipboard not supported on this page
288
- QE('DeskClip', deskState == 3);
289
- QE('DeskType', deskState == 3);
290
- QV('DeskWD', viewOnly != 1);
291
- QE('DeskWD', deskState == 3);
292
- QV('deskkeys', viewOnly != 1);
293
- QE('deskkeys', deskState == 3);
294
-
295
- // Display this only if we have Chat & Notify permissions
296
- QV('DeskSaveImageButton', (deskState == 3) && (Q('Desk')['toBlob'] != null));
297
- QV('DeskControlSpan', viewOnly != 1);
298
- QV('deskActionsBtn', (browserfullscreen == false));
299
- QV('deskActionsSettings', (browserfullscreen == false));
300
- Q('DeskControl').checked = true;
301
- QS('DeskControlSpan').color = Q('DeskControl').checked ? null : 'red';
302
- }
303
-
304
- // Debug
305
- var autoConnectDesktopTimer = null;
306
- function autoConnectDesktop(e) { if (autoConnectDesktopTimer == null) { autoConnectDesktopTimer = setInterval(function () { connectDesktop(null, 1) }, 1000); } else { clearInterval(autoConnectDesktopTimer); autoConnectDesktopTimer = null; } }
307
-
308
- // Used to translate incoming agent console messages
309
- var agentConsoleMessages = ['', "Waiting for user to grant access...", "Denied", "Failed to start remote terminal session, {0} ({1})", "Timeout", "Received invalid network data"];
310
- function formatAgentConsoleMessage(msg, msgid, msgargs) {
311
- var r;
312
- if (msgargs == null) { msgargs = []; }
313
- while (msgargs.length < 3) { msgargs.push(''); } // We need to call the format function in a way that works with older browsers and minifier, can't use apply() or ...
314
- if (msgid && (msgid < agentConsoleMessages.length)) { r = EscapeHtml(format(agentConsoleMessages[msgid], (msgargs[0]), (msgargs[1]), (msgargs[2]))); } else { r = EscapeHtml(msg); }
315
- return r.split('\n').join('<br />') + '<br /><br />';
316
- }
317
-
318
- function connectDesktop(e, contype, tsid, consent) {
319
- if (xxdialogMode) return;
320
- if ((e != null) && (e.shiftKey != false) && (contype == 3)) { contype = 1; } // If the shift key is not pressed, don't try to ask for session list.
321
- QV('p11DeskSessionSelector', false);
322
- p11clearConsoleMsg();
323
- if (desktop == null) {
324
- if (contype == 2) {
325
- // Setup the Intel AMT remote desktop
326
- //if ((desktopNode.intelamt.user == null) || (desktopNode.intelamt.user == '')) { editDeviceAmtSettings(desktopNode._id, connectDesktop, 2); return; }
327
- desktop = CreateAmtRedirect(CreateAmtRemoteDesktop('Desk'), authCookie);
328
- desktop.debugmode = debugmode;
329
- desktop.onStateChanged = onDesktopStateChange;
330
- desktop.m.stopInput = (viewOnly == 1);
331
- desktop.m.bpp = (desktopsettings.encoding == 1 || desktopsettings.encoding == 3) ? 1 : 2;
332
- desktop.m.useZRLE = (desktopsettings.encoding < 3);
333
- desktop.m.localKeyMap = desktopsettings.localkeymap;
334
- desktop.m.showmouse = desktopsettings.showmouse;
335
- desktop.m.onScreenSizeChange = deskAdjust;
336
- desktop.m.onKvmData = function (x) {
337
- //console.log('onKvmData (' + x.length + '): ' + x);
338
- // Send the presense probe only once if needed.
339
- if (x.length == 0) { if (!desktop.m._sentPresence) { desktop.m._sentPresence = true; desktop.m.sendKvmData(JSON.stringify({ action: 'present', ver: 1 })); } return; }
340
- var data = null;
341
- try { data = JSON.parse(x); } catch (e) { }
342
- if ((data != null) && (data.action != null)) {
343
- if (data.action == 'restart') {
344
- // Clear WebRTC channel
345
- webRtcDesktopReset();
346
- desktop.m.sendKvmData(JSON.stringify({ action: 'present', ver: 1 }));
347
- } else if ((data.action == 'present') && (webRtcDesktop == null)) {
348
- // Setup WebRTC channel
349
- webRtcDesktop = { platform: data.platform };
350
- var configuration = null; //{ "iceServers": [ { 'urls': 'stun:stun.services.mozilla.com' }, { 'urls': 'stun:stun.l.google.com:19302' } ] };
351
- if (typeof RTCPeerConnection !== 'undefined') { webRtcDesktop.webrtc = new RTCPeerConnection(configuration); }
352
- else if (typeof webkitRTCPeerConnection !== 'undefined') { webRtcDesktop.webrtc = new webkitRTCPeerConnection(configuration); }
353
-
354
- webRtcDesktop.webchannel = webRtcDesktop.webrtc.createDataChannel("DataChannel", {}); // { ordered: false, maxRetransmits: 2 }
355
- webRtcDesktop.webchannel.onopen = function () {
356
- // Switch to software KVM
357
- //if (urlvars && urlvars['kvmdatatrace']) { console.log('WebRTC Data Channel Open'); }
358
- console.log('WebRTC Data Channel Open');
359
- Q('deskstatus').textContent = StatusStrs[desktop.State] + ", Soft-KVM";
360
- desktop.m.hold(true);
361
- webRtcDesktop.webRtcActive = true;
362
- webRtcDesktop.softdesktop = CreateKvmDataChannel(webRtcDesktop.webchannel, CreateAgentRemoteDesktop('Desk', Q('id_mainarea')), desktop.m);
363
- webRtcDesktop.softdesktop.m.setRotation(desktop.m.rotation);
364
- webRtcDesktop.softdesktop.m.onScreenSizeChange = deskAdjust;
365
- if (desktopsettings.quality) { webRtcDesktop.softdesktop.m.CompressionLevel = desktopsettings.quality; } // Number from 1 to 100. 50 or less is best.
366
- if (desktopsettings.scaling) { webRtcDesktop.softdesktop.m.ScalingLevel = desktopsettings.scaling; }
367
- webRtcDesktop.softdesktop.Start();
368
-
369
- // Check if we can get remote file access
370
- // ###BEGIN###{DesktopInbandFiles}
371
- /*
372
- QV('go24', true); // Files
373
- downloadFile = null;
374
- p24files = webRtcDesktop.softdesktop;
375
- p24targetpath = '';
376
- webRtcDesktop.softdesktop.onControlMsg = onFilesControlData;
377
- webRtcDesktop.softdesktop.sendCtrlMsg(JSON.stringify({ action: 'ls', reqid: 1, path: '' })); // Ask for the root folder
378
- */
379
- // ###END###{DesktopInbandFiles}
380
- }
381
- webRtcDesktop.webchannel.onclose = function (event) {
382
- //if (urlvars['kvmdatatrace']) { console.log('WebRTC Data Channel Closed'); }
383
- console.log('WebRTC Data Channel Closed');
384
- webRtcDesktopReset();
385
- }
386
- webRtcDesktop.webrtc.onicecandidate = function (e) {
387
- if (e.candidate == null) {
388
- desktop.m.sendKvmData(JSON.stringify({ action: 'offer', ver: 1, sdp: webRtcDesktop.webrtcoffer.sdp }));
389
- } else {
390
- webRtcDesktop.webrtcoffer.sdp += ('a=' + e.candidate.candidate + '\r\n'); // New candidate, add it to the SDP
391
- }
392
- }
393
- webRtcDesktop.webrtc.oniceconnectionstatechange = function () {
394
- if ((webRtcDesktop != null) && (webRtcDesktop.webrtc != null) && ((webRtcDesktop.webrtc.iceConnectionState == 'disconnected') || (webRtcDesktop.webrtc.iceConnectionState == 'failed'))) { /*console.log('WebRTC ICE Failed');*/ webRtcDesktopReset(); }
395
- }
396
- webRtcDesktop.webrtc.createOffer(function (offer) {
397
- // Got the offer
398
- webRtcDesktop.webrtcoffer = offer;
399
- webRtcDesktop.webrtc.setLocalDescription(offer, function () { }, webRtcDesktopReset);
400
- }, webRtcDesktopReset, { mandatory: { OfferToReceiveAudio: false, OfferToReceiveVideo: false } });
401
- } else if ((data.action == 'answer') && (webRtcDesktop != null)) {
402
- // Complete the WebRTC channel
403
- webRtcDesktop.webrtc.setRemoteDescription(new RTCSessionDescription({ type: 'answer', sdp: data.sdp }), function () { }, webRtcDesktopReset);
404
- }
405
- }
406
- };
407
- desktop.Start(null, 16994, '*', '*', 0);
408
- desktop.contype = 2;
409
- } else if ((contype == null) || (contype == 1) || (contype == 3)) {
410
- // Setup the Mesh Agent remote desktop
411
- desktop = CreateAgentRedirect(null, CreateAgentRemoteDesktop('Desk'), serverPublicNamePort, authCookie, null, domainUrl);
412
- desktop.m.stopInput = (viewOnly == 1);
413
- desktop.m.mouseCursorActive(true);
414
- desktop.debugmode = debugmode;
415
- desktop.m.debugmode = debugmode;
416
- desktop.attemptWebRTC = attemptWebRTC;
417
- desktop.options = {};
418
- if (tsid != null) { desktop.options.tsid = tsid; }
419
- if (consent != null) { desktop.options.consent = consent; }
420
- desktop.onStateChanged = onDesktopStateChange;
421
- desktop.onConsoleMessageChange = function () {
422
- if (desktop.consoleMessage) {
423
- Q('p11DeskConsoleMsg').innerHTML += formatAgentConsoleMessage(desktop.consoleMessage, desktop.consoleMessageId, desktop.consoleMessageArgs);
424
- QV('p11DeskConsoleMsg', true);
425
- if (p11DeskConsoleMsgTimer != null) { clearTimeout(p11DeskConsoleMsgTimer); }
426
- if (desktop.consoleMessageTimeout) { p11DeskConsoleMsgTimer = setTimeout(p11clearConsoleMsg, desktop.consoleMessageTimeout * 1000); }
427
- } else {
428
- p11clearConsoleMsg();
429
- }
430
- }
431
- desktop.onMetadataChange = function (metadata) { updateMetadata(desktop, 'deskmetadata'); }
432
- desktop.m.CompressionLevel = desktopsettings.quality; // Number from 1 to 100. 50 or less is best.
433
- desktop.m.ScalingLevel = desktopsettings.scaling;
434
- if (desktopsettings.framerate) { desktop.m.FrameRateTimer = desktopsettings.framerate; }
435
- desktop.m.onDisplayinfo = deskDisplayInfo;
436
- desktop.m.onScreenSizeChange = deskAdjust;
437
- desktop.Start(null);
438
- desktop.latency.callback = function (ms) { console.log('latency', ms); updateSessionTime(); };
439
- desktop.contype = 1;
440
- }
441
- } else {
442
- // Disconnect and clean up the remote desktop
443
- desktop.Stop();
444
- webRtcDesktopReset();
445
- desktop = null;
446
- //if (pluginHandler != null) { pluginHandler.callHook('onDesktopDisconnect'); }
447
- }
448
- }
449
-
450
- function updateMetadata(conn, elementid) {
451
- var str = '', viewerCount = 0;
452
- if (conn && (conn.State == 3)) {
453
- if (conn.metadata && conn.metadata.users) { for (var i in conn.metadata.users) { viewerCount += conn.metadata.users[i]; } }
454
- if (viewerCount > 1) { str = '<span onclick=showSessionMetadata(1) style=cursor:pointer>' + format(", {0} watching", viewerCount) + '</span>'; }
455
- }
456
- QH('deskmetadata', str);
457
- if ((conn == desktop) && (xxdialogTag == ('sessionMetadata1'))) { showSessionMetadata(1); }
458
- }
459
-
460
- function showSessionMetadata(cid) {
461
- if (xxdialogMode && (xxdialogTag != ('sessionMetadata' + cid))) return;
462
- if (xxdialogMode) { setDialogMode(0); }
463
- var conn = null;
464
- if (cid == 1) { conn = desktop; }
465
- if (conn && conn.metadata) {
466
- var x = '';
467
- if (conn.metadata.startTime) { x += addHtmlValue4("Start Time", printDateTime(new Date(conn.metadata.startTime))); }
468
- if (conn.metadata.users) {
469
- for (var i in conn.metadata.users) {
470
- var val = (conn.metadata.users[i] == 1) ? "1 connection" : format("{0} connections", conn.metadata.users[i]);
471
- var username = i.split('/')[2];
472
- if ((users != null) && (users[i] != null)) { username = users[i].name; }
473
- x += addHtmlValue4(format("User \"{0}\"", username), val);
474
- }
475
- }
476
- setDialogMode(2, "Session Information", 1, null, x, 'sessionMetadata' + cid);
477
- }
478
- }
479
-
480
- function p11clearConsoleMsg() { QH('p11DeskConsoleMsg', ''); QV('p11DeskConsoleMsg', false); if (p11DeskConsoleMsgTimer) { clearTimeout(p11DeskConsoleMsgTimer); p11DeskConsoleMsgTimer = null; } }
481
-
482
- var webRtcDesktop = null;
483
- function webRtcDesktopReset() {
484
- if (webRtcDesktop == null) return;
485
- if (webRtcDesktop.softdesktop != null) { webRtcDesktop.softdesktop.Stop(); webRtcDesktop.softdesktop = null; }
486
- if (webRtcDesktop.webchannel != null) { try { webRtcDesktop.webchannel.close(); } catch (e) { } webRtcDesktop.webchannel = null; }
487
- if (webRtcDesktop.webrtc != null) { try { webRtcDesktop.webrtc.close(); } catch (e) { } webRtcDesktop.webrtc = null; }
488
- webRtcDesktop = null;
489
- // Switch back to hardware KVM
490
- if (desktop && desktop.m) {
491
- desktop.m.hold(false);
492
- Q('deskstatus').textContent = StatusStrs[desktop.State];
493
- }
494
- // ###BEGIN###{DesktopInbandFiles}
495
- /*
496
- p24files = null;
497
- p24downloadFileCancel() // If any downloads are in process, cancel them.
498
- p24uploadFileCancel(); // If any uploads are in process, cancel them.
499
- QV('go24', false); // Files
500
- if (currentView == 24) { go(14); }
501
- */
502
- // ###END###{DesktopInbandFiles}
503
- }
504
-
505
- function onDesktopStateChange(xdesktop, state) {
506
- var xstate = state;
507
- if ((xstate == 3) && (xdesktop.contype == 2)) { xstate++; }
508
- var str = StatusStrs[xstate];
509
- if ((desktop != null) && (desktop.webRtcActive == true)) { str += ", WebRTC"; }
510
- //if (desktop.m.stopInput == true) { str += ', Loopback'; }
511
- QH('deskstatus', str);
512
- switch (state) {
513
- case 0:
514
- // Stop recording
515
- if (desktop.m.recordedData != null) { deskRecordSession(); }
516
-
517
- // Disconnect and clean up the remote desktop
518
- desktop.Stop();
519
- desktop = null;
520
- QV('DeskFocus', false);
521
- QV('termdisplays', false);
522
- QV('deskRecordIcon', false);
523
- if (fullscreen == true) { deskToggleFull(); }
524
- webRtcDesktopReset();
525
- deskPreferedStickyDisplay = 0;
526
- break;
527
- case 2:
528
- break;
529
- case 3:
530
- if (desktop && (desktop.serverIsRecording == true)) { QV('deskRecordIcon', true); }
531
- desktop.startTime = new Date();
532
- if (updateSessionTimer == null) { updateSessionTimer = setInterval(updateSessionTime, 1000); }
533
- break;
534
- default:
535
- //console.log('Unknown onDesktopStateChange state', state);
536
- break;
537
- }
538
- updateDesktopButtons();
539
- deskAdjust();
540
- setTimeout(deskAdjust, 50);
541
- updateMetadata(desktop, 'deskmetadata');
542
- }
543
-
544
- function updateSessionTime() {
545
- // Desktop
546
- var latencyStr = '', seconds = 0;
547
- if (desktop && desktop.startTime) {
548
- if (desktop.latency && (desktop.latency.current >= 0)) { latencyStr = format('{0} ms, ', desktop.latency.current); }
549
- seconds = Math.floor((new Date() - desktop.startTime) / 1000);
550
- QH('DeskTimer', latencyStr + zeroPad(Math.floor(seconds / 3600), 2) + ':' + zeroPad((Math.floor(seconds / 60) % 60), 2) + ':' + zeroPad((seconds % 60), 2));
551
- } else {
552
- QH('DeskTimer', '');
553
- }
554
-
555
- if (desktop == null) { clearInterval(updateSessionTimer); updateSessionTimer = null; }
556
- }
557
-
558
- function showDesktopSettings() {
559
- if (xxdialogMode) return;
560
- applyDesktopSettings();
561
- updateDesktopButtons();
562
- setDialogMode(7, "Remote Desktop Settings", 3, showDesktopSettingsChanged);
563
- }
564
-
565
- function showDesktopSettingsChanged() {
566
- desktopsettings.encoding = d7desktopmode.value;
567
- desktopsettings.showfocus = d7showfocus.checked;
568
- desktopsettings.showmouse = d7showcursor.checked;
569
- desktopsettings.quality = d7bitmapquality.value;
570
- desktopsettings.scaling = d7bitmapscaling.value;
571
- desktopsettings.framerate = d7framelimiter.value;
572
- desktopsettings.localkeymap = d7localKeyMap.checked;
573
- localStorage.setItem('desktopsettings', JSON.stringify(desktopsettings));
574
- applyDesktopSettings();
575
- if (desktop) {
576
- if (desktop.contype == 1) {
577
- if (desktop.State != 0) {
578
- desktop.m.SendCompressionLevel(1, desktopsettings.quality, desktopsettings.scaling, desktopsettings.framerate);
579
- }
580
- }
581
- if (desktop.contype == 2) {
582
- if (desktop.State != 0) { desktop.Stop(); setTimeout(function () { connectDesktop(null, 2); }, 50); }
583
- }
584
- }
585
- }
586
-
587
- function applyDesktopSettings() {
588
- var r = '', ops = [60, 50, 40, 30, 20, 10, 5, 1];
589
- for (var i in ops) { r += '<option value=' + ops[i] + '>' + ops[i] + '%</option>'; }
590
- QH('d7bitmapquality', r);
591
- d7desktopmode.value = desktopsettings.encoding;
592
- d7showfocus.checked = desktopsettings.showfocus;
593
- d7showcursor.checked = desktopsettings.showmouse;
594
- d7bitmapquality.value = 40; // Default value
595
- if (ops.indexOf(parseInt(desktopsettings.quality)) >= 0) { d7bitmapquality.value = desktopsettings.quality; }
596
- d7bitmapscaling.value = desktopsettings.scaling;
597
- if (desktopsettings.framerate) { d7framelimiter.value = desktopsettings.framerate; } else { d7framelimiter.value = 100; }
598
- if (desktopsettings.localkeymap) { d7localKeyMap.checked = desktopsettings.localkeymap; }
599
- }
600
-
601
- // Enter browser fullscreen
602
- function enterBrowserFullscreen(elem) {
603
- if (elem.requestFullscreen) { elem.requestFullscreen(); }
604
- else if (elem.msRequestFullscreen) { elem.msRequestFullscreen(); }
605
- else if (elem.mozRequestFullScreen) { elem.mozRequestFullScreen(); }
606
- else if (elem.webkitRequestFullscreen) { elem.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT); }
607
- }
608
-
609
- // Exit browser fullscreen
610
- function exitBrowserFullscreen() {
611
- if (document.exitFullscreen) { document.exitFullscreen(); }
612
- else if (document.msExitFullscreen) { document.msExitFullscreen(); }
613
- else if (document.mozCancelFullScreen) { document.mozCancelFullScreen(); }
614
- else if (document.webkitExitFullscreen) { document.webkitExitFullscreen(); }
615
- }
616
-
617
- // Return true if the browser is fullscreen. This is a delayed method that will return true/false late. Not very useful.
618
- function isBrowserFullscreen() {
619
- if (!document.fullscreenElement && !document.mozFullScreenElement && !document.webkitFullscreenElement && !document.msFullscreenElement) { return false; } else { return true; }
620
- }
621
-
622
- var fullscreen = false;
623
- var browserfullscreen = false;
624
- function deskToggleFull(e) {
625
- var xtermActive = !((urlargs.xterm === 0) || ((terminal != null) && (xterm == null)));
626
- fullscreen = !fullscreen;
627
- if (fullscreen) {
628
- QC('body').add('fulldesk');
629
- QS('deskarea3x')['height'] = '100%';
630
- QS('deskarea3x')['max-height'] = '100%';
631
- if (xtermActive) {
632
- // XTerm terminal
633
- QS('termTable')['position'] = 'absolute';
634
- QS('termTable')['top'] = QS('termTable')['bottom'] = QS('termTable')['left'] = QS('termTable')['right'] = '0';
635
- } else {
636
- // Legacy terminal
637
- QS('termTable')['height'] = '100%';
638
- QS('termTable')['max-height'] = '100%';
639
- }
640
-
641
- // If shift is pressed, enter browser full screen.
642
- if (e.shiftKey == true) {
643
- enterBrowserFullscreen(Q('container'));
644
- browserfullscreen = true;
645
- }
646
- } else {
647
- QC('body').remove('fulldesk');
648
- var hide = urlargs.hide;
649
- if (footerBar == false) { hide |= 4; }
650
- var xh = (((hide & 1) ? 0 : 66) + ((hide & 2) ? 0 : 24) + ((hide & 4) ? 0 : 45) + ((hide & 8) ? 0 : 60)); // 0 to 195
651
- QS('deskarea3x')['height'] = 'calc(100vh - ' + (75 + xh) + 'px)';
652
- QS('deskarea3x')['max-height'] = 'calc(100vh - ' + (75 + xh) + 'px)';
653
- if (xtermActive) {
654
- // XTerm terminal
655
- QS('termTable')['position'] = null;
656
- QS('termTable')['top'] = QS('termTable')['bottom'] = QS('termTable')['left'] = QS('termTable')['right'] = null;
657
- } else {
658
- // Legacy terminal
659
- QS('termTable')['height'] = 'calc(100vh - ' + (75 + xh) + 'px)';
660
- QS('termTable')['max-height'] = 'calc(100vh - ' + (75 + xh) + 'px)';
661
- }
662
- if (browserfullscreen == true) { exitBrowserFullscreen(); browserfullscreen = false; }
663
- }
664
- deskAdjust();
665
- updateDesktopButtons();
666
- adjustPanels();
667
- //setTimeout(adjustPanels, 10);
668
- //setTimeout(function() { xtermfit.fit(); }, 10);
669
- if (xterm != null) { if (xxcurrentView == 12) { xtermfit.fit(); xterm.focus(); } }
670
- }
671
-
672
- function deskAdjust() {
673
- var parentH = Q('DeskParent').clientHeight, parentW = Q('DeskParent').clientWidth;
674
- var deskH = Q('Desk').height, deskW = Q('Desk').width;
675
-
676
- if (deskAspectRatio == 2) {
677
- // Scale mode
678
- QS('Desk')['margin-top'] = null;
679
- QS('Desk').height = '100%';
680
- QS('Desk').width = '100%';
681
- //QS('deskarea3x').height = null;
682
- QS('DeskParent').overflow = 'hidden';
683
- } else if (deskAspectRatio == 1) {
684
- // Zoomed mode
685
- QS('Desk')['margin-top'] = '0px';
686
- QS('Desk').height = deskH + 'px';
687
- QS('Desk').width = deskW + 'px';
688
- QS('DeskParent').overflow = 'scroll';
689
- } else {
690
- // Fixed aspect ratio
691
- if ((parentH / parentW) > (deskH / deskW)) {
692
- var hNew = ((deskH * parentW) / deskW) + 'px';
693
- //if (webPageFullScreen || fullscreen) {
694
- //QS('deskarea3x').height = null;
695
- //} else {
696
- // QS('deskarea3x').height = hNew;
697
- //QS('deskarea3x').height = null;
698
- //}
699
- QS('Desk').height = hNew;
700
- QS('Desk').width = '100%';
701
- } else {
702
- var wNew = ((deskW * parentH) / deskH) + 'px';
703
- if (webPageFullScreen || fullscreen) {
704
- QS('Desk').height = null;
705
- } else {
706
- QS('Desk').height = '100%';
707
- }
708
- QS('Desk').width = wNew;
709
- }
710
- QS('Desk')['margin-top'] = null;
711
- QS('DeskParent').overflow = 'hidden';
712
- }
713
- }
714
-
715
- function mdeskAdjust(mod, sw, sh, cv) {
716
- if (!mod || !sw || !sh || !cv) return;
717
-
718
- // Check if we are in single desktop mode
719
- if (cv.id == 'Desk') { deskAdjust(); return; }
720
-
721
- // Figure out and adjust the size to fill the width of the div
722
- var vsize = [{ x: 180, y: 101 }, { x: 302, y: 169 }, { x: 454, y: 255 }][Q('sizeselect').selectedIndex];
723
- var realw = vsize.x + 2, tw = Q('xdevices').clientWidth - 30, xw = Math.floor(tw / realw);
724
- xw = realw + Math.floor((tw - (xw * realw)) / xw);
725
- vsize.y = vsize.y * (xw / vsize.x);
726
- vsize.x = xw;
727
- var mh = vsize.y, mw = vsize.x;
728
- if (mod.State != 0) { mh = vsize.y; mw = (sw / sh) * vsize.y; }
729
- QS(cv.id)['max-height'] = mh + 'px';
730
- QS(cv.id)['max-width'] = mw + 'px';
731
- QS(cv.id)['margin-top'] = '0';
732
- QS(cv.id)['margin-bottom'] = '0';
733
- }
734
-
735
- // Remote desktop special key combos for Windows
736
- function deskSendKeys() {
737
- if (xxdialogMode || desktop == null || desktop.State != 3) return;
738
- var ks = Q('deskkeys').value;
739
- if (ks == 0) { // WIN+Down arrow
740
- if (desktop.contype == 2) {
741
- desktop.m.sendkey([[0xffe7, 1], [0xff54, 1], [0xff54, 0], [0xffe7, 0]]); // Intel AMT: Meta-left down, Down arrow press, Down arrow release, Meta-left release
742
- } else {
743
- desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN, 0x5B], [desktop.m.KeyAction.DOWN, 40], [desktop.m.KeyAction.UP, 40], [desktop.m.KeyAction.EXUP, 0x5B]]); // Agent: L-Winkey press, Down arrow press, Down arrow release, L-Winkey release
744
- }
745
- } else if (ks == 1) { // WIN+Up arrow
746
- if (desktop.contype == 2) {
747
- desktop.m.sendkey([[0xffe7, 1], [0xff52, 1], [0xff52, 0], [0xffe7, 0]]); // Intel AMT: Meta-left down, Up arrow press, Up arrow release, Meta-left release
748
- } else {
749
- desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN, 0x5B], [desktop.m.KeyAction.DOWN, 38], [desktop.m.KeyAction.UP, 38], [desktop.m.KeyAction.EXUP, 0x5B]]); // MeshAgent: L-Winkey press, Up arrow press, Up arrow release, L-Winkey release
750
- }
751
- } else if (ks == 2) { // WIN+L arrow
752
- if (desktop.contype == 2) {
753
- desktop.m.sendkey([[0xffe7, 1], [0x6c, 1], [0x6c, 0], [0xffe7, 0]]); // Intel AMT: Meta-left down, 'l' press, 'l' release, Meta-left release
754
- } else {
755
- desktop.sendCtrlMsg('{"action":"lock"}');
756
- //desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN,0x5B],[desktop.m.KeyAction.DOWN,76],[desktop.m.KeyAction.UP,76],[desktop.m.KeyAction.EXUP,0x5B]]); // MeshAgent: L-Winkey press, 'L' press, 'L' release, L-Winkey release
757
- //desktop.m.SendKeyMsgKC(desktop.m.KeyAction.EXDOWN, 0x5B);
758
- //desktop.m.SendKeyMsgKC(desktop.m.KeyAction.DOWN, 76);
759
- //desktop.m.SendKeyMsgKC(desktop.m.KeyAction.UP, 76);
760
- //desktop.m.SendKeyMsgKC(desktop.m.KeyAction.EXUP, 0x5B);
761
- }
762
- } else if (ks == 3) { // WIN+M arrow
763
- if (desktop.contype == 2) {
764
- desktop.m.sendkey([[0xffe7, 1], [0x6d, 1], [0x6d, 0], [0xffe7, 0]]); // Intel AMT: Meta-left down, 'm' press, 'm' release, Meta-left release
765
- } else {
766
- desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN, 0x5B], [desktop.m.KeyAction.DOWN, 77], [desktop.m.KeyAction.UP, 77], [desktop.m.KeyAction.EXUP, 0x5B]]); // MeshAgent: L-Winkey press, 'M' press, 'M' release, L-Winkey release
767
- }
768
- } else if (ks == 4) { // Shift+WIN+M arrow
769
- if (desktop.contype == 2) {
770
- desktop.m.sendkey([[0xffe1, 1], [0xffe7, 1], [0x6d, 1], [0x6d, 0], [0xffe7, 0], [0xffe1, 0]]); // Intel AMT: Shift-left down, Meta-left down, 'm' press, 'm' release, Meta-left release, Shift-left release
771
- } else {
772
- desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.DOWN, 16], [desktop.m.KeyAction.EXDOWN, 0x5B], [desktop.m.KeyAction.DOWN, 77], [desktop.m.KeyAction.UP, 77], [desktop.m.KeyAction.EXUP, 0x5B], [desktop.m.KeyAction.UP, 16]]); // MeshAgent: L-shift press, L-Winkey press, 'M' press, 'M' release, L-Winkey release, L-shift release
773
- }
774
- } else if (ks == 5) { // WIN
775
- if (desktop.contype == 2) {
776
- desktop.m.sendkey([[0xffe7, 1], [0xffe7, 0]]); // Intel AMT: Meta-left down, Meta-left release
777
- } else {
778
- desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN, 0x5B], [desktop.m.KeyAction.EXUP, 0x5B]]); // MeshAgent: L-Winkey press, L-Winkey release
779
- }
780
- } else if (ks == 6) { // WIN+R
781
- if (desktop.contype == 2) {
782
- desktop.m.sendkey([[0xffe7, 1], [0x72, 1], [0x72, 0], [0xffe7, 0]]); // Intel AMT: Meta-left down, 'r' press, 'r' release, Meta-left release
783
- } else {
784
- desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN, 0x5B], [desktop.m.KeyAction.DOWN, 82], [desktop.m.KeyAction.UP, 82], [desktop.m.KeyAction.EXUP, 0x5B]]); // MeshAgent: L-Winkey press, 'R' press, 'R' release, L-Winkey release
785
- }
786
- } else if (ks == 7) { // ALT-F4
787
- if (desktop.contype == 2) {
788
- desktop.m.sendkey([[0xffe9, 1], [0xffc1, 1], [0xffc1, 0], [0xffe9, 0]]); // Intel AMT: Alt down, 'F4' press, 'F4' release, Alt release
789
- } else {
790
- desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN, 18], [desktop.m.KeyAction.DOWN, 115], [desktop.m.KeyAction.UP, 115], [desktop.m.KeyAction.EXUP, 18]]); // MeshAgent: Alt press, 'F4' press, 'F4' release, Alt release
791
- }
792
- } else if (ks == 8) { // CTRL-W
793
- if (desktop.contype == 2) {
794
- desktop.m.sendkey([[0xffe3, 1], [0x77, 1], [0x77, 0], [0xffe3, 0]]); // Intel AMT: Ctrl down, 'w' press, 'w' release, Ctrl release
795
- } else {
796
- desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN, 17], [desktop.m.KeyAction.DOWN, 87], [desktop.m.KeyAction.UP, 87], [desktop.m.KeyAction.EXUP, 17]]); // MeshAgent: Ctrl press, 'W' press, 'W' release, Ctrl release
797
- }
798
- } else if (ks == 9) { // ALT-TAB
799
- if (desktop.contype == 2) {
800
- desktop.m.sendkey([[0xffe9, 1], [0xff09, 1], [0xff09, 0], [0xffe9, 0]]); // Intel AMT: Alt down, 'TAB' press, 'TAB' release, Alt release
801
- } else {
802
- desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN, 18], [desktop.m.KeyAction.DOWN, 9], [desktop.m.KeyAction.UP, 9], [desktop.m.KeyAction.EXUP, 18]]); // MeshAgent: Alt press, 'TAB' press, 'TAB' release, Alt release
803
- }
804
- } else if (ks == 10) { // CTRL-ALT-DEL
805
- desktop.m.sendcad();
806
- } else if (ks == 11) { // WIN-LEFT
807
- if (desktop.contype == 2) {
808
- desktop.m.sendkey([[0xffe7, 1], [0xff51, 1], [0xff51, 0], [0xffe7, 0]]); // Intel AMT: Meta-left down, Left arrow press, Left arrow release, Meta-left release
809
- } else {
810
- desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN, 0x5B], [desktop.m.KeyAction.DOWN, 37], [desktop.m.KeyAction.UP, 37], [desktop.m.KeyAction.EXUP, 0x5B]]);
811
- }
812
- } else if (ks == 12) { // WIN-RIGHT
813
- if (desktop.contype == 2) {
814
- desktop.m.sendkey([[0xffe7, 1], [0xff53, 1], [0xff53, 0], [0xffe7, 0]]); // Intel AMT: Meta-left down, Right arrow press, Right arrow release, Meta-left release
815
- } else {
816
- desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN, 0x5B], [desktop.m.KeyAction.DOWN, 39], [desktop.m.KeyAction.UP, 39], [desktop.m.KeyAction.EXUP, 0x5B]]);
817
- }
818
- }
819
- }
820
-
821
- function ondockeypress(e) {
822
- setSessionActivity();
823
- if (!xxdialogMode && desktop && isInputAllowed()) {
824
- // Check what keys we are allows to send
825
- /*
826
- if (currentNode != null) {
827
- var meshrights = GetNodeRights(currentNode);
828
- var inputAllowed = ((meshrights == 0xFFFFFFFF) || (((meshrights & 8) != 0) && ((meshrights & 256) == 0)));
829
- if (inputAllowed == false) return false;
830
- var limitedInputAllowed = ((meshrights != 0xFFFFFFFF) && (((meshrights & 8) != 0) && ((meshrights & 256) == 0) && ((meshrights & 4096) != 0)));
831
- if (limitedInputAllowed == true) { if ((e.altKey == true) || (e.ctrlKey == true) || ((e.keyCode < 32) && (e.keyCode != 8) && (e.keyCode != 13)) || (e.keyCode > 90)) return false; }
832
- }
833
- */
834
- return desktop.m.handleKeys(e);
835
- }
836
- }
837
-
838
- function ondockeydown(e) {
839
- setSessionActivity();
840
- if (!xxdialogMode && desktop && isInputAllowed()) {
841
- // Check what keys we are allows to send
842
- /*
843
- if (currentNode != null) {
844
- var meshrights = GetNodeRights(currentNode);
845
- var inputAllowed = ((meshrights == 0xFFFFFFFF) || (((meshrights & 8) != 0) && ((meshrights & 256) == 0)));
846
- if (inputAllowed == false) return false;
847
- var limitedInputAllowed = ((meshrights != 0xFFFFFFFF) && (((meshrights & 8) != 0) && ((meshrights & 256) == 0) && ((meshrights & 4096) != 0)));
848
- if (limitedInputAllowed == true) { if ((e.altKey == true) || (e.ctrlKey == true) || ((e.keyCode < 32) && (e.keyCode != 8) && (e.keyCode != 13)) || (e.keyCode > 90)) return false; }
849
- }
850
- */
851
- return desktop.m.handleKeyDown(e);
852
- }
853
- }
854
-
855
- function ondockeyup(e) {
856
- setSessionActivity();
857
- if (!xxdialogMode && desktop && isInputAllowed()) {
858
- // Check what keys we are allows to send
859
- /*
860
- if (currentNode != null) {
861
- var meshrights = GetNodeRights(currentNode);
862
- var inputAllowed = ((meshrights == 0xFFFFFFFF) || (((meshrights & 8) != 0) && ((meshrights & 256) == 0)));
863
- if (inputAllowed == false) return false;
864
- var limitedInputAllowed = ((meshrights != 0xFFFFFFFF) && (((meshrights & 8) != 0) && ((meshrights & 256) == 0) && ((meshrights & 4096) != 0)));
865
- if (limitedInputAllowed == true) { if ((e.altKey == true) || (e.ctrlKey == true) || ((e.keyCode < 32) && (e.keyCode != 8) && (e.keyCode != 13)) || (e.keyCode > 90)) return false; }
866
- }
867
- */
868
- return desktop.m.handleKeyUp(e);
869
- }
870
- }
871
-
872
- // Remote desktop typing
873
- function showDeskType() {
874
- if (xxdialogMode || desktop == null || desktop.State != 3) return;
875
- Q('DeskType').blur();
876
- var x = '<div>' + "Enter text and click OK to remotely type it using a US english keyboard. Make sure to place the remote cursor at the correct position before proceeding." + '<div>';
877
- x += '<textarea id=d2typeText style="margin-top:5px;width:100%;height:184px;resize:none" maxlength=2000></textarea>';
878
- setDialogMode(2, "Remote Keyboard Entry", 3, showDeskTypeEx, x);
879
- Q('d2typeText').focus();
880
- }
881
-
882
- var AmtDeskTypeTimer = null;
883
- var AmtDeskTypeContent = null;
884
- var DeskTypeTranslate = { 39: 222, 42: 106, 43: 107, 44: 188, 45: 189, 46: 190, 47: 191, 59: 186, 61: 187, 91: 219, 92: 220, 93: 221, 96: 192, 191: 111 };
885
- var DeskTypeShiftTranslate = { 33: 49, 34: 222, 35: 51, 36: 52, 37: 53, 38: 55, 40: 57, 41: 48, 58: 186, 60: 188, 62: 190, 63: 191, 64: 50, 94: 54, 95: 189, 106: 56, 107: 187, 123: 219, 124: 220, 125: 221, 126: 192 };
886
- function showDeskTypeEx() {
887
- var txt = Q('d2typeText').value, ltxt = Q('d2typeText').value.toUpperCase(), x = [], shift = false;
888
- if (desktop.contype == 2) {
889
- // Intel AMT
890
- for (var i in txt) { var a = txt.charCodeAt(i); x.push([a, 1], [a, 0]); }
891
- AmtDeskTypeContent = x;
892
- AmtDeskTypeTimer = setInterval(function () {
893
- var key = AmtDeskTypeContent.shift();
894
- if (desktop) { desktop.m.sendkey(key[0], key[1]); }
895
- if ((desktop == null) || (AmtDeskTypeContent.length == 0)) { clearInterval(AmtDeskTypeTimer); AmtDeskTypeContent = null; }
896
- }, 10);
897
- } else {
898
- // MeshAgent
899
- for (var i in txt) {
900
- var a = txt.charCodeAt(i), b = ltxt.charCodeAt(i);
901
- if (((a >= 65) && (a <= 90)) || ((a >= 97) && (a <= 122))) {
902
- if ((a == b) && (shift == false)) { x.push([desktop.m.KeyAction.DOWN, 16]); shift = true; } // LShift down
903
- if ((a != b) && (shift == true)) { x.push([desktop.m.KeyAction.UP, 16]); shift = false; } // LShift up
904
- } else if ((a >= 48) && (a <= 57)) {
905
- if (shift == true) { x.push([desktop.m.KeyAction.UP, 16]); shift = false; } // Shift up
906
- } else if (DeskTypeTranslate[a]) {
907
- if (shift == true) { x.push([desktop.m.KeyAction.UP, 16]); shift = false; } // Shift up
908
- b = DeskTypeTranslate[a];
909
- } else if (DeskTypeShiftTranslate[a]) {
910
- if (shift == false) { x.push([desktop.m.KeyAction.DOWN, 16]); shift = true; } // LShift down
911
- b = DeskTypeShiftTranslate[a];
912
- }
913
- x.push([desktop.m.KeyAction.DOWN, b], [desktop.m.KeyAction.UP, b]);
914
- }
915
- if (shift == true) { x.push([desktop.m.KeyAction.UP, 16]); shift = false; } // Shift up
916
- desktop.m.SendKeyMsgKC(x);
917
- }
918
- }
919
-
920
- /*
921
- // Show clipboard dialog
922
- function showDeskClip() {
923
- if (xxdialogMode || desktop == null || desktop.State != 3) return;
924
- Q('DeskClip').blur();
925
- var x = '';
926
- x += '<input id=dlgClipGet type=button value="Get Clipboard" style=width:120px onclick=showDeskClipGet()>';
927
- x += '<input id=dlgClipSet type=button value="Set Clipboard" style=width:120px onclick=showDeskClipSet()>';
928
- x += '<div id=dlgClipStatus style="display:inline-block;margin-left:8px" ></div>';
929
- x += '<textarea id=d2clipText style="width:100%;height:184px;resize:none" maxlength=65535></textarea>';
930
- x += '<input type=button value="Close" style=width:80px;float:right onclick=dialogclose(0)><div style=height:26px;margin-top:3px><span id=linuxClipWarn style=display:none>' + "Remote clipboard is valid for 60 seconds." + '</span> </div><div></div>';
931
- setDialogMode(2, "Remote Clipboard", 8, null, x, 'clipboard');
932
- Q('d2clipText').focus();
933
- }
934
-
935
- function showDeskClipGet() {
936
- if (desktop == null || desktop.State != 3) return;
937
- meshserver.send({ action: 'msg', type: 'getclip', nodeid: currentNode._id });
938
- }
939
-
940
- function showDeskClipSet() {
941
- if (desktop == null || desktop.State != 3) return;
942
- meshserver.send({ action: 'msg', type: 'setclip', nodeid: currentNode._id, data: Q('d2clipText').value });
943
- //QV('linuxClipWarn', currentNode && currentNode.agent && (currentNode.agent.id > 4) && (currentNode.agent.id != 21) && (currentNode.agent.id != 22));
944
- }
945
- */
946
-
947
- // Send CTRL-ALT-DEL
948
- function sendCAD() {
949
- if (xxdialogMode || desktop == null || desktop.State != 3) return;
950
- desktop.m.sendcad();
951
- }
952
-
953
- /*
954
- // Show process dialogs
955
- function toggleDeskTools() {
956
- if (xxdialogMode) return;
957
- if (QS('DeskTools').display == 'none') {
958
- QV('DeskTools', true);
959
- Q('DeskTools').nodeid = currentNode._id;
960
- QH('DeskToolsProcesses', '');
961
- QH('DeskToolsServices', '');
962
- QV('deskToolsTopTabService', false);
963
- changeDeskToolTab(0)
964
- refreshDeskTools(0);
965
- refreshDeskTools(1);
966
- } else {
967
- QV('DeskTools', false);
968
- }
969
- }
970
-
971
- var deskToolTabSelection = 0;
972
- function changeDeskToolTab(tabnum) {
973
- deskToolTabSelection = tabnum;
974
- QV('DeskToolsProcessTab', tabnum == 0);
975
- QV('DeskToolsServiceTab', tabnum == 1);
976
- QS('deskToolsTopTabProcess')['bottom'] = (tabnum == 0) ? '0px' : '3px';
977
- QS('deskToolsTopTabService')['bottom'] = (tabnum == 1) ? '0px' : '3px';
978
- QS('deskToolsTopTabProcess')['color'] = (tabnum == 0) ? 'black' : 'gray';
979
- QS('deskToolsTopTabService')['color'] = (tabnum == 1) ? 'black' : 'gray';
980
- }
981
-
982
- // Refresh all of the desktop tool panels
983
- function refreshDeskTools(x) {
984
- var sel = (x == null) ? deskToolTabSelection : x;
985
- QV('DeskToolsRefreshButton', false);
986
- setTimeout(refreshDeskToolsEx, 500);
987
- if (sel == 0) meshserver.send({ action: 'msg', type: 'ps', nodeid: currentNode._id });
988
- if (sel == 1) meshserver.send({ action: 'msg', type: 'services', nodeid: currentNode._id });
989
- }
990
- function refreshDeskToolsEx() { QV('DeskToolsRefreshButton', true); }
991
- var deskTools = { sort: 1, ssort: 1, msg: null, smsg: null };
992
- function sortProcess(sort) { deskTools.sort = sort; showDeskToolsProcesses(deskTools.msg); }
993
- function sortService(sort) { deskTools.ssort = sort; showDeskToolsServices(deskTools.smsg); }
994
- function sortProcessPid(a, b) { if (a.p > b.p) return 1; if (a.p < b.p) return (-1); return sortProcessName(a, b); }
995
- function sortProcessName(a, b) { if (a.d > b.d) return 1; if (a.d < b.d) return (-1); return 0; }
996
- function showDeskToolsProcesses(message) {
997
- deskTools.msg = message;
998
- if (message == null) { QH('DeskToolsProcesses', ''); return; }
999
- if (Q('DeskTools').nodeid != message.nodeid) return;
1000
- var p = [], processes = null;
1001
- try { processes = JSON.parse(message.value); } catch (e) { }
1002
- if (processes != null) {
1003
- for (var pid in processes) { p.push({ p: parseInt(pid), c: processes[pid].cmd, d: processes[pid].cmd.toLowerCase(), u: processes[pid].user }); }
1004
- if (deskTools.sort == 0) { p.sort(sortProcessPid); } else if (deskTools.sort == 1) { p.sort(sortProcessName); }
1005
- var x = '';
1006
- for (var i in p) {
1007
- if (p[i].p != 0) {
1008
- var c = p[i].c;
1009
- if (c.length > 30) { c = '<span title="' + EscapeHtml(c) + '">' + EscapeHtml(c.substring(0, 30)) + '...</span>' } else { c = EscapeHtml(c); }
1010
- x += '<div class=deskToolsBar><div style=width:50px;float:left;text-align:right;padding-right:5px>' + EscapeHtml(p[i].p) + '</div><a href=# style=float:right;padding-right:5px;cursor:pointer title="' + "Stop process" + '" onclick=\'return stopProcess(' + EscapeHtml(p[i].p) + ',"' + EscapeHtml(p[i].c) + '")\'><img width=10 height=10 src="images/trash.png"></a><div style=float:right;padding-right:5px>' + (p[i].u ? EscapeHtml(p[i].u) : '') + '</div><div>' + c + '</div></div>';
1011
- }
1012
- }
1013
- QH('DeskToolsProcesses', x);
1014
- }
1015
- }
1016
- function showDeskToolsServices(message) {
1017
- deskTools.smsg = message;
1018
- if (message == null) { QH('DeskToolsProcesses', ''); return; }
1019
- if (Q('DeskTools').nodeid != message.nodeid) return;
1020
- QV('deskToolsTopTabService', true);
1021
- var s = [], services = null;
1022
- try { services = JSON.parse(message.value); } catch (e) { }
1023
- deskTools.services = services;
1024
- if (services != null) {
1025
- for (var i in services) {
1026
- if (services[i].status) {
1027
- // Windows
1028
- s.push({ p: capitalizeFirstLetter(services[i].status.state.toLowerCase()), d: services[i].displayName, i: i });
1029
- } else if (services[i].serviceType) {
1030
- // Linux (TODO: This the service status is not displayed, not sure start/stop/restart will work).
1031
- s.push({ p: services[i].serviceType, d: services[i].name, i: i });
1032
- }
1033
- }
1034
- if (deskTools.ssort == 0) { s.sort(sortProcessPid); } else if (deskTools.ssort == 1) { s.sort(sortProcessName); }
1035
- var x = '';
1036
- for (var i in s) {
1037
- if (s[i].p != 0) {
1038
- var c = s[i].d;
1039
- if (c.length > 30) { c = '<span title="' + c + '">' + c.substring(0, 30) + '...</span>' } else { c = EscapeHtml(c); }
1040
- x += '<div onclick=showServiceDetailsDialog(' + s[i].i + ') class=deskToolsBar><div style=width:70px;float:left;padding-right:5px>' + EscapeHtml(s[i].p) + '</div><div>' + c + '</div></div>';
1041
- }
1042
- }
1043
- QH('DeskToolsServices', x);
1044
- }
1045
- }
1046
-
1047
- function showServiceDetailsDialog(index) {
1048
- if (xxdialogMode) return;
1049
- var service = deskTools.services[index];
1050
- if (service != null) {
1051
- var x = '';
1052
- if (service.name) { x += addHtmlValue("Name", service.name); }
1053
- if (service.displayName) { x += addHtmlValue("Display name", service.displayName); }
1054
- if (service.status) {
1055
- if (service.status.state) { x += addHtmlValue("State", capitalizeFirstLetter(service.status.state.toLowerCase())); }
1056
- if (service.status.pid) { x += addHtmlValue("PID", service.status.pid); }
1057
- var serviceTypes = [];
1058
- if (service.status.isFileSystemDriver === true) { serviceTypes.push("FileSystemDriver"); }
1059
- if (service.status.isInteractive === true) { serviceTypes.push("Interactive"); }
1060
- if (service.status.isKernelDriver === true) { serviceTypes.push("KernelDriver"); }
1061
- if (service.status.isOwnProcess === true) { serviceTypes.push("OwnProcess"); }
1062
- if (service.status.isSharedProcess === true) { serviceTypes.push("SharedProcess"); }
1063
- if (serviceTypes.length > 0) { x += addHtmlValue("Type", serviceTypes.join(', ')); }
1064
- }
1065
- x += '<br/><div style=float:right;margin-bottom:12px><input type=button value="' + "Close" + '" onclick=showServiceDetailsDialogEx(0,' + index + ')></div><div style=margin-bottom:12px><input type=button value="' + "Start" + '" onclick=showServiceDetailsDialogEx(1,' + index + ')><input type=button value="' + "Stop" + '" onclick=showServiceDetailsDialogEx(2,' + index + ')><input type=button value="' + "Restart" + '" onclick=showServiceDetailsDialogEx(3,' + index + ')></div>';
1066
- setDialogMode(2, "Service Details", 8, null, x, name);
1067
- }
1068
- }
1069
-
1070
- function showServiceDetailsDialogEx(action, index) {
1071
- setDialogMode(0);
1072
- if (action == 0) return;
1073
- var service = deskTools.services[index];
1074
- if (service != null) {
1075
- if (action == 1) { meshserver.send({ action: 'msg', type: 'serviceStart', nodeid: currentNode._id, serviceName: service.name }); }
1076
- if (action == 2) { meshserver.send({ action: 'msg', type: 'serviceStop', nodeid: currentNode._id, serviceName: service.name }); }
1077
- if (action == 3) { meshserver.send({ action: 'msg', type: 'serviceRestart', nodeid: currentNode._id, serviceName: service.name }); }
1078
- setTimeout(function () { refreshDeskTools(1) }, 1000);
1079
- }
1080
- }
1081
- */
1082
-
1083
- // Toggle mouse and keyboard input
1084
- function toggleKvmControl() { QS('DeskControlSpan').color = Q('DeskControl').checked ? null : 'red'; }
1085
-
1086
- // Save the desktop image to file
1087
- function deskSaveImage() {
1088
- if (xxdialogMode || desktop == null || desktop.State != 3) return;
1089
- var d = new Date(), n = "Desktop" + '-' + d.getFullYear() + '-' + ('0' + (d.getMonth() + 1)).slice(-2) + '-' + ('0' + d.getDate()).slice(-2) + '-' + ('0' + d.getHours()).slice(-2) + '-' + ('0' + d.getMinutes()).slice(-2);
1090
- Q('Desk')['toBlob'](function (blob) { saveAs(blob, n + '.png'); });
1091
- }
1092
-
1093
- function deskDisplayInfo(sender, displays, selDisplay) {
1094
- var displayCount = 0, displaySelector = '';
1095
- for (var i in displays) {
1096
- displayCount++;
1097
- displaySelector += '<option' + ((selDisplay == i) ? ' selected' : '') + ' value=' + i + '>' + displays[i] + '</option>';
1098
- if ((deskPreferedStickyDisplay == i) && (selDisplay != deskPreferedStickyDisplay)) { desktop.m.SetDisplay(i); }
1099
- deskPreferedStickyDisplay = -1;
1100
- }
1101
- QH('termdisplays', displaySelector);
1102
- QV('termdisplays', displayCount > 1);
1103
- }
1104
-
1105
- function deskGetDisplayNumbers(e) { desktop.m.GetDisplayNumbers(); }
1106
- var deskPreferedStickyDisplay = -1;
1107
- function deskSetDisplay(e) { desktop.m.SetDisplay(deskPreferedStickyDisplay = parseInt(Q('termdisplays').value)); Q('termdisplays').blur(); }
1108
-
1109
- // Double click detection. This is important for macOS.
1110
- var dblClickDetectArgs = { t: 0, x: 0, y: 0 };
1111
- function dblClickDetect(e) {
1112
- if (e.buttons != 1) return;
1113
- var t = Date.now();
1114
- if (((t - dblClickDetectArgs.t) < 250) && (Math.abs(e.clientX - dblClickDetectArgs.x) < 2) && (Math.abs(e.clientY - dblClickDetectArgs.y) < 2)) {
1115
- if (!xxdialogMode && desktop != null && isInputAllowed()) { if ((webRtcDesktop != null) && (webRtcDesktop.softdesktop != null)) { webRtcDesktop.softdesktop.m.mousedblclick(e); desktop.m.sendKeepAlive(); } else { desktop.m.mousedblclick(e); } }
1116
- }
1117
- dblClickDetectArgs.t = t;
1118
- dblClickDetectArgs.x = e.clientX;
1119
- dblClickDetectArgs.y = e.clientY;
1120
- }
1121
-
1122
- function dmousedown(e) { setSessionActivity(); e.addx = Q('DeskParent').scrollLeft; e.addy = Q('DeskParent').scrollTop; if (!xxdialogMode && desktop != null && isInputAllowed()) { if ((webRtcDesktop != null) && (webRtcDesktop.softdesktop != null)) { webRtcDesktop.softdesktop.m.mousedown(e); desktop.m.sendKeepAlive(); } else { desktop.m.mousedown(e); } } dblClickDetect(e); }
1123
- function dmouseup(e) { setSessionActivity(); e.addx = Q('DeskParent').scrollLeft; e.addy = Q('DeskParent').scrollTop; if (!xxdialogMode && desktop != null && isInputAllowed()) if ((webRtcDesktop != null) && (webRtcDesktop.softdesktop != null)) { webRtcDesktop.softdesktop.m.mouseup(e); desktop.m.sendKeepAlive(); } else { desktop.m.mouseup(e); } }
1124
- function dmousemove(e) { setSessionActivity(); e.addx = Q('DeskParent').scrollLeft; e.addy = Q('DeskParent').scrollTop; if (!xxdialogMode && desktop != null && isInputAllowed()) { if ((webRtcDesktop != null) && (webRtcDesktop.softdesktop != null)) { webRtcDesktop.softdesktop.m.mousemove(e); desktop.m.sendKeepAlive(); } else { desktop.m.mousemove(e); } } }
1125
- function dmousewheel(e) { setSessionActivity(); e.addx = Q('DeskParent').scrollLeft; e.addy = Q('DeskParent').scrollTop; if (!xxdialogMode && desktop != null && isInputAllowed()) { if ((webRtcDesktop != null) && (webRtcDesktop.softdesktop != null)) { webRtcDesktop.softdesktop.m.mousewheel(e); desktop.m.sendKeepAlive(); } else { if (desktop.m.mousewheel) { desktop.m.mousewheel(e); } } haltEvent(e); return true; } return false; }
1126
- function drotate(x) { if (!xxdialogMode && desktop != null) { desktop.m.setRotation(desktop.m.rotation + x); deskAdjust(); deskAdjust(); } }
1127
- function stopProcess(id, name) { setDialogMode(2, "Process Control", 3, stopProcessEx, format("Stop process #{0} \"{1}\"?", id, name), id); return false; }
1128
- function stopProcessEx(buttons, tag) { meshserver.send({ action: 'msg', type: 'pskill', nodeid: currentNode._id, value: tag }); setTimeout(refreshDeskTools, 300); }
1129
-
1130
- //
1131
- // POPUP DIALOG
1132
- //
1133
-
1134
- // null = Hidden, 1 = Generic Message
1135
- var xxdialogMode;
1136
- var xxdialogFunc;
1137
- var xxdialogButtons;
1138
- var xxdialogTag;
1139
- var xxcurrentView = -1;
1140
-
1141
- // Display a dialog box
1142
- // Parameters: Dialog Mode (0 = none), Dialog Title, Buttons (1 = OK, 2 = Cancel, 3 = OK & Cancel), Call back function(0 = Cancel, 1 = OK), Dialog Content (Mode 2 only)
1143
- function setDialogMode(x, y, b, f, c, tag) {
1144
- xxdialogMode = x;
1145
- xxdialogFunc = f;
1146
- xxdialogButtons = b;
1147
- xxdialogTag = tag;
1148
- QE('idx_dlgOkButton', true);
1149
- QV('idx_dlgOkButton', b & 1);
1150
- QV('idx_dlgCancelButton', b & 2);
1151
- QV('id_dialogclose', (b & 2) || (b & 8));
1152
- QV('idx_dlgDeleteButton', b & 4);
1153
- QV('idx_dlgButtonBar', b & 7);
1154
- if (y) QH('id_dialogtitle', y);
1155
- for (var i = 1; i < 8; i++) { QV('dialog' + i, i == x); } // Edit this line when more dialogs are added
1156
- QV('dialog', x);
1157
- if (c) { if (x == 2) { QH('id_dialogOptions', c); } else { QH('id_dialogMessage', c); } }
1158
- }
1159
-
1160
- function dialogclose(x) {
1161
- var f = xxdialogFunc, b = xxdialogButtons, t = xxdialogTag;
1162
- setDialogMode();
1163
- if (((b & 8) || x) && f) f(x, t);
1164
- }
1165
-
1166
- function messagebox(t, m) { setSessionActivity(); QH('id_dialogMessage', m); setDialogMode(1, t, 1); }
1167
- function statusbox(t, m) { setSessionActivity(); QH('id_dialogMessage', m); setDialogMode(1, t); }
1168
- function haltEvent(e) { if (e.preventDefault) e.preventDefault(); if (e.stopPropagation) e.stopPropagation(); return false; }
1169
- function pad2(num) { var s = '00' + num; return s.substr(s.length - 2); }
1170
- function format(format) { var args = Array.prototype.slice.call(arguments, 1); return format.replace(/{(\d+)}/g, function (match, number) { return typeof args[number] != 'undefined' ? args[number] : match; }); };
1171
- function setSessionActivity() { sessionActivity = Date.now(); /*QH('idleTimeoutNotify', '');*/ }
1172
- function printDate(d) { return d.toLocaleDateString(urlargs.locale); }
1173
- function printTime(d) { return d.toLocaleTimeString(urlargs.locale); }
1174
- function printDateTime(d) { return d.toLocaleString(urlargs.locale); }
1175
- function printFlexDateTime(d) { if (printDate(new Date()) == printDate(d)) { return format("Expires at {0}", printTime(d)); } else { return format("Expires {0}", printDateTime(d)); } }
1176
-
1177
- start();
1178
- </script>
1179
-</body>
1180
-</html>
\ No newline at end of file
views/sharing.handlebars
+13
@@ -245,6 +245,13 @@
245
<option value=1000>Very slow</option>
246
</select>
247
</div>
248
+ <div id="d7desktopOtherSettings">
249
+ <div>Other Settings</div>
250
+ <div id="d7otherset2" style="display:block">
251
+ <label style="display:block"><input type="checkbox" id="d7deskSwapMouse" />Swap Mouse Buttons</label>
252
+ <label style="display:block"><input type="checkbox" id="d7deskRemoteKeyMap" />Use Remote Keyboard Map</label>
253
+ </div>
254
+ </div>
255
</div>
256
<div id="d7amtkvm">
257
<h4>Intel® AMT Hardware KVM</h4>
@@ -744,11 +751,15 @@
751
desktopsettings.quality = d7bitmapquality.value;
752
desktopsettings.scaling = d7bitmapscaling.value;
753
desktopsettings.framerate = d7framelimiter.value;
754
+ desktopsettings.swapmouse = d7deskSwapMouse.checked;
755
+ desktopsettings.remotekeymap = d7deskRemoteKeyMap.checked;
756
desktopsettings.localkeymap = d7localKeyMap.checked;
757
localStorage.setItem('desktopsettings', JSON.stringify(desktopsettings));
758
applyDesktopSettings();
759
if (desktop) {
760
if (desktop.contype == 1) {
761
+ desktop.m.SwapMouse = desktopsettings.swapmouse;
762
+ desktop.m.remoteKeyMap = desktopsettings.remotekeymap;
763
if (desktop.State != 0) {
764
desktop.m.SendCompressionLevel(1, desktopsettings.quality, desktopsettings.scaling, desktopsettings.framerate);
765
}
@@ -770,6 +781,8 @@
781
if (ops.indexOf(parseInt(desktopsettings.quality)) >= 0) { d7bitmapquality.value = desktopsettings.quality; }
782
d7bitmapscaling.value = desktopsettings.scaling;
783
if (desktopsettings.framerate) { d7framelimiter.value = desktopsettings.framerate; } else { d7framelimiter.value = 100; }
784
+ if (desktopsettings.swapmouse != null) { d7deskSwapMouse.checked = desktopsettings.swapmouse; }
785
+ if (desktopsettings.remotekeymap != null) { d7deskRemoteKeyMap.checked = desktopsettings.remotekeymap; }
786
if (desktopsettings.localkeymap) { d7localKeyMap.checked = desktopsettings.localkeymap; }
787
}
788
views/terminal.handlebars
deleted
-454
@@ -1,454 +0,0 @@
1
-<!DOCTYPE html>
2
-<html lang="en" dir="ltr" xmlns="http://www.w3.org/1999/xhtml">
3
-<head>
4
- <meta http-equiv="X-UA-Compatible" content="IE=edge" />
5
- <meta content="text/html;charset=utf-8" http-equiv="Content-Type" />
6
- <meta name="viewport" content="user-scalable=1.0,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0" />
7
- <meta name="apple-mobile-web-app-capable" content="yes" />
8
- <meta name="format-detection" content="telephone=no" />
9
- <meta name="robots" content="noindex,nofollow">
10
- <link type="text/css" href="styles/style.css" media="screen" rel="stylesheet" title="CSS" />
11
- <link type="text/css" href="styles/xterm.css" media="screen" rel="stylesheet" title="CSS" />
12
- <link rel="apple-touch-icon" href="/favicon-303x303.png" />
13
- <script type="text/javascript" src="scripts/common-0.0.1{{min}}.js"></script>
14
- <script type="text/javascript" src="scripts/amt-redir-ws-0.1.0{{{min}}}.js"></script>
15
- <script type="text/javascript" src="scripts/amt-wsman-ws-0.2.0{{{min}}}.js"></script>
16
- <script type="text/javascript" src="scripts/agent-redir-ws-0.1.1{{{min}}}.js"></script>
17
- <script type="text/javascript" src="scripts/agent-redir-rtc-0.1.0{{{min}}}.js"></script>
18
- <script type="text/javascript" src="scripts/amt-terminal-0.0.2{{min}}.js"></script>
19
- <script type="text/javascript" src="scripts/xterm{{{min}}}.js"></script>
20
- <script type="text/javascript" src="scripts/xterm-addon-fit{{{min}}}.js"></script>
21
- <script keeplink=1 type="text/javascript" src="scripts/filesaver.min.js"></script>
22
- <title>{{{title}}}</title>
23
-</head>
24
-<body style="overflow:hidden;background-color:black">
25
- <div id=p12 style="overflow:hidden">
26
- <div id="p12warning" onclick=showFeaturesDlg()>
27
- <div class="icon2"></div>
28
- <div class="warningbox">Intel® AMT Redirection port or KVM feature is disabled<span id="p12warninga">, click here to enable it.</span></div>
29
- </div>
30
- <div id="p12warning2" onclick=showPowerActionDlg()>
31
- <div class="icon2"></div>
32
- <div class="warningbox">Remote computer is not powered on, click here to issue a power command.</div>
33
- </div>
34
- <div class="areaHead" style="position:absolute;top:0;left:0;right:0;height:24px">
35
- <div class="toright2">
36
- <div id="p11power" style="margin-top:3px;margin-right:4px"></div>
37
- <div id="termRecordIcon" class='deskareaicon' title="Server is recording this session" style="display:none;background-color:red;width:12px;height:12px;border-radius:6px;margin-top:5px;margin-left:5px"></div>
38
- <div id="terminalCustomUiButtons" style="float:left"></div>
39
- </div>
40
- <div>
41
- <div id="idx_termFullBtn2" onclick=deskToggleFull(event)> ✖</div>
42
- <span id="connectbutton2span"><input type="button" id="connectbutton2" cmenu="termConnectButton" value="Connect" onclick=connectTerminal(event,1) onkeypress="return false" onkeydown="return false" disabled="disabled" /></span>
43
- <span id="disconnectbutton2span"> <input type="button" id="disconnectbutton2" value="Disconnect" onclick=connectTerminal(event,0) onkeypress="return false" onkeydown="return false" /></span>
44
- <span id="termstatus">Disconnected</span><span id="termtitle"></span>
45
- </div>
46
- </div>
47
- <div id="termarea3xdiv" style="position:absolute;top:28px;bottom:28px;left:0;right:0"></div>
48
- <div class="areaFoot" style="position:absolute;bottom:0;left:0;right:0;height:24px">
49
- <div class="toright2">
50
- <span id="TermLatency" title="Terminal Session Latency"></span>
51
- <span id="TermTimer" title="Session time"></span>
52
- <span id="terminalSettingsButtons" style="display:none">
53
- <input id="id_tcrbutton" type="button" onkeypress="return false" onkeydown="return false" class="bottombutton" value="CR+LF" title="Toggle what the return key will send" onclick="termToggleCr()" />
54
- <input id="id_tfxkeysbutton" type="button" onkeypress="return false" onkeydown="return false" class="bottombutton" value="Intel (F10 = ESC+[OM)" title="Toggle F1 to F10 keys emulation type" onclick="termToggleFx()" />
55
- <input id="id_ttypebutton" type="button" onkeypress="return false" onkeydown="return false" class="bottombutton" value="Extended Ascii" title="Toggle terminal emulation type" onclick="termToggleType()" />
56
- </span>
57
- <span id="terminalSizeDropDown" style="display:none">
58
- <select id="termSizeList" onkeypress="return false"><option value="1">80x25</option><option value="2">100x30</option></select>
59
- </span>
60
- <span id="specialKeyDropDown">
61
- <select id="specialkeylist" onkeypress="return false"></select>
62
- <input id="specialkeylistinput" type="button" onkeypress="return false" class="bottombutton" value="Send" title="Send the selected special key" onclick="sendSpecialKey()" />
63
- </span>
64
- </div>
65
- <div>
66
-
67
- <input type=button onkeypress="return false" onkeydown="return false" class="bottombutton" id="ctrlcbutton" value="Ctl-C" onclick="termSendKey(3,'ctrlcbutton')" />
68
- <input type=button onkeypress="return false" onkeydown="return false" class="bottombutton" id="ctrlxbutton" value="Ctl-X" onclick="termSendKey(24,'ctrlxbutton')" />
69
- <input type=button onkeypress="return false" onkeydown="return false" class="bottombutton" id="escbutton" value="ESC" onclick="termSendKey(27,'escbutton')" />
70
- <input type=button onkeypress="return false" onkeydown="return false" class="bottombutton" id="bsbutton" value="Backspace" onclick="termSendKey(8,'bsbutton')" style="display:none" />
71
- <input type=button onkeypress="return false" onkeydown="return false" class="bottombutton" id="pastebutton" value="Paste" title="Paste text into the terminal" onclick="showTermPasteDialog()" style="display:none" />
72
- </div>
73
- </div>
74
- <div id=p12TermConsoleMsg style="display:none;cursor:pointer;position:absolute;left:30px;top:45px;color:yellow;background-color:rgba(0,0,0,0.6);padding:10px;border-radius:5px" onclick=p12clearConsoleMsg()></div>
75
- <div id=dialog class="noselect" style="display:none">
76
- <div id=dialogHeader>
77
- <div tabindex=0 id=id_dialogclose onclick=setDialogMode() onkeypress="if (event.key == 'Enter') setDialogMode()">✖</div>
78
- <div id=id_dialogtitle></div>
79
- </div>
80
- <div id=dialogBody>
81
- <div id=dialog1>
82
- <div id=id_dialogMessage style=""></div>
83
- </div>
84
- <div id=dialog2 style="">
85
- <div id=id_dialogOptions></div>
86
- </div>
87
- </div>
88
- <div id="idx_dlgButtonBar">
89
- <input id="idx_dlgCancelButton" type="button" value="Cancel" style="" onclick="dialogclose(0)">
90
- <input id="idx_dlgOkButton" type="button" value="OK" style="" onclick="dialogclose(1)">
91
- <div><input id="idx_dlgDeleteButton" type="button" value="Delete" style="display:none" onclick="dialogclose(2)"></div>
92
- </div>
93
- </div>
94
- </div>
95
- <script>
96
- var sessionActivity = null;
97
- var desktop = null;
98
- var agentPresent = true;
99
- var intelAmtPresent = false;
100
- var p11DeskConsoleMsgTimer = null;
101
- var serverPublicNamePort = '{{{serverDnsName}}}:{{{serverPublicPort}}}';
102
- var domain = '{{{domain}}}';
103
- var domainUrl = '{{{domainurl}}}';
104
- var authCookie = '{{{authCookie}}}';
105
- var urlargs = parseUriArgs();
106
- var debugmode = urlargs.debug;
107
- var attemptWebRTC = false;
108
- var updateSessionTimer = null;
109
- var StatusStrs = ["Disconnected", "Connecting...", "Setup...", "Connected", "Intel® AMT Connected"];
110
- var webPageFullScreen = false;
111
- var terminal = null;
112
- var p12TermConsoleMsgTimer = null;
113
- var xterm = null;
114
- var xtermfit = null;
115
- var xtermResizeTimer = null;
116
- var expire = '{{{expire}}}';
117
- if (expire != '') { QH('p11power', printFlexDateTime(new Date(parseInt(expire)))); }
118
-
119
- function start() {
120
- //window.onresize = deskAdjust;
121
- //document.onkeypress = ondockeypress;
122
- //document.onkeydown = ondockeydown;
123
- //document.onkeyup = ondockeyup;
124
- updateTerminalButtons();
125
-
126
- window.onresize = function () { if (xtermfit != null) { xtermfit.fit(); } }
127
-
128
- // Terminal special keys
129
- var x = '';
130
- for (var c = 1; c < 27; c++) x += '<option value=\'' + c + '\'>' + "Ctrl" + '-' + String.fromCharCode(64 + c) + ' (' + c + ')</option>';
131
- QH('specialkeylist', x);
132
- }
133
-
134
-
135
-
136
- var terminalNode;
137
- function setupTerminal() {
138
- // Setup the terminal
139
- if ((terminalNode != currentNode) && (terminal != null)) { terminal.Stop(); terminal = null; }
140
- terminalNode = currentNode;
141
- updateTerminalButtons();
142
- }
143
-
144
- // Show and enable the right buttons
145
- function updateTerminalButtons() {
146
- var termState = ((terminal != null) && (terminal.state != 0));
147
-
148
- // Show the right buttons
149
- QV('disconnectbutton2span', termState == true);
150
- QV('connectbutton2span', termState == false);
151
- //QV('terminalSizeDropDown', termState == false);
152
-
153
- // Enable buttons
154
- QE('connectbutton2', true);
155
-
156
- // Key buttons
157
- QE('ctrlcbutton', termState);
158
- QE('ctrlxbutton', termState);
159
- QE('escbutton', termState);
160
- QE('bsbutton', termState);
161
- QE('pastebutton', termState);
162
- QE('specialkeylist', termState);
163
- QE('specialkeylistinput', termState);
164
-
165
- // Terminal settings
166
- QV('terminalSettingsButtons', (terminal) && (terminal.contype == 2));
167
- if (terminal) {
168
- Q('id_ttypebutton').value = terminalEmulations[terminal.m.terminalEmulation];
169
- Q('id_tfxkeysbutton').value = fxEmulations[terminal.m.fxEmulation];
170
- Q('id_tcrbutton').value = (terminal.m.lineFeed == '\r\n') ? "CR+LF" : "LF";
171
- }
172
-
173
- // Display extra buttons on legacy terminal
174
- var xtermActive = true;
175
- QV('termarea3xdiv', xtermActive);
176
- QV('bsbutton', !xtermActive);
177
- QV('pastebutton', !xtermActive);
178
- QV('devListToolbarViewIcons2', xtermActive);
179
- QE('termSizeList', terminal == null);
180
- }
181
-
182
- // Called when the terminal state changes
183
- function onTerminalStateChange(xterminal, state) {
184
- var xstate = state;
185
- if ((xstate == 3) && (xterminal.contype == 2)) { xstate++; }
186
- var str = StatusStrs[xstate];
187
- if (terminal.webRtcActive == true) { str += ", WebRTC"; }
188
- QH('termstatus', str);
189
- switch (state) {
190
- case 0:
191
- // Disconnected, clear the terminal
192
- QH('termtitle', '');
193
- QV('termRecordIcon', false);
194
- if (xterm == null) {
195
- xterminal.m.TermResetScreen();
196
- xterminal.m.TermDraw();
197
- } else {
198
- xterm.dispose();
199
- xterm = xtermfit = null;
200
- }
201
- if (terminal != null) { terminal.Stop(); terminal = null; }
202
- break;
203
- case 3:
204
- if (xterminal && (xterminal.serverIsRecording == true)) { QV('termRecordIcon', true); }
205
- terminal.startTime = new Date();
206
- if (updateSessionTimer == null) { updateSessionTimer = setInterval(updateSessionTime, 1000); }
207
- if (xterm != null) { xterm.focus(); }
208
- break;
209
- default:
210
- //console.log('Unhandled onTerminalStateChange state', state);
211
- break;
212
- }
213
- updateTerminalButtons();
214
- }
215
-
216
- function updateSessionTime() {
217
- // Terminal
218
- var latencyStr = '', seconds = 0;
219
- if (terminal && terminal.startTime) {
220
- if (terminal.latency && (terminal.latency.current >= 0)) { latencyStr = format('{0} ms, ', terminal.latency.current); }
221
- seconds = Math.floor((new Date() - terminal.startTime) / 1000);
222
- QH('TermTimer', latencyStr + zeroPad(Math.floor(seconds / 3600), 2) + ':' + zeroPad((Math.floor(seconds / 60) % 60), 2) + ':' + zeroPad((seconds % 60), 2));
223
- } else {
224
- QH('TermTimer', '');
225
- }
226
-
227
- if (terminal == null) { clearInterval(updateSessionTimer); updateSessionTimer = null; }
228
- }
229
-
230
- // DEBUG
231
- var autoConnectTerminalTimer = null;
232
- function autoConnectTerminal(e) { if (autoConnectTerminalTimer == null) { autoConnectTerminalTimer = setInterval(connectTerminal, 100); } else { clearInterval(autoConnectTerminalTimer); autoConnectTerminalTimer = null; } }
233
-
234
- // Handles a tunnel to a remote shell
235
- function CreateRemoteTunnel(onTunnelUpdate, options) {
236
- var obj = { protocol: 1 };
237
- if ((options != null) && (typeof options.protocol == 'number')) { obj.protocol = options.protocol; }
238
- obj.onTunnelUpdate = onTunnelUpdate;
239
- obj.xxStateChange = function (state) { }
240
- obj.ProcessBinaryData = function (data) { obj.onTunnelUpdate(data); }
241
- obj.ProcessData = function (data) { obj.onTunnelUpdate(data); }
242
- obj.terminalEmulation = 1;
243
- obj.fxEmulation = 0;
244
- obj.lineFeed = '\r\n';
245
- return obj;
246
- }
247
-
248
- function tunnelUpdate(data) { if (typeof data == 'string') { xterm.writeUtf8(data); } else { xterm.writeUtf8(new Uint8Array(data)); } }
249
-
250
- // Send the new terminal size to the agent
251
- function xTermSendResize() {
252
- xtermResizeTimer = null;
253
- if ((xterm != null) && (terminal != null) && (terminal.sendCtrlMsg != null)) { terminal.sendCtrlMsg(JSON.stringify({ ctrlChannel: '102938', type: 'termsize', cols: xterm.cols, rows: xterm.rows })); }
254
- }
255
-
256
- // Used to translate incoming agent console messages
257
- var agentConsoleMessages = ['', "Waiting for user to grant access...", "Denied", "Failed to start remote terminal session, {0} ({1})", "Timeout", "Received invalid network data"];
258
- function formatAgentConsoleMessage(msg, msgid, msgargs) {
259
- var r;
260
- if (msgargs == null) { msgargs = []; }
261
- while (msgargs.length < 3) { msgargs.push(''); } // We need to call the format function in a way that works with older browsers and minifier, can't use apply() or ...
262
- if (msgid && (msgid < agentConsoleMessages.length)) { r = EscapeHtml(format(agentConsoleMessages[msgid], (msgargs[0]), (msgargs[1]), (msgargs[2]))); } else { r = EscapeHtml(msg); }
263
- return r.split('\n').join('<br />') + '<br /><br />';
264
- }
265
-
266
- function connectTerminal(e, contype, options) {
267
- p12clearConsoleMsg();
268
- if (!terminal) {
269
- // Terminal setup
270
- var termoptions = { protocol: ((options != null) && (typeof options.protocol == 'number')) ? options.protocol : 1 };
271
- if (options && options.requireLogin) { termoptions.requireLogin = true; }
272
- /*
273
- if ([1, 2, 3, 4, 21, 22].indexOf(currentNode.agent.id) == -1) {
274
- if (Q('termSizeList').value == 1) { termoptions.cols = 80; termoptions.rows = 25; termoptions.xterm = true; }
275
- else if (Q('termSizeList').value == 2) { termoptions.cols = 100; termoptions.rows = 30; termoptions.xterm = true; }
276
- else if (Q('termSizeList').value == 3) {
277
- // TODO: Try to improve terminal auto-size.
278
- termoptions.cols = Math.floor((Q('column_l').clientWidth - 60) / 10);
279
- termoptions.rows = Math.floor((Q('column_l').clientHeight - 120) / 20);
280
- termoptions.xterm = true;
281
- }
282
- }
283
- */
284
-
285
- // If shift is pressed
286
- if ((e && (e.shiftKey == true))) {
287
- if (currentNode.agent.id > 4) {
288
- if (termoptions.protocol == 1) { termoptions.protocol = 7; } // Switch to user shell
289
- } else {
290
- if (termoptions.protocol == 1) { termoptions.protocol = 6; } // Switch to Powershell
291
- }
292
- }
293
-
294
- // Setup a mesh agent xterm terminal
295
- QV('termarea3xdiv', true);
296
-
297
- // Setup the terminal with auto-fit
298
- if (xterm != null) { xterm.dispose(); }
299
- xtermfit = new FitAddon.FitAddon();
300
- xterm = new Terminal();
301
- if (xtermfit) { xterm.loadAddon(xtermfit); }
302
- xterm.open(Q('termarea3xdiv')); // termarea3x
303
- xterm.onData(function (data) { if (terminal != null) { terminal.sendText(data); } })
304
- if (xtermfit) { xtermfit.fit(); }
305
- xterm.onTitleChange(function (title) { QH('termtitle', ' - ' + EscapeHtml(title)); });
306
- xterm.onResize(function (size) {
307
- // Despam resize
308
- if (xtermResizeTimer) clearTimeout(xtermResizeTimer);
309
- xtermResizeTimer = setTimeout(xTermSendResize, 200);
310
- });
311
-
312
- // Setup a terminal tunnel to the agent
313
- terminal = CreateAgentRedirect(null, CreateRemoteTunnel(tunnelUpdate, options), serverPublicNamePort, authCookie, null, domainUrl);
314
- terminal.debugmode = debugmode;
315
- terminal.m.debugmode = debugmode;
316
- terminal.options = { cols: xterm.cols, rows: xterm.rows };
317
- if (options && options.requireLogin) { terminal.options.requireLogin = true; }
318
- terminal.Start(null);
319
- terminal.onStateChanged = onTerminalStateChange;
320
- terminal.contype = 1;
321
- terminal.attemptWebRTC = false; // Never do WebRTC on terminal, because of a race condition we can't do it.
322
- terminal.onConsoleMessageChange = function (server, msg) {
323
- if (terminal.consoleMessage) {
324
- Q('p12TermConsoleMsg').innerHTML += formatAgentConsoleMessage(terminal.consoleMessage, terminal.consoleMessageId, terminal.consoleMessageArgs);
325
- QV('p12TermConsoleMsg', true);
326
- if (p12TermConsoleMsgTimer != null) { clearTimeout(p12TermConsoleMsgTimer); }
327
- if (terminal.consoleMessageTimeout) { p12TermConsoleMsgTimer = setTimeout(p12clearConsoleMsg, terminal.consoleMessageTimeout * 1000); }
328
- } else {
329
- p12clearConsoleMsg();
330
- }
331
- };
332
- } else {
333
- terminal.Stop();
334
- terminal = null;
335
- }
336
- Q('connectbutton2').blur(); // Deselect the connect button so the button does not get key presses.
337
- }
338
-
339
- var terminalEmulations = ["UTF8 Terminal", "Extended ASCII", "Intel ASCII"];
340
- function termToggleType() {
341
- if (!terminal || xxdialogMode) return;
342
- terminal.m.terminalEmulation = (terminal.m.terminalEmulation + 1) % 3;
343
- Q('id_ttypebutton').value = terminalEmulations[terminal.m.terminalEmulation];
344
- Q('id_ttypebutton').blur(); // Deselect the connect button so the button does not get key presses.
345
- }
346
-
347
- var fxEmulations = ["Intel (F10 = ESC+[OM)", "Alternate (F10 = ESC+0)", "VT100+ (F10 = ESC+[OY)"];
348
- function termToggleFx() {
349
- if (!terminal || xxdialogMode) return;
350
- terminal.m.fxEmulation = (terminal.m.fxEmulation + 1) % 3;
351
- Q('id_tfxkeysbutton').value = fxEmulations[terminal.m.fxEmulation];
352
- Q('id_tfxkeysbutton').blur(); // Deselect the connect button so the button does not get key presses.
353
- }
354
-
355
- function termToggleCr() {
356
- if (!terminal || xxdialogMode) return;
357
- if (terminal.m.lineFeed == '\n') { terminal.m.lineFeed = '\r\n'; } else { terminal.m.lineFeed = '\n'; }
358
- Q('id_tcrbutton').value = (terminal.m.lineFeed == '\r\n') ? "CR+LF" : "LF";
359
- }
360
-
361
- function termSendKey(key, id) {
362
- if (!terminal || xxdialogMode) return;
363
- if (xterm != null) {
364
- if (terminal.sendText) {
365
- // MeshAgent
366
- terminal.sendText(String.fromCharCode(key));
367
- } else {
368
- // CIRA
369
- terminal.send(String.fromCharCode(key));
370
- }
371
- xterm.focus();
372
- } else if (terminal != null) {
373
- terminal.m.TermSendKey(key);
374
- Q(id).blur(); // Deselect the connect button so the button does not get key presses.
375
- }
376
- }
377
-
378
- function showTermPasteDialog() {
379
- if (!terminal || xxdialogMode) return;
380
- Q('pastebutton').blur();
381
- setDialogMode(2, "Paste", 3, showTermPasteDialogEx, '<textarea id=d2pasteText style="width:100%;height:184px;resize:none"></textarea>');
382
- Q('d2pasteText').focus();
383
- }
384
-
385
- function showTermPasteDialogEx() {
386
- if (!terminal) return;
387
- terminal.m.TermSendKeys(Q('d2pasteText').value);
388
- }
389
-
390
- // Send special key
391
- function sendSpecialKey() {
392
- if (xterm != null) {
393
- terminal.sendText(String.fromCharCode(Q('specialkeylist').value));
394
- xterm.focus();
395
- } else if (terminal != null) {
396
- terminal.m.TermSendKey(Q('specialkeylist').value);
397
- Q('specialkeylist').blur();
398
- Q('specialkeylistinput').blur();
399
- }
400
- }
401
-
402
- function p12clearConsoleMsg() { QH('p12TermConsoleMsg', ''); QV('p12TermConsoleMsg', false); if (p12TermConsoleMsgTimer) { clearTimeout(p12TermConsoleMsgTimer); p12TermConsoleMsgTimer = null; } }
403
-
404
- //
405
- // POPUP DIALOG
406
- //
407
-
408
- // null = Hidden, 1 = Generic Message
409
- var xxdialogMode;
410
- var xxdialogFunc;
411
- var xxdialogButtons;
412
- var xxdialogTag;
413
- var xxcurrentView = -1;
414
-
415
- // Display a dialog box
416
- // Parameters: Dialog Mode (0 = none), Dialog Title, Buttons (1 = OK, 2 = Cancel, 3 = OK & Cancel), Call back function(0 = Cancel, 1 = OK), Dialog Content (Mode 2 only)
417
- function setDialogMode(x, y, b, f, c, tag) {
418
- xxdialogMode = x;
419
- xxdialogFunc = f;
420
- xxdialogButtons = b;
421
- xxdialogTag = tag;
422
- QE('idx_dlgOkButton', true);
423
- QV('idx_dlgOkButton', b & 1);
424
- QV('idx_dlgCancelButton', b & 2);
425
- QV('id_dialogclose', (b & 2) || (b & 8));
426
- QV('idx_dlgDeleteButton', b & 4);
427
- QV('idx_dlgButtonBar', b & 7);
428
- if (y) QH('id_dialogtitle', y);
429
- for (var i = 1; i < 8; i++) { QV('dialog' + i, i == x); } // Edit this line when more dialogs are added
430
- QV('dialog', x);
431
- if (c) { if (x == 2) { QH('id_dialogOptions', c); } else { QH('id_dialogMessage', c); } }
432
- }
433
-
434
- function dialogclose(x) {
435
- var f = xxdialogFunc, b = xxdialogButtons, t = xxdialogTag;
436
- setDialogMode();
437
- if (((b & 8) || x) && f) f(x, t);
438
- }
439
-
440
- function messagebox(t, m) { setSessionActivity(); QH('id_dialogMessage', m); setDialogMode(1, t, 1); }
441
- function statusbox(t, m) { setSessionActivity(); QH('id_dialogMessage', m); setDialogMode(1, t); }
442
- function haltEvent(e) { if (e.preventDefault) e.preventDefault(); if (e.stopPropagation) e.stopPropagation(); return false; }
443
- function pad2(num) { var s = '00' + num; return s.substr(s.length - 2); }
444
- function format(format) { var args = Array.prototype.slice.call(arguments, 1); return format.replace(/{(\d+)}/g, function (match, number) { return typeof args[number] != 'undefined' ? args[number] : match; }); };
445
- function setSessionActivity() { sessionActivity = Date.now(); /*QH('idleTimeoutNotify', '');*/ }
446
- function printDate(d) { return d.toLocaleDateString(urlargs.locale); }
447
- function printTime(d) { return d.toLocaleTimeString(urlargs.locale); }
448
- function printDateTime(d) { return d.toLocaleString(urlargs.locale); }
449
- function printFlexDateTime(d) { if (printDate(new Date()) == printDate(d)) { return format("Expires at {0}", printTime(d)); } else { return format("Expires {0}", printDateTime(d)); } }
450
-
451
- start();
452
- </script>
453
-</body>
454
-</html>
\ No newline at end of file
webserver.js
+1
-81
@@ -3384,84 +3384,6 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
3384
render(req, res, getRenderPage('player', req, domain), getRenderArgs({}, req, domain));
3385
}
3386
3387
- // Serve the guest desktop page
3388
- function handleDesktopRequest(req, res) {
3389
- const domain = getDomain(req, res);
3390
- if (domain == null) { return; }
3391
- if (req.query.c == null) { res.sendStatus(404); return; }
3392
- if (domain.guestdevicesharing === false) { res.sendStatus(404); return; } // This feature is not allowed.
3393
-
3394
- // Check the inbound desktop sharing cookie
3395
- var c = obj.parent.decodeCookie(req.query.c, obj.parent.invitationLinkEncryptionKey, 60); // 60 minute timeout
3396
- if ((c == null) || (c.a !== 5) || ((c.p !== 2) && (c.p != null)) || (typeof c.uid != 'string') || (typeof c.nid != 'string') || (typeof c.gn != 'string') || (typeof c.cf != 'number') || (typeof c.start != 'number') || (typeof c.expire != 'number') || (typeof c.pid != 'string')) { res.sendStatus(404); return; }
3397
-
3398
- // Check the expired time, expire message.
3399
- if (c.expire <= Date.now()) { render(req, res, getRenderPage((domain.sitestyle == 2) ? 'message2' : 'message', req, domain), getRenderArgs({ titleid: 2, msgid: 12, domainurl: encodeURIComponent(domain.url).replace(/'/g, '%27') }, req, domain)); return; }
3400
-
3401
- // Check the public id
3402
- obj.db.GetAllTypeNodeFiltered([c.nid], domain.id, 'deviceshare', null, function (err, docs) {
3403
- // Check if any desktop sharing links are present, expire message.
3404
- if ((err != null) || (docs.length == 0)) { render(req, res, getRenderPage((domain.sitestyle == 2) ? 'message2' : 'message', req, domain), getRenderArgs({ titleid: 2, msgid: 12, domainurl: encodeURIComponent(domain.url).replace(/'/g, '%27') }, req, domain)); return; }
3405
-
3406
- // Search for the device share public identifier, expire message.
3407
- var found = false;
3408
- for (var i = 0; i < docs.length; i++) { if (docs[i].publicid == c.pid) { found = true; } }
3409
- if (found == false) { render(req, res, getRenderPage((domain.sitestyle == 2) ? 'message2' : 'message', req, domain), getRenderArgs({ titleid: 2, msgid: 12, domainurl: encodeURIComponent(domain.url).replace(/'/g, '%27') }, req, domain)); return; }
3410
-
3411
- // Check the start time, not yet valid message.
3412
- if ((c.start > Date.now()) || (c.start > c.expire)) { render(req, res, getRenderPage((domain.sitestyle == 2) ? 'message2' : 'message', req, domain), getRenderArgs({ titleid: 2, msgid: 11, domainurl: encodeURIComponent(domain.url).replace(/'/g, '%27') }, req, domain)); return; }
3413
-
3414
- // Looks good, let's create the outbound session cookies.
3415
- // Consent flags are 1 = Notify, 8 = Prompt, 64 = Privacy Bar.
3416
- const authCookie = obj.parent.encodeCookie({ userid: c.uid, domainid: domain.id, nid: c.nid, ip: req.clientIp, p: 2, gn: c.gn, cf: 65 | c.cf, r: 8, expire: c.expire, pid: c.pid, vo: c.vo }, obj.parent.loginCookieEncryptionKey);
3417
-
3418
- // Lets respond by sending out the desktop viewer.
3419
- var httpsPort = ((obj.args.aliasport == null) ? obj.args.port : obj.args.aliasport); // Use HTTPS alias port is specified
3420
- parent.debug('web', 'handleDesktopRequest: Sending guest desktop page for \"' + c.uid + '\", guest \"' + c.gn + '\".');
3421
- res.set({ 'Cache-Control': 'no-store' });
3422
- render(req, res, getRenderPage('desktop', req, domain), getRenderArgs({ authCookie: authCookie, authRelayCookie: '', domainurl: encodeURIComponent(domain.url).replace(/'/g, '%27'), nodeid: c.nid, serverDnsName: obj.getWebServerName(domain), serverRedirPort: args.redirport, serverPublicPort: httpsPort, expire: c.expire, viewOnly: (c.vo == 1) ? 1 : 0 }, req, domain));
3423
- });
3424
- }
3425
-
3426
- // Serve the guest terminal page
3427
- function handleTerminalRequest(req, res) {
3428
- const domain = getDomain(req, res);
3429
- if (domain == null) { return; }
3430
- if (req.query.c == null) { res.sendStatus(404); return; }
3431
- if (domain.guestdevicesharing === false) { res.sendStatus(404); return; } // This feature is not allowed.
3432
-
3433
- // Check the inbound desktop sharing cookie
3434
- var c = obj.parent.decodeCookie(req.query.c, obj.parent.invitationLinkEncryptionKey, 60); // 60 minute timeout
3435
- if ((c == null) || (c.a !== 5) || (c.p !== 1) || (typeof c.uid != 'string') || (typeof c.nid != 'string') || (typeof c.gn != 'string') || (typeof c.cf != 'number') || (typeof c.start != 'number') || (typeof c.expire != 'number') || (typeof c.pid != 'string')) { res.sendStatus(404); return; }
3436
-
3437
- // Check the expired time, expire message.
3438
- if (c.expire <= Date.now()) { render(req, res, getRenderPage((domain.sitestyle == 2) ? 'message2' : 'message', req, domain), getRenderArgs({ titleid: 4, msgid: 12, domainurl: encodeURIComponent(domain.url).replace(/'/g, '%27') }, req, domain)); return; }
3439
-
3440
- // Check the public id
3441
- obj.db.GetAllTypeNodeFiltered([c.nid], domain.id, 'deviceshare', null, function (err, docs) {
3442
- // Check if any desktop sharing links are present, expire message.
3443
- if ((err != null) || (docs.length == 0)) { render(req, res, getRenderPage((domain.sitestyle == 2) ? 'message2' : 'message', req, domain), getRenderArgs({ titleid: 4, msgid: 12, domainurl: encodeURIComponent(domain.url).replace(/'/g, '%27') }, req, domain)); return; }
3444
-
3445
- // Search for the device share public identifier, expire message.
3446
- var found = false;
3447
- for (var i = 0; i < docs.length; i++) { if (docs[i].publicid == c.pid) { found = true; } }
3448
- if (found == false) { render(req, res, getRenderPage((domain.sitestyle == 2) ? 'message2' : 'message', req, domain), getRenderArgs({ titleid: 4, msgid: 12, domainurl: encodeURIComponent(domain.url).replace(/'/g, '%27') }, req, domain)); return; }
3449
-
3450
- // Check the start time, not yet valid message.
3451
- if ((c.start > Date.now()) || (c.start > c.expire)) { render(req, res, getRenderPage((domain.sitestyle == 2) ? 'message2' : 'message', req, domain), getRenderArgs({ titleid: 4, msgid: 11, domainurl: encodeURIComponent(domain.url).replace(/'/g, '%27') }, req, domain)); return; }
3452
-
3453
- // Looks good, let's create the outbound session cookies.
3454
- // Consent flags are 2 = Notify, 16 = Prompt
3455
- const authCookie = obj.parent.encodeCookie({ userid: c.uid, domainid: domain.id, nid: c.nid, ip: req.clientIp, p: 1, gn: c.gn, cf: 2 | c.cf, r: 8, expire: c.expire, pid: c.pid }, obj.parent.loginCookieEncryptionKey);
3456
-
3457
- // Lets respond by sending out the desktop viewer.
3458
- var httpsPort = ((obj.args.aliasport == null) ? obj.args.port : obj.args.aliasport); // Use HTTPS alias port is specified
3459
- parent.debug('web', 'handleTerminalRequest: Sending guest terminal page for \"' + c.uid + '\", guest \"' + c.gn + '\".');
3460
- res.set({ 'Cache-Control': 'no-store' });
3461
- render(req, res, getRenderPage('terminal', req, domain), getRenderArgs({ authCookie: authCookie, authRelayCookie: '', domainurl: encodeURIComponent(domain.url).replace(/'/g, '%27'), nodeid: c.nid, serverDnsName: obj.getWebServerName(domain), serverRedirPort: args.redirport, serverPublicPort: httpsPort, expire: c.expire }, req, domain));
3462
- });
3463
- }
3464
-
3387
// Serve the guest sharing page
3388
function handleSharingRequest(req, res) {
3389
const domain = getDomain(req, res);
@@ -3500,7 +3422,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
3422
3423
// Lets respond by sending out the desktop viewer.
3424
var httpsPort = ((obj.args.aliasport == null) ? obj.args.port : obj.args.aliasport); // Use HTTPS alias port is specified
3503
- parent.debug('web', 'handleDesktopRequest: Sending guest sharing page for \"' + c.uid + '\", guest \"' + c.gn + '\".');
3425
+ parent.debug('web', 'handleSharingRequest: Sending guest sharing page for \"' + c.uid + '\", guest \"' + c.gn + '\".');
3426
res.set({ 'Cache-Control': 'no-store' });
3427
render(req, res, getRenderPage('sharing', req, domain), getRenderArgs({ authCookie: authCookie, authRelayCookie: '', domainurl: encodeURIComponent(domain.url).replace(/'/g, '%27'), nodeid: c.nid, serverDnsName: obj.getWebServerName(domain), serverRedirPort: args.redirport, serverPublicPort: httpsPort, expire: c.expire, viewOnly: (c.vo == 1) ? 1 : 0, nodeName: encodeURIComponent(node.name), features: c.p }, req, domain));
3428
});
@@ -5549,8 +5471,6 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
5471
obj.app.get(url + 'recordings.ashx', handleGetRecordings);
5472
obj.app.get(url + 'player.htm', handlePlayerRequest);
5473
obj.app.get(url + 'player', handlePlayerRequest);
5552
- obj.app.get(url + 'desktop', handleDesktopRequest);
5553
- obj.app.get(url + 'terminal', handleTerminalRequest);
5474
obj.app.get(url + 'sharing', handleSharingRequest);
5475
obj.app.ws(url + 'agenttransfer.ashx', handleAgentFileTransfer); // Setup agent to/from server file transfer handler
5476
obj.app.ws(url + 'meshrelay.ashx', function (ws, req) {