blob: a81af48c5f9937a2db723fd529eaebda2871c29b [file] [log] [blame]
Constantin Kaplinskyb30ae7f2006-05-25 05:04:46 +00001/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
2 *
3 * This is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This software is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this software; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
16 * USA.
17 */
18//
19// CConn represents a client connection to a VNC server.
20//
21
22#ifndef __CCONN_H__
23#define __CCONN_H__
24
25#include <rfb/CConnection.h>
26#include <rfb/Exception.h>
27#include <rfb/UserPasswdGetter.h>
28#include <rdr/FdInStream.h>
29#include <list>
30
31#include "TXWindow.h"
32#include "AboutDialog.h"
33#include "InfoDialog.h"
34#include "TXMenu.h"
35#include "OptionsDialog.h"
36
37class TXWindow;
38class TXViewport;
39class DesktopWindow;
40namespace network { class Socket; }
41
42class CConn : public rfb::CConnection, public rfb::UserPasswdGetter,
43 public TXDeleteWindowCallback,
44 public rdr::FdInStreamBlockCallback,
45 public TXMenuCallback , public OptionsDialogCallback,
46 public TXEventHandler
47{
48public:
49
50 CConn(Display* dpy_, int argc_, char** argv_, network::Socket* sock_,
51 char* vncServerName, bool reverse=false);
52 ~CConn();
53
54 // TXDeleteWindowCallback methods
55 void deleteWindow(TXWindow* w);
56
57 // FdInStreamBlockCallback methods
58 void blockCallback();
59
60 // UserPasswdGetter methods
61 virtual void getUserPasswd(char** user, char** password);
62
63 // TXMenuCallback methods
64 void menuSelect(long id, TXMenu* m);
65
66 // OptionsDialogCallback methods
67 virtual void setOptions();
68 virtual void getOptions();
69
70 // TXEventHandler callback method
71 virtual void handleEvent(TXWindow* w, XEvent* ev);
72
73 // CConnection callback methods
74 rfb::CSecurity* getCSecurity(int secType);
75 void serverInit();
76 void setDesktopSize(int w, int h);
77 void setColourMapEntries(int firstColour, int nColours, rdr::U16* rgbs);
78 void bell();
79 void serverCutText(const char* str, int len);
80 void framebufferUpdateEnd();
81 void beginRect(const rfb::Rect& r, unsigned int encoding);
82 void endRect(const rfb::Rect& r, unsigned int encoding);
83 void fillRect(const rfb::Rect& r, rfb::Pixel p);
84 void imageRect(const rfb::Rect& r, void* p);
85 void copyRect(const rfb::Rect& r, int sx, int sy);
86 void setCursor(int width, int height, const rfb::Point& hotspot,
87 void* data, void* mask);
88
89private:
90
91 void recreateViewport();
92 void reconfigureViewport();
93 void initMenu();
94 void showMenu(int x, int y);
95 void autoSelectFormatAndEncoding();
96 void checkEncodings();
97 void requestNewUpdate();
98
99 Display* dpy;
100 int argc;
101 char** argv;
102 char* serverHost;
103 int serverPort;
104 network::Socket* sock;
105 rfb::PixelFormat serverPF;
106 TXViewport* viewport;
107 DesktopWindow* desktop;
108 TXEventHandler* desktopEventHandler;
109 rfb::PixelFormat fullColourPF;
110 std::list<rfb::Rect> debugRects;
111 unsigned int currentEncoding, lastServerEncoding;
112 bool fullColour;
113 bool autoSelect;
114 bool shared;
115 bool formatChange;
116 bool encodingChange;
117 bool sameMachine;
118 bool fullScreen;
119 bool ctrlDown;
120 bool altDown;
121 KeySym menuKeysym;
122 TXMenu menu;
123 TXEventHandler* menuEventHandler;
124 OptionsDialog options;
125 AboutDialog about;
126 InfoDialog info;
127 bool reverseConnection;
128};
129
130#endif