Added server-side remote user input lock support

This commit is contained in:
Ylian Saint-Hilaire 2021-04-28 15:46:19 -07:00
parent ab538b086f
commit 811611ab7a
8 changed files with 1685 additions and 1615 deletions

View File

@ -524,6 +524,9 @@ function CreateDesktopMultiplexor(parent, domain, nodeid, func) {
case 85: // Unicode Key Events, forward to agent
if (viewer.viewOnly == false) { obj.sendToAgent(data); }
break;
case 87: // Remote input lock, forward to agent
if (viewer.viewOnly == false) { obj.sendToAgent(data); }
break;
default:
console.log('Un-handled viewer command: ' + command);
break;
@ -672,6 +675,11 @@ function CreateDesktopMultiplexor(parent, domain, nodeid, func) {
// Send this to all viewers right away
obj.sendToAllViewers(data);
break;
case 87: // MNG_KVM_INPUT_LOCK
// Send this to all viewers right away
// This will update all views on the current state of the input lock
obj.sendToAllViewers(data);
break;
case 88: // MNG_KVM_MOUSE_CURSOR
// Send this to all viewers right away
obj.sendToAllViewers(data);

Binary file not shown.

After

Width:  |  Height:  |  Size: 351 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 361 B

File diff suppressed because one or more lines are too long

View File

@ -47,6 +47,10 @@ var CreateAgentRemoteDesktop = function (canvasid, scrolldiv) {
obj.SwapMouse = false;
obj.FirstDraw = false;
// Remote user mouse and keyboard lock
obj.onRemoteInputLockChanged = null;
obj.RemoteInputLock = null;
obj.ScreenWidth = 960;
obj.ScreenHeight = 701;
obj.width = 960;
@ -193,6 +197,7 @@ var CreateAgentRemoteDesktop = function (canvasid, scrolldiv) {
while (obj.PendingOperations.length > 0) { obj.PendingOperations.shift(); }
obj.SendCompressionLevel(1);
obj.SendUnPause();
obj.SendRemoteInputLock(2); // Query input lock state
// No need to event the display size change now, it will be evented on first draw.
if (obj.onScreenSizeChange != null) { obj.onScreenSizeChange(obj, obj.ScreenWidth, obj.ScreenHeight, obj.CanvasId); }
}
@ -266,6 +271,13 @@ var CreateAgentRemoteDesktop = function (canvasid, scrolldiv) {
console.log('KVM: ' + str.substring(1));
}
break;
case 87: // MNG_KVM_INPUT_LOCK
if (cmdsize != 5) break;
if (obj.RemoteInputLock != (view[4] != 0)) {
obj.RemoteInputLock = (view[4] != 0);
if (obj.onRemoteInputLockChanged) { obj.onRemoteInputLockChanged(obj, obj.RemoteInputLock); }
}
break;
case 88: // MNG_KVM_MOUSE_CURSOR
if ((cmdsize != 5) || (obj.stopInput)) break;
var cursorNum = view[4];
@ -385,6 +397,9 @@ var CreateAgentRemoteDesktop = function (canvasid, scrolldiv) {
}
}
// Send remote input lock. 0 = Unlock, 1 = Lock, 2 = Query
obj.SendRemoteInputLock = function (code) { obj.send(String.fromCharCode(0x00, obj.InputType.KEYUNICODE, 0x00, 0x05, code)); }
obj.SendMessage = function (msg) {
if (obj.State == 3) obj.send(String.fromCharCode(0x00, 0x11) + obj.shortToStr(4 + msg.length) + msg); // 0x11 = 17 MNG_KVM_MESSAGE
}

View File

@ -2625,7 +2625,7 @@ a {
-ms-grid-row: 4;
}
#DeskChatButton, #DeskNotifyButton, #DeskOpenWebButton, #DeskBackgroundButton, #DeskSaveImageButton, #DeskRecordButton, #DeskClipboardInButton, #DeskClipboardOutButton, #DeskRefreshButton, #DeskLockButton {
#DeskChatButton, #DeskNotifyButton, #DeskOpenWebButton, #DeskBackgroundButton, #DeskSaveImageButton, #DeskRecordButton, #DeskClipboardInButton, #DeskClipboardOutButton, #DeskRefreshButton, #DeskLockButton, #DeskInputLockedButton, #DeskInputUnLockedButton {
float: right;
margin-top: 1px;
margin-right: 4px;

File diff suppressed because it is too large Load Diff

View File

@ -650,6 +650,8 @@
<span id=DeskClipboardInButton title="Download remote clipboard to local clipboard" style="display:none"><img id=DeskClipboardInButtonImage src='images/icon-clipboard-in.png' onclick=deskClipboardInFunction() height=16 width=16 style=padding-top:2px /></span>
<span id=DeskClipboardOutButton title="Upload local clipboard to remote device"><img id=DeskClipboardOutButtonImage src='images/icon-clipboard-out.png' onclick=deskClipboardOutFunction() height=16 width=16 style=padding-top:2px /></span>
<span id=DeskRefreshButton title="Refresh the desktop"><img id=DeskRefreshButtonImage src='images/icon-refresh.png' onclick=deskRefreshFunction() height=16 width=16 style=padding-top:2px /></span>
<span id=DeskInputLockedButton title="Remote input is locked"><img id=DeskInputLockedButtonImage src='images/icon-keylock-red.png' onclick=deskInputLockFunction(0) height=16 width=16 style=padding-top:2px /></span>
<span id=DeskInputUnLockedButton title="Remote input is unlocked"><img id=DeskInputUnLockedButtonImage src='images/icon-keylock.png' onclick=deskInputLockFunction(1) height=16 width=16 style=padding-top:2px /></span>
</div>
<div>
<select id="deskkeys" cmenu=deskKeyShortcutContextMenu></select>
@ -3953,6 +3955,7 @@
if (desktop.m.SendCompressionLevel) { desktop.m.SendCompressionLevel(1, multidesktopsettings.quality, multidesktopsettings.scaling, multidesktopsettings.framerate); }
desktop.shortid = shortid;
desktop.onStateChanged = onMultiDesktopStateChange;
desktop.m.onRemoteInputLockChanged = null;
multiDesktop[id] = desktop;
desktop = desktopNode = currentNode = null;
// Setup a replacement desktop
@ -6777,6 +6780,12 @@
meshserver.send({ action: 'msg', type: 'getclip', nodeid: currentNode._id, tag: 2 });
}
// Called to lock or unlock remote desktop user input
function deskInputLockFunction(value) {
if (xxdialogMode || desktop == null || desktop.State != 3) return;
setDialogMode(2, "Remote Input Lock", 3, function() { try { desktop.m.SendRemoteInputLock(value); } catch (ex) {} }, (value == 1)?"Lock remote user's mouse and keyboard?":"Unlock remote user's mouse and keyboard?");
}
function deskClipboardOutFunction() {
if ((navigator.clipboard != null) && (navigator.clipboard.readText != null)) {
try {
@ -7424,6 +7433,9 @@
desktop.onStateChanged = onDesktopStateChange;
desktop.onMetadataChange = function(metadata) { updateMetadata(desktop, 'deskmetadata'); }
if (desktop && desktop.m.mouseCursorActive) { desktop.m.mouseCursorActive(true); }
QV('DeskInputLockedButton', desktop.m.RemoteInputLock === 1);
QV('DeskInputUnLockedButton', desktop.m.RemoteInputLock === 0);
desktop.m.onRemoteInputLockChanged = function(obj, state) { QV('DeskInputLockedButton', state === 1); QV('DeskInputUnLockedButton', state === 0); }
desktopNode = currentNode;
onDesktopStateChange(desktop, desktop.State);
delete multiDesktop[currentNode._id];
@ -7501,6 +7513,8 @@
QV('DeskClipboardOutButton', inputAllowed && (navigator.clipboard != null) && (navigator.clipboard.readText != null));
QV('DeskClipboardInButton', inputAllowed && (navigator.clipboard != null) && (navigator.clipboard.writeText != null));
if (deskState != 3) { QV('DeskInputLockedButton', false); QV('DeskInputUnLockedButton', false); }
// Display this only if we have Chat & Notify permissions
QV('DeskSaveImageButton', (deskState == 3) && (Q('Desk')['toBlob'] != null));
QV('DeskRecordButton', (deskState == 3) && (Q('Desk')['toBlob'] != null) && (desktop.m.StartRecording != null));
@ -7636,6 +7650,7 @@
if (tsid != null) { desktop.options.tsid = tsid; }
if (consent != null) { desktop.options.consent = consent; }
desktop.onStateChanged = onDesktopStateChange;
desktop.m.onRemoteInputLockChanged = function(obj, state) { QV('DeskInputLockedButton', state === 1); QV('DeskInputUnLockedButton', state === 0); }
desktop.onConsoleMessageChange = function () {
if (desktop.consoleMessage) {
Q('p11DeskConsoleMsg').innerHTML += formatAgentConsoleMessage(desktop.consoleMessage, desktop.consoleMessageId, desktop.consoleMessageArgs);
@ -7745,6 +7760,8 @@
QV('DeskFocus', false);
QV('termdisplays', false);
QV('deskRecordIcon', false);
QV('DeskInputLockedButton', false);
QV('DeskInputUnLockedButton', false);
deskFocusBtn.value = "All Focus";
if (fullscreen == true) { deskToggleFull(); }
webRtcDesktopReset();