blob: 286a09eda04041a9f435e665cc5fdc829b29a206 [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
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>
26#include <network/Socket.h>
27
Pierre Ossman947b48d2014-01-27 16:52:35 +010028class DesktopWindow;
Pierre Ossman5156d5e2011-03-09 09:42:34 +000029
30class CConn : public rfb::CConnection,
31 public rdr::FdInStreamBlockCallback
32{
33public:
Pierre Ossman2a7a8d62013-02-15 08:33:39 +000034 CConn(const char* vncServerName, network::Socket* sock);
Pierre Ossman5156d5e2011-03-09 09:42:34 +000035 ~CConn();
36
Pierre Ossmand4c61ce2011-04-29 11:18:12 +000037 void refreshFramebuffer();
38
Pierre Ossman2eb1d112011-05-16 12:18:08 +000039 const char *connectionInfo();
40
Pierre Ossman5156d5e2011-03-09 09:42:34 +000041 // FdInStreamBlockCallback methods
42 void blockCallback();
43
44 // Callback when socket is ready (or broken)
DRC3e7ed812013-02-26 10:34:22 +000045 static void socketEvent(FL_SOCKET fd, void *data);
Pierre Ossman5156d5e2011-03-09 09:42:34 +000046
47 // CConnection callback methods
48 void serverInit();
49
50 void setDesktopSize(int w, int h);
51 void setExtendedDesktopSize(int reason, int result, int w, int h,
52 const rfb::ScreenSet& layout);
53
54 void setName(const char* name);
55
56 void setColourMapEntries(int firstColour, int nColours, rdr::U16* rgbs);
57
58 void bell();
59
60 void serverCutText(const char* str, rdr::U32 len);
61
62 void framebufferUpdateStart();
63 void framebufferUpdateEnd();
64
65 void beginRect(const rfb::Rect& r, int encoding);
66 void endRect(const rfb::Rect& r, int encoding);
67
68 void fillRect(const rfb::Rect& r, rfb::Pixel p);
69 void imageRect(const rfb::Rect& r, void* p);
70 void copyRect(const rfb::Rect& r, int sx, int sy);
71
Pierre Ossman945cdda2014-01-28 14:13:12 +010072 rdr::U8* getRawBufferRW(const rfb::Rect& r, int* stride);
73 void releaseRawBuffer(const rfb::Rect& r);
DRC33c15e32011-11-03 18:49:21 +000074
75 const rfb::PixelFormat &getPreferredPF() { return fullColourPF; }
76
Pierre Ossman5156d5e2011-03-09 09:42:34 +000077 void setCursor(int width, int height, const rfb::Point& hotspot,
78 void* data, void* mask);
79
Pierre Ossmane28bdb22011-11-14 16:02:06 +000080 void fence(rdr::U32 flags, unsigned len, const char data[]);
81
Pierre Ossman5156d5e2011-03-09 09:42:34 +000082private:
83
84 void resizeFramebuffer();
85
86 void autoSelectFormatAndEncoding();
87 void checkEncodings();
88 void requestNewUpdate();
89
Pierre Ossmanf4f30942011-05-17 09:39:07 +000090 static void handleOptions(void *data);
91
Pierre Ossman5156d5e2011-03-09 09:42:34 +000092private:
93 char* serverHost;
94 int serverPort;
95 network::Socket* sock;
96
97 DesktopWindow *desktop;
98
99 rfb::PixelFormat serverPF;
100 rfb::PixelFormat fullColourPF;
101
Pierre Ossman5d512c32011-11-04 11:42:16 +0000102 bool pendingPFChange;
103 rfb::PixelFormat pendingPF;
104
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000105 int currentEncoding, lastServerEncoding;
106
107 bool formatChange;
108 bool encodingChange;
109
110 bool firstUpdate;
111 bool pendingUpdate;
Pierre Ossmanaa73c892011-11-15 12:13:37 +0000112 bool continuousUpdates;
Pierre Ossmand4c61ce2011-04-29 11:18:12 +0000113
114 bool forceNonincremental;
Pierre Ossmane28bdb22011-11-14 16:02:06 +0000115
116 bool supportsSyncFence;
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000117};
118
119#endif