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