• Home
  • Raw
  • Download

Lines Matching full:this

25         this._rfb_host = '';
26 this._rfb_port = 5900;
27 this._rfb_password = '';
28 this._rfb_path = '';
30 this._rfb_state = 'disconnected';
31 this._rfb_version = 0;
32 this._rfb_max_version = 3.8;
33 this._rfb_auth_scheme = '';
35 this._rfb_tightvnc = false;
36 this._rfb_xvp_ver = 0;
39 this._encodings = [
59 this._encHandlers = {};
60 this._encNames = {};
61 this._encStats = {};
63 this._sock = null; // Websock object
64 this._display = null; // Display object
65 this._keyboard = null; // Keyboard input handler object
66 this._mouse = null; // Mouse input handler object
67 this._sendTimer = null; // Send Queue check timer
68 this._disconnTimer = null; // disconnection timer
69 this._msgTimer = null; // queued handle_msg timer
72 this._FBU = {
88 this._fb_Bpp = 4;
89 this._fb_depth = 3;
90 this._fb_width = 0;
91 this._fb_height = 0;
92 this._fb_name = "";
94 this._rre_chunk_sz = 100;
96 this._timing = {
110 this._mouse_buttonMask = 0;
111 this._mouse_arr = [];
112 this._viewportDragging = false;
113 this._viewportDragPos = {};
116 Util.set_defaults(this, defaults, {
139 …pInit': function () { }, // onXvpInit(version): XVP extensions active for this connection
147 this._encHandlers[encName] = RFB.encodingHandlers[encName].bind(this);
148 }.bind(this));
151 for (var i = 0; i < this._encodings.length; i++) {
152 this._encHandlers[this._encodings[i][1]] = this._encHandlers[this._encodings[i][0]];
153 this._encNames[this._encodings[i][1]] = this._encodings[i][0];
154 this._encStats[this._encodings[i][1]] = [0, 0];
158 this._display = new Display({target: this._target});
161 this._updateState('fatal', "No working Display");
164 this._keyboard = new Keyboard({target: this._focusContainer,
165 onKeyPress: this._handleKeyPress.bind(this)});
167 this._mouse = new Mouse({target: this._target,
168 onMouseButton: this._handleMouseButton.bind(this),
169 onMouseMove: this._handleMouseMove.bind(this),
170 notify: this._keyboard.sync.bind(this._keyboard)});
172 this._sock = new Websock();
173 this._sock.on('message', this._handle_message.bind(this));
174 this._sock.on('open', function () {
175 if (this._rfb_state === 'connect') {
176 this._updateState('ProtocolVersion', "Starting VNC handshake");
178 this._fail("Got unexpected WebSocket connection");
180 }.bind(this));
181 this._sock.on('close', function (e) {
191 if (this._rfb_state === 'disconnect') {
192 this._updateState('disconnected', 'VNC disconnected' + msg);
193 } else if (this._rfb_state === 'ProtocolVersion') {
194 this._fail('Failed to connect to server' + msg);
195 } else if (this._rfb_state in {'failed': 1, 'disconnected': 1}) {
198 this._fail("Server disconnected" + msg);
200 }.bind(this));
201 this._sock.on('error', function (e) {
205 this._init_vars();
207 var rmode = this._display.get_render_mode();
210 this._updateState('loaded', 'noVNC ready: native WebSockets, ' + rmode);
214this._updateState('fatal', "WebSockets or <a href='http://get.adobe.com/flashplayer'>Adobe Flash</…
216 this._updateState('fatal', "'file://' URL is incompatible with Adobe Flash");
218 this._updateState('loaded', 'noVNC ready: WebSockets emulation, ' + rmode);
228 this._rfb_host = host;
229 this._rfb_port = port;
230 this._rfb_password = (password !== undefined) ? password : "";
231 this._rfb_path = (path !== undefined) ? path : "";
233 if (!this._rfb_host || !this._rfb_port) {
234 return this._fail("Must set host and port");
237 this._updateState('connect');
241 this._updateState('disconnect', 'Disconnecting');
245 this._rfb_password = passwd;
246 this._rfb_state = 'Authentication';
247 setTimeout(this._init_msg.bind(this), 1);
251 if (this._rfb_state !== 'normal' || this._view_only) { return false; }
261 this._sock.send(arr);
265 if (this._rfb_xvp_ver < ver) { return false; }
267 this._sock.send_string("\xFA\x00" + String.fromCharCode(ver) + String.fromCharCode(op));
272 return this.xvpOp(1, 2);
276 return this.xvpOp(1, 3);
280 return this.xvpOp(1, 4);
286 if (this._rfb_state !== "normal" || this._view_only) { return false; }
296 this._sock.send(arr);
300 if (this._rfb_state !== 'normal') { return; }
301 this._sock.send(RFB.messages.clientCutText(text));
313 uri = this._encrypt ? 'wss' : 'ws';
316 uri += '://' + this._rfb_host + ':' + this._rfb_port + '/' + this._rfb_path;
319 this._sock.open(uri, this._wsProtocols);
326 this._sock.init();
328 this._FBU.rects = 0;
329 this._FBU.subrects = 0; // RRE and HEXTILE
330 this._FBU.lines = 0; // RAW
331 this._FBU.tiles = 0; // HEXTILE
332 this._FBU.zlibs = []; // TIGHT zlib encoders
333 this._mouse_buttonMask = 0;
334 this._mouse_arr = [];
335 this._rfb_tightvnc = false;
339 for (i = 0; i < this._encodings.length; i++) {
340 this._encStats[this._encodings[i][1]][0] = 0;
344 this._FBU.zlibs[i] = new TINF();
345 this._FBU.zlibs[i].init();
350 Util.Info("Encoding stats for this connection:");
352 for (i = 0; i < this._encodings.length; i++) {
353 s = this._encStats[this._encodings[i][1]];
355 Util.Info(" " + this._encodings[i][0] + ": " + s[0] + " rects");
360 for (i = 0; i < this._encodings.length; i++) {
361 s = this._encStats[this._encodings[i][1]];
362 Util.Info(" " + this._encodings[i][0] + ": " + s[1] + " rects");
387 var oldstate = this._rfb_state;
401 if (this._sendTimer) {
402 clearInterval(this._sendTimer);
403 this._sendTimer = null;
406 if (this._msgTimer) {
407 clearInterval(this._msgTimer);
408 this._msgTimer = null;
411 if (this._display && this._display.get_context()) {
412 this._keyboard.ungrab();
413 this._mouse.ungrab();
414 this._display.defaultCursor();
418 this._display.clear();
422 this._sock.close();
439 this._rfb_state = 'failed';
441 this._rfb_state = state;
444 if (this._disconnTimer && this._rfb_state !== 'disconnect') {
446 clearTimeout(this._disconnTimer);
447 this._disconnTimer = null;
458 this._init_vars();
459 this._connect();
464 this._disconnTimer = setTimeout(function () {
465 this._fail("Disconnect timeout");
466 }.bind(this), this._disconnectTimeout * 1000);
468 this._print_stats();
484 this._updateState('disconnected');
485 }.bind(this), 50);
494 this._onUpdateState(this, state, oldstate);
496 this._onUpdateState(this, state, oldstate, statusMsg);
501 this._updateState('failed', msg);
506 if (this._sock.rQlen() === 0) {
511 switch (this._rfb_state) {
517 if (this._normal_msg() && this._sock.rQlen() > 0) {
520 if (this._msgTimer === null) {
522 this._msgTimer = setTimeout(function () {
523 this._msgTimer = null;
524 this._handle_message();
525 }.bind(this), 10);
532 this._init_msg();
538 … if (this._rfb_state === 'normal' && !this._viewportDragging && this._mouse_arr.length > 0) {
539 this._sock.send(this._mouse_arr);
540 this._mouse_arr = [];
545 if (this._view_only) { return; } // View only, skip keyboard, events
546 this._sock.send(RFB.messages.keyEvent(keysym, down));
551 this._mouse_buttonMask |= bmask;
553 this._mouse_buttonMask ^= bmask;
556 if (this._viewportDrag) {
557 if (down && !this._viewportDragging) {
558 this._viewportDragging = true;
559 this._viewportDragPos = {'x': x, 'y': y};
564 this._viewportDragging = false;
568 if (this._view_only) { return; } // View only, skip mouse events
570 this._mouse_arr = this._mouse_arr.concat(
571 … RFB.messages.pointerEvent(this._display.absX(x), this._display.absY(y), this._mouse_buttonMask));
572 this._sock.send(this._mouse_arr);
573 this._mouse_arr = [];
577 if (this._viewportDragging) {
578 var deltaX = this._viewportDragPos.x - x;
579 var deltaY = this._viewportDragPos.y - y;
580 this._viewportDragPos = {'x': x, 'y': y};
582 this._display.viewportChange(deltaX, deltaY);
588 if (this._view_only) { return; } // View only, skip mouse events
590 this._mouse_arr = this._mouse_arr.concat(
591 … RFB.messages.pointerEvent(this._display.absX(x), this._display.absY(y), this._mouse_buttonMask));
593 this._checkEvents();
599 if (this._sock.rQlen() < 12) {
600 return this._fail("Incomplete protocol version");
603 var sversion = this._sock.rQshiftStr(12).substr(4, 7);
613 this._rfb_version = 3.3;
616 this._rfb_version = 3.7;
621 this._rfb_version = 3.8;
624 return this._fail("Invalid server version " + sversion);
628 var repeaterID = this._repeaterID;
632 this._sock.send_string(repeaterID);
636 if (this._rfb_version > this._rfb_max_version) {
637 this._rfb_version = this._rfb_max_version;
642 this._sendTimer = setInterval(this._sock.flush.bind(this._sock), 50);
644 var cversion = "00" + parseInt(this._rfb_version, 10) +
645 ".00" + ((this._rfb_version * 10) % 10);
646 this._sock.send_string("RFB " + cversion + "\n");
647 this._updateState('Security', 'Sent ProtocolVersion: ' + cversion);
651 if (this._rfb_version >= 3.7) {
653 var num_types = this._sock.rQshift8();
654 if (this._sock.rQwait("security type", num_types, 1)) { return false; }
657 var strlen = this._sock.rQshift32();
658 var reason = this._sock.rQshiftStr(strlen);
659 return this._fail("Security failure: " + reason);
662 this._rfb_auth_scheme = 0;
663 var types = this._sock.rQshiftBytes(num_types);
666 if (types[i] > this._rfb_auth_scheme && (types[i] <= 16 || types[i] == 22)) {
667 this._rfb_auth_scheme = types[i];
671 if (this._rfb_auth_scheme === 0) {
672 return this._fail("Unsupported security types: " + types);
675 this._sock.send([this._rfb_auth_scheme]);
678 if (this._sock.rQwait("security scheme", 4)) { return false; }
679 this._rfb_auth_scheme = this._sock.rQshift32();
682this._updateState('Authentication', 'Authenticating using scheme: ' + this._rfb_auth_scheme);
683 return this._init_msg(); // jump to authentication
688 var xvp_sep = this._xvp_password_sep;
689 var xvp_auth = this._rfb_password.split(xvp_sep);
691 this._updateState('password', 'XVP credentials required (user' + xvp_sep +
692 … 'target' + xvp_sep + 'password) -- got only ' + this._rfb_password);
693 this._onPasswordRequired(this);
701 this._sock.send_string(xvp_auth_str);
702 this._rfb_password = xvp_auth.slice(2).join(xvp_sep);
703 this._rfb_auth_scheme = 2;
704 return this._negotiate_authentication();
708 if (this._rfb_password.length === 0) {
711 this._updateState('password', "Password Required");
712 this._onPasswordRequired(this);
715 if (this._sock.rQwait("auth challenge", 16)) { return false; }
717 var challenge = this._sock.rQshiftBytes(16);
718 var response = RFB.genDES(this._rfb_password, challenge);
719 this._sock.send(response);
720 this._updateState("SecurityResult");
731 var cap_code = this._sock.rQshift32();
732 var cap_vendor = this._sock.rQshiftStr(4);
733 var cap_signature = this._sock.rQshiftStr(8);
741 return this._fail("Client's tunnel type had the incorrect vendor or signature");
743 this._sock.send([0, 0, 0, 0]); // use NOTUNNEL
746 return this._fail("Server wanted tunnels, but doesn't support the notunnel type");
751 if (!this._rfb_tightvnc) { // first pass, do the tunnel negotiation
752 if (this._sock.rQwait("num tunnels", 4)) { return false; }
753 var numTunnels = this._sock.rQshift32();
754 …if (numTunnels > 0 && this._sock.rQwait("tunnel capabilities", 16 * numTunnels, 4)) { return false…
756 this._rfb_tightvnc = true;
759 this._negotiate_tight_tunnels(numTunnels);
765 if (this._sock.rQwait("sub auth count", 4)) { return false; }
766 var subAuthCount = this._sock.rQshift32();
767 if (this._sock.rQwait("sub auth capabilities", 16 * subAuthCount, 4)) { return false; }
777 var capNum = this._sock.rQshift32();
778 var capabilities = this._sock.rQshiftStr(12);
784 this._sock.send([0, 0, 0, clientSupportedTypes[authType]]);
788 this._updateState('SecurityResult');
791 this._rfb_auth_scheme = 2;
792 return this._init_msg();
794 return this._fail("Unsupported tiny auth scheme: " + authType);
799 this._fail("No supported sub-auth types!");
803 switch (this._rfb_auth_scheme) {
805 if (this._sock.rQwait("auth reason", 4)) { return false; }
806 var strlen = this._sock.rQshift32();
807 var reason = this._sock.rQshiftStr(strlen);
808 return this._fail("Auth failure: " + reason);
811 if (this._rfb_version >= 3.8) {
812 this._updateState('SecurityResult');
815 this._updateState('ClientInitialisation', "No auth required");
816 return this._init_msg();
819 return this._negotiate_xvp_auth();
822 return this._negotiate_std_vnc_auth();
825 return this._negotiate_tight_auth();
828 return this._fail("Unsupported auth scheme: " + this._rfb_auth_scheme);
833 if (this._sock.rQwait('VNC auth response ', 4)) { return false; }
834 switch (this._sock.rQshift32()) {
836 this._updateState('ClientInitialisation', 'Authentication OK');
837 return this._init_msg();
839 if (this._rfb_version >= 3.8) {
840 var length = this._sock.rQshift32();
841 if (this._sock.rQwait("SecurityResult reason", length, 8)) { return false; }
842 var reason = this._sock.rQshiftStr(length);
843 return this._fail(reason);
845 return this._fail("Authentication failure");
849 return this._fail("Too many auth attempts");
854 if (this._sock.rQwait("server initialization", 24)) { return false; }
857 this._fb_width = this._sock.rQshift16();
858 this._fb_height = this._sock.rQshift16();
861 var bpp = this._sock.rQshift8();
862 var depth = this._sock.rQshift8();
863 var big_endian = this._sock.rQshift8();
864 var true_color = this._sock.rQshift8();
866 var red_max = this._sock.rQshift16();
867 var green_max = this._sock.rQshift16();
868 var blue_max = this._sock.rQshift16();
869 var red_shift = this._sock.rQshift8();
870 var green_shift = this._sock.rQshift8();
871 var blue_shift = this._sock.rQshift8();
872 this._sock.rQskipBytes(3); // padding
878 var name_length = this._sock.rQshift32();
879 if (this._sock.rQwait('server init name', name_length, 24)) { return false; }
880 this._fb_name = Util.decodeUTF8(this._sock.rQshiftStr(name_length));
882 if (this._rfb_tightvnc) {
883 …if (this._sock.rQwait('TightVNC extended server init header', 8, 24 + name_length)) { return false…
885 var numServerMessages = this._sock.rQshift16();
886 var numClientMessages = this._sock.rQshift16();
887 var numEncodings = this._sock.rQshift16();
888 this._sock.rQskipBytes(2); // padding
891 …if (this._sock.rQwait('TightVNC extended server init header', totalMessagesLength, 32 + name_lengt…
895 var srvMsg = this._sock.rQshiftStr(16);
899 var clientMsg = this._sock.rQshiftStr(16);
903 var encoding = this._sock.rQshiftStr(16);
909 Util.Info("Screen: " + this._fb_width + "x" + this._fb_height +
932 // we're past the point where we could backtrack, so it's safe to call this
933 this._onDesktopName(this, this._fb_name);
935 if (this._true_color && this._fb_name === "Intel(r) AMT KVM") {
937 this._true_color = false;
940 this._display.set_true_color(this._true_color);
941 this._onFBResize(this, this._fb_width, this._fb_height);
942 this._display.resize(this._fb_width, this._fb_height);
943 this._keyboard.grab();
944 this._mouse.grab();
946 if (this._true_color) {
947 this._fb_Bpp = 4;
948 this._fb_depth = 3;
950 this._fb_Bpp = 1;
951 this._fb_depth = 1;
954 var response = RFB.messages.pixelFormat(this._fb_Bpp, this._fb_depth, this._true_color);
956 … RFB.messages.clientEncodings(this._encodings, this._local_cursor, this._true_color));
958 RFB.messages.fbUpdateRequests(this._display.getCleanDirtyReset(),
959 this._fb_width, this._fb_height));
961 this._timing.fbu_rt_start = (new Date()).getTime();
962 this._timing.pixels = 0;
963 this._sock.send(response);
965 this._checkEvents();
967 if (this._encrypt) {
968 this._updateState('normal', 'Connected (encrypted) to: ' + this._fb_name);
970 this._updateState('normal', 'Connected (unencrypted) to: ' + this._fb_name);
975 switch (this._rfb_state) {
977 return this._negotiate_protocol_version();
980 return this._negotiate_security();
983 return this._negotiate_authentication();
986 return this._handle_security_result();
989 this._sock.send([this._shared ? 1 : 0]); // ClientInitialisation
990 this._updateState('ServerInitialisation', "Authentication OK");
994 return this._negotiate_server_init();
1000 this._sock.rQskip8(); // Padding
1002 var first_colour = this._sock.rQshift16();
1003 var num_colours = this._sock.rQshift16();
1004 if (this._sock.rQwait('SetColorMapEntries', num_colours * 6, 6)) { return false; }
1007 var red = parseInt(this._sock.rQshift16() / 256, 10);
1008 var green = parseInt(this._sock.rQshift16() / 256, 10);
1009 var blue = parseInt(this._sock.rQshift16() / 256, 10);
1010 this._display.set_colourMap([blue, green, red], first_colour + c);
1012 Util.Debug("colourMap: " + this._display.get_colourMap());
1020 if (this._sock.rQwait("ServerCutText header", 7, 1)) { return false; }
1021 this._sock.rQskipBytes(3); // Padding
1022 var length = this._sock.rQshift32();
1023 if (this._sock.rQwait("ServerCutText", length, 8)) { return false; }
1025 var text = this._sock.rQshiftStr(length);
1026 this._onClipboard(this, text);
1032 if (this._sock.rQwait("XVP version and message", 3, 1)) { return false; }
1033 this._sock.rQskip8(); // Padding
1034 var xvp_ver = this._sock.rQshift8();
1035 var xvp_msg = this._sock.rQshift8();
1039 this._updateState(this._rfb_state, "Operation Failed");
1042 this._rfb_xvp_ver = xvp_ver;
1043 Util.Info("XVP extensions enabled (version " + this._rfb_xvp_ver + ")");
1044 this._onXvpInit(this._rfb_xvp_ver);
1047 this._fail("Disconnected: illegal server XVP message " + xvp_msg);
1057 if (this._FBU.rects > 0) {
1060 msg_type = this._sock.rQshift8();
1065 var ret = this._framebufferUpdate();
1067this._sock.send(RFB.messages.fbUpdateRequests(this._display.getCleanDirtyReset(),
1068this._fb_width, this._fb_height));
1073 return this._handle_set_colour_map_msg();
1077 this._onBell(this);
1081 return this._handle_server_cut_text();
1084 return this._handle_xvp_msg();
1087 this._fail("Disconnected: illegal server message type " + msg_type);
1088 Util.Debug("sock.rQslice(0, 30): " + this._sock.rQslice(0, 30));
1097 if (this._FBU.rects === 0) {
1098 if (this._sock.rQwait("FBU header", 3, 1)) { return false; }
1099 this._sock.rQskip8(); // Padding
1100 this._FBU.rects = this._sock.rQshift16();
1101 this._FBU.bytes = 0;
1102 this._timing.cur_fbu = 0;
1103 if (this._timing.fbu_rt_start > 0) {
1105 Util.Info("First FBU latency: " + (now - this._timing.fbu_rt_start));
1109 while (this._FBU.rects > 0) {
1110 if (this._rfb_state !== "normal") { return false; }
1112 if (this._sock.rQwait("FBU", this._FBU.bytes)) { return false; }
1113 if (this._FBU.bytes === 0) {
1114 if (this._sock.rQwait("rect header", 12)) { return false; }
1117 var hdr = this._sock.rQshiftBytes(12);
1118 this._FBU.x = (hdr[0] << 8) + hdr[1];
1119 this._FBU.y = (hdr[2] << 8) + hdr[3];
1120 this._FBU.width = (hdr[4] << 8) + hdr[5];
1121 this._FBU.height = (hdr[6] << 8) + hdr[7];
1122 this._FBU.encoding = parseInt((hdr[8] << 24) + (hdr[9] << 16) +
1125 this._onFBUReceive(this,
1126 {'x': this._FBU.x, 'y': this._FBU.y,
1127 'width': this._FBU.width, 'height': this._FBU.height,
1128 'encoding': this._FBU.encoding,
1129 'encodingName': this._encNames[this._FBU.encoding]});
1131 if (!this._encNames[this._FBU.encoding]) {
1132 this._fail("Disconnected: unsupported encoding " +
1133 this._FBU.encoding);
1138 this._timing.last_fbu = (new Date()).getTime();
1140 ret = this._encHandlers[this._FBU.encoding]();
1143 this._timing.cur_fbu += (now - this._timing.last_fbu);
1146 this._encStats[this._FBU.encoding][0]++;
1147 this._encStats[this._FBU.encoding][1]++;
1148 this._timing.pixels += this._FBU.width * this._FBU.height;
1151 if (this._timing.pixels >= (this._fb_width * this._fb_height)) {
1152 … if ((this._FBU.width === this._fb_width && this._FBU.height === this._fb_height) ||
1153 this._timing.fbu_rt_start > 0) {
1154 this._timing.full_fbu_total += this._timing.cur_fbu;
1155 this._timing.full_fbu_cnt++;
1157 this._timing.cur_fbu + ", total: " +
1158 this._timing.full_fbu_total + ", cnt: " +
1159 this._timing.full_fbu_cnt + ", avg: " +
1160 (this._timing.full_fbu_total / this._timing.full_fbu_cnt));
1163 if (this._timing.fbu_rt_start > 0) {
1164 var fbu_rt_diff = now - this._timing.fbu_rt_start;
1165 this._timing.fbu_rt_total += fbu_rt_diff;
1166 this._timing.fbu_rt_cnt++;
1169 this._timing.fbu_rt_total + ", cnt: " +
1170 this._timing.fbu_rt_cnt + ", avg: " +
1171 (this._timing.fbu_rt_total / this._timing.fbu_rt_cnt));
1172 this._timing.fbu_rt_start = 0;
1179 this._onFBUComplete(this,
1180 {'x': this._FBU.x, 'y': this._FBU.y,
1181 'width': this._FBU.width, 'height': this._FBU.height,
1182 'encoding': this._FBU.encoding,
1183 'encodingName': this._encNames[this._FBU.encoding]});
1185 return true; // We finished this FBU
1212 …vpInit', 'rw', 'func'], // onXvpInit(version): XVP extensions active for this connection
1217 this._local_cursor = false;
1219 if (this._display.get_cursor_uri()) {
1220 this._local_cursor = true;
1227 RFB.prototype.get_display = function () { return this._display; };
1228 RFB.prototype.get_keyboard = function () { return this._keyboard; };
1229 RFB.prototype.get_mouse = function () { return this._mouse; };
1249 // TODO(directxman12): make this unicode compatible?
1295 // TODO: remove this when we have tight+non-true-color
1365 if (this._FBU.lines === 0) {
1366 this._FBU.lines = this._FBU.height;
1369 this._FBU.bytes = this._FBU.width * this._fb_Bpp; // at least a line
1370 if (this._sock.rQwait("RAW", this._FBU.bytes)) { return false; }
1371 var cur_y = this._FBU.y + (this._FBU.height - this._FBU.lines);
1372 var curr_height = Math.min(this._FBU.lines,
1373 … Math.floor(this._sock.rQlen() / (this._FBU.width * this._fb_Bpp)));
1374 this._display.blitImage(this._FBU.x, cur_y, this._FBU.width,
1375 curr_height, this._sock.get_rQ(),
1376 this._sock.get_rQi());
1377 this._sock.rQskipBytes(this._FBU.width * curr_height * this._fb_Bpp);
1378 this._FBU.lines -= curr_height;
1380 if (this._FBU.lines > 0) {
1381 this._FBU.bytes = this._FBU.width * this._fb_Bpp; // At least another line
1383 this._FBU.rects--;
1384 this._FBU.bytes = 0;
1391 this._FBU.bytes = 4;
1392 if (this._sock.rQwait("COPYRECT", 4)) { return false; }
1393 this._display.renderQ_push({
1395 'old_x': this._sock.rQshift16(),
1396 'old_y': this._sock.rQshift16(),
1397 'x': this._FBU.x,
1398 'y': this._FBU.y,
1399 'width': this._FBU.width,
1400 'height': this._FBU.height
1402 this._FBU.rects--;
1403 this._FBU.bytes = 0;
1409 if (this._FBU.subrects === 0) {
1410 this._FBU.bytes = 4 + this._fb_Bpp;
1411 if (this._sock.rQwait("RRE", 4 + this._fb_Bpp)) { return false; }
1412 this._FBU.subrects = this._sock.rQshift32();
1413 color = this._sock.rQshiftBytes(this._fb_Bpp); // Background
1414this._display.fillRect(this._FBU.x, this._FBU.y, this._FBU.width, this._FBU.height, color);
1417 while (this._FBU.subrects > 0 && this._sock.rQlen() >= (this._fb_Bpp + 8)) {
1418 color = this._sock.rQshiftBytes(this._fb_Bpp);
1419 var x = this._sock.rQshift16();
1420 var y = this._sock.rQshift16();
1421 var width = this._sock.rQshift16();
1422 var height = this._sock.rQshift16();
1423 this._display.fillRect(this._FBU.x + x, this._FBU.y + y, width, height, color);
1424 this._FBU.subrects--;
1427 if (this._FBU.subrects > 0) {
1428 var chunk = Math.min(this._rre_chunk_sz, this._FBU.subrects);
1429 this._FBU.bytes = (this._fb_Bpp + 8) * chunk;
1431 this._FBU.rects--;
1432 this._FBU.bytes = 0;
1439 var rQ = this._sock.get_rQ();
1440 var rQi = this._sock.get_rQi();
1442 if (this._FBU.tiles === 0) {
1443 this._FBU.tiles_x = Math.ceil(this._FBU.width / 16);
1444 this._FBU.tiles_y = Math.ceil(this._FBU.height / 16);
1445 this._FBU.total_tiles = this._FBU.tiles_x * this._FBU.tiles_y;
1446 this._FBU.tiles = this._FBU.total_tiles;
1449 while (this._FBU.tiles > 0) {
1450 this._FBU.bytes = 1;
1451 if (this._sock.rQwait("HEXTILE subencoding", this._FBU.bytes)) { return false; }
1454 this._fail("Disconnected: illegal hextile subencoding " + subencoding);
1459 var curr_tile = this._FBU.total_tiles - this._FBU.tiles;
1460 var tile_x = curr_tile % this._FBU.tiles_x;
1461 var tile_y = Math.floor(curr_tile / this._FBU.tiles_x);
1462 var x = this._FBU.x + tile_x * 16;
1463 var y = this._FBU.y + tile_y * 16;
1464 var w = Math.min(16, (this._FBU.x + this._FBU.width) - x);
1465 var h = Math.min(16, (this._FBU.y + this._FBU.height) - y);
1469 this._FBU.bytes += w * h * this._fb_Bpp;
1472 this._FBU.bytes += this._fb_Bpp;
1475 this._FBU.bytes += this._fb_Bpp;
1478 this._FBU.bytes++; // Since we aren't shifting it off
1479 … if (this._sock.rQwait("hextile subrects header", this._FBU.bytes)) { return false; }
1480 subrects = rQ[rQi + this._FBU.bytes - 1]; // Peek
1482 this._FBU.bytes += subrects * (this._fb_Bpp + 2);
1484 this._FBU.bytes += subrects * 2;
1489 if (this._sock.rQwait("hextile", this._FBU.bytes)) { return false; }
1492 this._FBU.subencoding = rQ[rQi];
1494 if (this._FBU.subencoding === 0) {
1495 if (this._FBU.lastsubencoding & 0x01) {
1499 this._display.fillRect(x, y, w, h, rQ, rQi);
1500 rQi += this._FBU.bytes - 1;
1502 } else if (this._FBU.subencoding & 0x01) { // Raw
1503 this._display.blitImage(x, y, w, h, rQ, rQi);
1504 rQi += this._FBU.bytes - 1;
1506 if (this._FBU.subencoding & 0x02) { // Background
1507 this._FBU.background = rQ.slice(rQi, rQi + this._fb_Bpp);
1508 rQi += this._fb_Bpp;
1510 if (this._FBU.subencoding & 0x04) { // Foreground
1511 this._FBU.foreground = rQ.slice(rQi, rQi + this._fb_Bpp);
1512 rQi += this._fb_Bpp;
1515 this._display.startTile(x, y, w, h, this._FBU.background);
1516 if (this._FBU.subencoding & 0x08) { // AnySubrects
1522 if (this._FBU.subencoding & 0x10) { // SubrectsColoured
1523 color = rQ.slice(rQi, rQi + this._fb_Bpp);
1524 rQi += this._fb_Bpp;
1526 color = this._FBU.foreground;
1538 this._display.subTile(sx, sy, sw, sh, color);
1541 this._display.finishTile();
1543 this._sock.set_rQi(rQi);
1544 this._FBU.lastsubencoding = this._FBU.subencoding;
1545 this._FBU.bytes = 0;
1546 this._FBU.tiles--;
1549 if (this._FBU.tiles === 0) {
1550 this._FBU.rects--;
1571 if (this._fb_depth === 1) {
1572 this._fail("Tight protocol handler only implements true color mode");
1575 this._FBU.bytes = 1; // compression-control byte
1576 if (this._sock.rQwait("TIGHT compression-control", this._FBU.bytes)) { return false; }
1592 this._FBU.zlibs[i].reset();
1597 var uncompressed = this._FBU.zlibs[streamId].uncompress(data, 0);
1603 }.bind(this);
1647 }.bind(this);
1649 var rQ = this._sock.get_rQ();
1650 var rQi = this._sock.get_rQi();
1655 var paletteSize = numColors * this._fb_depth;
1656 this._FBU.bytes += paletteSize;
1657 if (this._sock.rQwait("TIGHT palette " + cmode, this._FBU.bytes)) { return false; }
1660 var rowSize = Math.floor((this._FBU.width * bpp + 7) / 8);
1662 if (rowSize * this._FBU.height < 12) {
1664 clength = [0, rowSize * this._FBU.height];
1666 … clength = RFB.encodingHandlers.getTightCLength(this._sock.rQslice(3 + paletteSize,
1670 this._FBU.bytes += clength[0] + clength[1];
1671 if (this._sock.rQwait("TIGHT " + cmode, this._FBU.bytes)) { return false; }
1674 this._sock.rQskipBytes(3);
1675 var palette = this._sock.rQshiftBytes(paletteSize);
1676 this._sock.rQskipBytes(clength[0]);
1679 data = this._sock.rQshiftBytes(clength[1]);
1681 data = decompress(this._sock.rQshiftBytes(clength[1]));
1685 var rgb = indexedToRGB(data, numColors, palette, this._FBU.width, this._FBU.height);
1687 this._display.renderQ_push({
1690 'x': this._FBU.x,
1691 'y': this._FBU.y,
1692 'width': this._FBU.width,
1693 'height': this._FBU.height
1697 }.bind(this);
1701 var uncompressedSize = this._FBU.width * this._FBU.height * this._fb_depth;
1706 clength = RFB.encodingHandlers.getTightCLength(this._sock.rQslice(1, 4));
1708 this._FBU.bytes = 1 + clength[0] + clength[1];
1709 if (this._sock.rQwait("TIGHT " + cmode, this._FBU.bytes)) { return false; }
1712 this._sock.rQshiftBytes(1 + clength[0]);
1715 data = this._sock.rQshiftBytes(clength[1]);
1717 data = decompress(this._sock.rQshiftBytes(clength[1]));
1720 this._display.renderQ_push({
1723 'x': this._FBU.x,
1724 'y': this._FBU.y,
1725 'width': this._FBU.width,
1726 'height': this._FBU.height
1730 }.bind(this);
1732 var ctl = this._sock.rQpeek8();
1746 else return this._fail("Illegal tight compression received, ctl: " + ctl);
1749 return this._fail("filter/copy received in tightPNG mode");
1755 this._FBU.bytes += this._fb_depth;
1758 this._FBU.bytes += 3;
1761 this._FBU.bytes += 3;
1764 this._FBU.bytes += 2;
1770 if (this._sock.rQwait("TIGHT " + cmode, this._FBU.bytes)) { return false; }
1775 this._sock.rQskip8(); // shift off ctl
1776 var color = this._sock.rQshiftBytes(this._fb_depth);
1777 this._display.renderQ_push({
1779 'x': this._FBU.x,
1780 'y': this._FBU.y,
1781 'width': this._FBU.width,
1782 'height': this._FBU.height,
1788 clength = RFB.encodingHandlers.getTightCLength(this._sock.rQslice(1, 4));
1789this._FBU.bytes = 1 + clength[0] + clength[1]; // ctl + clength size + jpeg-data
1790 if (this._sock.rQwait("TIGHT " + cmode, this._FBU.bytes)) { return false; }
1793 this._sock.rQskipBytes(1 + clength[0]); // shift off clt + compact length
1796 RFB.extract_data_uri(this._sock.rQshiftBytes(clength[1]));
1797 this._display.renderQ_push({
1800 'x': this._FBU.x,
1801 'y': this._FBU.y
1822 this._FBU.bytes = 0;
1823 this._FBU.rects--;
1828 TIGHT: function () { return this._encHandlers.display_tight(false); },
1829 TIGHT_PNG: function () { return this._encHandlers.display_tight(true); },
1832 this._FBU.rects = 0;
1838 this._fb_width = this._FBU.width;
1839 this._fb_height = this._FBU.height;
1840 this._onFBResize(this, this._fb_width, this._fb_height);
1841 this._display.resize(this._fb_width, this._fb_height);
1842 this._timing.fbu_rt_start = (new Date()).getTime();
1844 this._FBU.bytes = 0;
1845 this._FBU.rects--;
1853 var x = this._FBU.x; // hotspot-x
1854 var y = this._FBU.y; // hotspot-y
1855 var w = this._FBU.width;
1856 var h = this._FBU.height;
1858 var pixelslength = w * h * this._fb_Bpp;
1861 this._FBU.bytes = pixelslength + masklength;
1862 if (this._sock.rQwait("cursor encoding", this._FBU.bytes)) { return false; }
1864 this._display.changeCursor(this._sock.rQshiftBytes(pixelslength),
1865 this._sock.rQshiftBytes(masklength),
1868 this._FBU.bytes = 0;
1869 this._FBU.rects--;