blob: 3bf0a82ea31893c1c97c9dd6c585e42e691e5af4 [file] [log] [blame]
Constantin Kaplinskyb30ae7f2006-05-25 05:04:46 +00001/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
Pierre Ossman49f88222009-03-20 13:02:50 +00002 * Copyright 2009 Pierre Ossman for Cendio AB
Constantin Kaplinskyb30ae7f2006-05-25 05:04:46 +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// CConn represents a client connection to a VNC server.
21//
22
23#ifndef __CCONN_H__
24#define __CCONN_H__
25
26#include <rfb/CConnection.h>
27#include <rfb/Exception.h>
28#include <rfb/UserPasswdGetter.h>
29#include <rdr/FdInStream.h>
30#include <list>
31
32#include "TXWindow.h"
33#include "AboutDialog.h"
34#include "InfoDialog.h"
35#include "TXMenu.h"
36#include "OptionsDialog.h"
37
38class TXWindow;
39class TXViewport;
40class DesktopWindow;
41namespace network { class Socket; }
42
43class CConn : public rfb::CConnection, public rfb::UserPasswdGetter,
44 public TXDeleteWindowCallback,
45 public rdr::FdInStreamBlockCallback,
46 public TXMenuCallback , public OptionsDialogCallback,
47 public TXEventHandler
48{
49public:
50
51 CConn(Display* dpy_, int argc_, char** argv_, network::Socket* sock_,
52 char* vncServerName, bool reverse=false);
53 ~CConn();
54
55 // TXDeleteWindowCallback methods
56 void deleteWindow(TXWindow* w);
57
58 // FdInStreamBlockCallback methods
59 void blockCallback();
60
61 // UserPasswdGetter methods
62 virtual void getUserPasswd(char** user, char** password);
63
64 // TXMenuCallback methods
65 void menuSelect(long id, TXMenu* m);
66
67 // OptionsDialogCallback methods
68 virtual void setOptions();
69 virtual void getOptions();
70
71 // TXEventHandler callback method
72 virtual void handleEvent(TXWindow* w, XEvent* ev);
73
74 // CConnection callback methods
75 rfb::CSecurity* getCSecurity(int secType);
76 void serverInit();
77 void setDesktopSize(int w, int h);
Pierre Ossmancbd1b2c2009-03-20 16:05:04 +000078 void setExtendedDesktopSize(int reason, int result, int w, int h,
79 const rfb::ScreenSet& layout);
Peter Åstrandc39e0782009-01-15 12:21:42 +000080 void setName(const char* name);
Constantin Kaplinskyb30ae7f2006-05-25 05:04:46 +000081 void setColourMapEntries(int firstColour, int nColours, rdr::U16* rgbs);
82 void bell();
83 void serverCutText(const char* str, int len);
Pierre Ossman42d20e72009-04-01 14:42:34 +000084 void framebufferUpdateStart();
Constantin Kaplinskyb30ae7f2006-05-25 05:04:46 +000085 void framebufferUpdateEnd();
86 void beginRect(const rfb::Rect& r, unsigned int encoding);
87 void endRect(const rfb::Rect& r, unsigned int encoding);
88 void fillRect(const rfb::Rect& r, rfb::Pixel p);
89 void imageRect(const rfb::Rect& r, void* p);
90 void copyRect(const rfb::Rect& r, int sx, int sy);
91 void setCursor(int width, int height, const rfb::Point& hotspot,
92 void* data, void* mask);
93
94private:
95
Pierre Ossman49f88222009-03-20 13:02:50 +000096 void resizeFramebuffer();
Constantin Kaplinskyb30ae7f2006-05-25 05:04:46 +000097 void recreateViewport();
98 void reconfigureViewport();
99 void initMenu();
100 void showMenu(int x, int y);
101 void autoSelectFormatAndEncoding();
102 void checkEncodings();
103 void requestNewUpdate();
104
105 Display* dpy;
106 int argc;
107 char** argv;
108 char* serverHost;
109 int serverPort;
110 network::Socket* sock;
111 rfb::PixelFormat serverPF;
112 TXViewport* viewport;
113 DesktopWindow* desktop;
114 TXEventHandler* desktopEventHandler;
115 rfb::PixelFormat fullColourPF;
116 std::list<rfb::Rect> debugRects;
117 unsigned int currentEncoding, lastServerEncoding;
118 bool fullColour;
119 bool autoSelect;
120 bool shared;
121 bool formatChange;
122 bool encodingChange;
123 bool sameMachine;
124 bool fullScreen;
125 bool ctrlDown;
126 bool altDown;
127 KeySym menuKeysym;
128 TXMenu menu;
129 TXEventHandler* menuEventHandler;
130 OptionsDialog options;
131 AboutDialog about;
132 InfoDialog info;
133 bool reverseConnection;
Pierre Ossmaneb3cecb2009-03-23 16:49:47 +0000134 bool firstUpdate;
Constantin Kaplinskyb30ae7f2006-05-25 05:04:46 +0000135};
136
137#endif