blob: 650f1642319af9e1035bccc8e620f785a3c67f0f [file] [log] [blame]
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +00001/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
Pierre Ossman7638e9c2014-01-16 13:12:40 +01002 * Copyright 2009-2014 Pierre Ossman for Cendio AB
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +00003 *
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 */
19//
20// CMsgReader - class for reading RFB messages on the server side
21// (i.e. messages from client to server).
22//
23
24#ifndef __RFB_CMSGREADER_H__
25#define __RFB_CMSGREADER_H__
26
27#include <rdr/types.h>
Pierre Ossman7638e9c2014-01-16 13:12:40 +010028
29#include <rfb/Rect.h>
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000030#include <rfb/encodings.h>
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000031
32namespace rdr { class InStream; }
33
34namespace rfb {
35 class CMsgHandler;
Pierre Ossman7638e9c2014-01-16 13:12:40 +010036 class Decoder;
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000037 struct Rect;
38
39 class CMsgReader {
40 public:
Pierre Ossman7638e9c2014-01-16 13:12:40 +010041 CMsgReader(CMsgHandler* handler, rdr::InStream* is);
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000042 virtual ~CMsgReader();
43
Pierre Ossman7638e9c2014-01-16 13:12:40 +010044 void readServerInit();
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000045
46 // readMsg() reads a message, calling the handler as appropriate.
Pierre Ossman7638e9c2014-01-16 13:12:40 +010047 void readMsg();
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000048
49 rdr::InStream* getInStream() { return is; }
50 rdr::U8* getImageBuf(int required, int requested=0, int* nPixels=0);
51 int bpp();
52
53 int imageBufIdealSize;
54
55 protected:
Pierre Ossman7638e9c2014-01-16 13:12:40 +010056 void readSetColourMapEntries();
57 void readBell();
58 void readServerCutText();
59 void readFence();
60 void readEndOfContinuousUpdates();
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000061
Pierre Ossman7638e9c2014-01-16 13:12:40 +010062 void readFramebufferUpdate();
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000063
Pierre Ossman7638e9c2014-01-16 13:12:40 +010064 void readRect(const Rect& r, int encoding);
65 void readCopyRect(const Rect& r);
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000066
Pierre Ossman7638e9c2014-01-16 13:12:40 +010067 void readSetCursor(int width, int height, const Point& hotspot);
68 void readSetDesktopName(int x, int y, int w, int h);
69 void readExtendedDesktopSize(int x, int y, int w, int h);
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000070
71 CMsgHandler* handler;
72 rdr::InStream* is;
73 Decoder* decoders[encodingMax+1];
74 rdr::U8* imageBuf;
75 int imageBufSize;
Pierre Ossman7638e9c2014-01-16 13:12:40 +010076 int nUpdateRectsLeft;
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000077 };
78}
79#endif