blob: 709ca2f80362f5462da92cbb7b84b7095aab5889 [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 Ossmanfdba3fe2014-01-31 13:12:18 +010026#include <rfb/encodings.h>
Pierre Ossman5156d5e2011-03-09 09:42:34 +000027#include <network/Socket.h>
28
Pierre Ossmanfdba3fe2014-01-31 13:12:18 +010029namespace rfb { class Decoder; }
30
Pierre Ossman947b48d2014-01-27 16:52:35 +010031class DesktopWindow;
Pierre Ossman5156d5e2011-03-09 09:42:34 +000032
33class CConn : public rfb::CConnection,
34 public rdr::FdInStreamBlockCallback
35{
36public:
Pierre Ossman2a7a8d62013-02-15 08:33:39 +000037 CConn(const char* vncServerName, network::Socket* sock);
Pierre Ossman5156d5e2011-03-09 09:42:34 +000038 ~CConn();
39
Pierre Ossmand4c61ce2011-04-29 11:18:12 +000040 void refreshFramebuffer();
41
Pierre Ossman2eb1d112011-05-16 12:18:08 +000042 const char *connectionInfo();
43
Pierre Ossman5156d5e2011-03-09 09:42:34 +000044 // FdInStreamBlockCallback methods
45 void blockCallback();
46
47 // Callback when socket is ready (or broken)
DRC3e7ed812013-02-26 10:34:22 +000048 static void socketEvent(FL_SOCKET fd, void *data);
Pierre Ossman5156d5e2011-03-09 09:42:34 +000049
50 // CConnection callback methods
51 void serverInit();
52
53 void setDesktopSize(int w, int h);
54 void setExtendedDesktopSize(int reason, int result, int w, int h,
55 const rfb::ScreenSet& layout);
56
57 void setName(const char* name);
58
59 void setColourMapEntries(int firstColour, int nColours, rdr::U16* rgbs);
60
61 void bell();
62
63 void serverCutText(const char* str, rdr::U32 len);
64
65 void framebufferUpdateStart();
66 void framebufferUpdateEnd();
Pierre Ossmanfdba3fe2014-01-31 13:12:18 +010067 void dataRect(const rfb::Rect& r, int encoding);
Pierre Ossman5156d5e2011-03-09 09:42:34 +000068
Pierre Ossman5156d5e2011-03-09 09:42:34 +000069 void setCursor(int width, int height, const rfb::Point& hotspot,
70 void* data, void* mask);
71
Pierre Ossmane28bdb22011-11-14 16:02:06 +000072 void fence(rdr::U32 flags, unsigned len, const char data[]);
73
Pierre Ossman5156d5e2011-03-09 09:42:34 +000074private:
75
76 void resizeFramebuffer();
77
78 void autoSelectFormatAndEncoding();
79 void checkEncodings();
80 void requestNewUpdate();
81
Pierre Ossmanf4f30942011-05-17 09:39:07 +000082 static void handleOptions(void *data);
83
Pierre Ossman5156d5e2011-03-09 09:42:34 +000084private:
85 char* serverHost;
86 int serverPort;
87 network::Socket* sock;
88
89 DesktopWindow *desktop;
90
91 rfb::PixelFormat serverPF;
92 rfb::PixelFormat fullColourPF;
93
Pierre Ossman5d512c32011-11-04 11:42:16 +000094 bool pendingPFChange;
95 rfb::PixelFormat pendingPF;
96
Pierre Ossmanfdba3fe2014-01-31 13:12:18 +010097 rfb::Decoder *decoders[rfb::encodingMax+1];
98
Pierre Ossman5156d5e2011-03-09 09:42:34 +000099 int currentEncoding, lastServerEncoding;
100
101 bool formatChange;
102 bool encodingChange;
103
104 bool firstUpdate;
105 bool pendingUpdate;
Pierre Ossmanaa73c892011-11-15 12:13:37 +0000106 bool continuousUpdates;
Pierre Ossmand4c61ce2011-04-29 11:18:12 +0000107
108 bool forceNonincremental;
Pierre Ossmane28bdb22011-11-14 16:02:06 +0000109
110 bool supportsSyncFence;
Pierre Ossman5156d5e2011-03-09 09:42:34 +0000111};
112
113#endif