diff options
author | Pierre Ossman <ossman@cendio.se> | 2014-01-16 13:12:40 +0100 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2014-07-07 14:42:08 +0200 |
commit | 7638e9c5b1c59abc98e27986b8178f19e5e6cf2a (patch) | |
tree | 3e87cbfbbdc731017a5b0bff751a8b9deaa83c66 /common/rfb/SMsgReader.cxx | |
parent | 95f1f294d0fd7b006f52d18d39ae0c3116258d91 (diff) | |
download | tigervnc-7638e9c5b1c59abc98e27986b8178f19e5e6cf2a.tar.gz tigervnc-7638e9c5b1c59abc98e27986b8178f19e5e6cf2a.zip |
Merge the "V3" message classes into the normal ones
We have no need for this abstraction so let's keep things simple.
Diffstat (limited to 'common/rfb/SMsgReader.cxx')
-rw-r--r-- | common/rfb/SMsgReader.cxx | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/common/rfb/SMsgReader.cxx b/common/rfb/SMsgReader.cxx index 49d8dcf1..89c9a8fd 100644 --- a/common/rfb/SMsgReader.cxx +++ b/common/rfb/SMsgReader.cxx @@ -1,4 +1,5 @@ /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. + * Copyright 2009-2014 Pierre Ossman for Cendio AB * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,6 +18,7 @@ */ #include <stdio.h> #include <rdr/InStream.h> +#include <rfb/msgTypes.h> #include <rfb/Exception.h> #include <rfb/util.h> #include <rfb/SMsgHandler.h> @@ -39,6 +41,49 @@ SMsgReader::~SMsgReader() { } +void SMsgReader::readClientInit() +{ + bool shared = is->readU8(); + handler->clientInit(shared); +} + +void SMsgReader::readMsg() +{ + int msgType = is->readU8(); + switch (msgType) { + case msgTypeSetPixelFormat: + readSetPixelFormat(); + break; + case msgTypeSetEncodings: + readSetEncodings(); + break; + case msgTypeSetDesktopSize: + readSetDesktopSize(); + break; + case msgTypeFramebufferUpdateRequest: + readFramebufferUpdateRequest(); + break; + case msgTypeEnableContinuousUpdates: + readEnableContinuousUpdates(); + break; + case msgTypeClientFence: + readFence(); + break; + case msgTypeKeyEvent: + readKeyEvent(); + break; + case msgTypePointerEvent: + readPointerEvent(); + break; + case msgTypeClientCutText: + readClientCutText(); + break; + default: + fprintf(stderr, "unknown message type %d\n", msgType); + throw Exception("unknown message type"); + } +} + void SMsgReader::readSetPixelFormat() { is->skip(3); @@ -57,6 +102,36 @@ void SMsgReader::readSetEncodings() handler->setEncodings(nEncodings, encodings.buf); } +void SMsgReader::readSetDesktopSize() +{ + int width, height; + int screens, i; + rdr::U32 id, flags; + int sx, sy, sw, sh; + ScreenSet layout; + + is->skip(1); + + width = is->readU16(); + height = is->readU16(); + + screens = is->readU8(); + is->skip(1); + + for (i = 0;i < screens;i++) { + id = is->readU32(); + sx = is->readU16(); + sy = is->readU16(); + sw = is->readU16(); + sh = is->readU16(); + flags = is->readU32(); + + layout.add_screen(Screen(id, sx, sy, sw, sh, flags)); + } + + handler->setDesktopSize(width, height, layout); +} + void SMsgReader::readFramebufferUpdateRequest() { bool inc = is->readU8(); @@ -67,6 +142,43 @@ void SMsgReader::readFramebufferUpdateRequest() handler->framebufferUpdateRequest(Rect(x, y, x+w, y+h), inc); } +void SMsgReader::readEnableContinuousUpdates() +{ + bool enable; + int x, y, w, h; + + enable = is->readU8(); + + x = is->readU16(); + y = is->readU16(); + w = is->readU16(); + h = is->readU16(); + + handler->enableContinuousUpdates(enable, x, y, w, h); +} + +void SMsgReader::readFence() +{ + rdr::U32 flags; + rdr::U8 len; + char data[64]; + + is->skip(3); + + flags = is->readU32(); + + len = is->readU8(); + if (len > sizeof(data)) { + fprintf(stderr, "Ignoring fence with too large payload\n"); + is->skip(len); + return; + } + + is->readBytes(data, len); + + handler->fence(flags, len, data); +} + void SMsgReader::readKeyEvent() { bool down = is->readU8(); |