Add setting for clipboard

This commit is contained in:
Samuel Mannehed 2017-09-01 16:30:27 +02:00
parent 6a1152e6b4
commit 40654f2586
3 changed files with 34 additions and 2 deletions

View File

@ -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
* ==============

View File

@ -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

View File

@ -204,6 +204,9 @@
<li>
<label><input id="noVNC_setting_view_only" type="checkbox" /> View Only</label>
</li>
<li>
<label><input id="noVNC_setting_clipboard" type="checkbox" /> Clipboard</label>
</li>
<li><hr></li>
<li>
<label><input id="noVNC_setting_view_clip" type="checkbox" /> Clip to Window</label>