blob: 0f5be621cb38e1954756dd91cd3fab32c61daf17 [file] [log] [blame]
Pierre Ossman5156d5e2011-03-09 09:42:34 +00001/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
2 * Copyright 2009-2011 Pierre Ossman <ossman@cendio.se> for Cendio AB
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 */
19
20#ifndef __CCONN_H__
21#define __CCONN_H__
22
23#include <rfb/CConnection.h>
24#include <network/Socket.h>
25
26#include "DesktopWindow.h"
27
28class CConn : public rfb::CConnection,
29 public rdr::FdInStreamBlockCallback
30{
31public:
32 CConn(const char* vncServerName);
33 ~CConn();
34
35 // FdInStreamBlockCallback methods
36 void blockCallback();
37
38 // Callback when socket is ready (or broken)
39 static void socketEvent(int fd, void *data);
40
41 // CConnection callback methods
42 void serverInit();
43
44 void setDesktopSize(int w, int h);
45 void setExtendedDesktopSize(int reason, int result, int w, int h,
46 const rfb::ScreenSet& layout);
47
48 void setName(const char* name);
49
50 void setColourMapEntries(int firstColour, int nColours, rdr::U16* rgbs);
51
52 void bell();
53
54 void serverCutText(const char* str, rdr::U32 len);
55
56 void framebufferUpdateStart();
57 void framebufferUpdateEnd();
58
59 void beginRect(const rfb::Rect& r, int encoding);
60 void endRect(const rfb::Rect& r, int encoding);
61
62 void fillRect(const rfb::Rect& r, rfb::Pixel p);
63 void imageRect(const rfb::Rect& r, void* p);
64 void copyRect(const rfb::Rect& r, int sx, int sy);
65
66 void setCursor(int width, int height, const rfb::Point& hotspot,
67 void* data, void* mask);
68
69private:
70
71 void resizeFramebuffer();
72
73 void autoSelectFormatAndEncoding();
74 void checkEncodings();
75 void requestNewUpdate();
76
77private:
78 char* serverHost;
79 int serverPort;
80 network::Socket* sock;
81
82 DesktopWindow *desktop;
83
84 rfb::PixelFormat serverPF;
85 rfb::PixelFormat fullColourPF;
86
87 int currentEncoding, lastServerEncoding;
88
89 bool formatChange;
90 bool encodingChange;
91
92 bool firstUpdate;
93 bool pendingUpdate;
94};
95
96#endif