MCPcopy Create free account
hub / github.com/apache/cloudstack / _handleServerCutText

Method _handleServerCutText

systemvm/agent/noVNC/core/rfb.js:2485–2651  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2483 }
2484
2485 _handleServerCutText() {
2486 Log.Debug("ServerCutText");
2487
2488 if (this._sock.rQwait("ServerCutText header", 7, 1)) { return false; }
2489
2490 this._sock.rQskipBytes(3); // Padding
2491
2492 let length = this._sock.rQshift32();
2493 length = toSigned32bit(length);
2494
2495 if (this._sock.rQwait("ServerCutText content", Math.abs(length), 8)) { return false; }
2496
2497 if (length >= 0) {
2498 //Standard msg
2499 const text = this._sock.rQshiftStr(length);
2500 if (this._viewOnly) {
2501 return true;
2502 }
2503
2504 this.dispatchEvent(new CustomEvent(
2505 "clipboard",
2506 { detail: { text: text } }));
2507
2508 } else {
2509 //Extended msg.
2510 length = Math.abs(length);
2511 const flags = this._sock.rQshift32();
2512 let formats = flags & 0x0000FFFF;
2513 let actions = flags & 0xFF000000;
2514
2515 let isCaps = (!!(actions & extendedClipboardActionCaps));
2516 if (isCaps) {
2517 this._clipboardServerCapabilitiesFormats = {};
2518 this._clipboardServerCapabilitiesActions = {};
2519
2520 // Update our server capabilities for Formats
2521 for (let i = 0; i <= 15; i++) {
2522 let index = 1 << i;
2523
2524 // Check if format flag is set.
2525 if ((formats & index)) {
2526 this._clipboardServerCapabilitiesFormats[index] = true;
2527 // We don't send unsolicited clipboard, so we
2528 // ignore the size
2529 this._sock.rQshift32();
2530 }
2531 }
2532
2533 // Update our server capabilities for Actions
2534 for (let i = 24; i <= 31; i++) {
2535 let index = 1 << i;
2536 this._clipboardServerCapabilitiesActions[index] = !!(actions & index);
2537 }
2538
2539 /* Caps handling done, send caps with the clients
2540 capabilities set as a response */
2541 let clientActions = [
2542 extendedClipboardActionCaps,

Callers 1

_normalMsgMethod · 0.95

Calls 12

_failMethod · 0.95
toSigned32bitFunction · 0.90
decodeUTF8Function · 0.90
rQwaitMethod · 0.80
rQskipBytesMethod · 0.80
rQshift32Method · 0.80
rQshiftStrMethod · 0.80
dispatchEventMethod · 0.80
rQshiftBytesMethod · 0.80
setInputMethod · 0.80
inflateMethod · 0.80
sliceMethod · 0.80

Tested by

no test coverage detected