blob: c934f3da55a7bceb31cfc4c033cfbada13e266a4 [file] [log] [blame]
Pierre Ossman5156d5e2011-03-09 09:42:34 +00001/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
Pierre Ossmanfdba3fe2014-01-31 13:12:18 +01002 * Copyright 2009-2014 Pierre Ossman for Cendio AB
Pierre Ossman5156d5e2011-03-09 09:42:34 +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#ifndef __CCONN_H__
21#define __CCONN_H__
22
Pierre Ossman947b48d2014-01-27 16:52:35 +010023#include <FL/Fl.H>
24
Pierre Ossman5156d5e2011-03-09 09:42:34 +000025#include <rfb/CConnection.h>
Pierre Ossman9f273e92015-11-09 16:34:54 +010026#include <rdr/FdInStream.h>
Pierre Ossman5156d5e2011-03-09 09:42:34 +000027
Pierre Ossman9f273e92015-11-09 16:34:54 +010028namespace network { class Socket; }
Pierre Ossmanfdba3fe2014-01-31 13:12:18 +010029
Pierre Ossman947b48d2014-01-27 16:52:35 +010030class DesktopWindow;
Pierre Ossman5156d5e2011-03-09 09:42:34 +000031
32class CConn : public rfb::CConnection,
33 public rdr::FdInStreamBlockCallback
34{
35public:
Pierre Ossman2a7a8d62013-02-15 08:33:39 +000036 CConn(const char* vncServerName, network::Socket* sock);
Pierre Ossman5156d5e2011-03-09 09:42:34 +000037 ~CConn();
38
Pierre Ossmand4c61ce2011-04-29 11:18:12 +000039 void refreshFramebuffer();
40
Pierre Ossman2eb1d112011-05-16 12:18:08 +000041 const char *connectionInfo();
42
Pierre Ossman5156d5e2011-03-09 09:42:34 +000043 // FdInStreamBlockCallback methods
44 void blockCallback();
45
46 // Callback when socket is ready (or broken)
DRC3e7ed812013-02-26 10:34:22 +000047 static void socketEvent(FL_SOCKET fd, void *data);
Pierre Ossman5156d5e2011-03-09 09:42:34 +000048
49 // CConnection callback methods
50 void serverInit();
51
52 void setDesktopSize(int w, int h);
Pierre Ossman28c1d542015-03-03 16:27:44 +010053 void setExtendedDesktopSize(unsigned reason, unsigned result,
54 int w, int h, const rfb::ScreenSet& layout);
Pierre Ossman5156d5e2011-03-09 09:42:34 +000055
56 void setName(const char* name);
57
58 void setColourMapEntries(int firstColour, int nColours, rdr::U16* rgbs);
59
60 void bell();
61
62 void serverCutText(const char* str, rdr::U32 len);
63
64 void framebufferUpdateStart();
65 void framebufferUpdateEnd();
Pierre Ossmanfdba3fe2014-01-31 13:12:18 +010066 void dataRect(const rfb::Rect& r, int encoding);
Pierre Ossman5156d5e2011-03-09 09:42:34 +000067
Pierre Ossman5156d5e2011-03-09 09:42:34 +000068 void setCursor(int width, int height, const rfb::Point& hotspot,
69 void* data, void* mask);
70
Pierre Ossmane28bdb22011-11-14 16:02:06 +000071 void fence(rdr::U32 flags, unsigned len, const char data[]);
72
Pierre Ossman5156d5e2011-03-09 09:42:34 +000073private:
74
75 void resizeFramebuffer();
76
77 void autoSelectFormatAndEncoding();
78 void checkEncodings();
79 void requestNewUpdate();
80
Pierre Ossmanf4f30942011-05-17 09:39:07 +000081 static void handleOptions(void *data);
82
Pierre Ossmand9b90032015-09-23 12:18:52 +020083 static void handleUpdateTimeout(void *data);
84
Pierre Ossman5156d5e2011-03-09 09:42:34 +000085private:
86 char* serverHost;
87 int serverPort;
88 network::Socket* sock;
89
90 DesktopWindow *desktop;
91
92 rfb::PixelFormat serverPF;
93 rfb::PixelFormat fullColourPF;
94
Pierre Ossman5d512c32011-11-04 11:42:16 +000095 bool pendingPFChange;
96 rfb::PixelFormat pendingPF;
97
Pierre Ossman5156d5e2011-03-09 09:42:34 +000098 int currentEncoding, lastServerEncoding;
99
100 bool formatChange;
101 bool encodingChange;
102
103 bool firstUpdate;
104 bool pendingUpdate;
Pierre Ossmanaa73c892011-11-15 12:13:37 +0000105 bool continuousUpdates;
Pierre Ossmand4c61ce2011-04-29 11:18:12 +0000106
107 bool forceNonincremental;
Pierre Ossmane28bdb22011-11-14 16:02:06 +0000108
109 bool supportsSyncFence;
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000110};
111
112#endif