blob: 5dacb1ee507e7d47bff5fac1d0f234d14a2140f1 [file] [log] [blame]
Constantin Kaplinsky729598c2006-05-25 05:12:25 +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.h
20
21// Windows-specific implementation of CConnection
22
23#ifndef __RFB_WIN32_CCONN_H__
24#define __RFB_WIN32_CCONN_H__
25
26#include <network/Socket.h>
27#include <rfb/CConnection.h>
28#include <rfb/Cursor.h>
29#include <rfb/UserPasswdGetter.h>
30#include <rfb_win32/Registry.h>
31#include <rfb_win32/Handle.h>
32#include <vncviewer/InfoDialog.h>
33#include <vncviewer/OptionsDialog.h>
34#include <vncviewer/CConnOptions.h>
35#include <vncviewer/DesktopWindow.h>
Constantin Kaplinsky729598c2006-05-25 05:12:25 +000036#include <list>
37
38
39namespace rfb {
40
41 namespace win32 {
42
43 class CConn : public CConnection,
44 UserPasswdGetter,
45 DesktopWindow::Callback,
46 rdr::FdInStreamBlockCallback
47 {
48 public:
49 CConn();
50 ~CConn();
51
52 // - Start the VNC session on the supplied socket
53 // The socket must already be connected to a host
54 bool initialise(network::Socket* s, bool reverse=false);
55
56 // - Set/get the session options
57 void applyOptions(CConnOptions& opt);
58 const CConnOptions& getOptions() const { return options; };
59
60 // - Show the options dialog for the connection
61 void showOptionsDialog();
62
63 // - Close the socket & set the reason for closure
64 void close(const char* reason=0);
65 bool isClosed() const { return isClosed_; }
66 const char* closeReason() const { return closeReason_.buf; }
67
68 // - Last received encoding, for the Info dialog
69 int lastUsedEncoding() const { return lastUsedEncoding_; }
70
71 // - Get at the DesktopWindow, if any
72 DesktopWindow* getWindow() { return window; }
73
74 // - Get at the underlying Socket
75 network::Socket* getSocket() { return sock; }
76
77 // - Get the server's preferred format
78 const PixelFormat& getServerDefaultPF() const { return serverDefaultPF; }
79
80 // Global user-config registry key
81 static RegKey userConfigKey;
82
Constantin Kaplinsky729598c2006-05-25 05:12:25 +000083 protected:
84 // InputHandler interface (via DesktopWindow::Callback)
85 void keyEvent(rdr::U32 key, bool down);
86 void pointerEvent(const Point& pos, int buttonMask);
87 void clientCutText(const char* str, int len);
88
89 // DesktopWindow::Callback interface
90 void displayChanged();
91 void paintCompleted();
92 bool sysCommand(WPARAM wParam, LPARAM lParam);
93 void closeWindow();
94 void refreshMenu(bool enableSysCommands);
95
96 // CConnection interface
97 CSecurity* getCSecurity(int secType);
98 void setColourMapEntries(int firstColour, int nColours, rdr::U16* rgbs);
99 void bell();
100 void framebufferUpdateEnd();
101 void setDesktopSize(int w, int h);
102 void setCursor(int w, int h, const Point& hotspot, void* data, void* mask);
103 void setName(const char* name);
104 void serverInit();
Adam Tkacacf6c6b2009-02-13 12:42:05 +0000105 void serverCutText(const char* str, rdr::U32 len);
Constantin Kaplinsky729598c2006-05-25 05:12:25 +0000106 void beginRect(const Rect& r, unsigned int encoding);
107 void endRect(const Rect& r, unsigned int encoding);
108 void fillRect(const Rect& r, Pixel pix);
109 void imageRect(const Rect& r, void* pixels);
110 void copyRect(const Rect& r, int srcX, int srcY);
111
112 // rdr::FdInStreamBlockCallback interface
113 void blockCallback();
114
115 // UserPasswdGetter interface
116 // (overridden to allow a pre-supplied username & password)
117 void getUserPasswd(char** user, char** password);
118
119 // CConn-specific internal interface
120 void autoSelectFormatAndEncoding();
121 void requestNewUpdate();
122 void calculateFullColourPF();
123
124 // The desktop window
125 DesktopWindow* window;
126
127 // Info and Options dialogs
128 OptionsDialog optionsDialog;
129 InfoDialog infoDialog;
130
131 // VNC Viewer options
132 CConnOptions options;
133
134 // Pixel format and encoding
135 PixelFormat serverDefaultPF;
136 PixelFormat fullColourPF;
137 bool sameMachine;
138 bool encodingChange;
139 bool formatChange;
140 int lastUsedEncoding_;
141
142 // Networking and RFB protocol
143 network::Socket* sock;
144 Handle sockEvent;
145 bool reverseConnection;
146 bool requestUpdate;
147
148 // Debugging/logging
149 std::list<Rect> debugRects;
150 CharArray closeReason_;
151 bool isClosed_;
Constantin Kaplinsky729598c2006-05-25 05:12:25 +0000152 };
153
154 };
155
156};
157
158#endif
159
160