Commit Graph

179 Commits

Author SHA1 Message Date
Samuel Mannehed a7127fee73 Don't abuse state change function for messages
This doesn't even work anymore since we fixed it to ignore changes
to the current state. Add a separate callback for notifications
instead.
2016-10-01 01:29:44 +02:00
Samuel Mannehed 4cfd49c8c3 Don't change state to same state
The comment already stated as much, but the code was broken.
2016-10-01 00:02:56 +02:00
Samuel Mannehed 7d714b15f5 Remove special password state
We already have a callback mechanism for this, so let's use that.
Adds an optional parameter 'msg' to the callback.
Fixes vnc_auto.html (#646) which was broken after
4e0c36dda7
2016-10-01 00:02:47 +02:00
Lars Ole Hurlen 49aa5b81c7 Detect RealVNC's RFB 5.0 Protocol Version
The RFB protocol specifies a max version of 3.8, but RealVNC likes to
increment their version when they add new features.  RealVNC 5.3 sends
"005.000" as the version string, since they've extended their
implementation upon RFB v3.8.  We can detect that, and just tell them we
only speak 3.8, instead of barfing on "005.000" as an invalid version.
2016-09-16 17:33:46 -04:00
Solly Ross bd5340c7ee Move input-related files into core/input
This commit moves all the input-related files from `core/`
to `core/input/`, and renames a couple as relevant
(input.js --> input/devices.js, keyboard.js --> input/util.js).
2016-09-16 15:49:52 -04:00
Solly Ross 3949a09534 Don't modify Array prototype
This commit removes our modification of the Array prototype.
It wasn't actually used much in the main code, anyway, and it's a
bad practice to modify built-in prototypes.
2016-09-16 15:49:52 -04:00
Daniel Henrique Barboza 8f06673a25 QEMU RFB extension - rfb.js and input.js changes
In input.js, a new keyboard handler was added to deal exclusively
with the QEMU key event extension. '_onKeyPress()' signature
was changed to allow the same method to treat both cases.

The extension will only be enabled if the browser has support
for the KeyboardEvent.code property.

Changes in rfb.js:

- added a new extension code, QEMUExtendedKeyEvent, value -258.

- handleKeyPress now receives 'keyevent' instead of 'keysym' and
'down'. Both values are retrieved from keyevent as they were
in the previous signature. This method now can send QEMU RFB
extended key messages if the flag was set to 'true'.

- tests/test.rfb.js were changed folowing the onKeyPress() signature
change.

- added a new function to send the QEMU extended key message.

Signed-off-by: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com>
2016-08-26 17:34:39 -03:00
samhed 76a86ff514 Add support for ContinuousUpdates
Instead of requesting frame buffer updates we can, if the server
supports it, continuously recieve frame buffer updates at a rate
determined by the server.

The server can use fencing messages and measure response times to
determine how often it will continue to send updates.
2016-08-26 11:04:19 +02:00
samhed 3df1326239 Add support for fences
We don't actually use these, but servers may require this for other
features.
2016-06-03 16:37:19 +02:00
samhed 37195e4b5e Lower level check for framebuffer update requests
Try to avoid using helper functions with complex logic when verifying
results as those helper functions are also something we want to verify.

Also add a test for a mix of clean and dirty areas specifically to make
sure that helper function behaves properly.
2016-06-03 16:35:59 +02:00
samhed 89d2837fa8 Always flush socket after each message
Make sure our messages go away right away, rather than having to
remember to call flush from the caller, or causing extra delays by
waiting for the send timer. This should result in a more responsive
system.
2016-06-03 16:32:28 +02:00
samhed cf0236de18 Fix typo in pointer event test 2016-06-03 16:31:12 +02:00
Samuel ae11605141 Split the setDesktopSize function (#618)
In order to follow the surrounding coding-standards, the
setDesktopSize client message is split from the public function which
now is called requestDesktopSize().
2016-06-02 22:37:52 +02:00
Samuel Mannehed 057cfc7cb4 Add missing parenthesis (#600) 2016-04-30 04:26:30 +02:00
Samuel Mannehed 12ae8b3d50 Respect the threshold in the viewdrag test (#600) 2016-04-30 04:08:34 +02:00
Solly Ross 9ff86fb718 Use Typed Arrays for the send queue
This commit converts the send queue to use typed arrays, and converts
message creation functions in 'rfb.js' to create messages directly into
the socket's send queue.  This commit also removes the separate mouse array,
which is no longer needed.
2015-08-06 14:47:03 -04:00
Solly Ross 38781d931e Use Typed Arrays for the Websock receive queue
**This commit removes Base64 (and Flash) support**

This commit converts websock.js to used Typed Arrays for the
receive queue (and tweaks rfb.js to ensure that it continues
to function, since only Firefox implements
`%TypedArray%.prototype.slice`).  Base64 support was removed
to simplify code paths, and pave the way for using Typed Arrays
for the send queue as well.

This provides two advantages: first, we allocate a buffer ahead
of time, meaning the browser doesn't have to do any work dynamically
increasing the receive queue size.  Secondly, we are now able to pass
around Typed Array Views (e.g. `Uint8Array`), which are lightweight, and
don't involve copying.

The downside is that we initially allocate more memory -- we currently
start out with 4 MiB, and then automatically double when it looks like
the amount unused is getting to small.

The commit also explicitly adds a check to the compacting logic that
avoids calling the copy functions if `_rQlen === _rQi`.
2015-08-06 14:47:03 -04:00
Solly Ross 6940936ffc WIP: Switch to Pako for zlib
This commit introduces an alternate implementation of the zlib
decompressor based on Pako (https://github.com/nodeca/pako).
2015-08-06 14:47:03 -04:00
samhed 798340b98d * Change name of ext_desktop_size to the proper ExtendedDesktopSize
* Added better error handling in ExtendedDesktopSize
* Added helper function to share code with DesktopSize
* Update test.rfb.js to only check for error handling if we were the
  ones requesting the resize
2015-03-05 14:56:47 +01:00
samhed 4dec490aae Support automatic resize [Part 4/4]: unit tests
* Added new tests for the setDesktopSize encoding
* Added new tests for the ExtendedDesktopSize encoding
2015-02-10 17:06:55 +01:00
samhed 636be753b2 Support automatic resize [Part 1/4]: display.js
* Split viewportChange into two functions, one for changing size and the other for changing position.
* Modified viewport code to be capable of changing to a bigger size in the context of a
  client-initiated resize.
* Made clearer distinctions between when viewport-clipping or not.
* Added public function for telling when viewport-clipping.
* Updated tests that were using viewportChange.
2015-02-06 16:54:14 +01:00
Jacob Swanner 155d78b399 Unregister event listeners from websock.
Prevents possible memory and event notification leaks when tearing down
connection and reestablishing a new one.
2015-01-08 15:25:55 -05:00
Solly Ross 4865278dee Fixed Erroneous HEXTILE test
The HEXTILE test which tested for a background tile followed
by an empty tile was only wide enough to actually test for one
tile, thus not actually testing the functionality.  It now actually
uses two tiles, thus actually testing the functionality.
2014-11-24 15:19:04 -05:00
Ramon de Klein 40ac6f0ab6 Don't draw "blank" HEXTILE tiles with random data
Previously, if a HEXTILE tiles was received with a subencoding
of 0x00, it would draw a rectangle using data from the render
queue, which would result in random colored blocks when using
the HEXTILE encoding.  This is the result of a miscopy during
the refactoring.  It now has the correct functionality according
to the RFB protocol specification, which is to draw a rectangle
with the last set background color.

Closes #411
2014-11-17 20:01:28 -05:00
Solly Ross fda40d8927 Fix broken tests from changing default screen size
Commit 795fca23dc changed the default
size from 640 to 240.  This broke a couple tests which depended on
the default size being 640.  Those tests have now been fixed.
2014-11-17 14:19:19 -05:00
Solly Ross 3b4fd003c2 Fixed broken mouse test in test.rfb.js
Because we use the XOR (`^`) operator, the button mask must be
set before a MouseUp event happens, otherwise we'll send a pointer
event like it was a MouseDown event.  The button mask was not set
in one of the tests, so the test was failing.
2014-09-19 15:14:34 -04:00
Solly Ross d02a99f0c8 Fixed Typo Causing MouseUp to not Register
There was a typo in one of the instances of the _buttonMask field
(it was written as _buttonMaks), causing MouseUp to never be sent.
This has been rectified, and the unit tests for the mouse handler
have been changed to check for explicitly sending mouseup and
mousedown.

Fixes #393
2014-09-19 14:18:45 -04:00
Solly Ross 2c9623b5a7 Fixed assertion collision issues
When run via karma, all the tests are loaded into the same page.
This was causing a collision in the 'displayed' assertion dealing
with using viewportLoc.

The assertions are now in their own file, pulled in by tests that
need them.  Additionally, several tests which only set fb_width
and fb_height were correct to set viewportLoc as well.

Closes #392

Also-Authored-By: Martin André (github: mandre)
2014-09-19 12:16:06 -04:00
Solly Ross b1dee94788 Cleanup: RFB Client
File: rfb.js (also websock.js)
Tests Added: True

Changes:
- De-Crockford-ified rfb.js
- Added methods to websock.js to skip bytes in the receive queue
2014-09-15 16:46:02 -04:00