blob: 27ab8e31e21b5d33347c160eb60b45049a31310f [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 Ossman49f88222009-03-20 13:02:50 +000078 void setExtendedDesktopSize(int reason, int result, int w, int h);
Peter Åstrandc39e0782009-01-15 12:21:42 +000079 void setName(const char* name);
Constantin Kaplinskyb30ae7f2006-05-25 05:04:46 +000080 void setColourMapEntries(int firstColour, int nColours, rdr::U16* rgbs);
81 void bell();
82 void serverCutText(const char* str, int len);
83 void framebufferUpdateEnd();
84 void beginRect(const rfb::Rect& r, unsigned int encoding);
85 void endRect(const rfb::Rect& r, unsigned int encoding);
86 void fillRect(const rfb::Rect& r, rfb::Pixel p);
87 void imageRect(const rfb::Rect& r, void* p);
88 void copyRect(const rfb::Rect& r, int sx, int sy);
89 void setCursor(int width, int height, const rfb::Point& hotspot,
90 void* data, void* mask);
91
92private:
93
Pierre Ossman49f88222009-03-20 13:02:50 +000094 void resizeFramebuffer();
Constantin Kaplinskyb30ae7f2006-05-25 05:04:46 +000095 void recreateViewport();
96 void reconfigureViewport();
97 void initMenu();
98 void showMenu(int x, int y);
99 void autoSelectFormatAndEncoding();
100 void checkEncodings();
101 void requestNewUpdate();
102
103 Display* dpy;
104 int argc;
105 char** argv;
106 char* serverHost;
107 int serverPort;
108 network::Socket* sock;
109 rfb::PixelFormat serverPF;
110 TXViewport* viewport;
111 DesktopWindow* desktop;
112 TXEventHandler* desktopEventHandler;
113 rfb::PixelFormat fullColourPF;
114 std::list<rfb::Rect> debugRects;
115 unsigned int currentEncoding, lastServerEncoding;
116 bool fullColour;
117 bool autoSelect;
118 bool shared;
119 bool formatChange;
120 bool encodingChange;
121 bool sameMachine;
122 bool fullScreen;
123 bool ctrlDown;
124 bool altDown;
125 KeySym menuKeysym;
126 TXMenu menu;
127 TXEventHandler* menuEventHandler;
128 OptionsDialog options;
129 AboutDialog about;
130 InfoDialog info;
131 bool reverseConnection;
132};
133
134#endif