diff --git a/app/ui.js b/app/ui.js index de7a9a27..9a5b1958 100644 --- a/app/ui.js +++ b/app/ui.js @@ -383,6 +383,8 @@ var UI = { UI.addSettingChangeHandler('encrypt'); UI.addSettingChangeHandler('cursor'); UI.addSettingChangeHandler('cursor', UI.updateLocalCursor); + UI.addSettingChangeHandler('clipboard'); + UI.addSettingChangeHandler('clipboard', UI.updateClipboard); UI.addSettingChangeHandler('resize'); UI.addSettingChangeHandler('resize', UI.enableDisableViewClip); UI.addSettingChangeHandler('resize', UI.applyResizeMode); @@ -1002,23 +1004,43 @@ var UI = { }, clipboardReceive: function(rfb, text) { + if (!UI.getSetting('clipboard')) return; + Log.Debug(">> UI.clipboardReceive: " + text.substr(0,40) + "..."); document.getElementById('noVNC_clipboard_text').value = text; Log.Debug("<< UI.clipboardReceive"); }, clipboardClear: function() { + if (!UI.getSetting('clipboard')) return; + document.getElementById('noVNC_clipboard_text').value = ""; UI.rfb.clipboardPasteFrom(""); }, clipboardSend: function() { + if (!UI.getSetting('clipboard')) return; + var text = document.getElementById('noVNC_clipboard_text').value; Log.Debug(">> UI.clipboardSend: " + text.substr(0,40) + "..."); UI.rfb.clipboardPasteFrom(text); Log.Debug("<< UI.clipboardSend"); }, + updateClipboard: function() { + if (!UI.rfb) return; + + var clipboard_enabled = UI.getSetting('clipboard'); + var clipboard_button = document.getElementById('noVNC_clipboard_button'); + if (clipboard_enabled) { + clipboard_button.disabled = false; + UI.rfb.set_clipboard(true); + } else { + clipboard_button.disabled = true; + UI.rfb.set_clipboard(false); + } + }, + /* ------^------- * /CLIPBOARD * ============== diff --git a/core/rfb.js b/core/rfb.js index ece0f008..8b3c6aeb 100644 --- a/core/rfb.js +++ b/core/rfb.js @@ -151,6 +151,7 @@ export default function RFB(defaults) { 'encrypt': false, // Use TLS/SSL/wss encryption 'local_cursor': false, // Request locally rendered cursor 'shared': true, // Request shared mode + 'clipboard': true, // Synchronize server and client clipboard contents 'view_only': false, // Disable client mouse/keyboard 'xvp_password_sep': '@', // Separator for XVP password fields 'disconnectTimeout': 3, // Time (s) to wait for disconnection @@ -356,7 +357,12 @@ RFB.prototype = { }, clipboardPasteFrom: function (text) { - if (this._rfb_connection_state !== 'connected' || this._view_only) { return; } + if (this._rfb_connection_state !== 'connected' || + this._view_only || + !this._clipboard) { + + return; + } RFB.messages.clientCutText(this._sock, text); }, @@ -1167,7 +1173,7 @@ RFB.prototype = { var text = this._sock.rQshiftStr(length); - if (this._view_only) { return true; } + if (this._view_only || !this._clipboard) { return true; } this._onClipboard(this, text); @@ -1426,6 +1432,7 @@ make_properties(RFB, [ ['encrypt', 'rw', 'bool'], // Use TLS/SSL/wss encryption ['local_cursor', 'rw', 'bool'], // Request locally rendered cursor ['shared', 'rw', 'bool'], // Request shared mode + ['clipboard', 'rw', 'bool'], // Synchronize server and client clipboard contents ['view_only', 'rw', 'bool'], // Disable client mouse/keyboard ['xvp_password_sep', 'rw', 'str'], // Separator for XVP password fields ['disconnectTimeout', 'rw', 'int'], // Time (s) to wait for disconnection diff --git a/vnc.html b/vnc.html index 7845fa66..4b35de64 100644 --- a/vnc.html +++ b/vnc.html @@ -204,6 +204,9 @@