Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 1 | /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. |
Pierre Ossman | c5e2560 | 2009-03-20 12:59:05 +0000 | [diff] [blame^] | 2 | * Copyright 2009 Pierre Ossman for Cendio AB |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 3 | * |
| 4 | * This is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License as published by |
| 6 | * the Free Software Foundation; either version 2 of the License, or |
| 7 | * (at your option) any later version. |
| 8 | * |
| 9 | * This software is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this software; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
| 17 | * USA. |
| 18 | */ |
Adam Tkac | 20e0d71 | 2008-11-14 14:48:21 +0000 | [diff] [blame] | 19 | |
| 20 | #include <stdio.h> |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 21 | #include <rfb/PixelFormat.h> |
| 22 | #include <rfb/msgTypes.h> |
| 23 | #include <rfb/Exception.h> |
| 24 | #include <rdr/InStream.h> |
| 25 | #include <rfb/SMsgReaderV3.h> |
| 26 | #include <rfb/SMsgHandler.h> |
| 27 | |
| 28 | using namespace rfb; |
| 29 | |
| 30 | SMsgReaderV3::SMsgReaderV3(SMsgHandler* handler, rdr::InStream* is) |
| 31 | : SMsgReader(handler, is) |
| 32 | { |
| 33 | } |
| 34 | |
| 35 | SMsgReaderV3::~SMsgReaderV3() |
| 36 | { |
| 37 | } |
| 38 | |
| 39 | void SMsgReaderV3::readClientInit() |
| 40 | { |
| 41 | bool shared = is->readU8(); |
| 42 | handler->clientInit(shared); |
| 43 | } |
| 44 | |
| 45 | void SMsgReaderV3::readMsg() |
| 46 | { |
| 47 | int msgType = is->readU8(); |
| 48 | switch (msgType) { |
| 49 | case msgTypeSetPixelFormat: readSetPixelFormat(); break; |
| 50 | case msgTypeSetEncodings: readSetEncodings(); break; |
| 51 | case msgTypeFramebufferUpdateRequest: readFramebufferUpdateRequest(); break; |
| 52 | case msgTypeKeyEvent: readKeyEvent(); break; |
| 53 | case msgTypePointerEvent: readPointerEvent(); break; |
| 54 | case msgTypeClientCutText: readClientCutText(); break; |
Pierre Ossman | c5e2560 | 2009-03-20 12:59:05 +0000 | [diff] [blame^] | 55 | case msgTypeSetDesktopSize: readSetDesktopSize(); break; |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 56 | |
Constantin Kaplinsky | a2adc8d | 2006-05-25 05:01:55 +0000 | [diff] [blame] | 57 | default: |
| 58 | fprintf(stderr, "unknown message type %d\n", msgType); |
| 59 | throw Exception("unknown message type"); |
| 60 | } |
| 61 | } |
Pierre Ossman | c5e2560 | 2009-03-20 12:59:05 +0000 | [diff] [blame^] | 62 | |
| 63 | void SMsgReaderV3::readSetDesktopSize() |
| 64 | { |
| 65 | int width, height; |
| 66 | int screens, i; |
| 67 | |
| 68 | is->skip(1); |
| 69 | |
| 70 | width = is->readU16(); |
| 71 | height = is->readU16(); |
| 72 | |
| 73 | screens = is->readU8(); |
| 74 | is->skip(1); |
| 75 | |
| 76 | // XXX: We don't support this command properly yet |
| 77 | is->skip(screens * 16); |
| 78 | |
| 79 | handler->setDesktopSize(width, height); |
| 80 | } |
| 81 | |