blob: 726a6e862ab130c35876fdd022787be321cd3611 [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);
Pierre Ossmand6d19942009-03-24 12:29:50 +0000102 void setExtendedDesktopSize(int reason, int result, int w, int h,
103 const rfb::ScreenSet& layout);
Constantin Kaplinsky729598c2006-05-25 05:12:25 +0000104 void setCursor(int w, int h, const Point& hotspot, void* data, void* mask);
105 void setName(const char* name);
106 void serverInit();
Adam Tkacacf6c6b2009-02-13 12:42:05 +0000107 void serverCutText(const char* str, rdr::U32 len);
Constantin Kaplinsky729598c2006-05-25 05:12:25 +0000108 void beginRect(const Rect& r, unsigned int encoding);
109 void endRect(const Rect& r, unsigned int encoding);
110 void fillRect(const Rect& r, Pixel pix);
111 void imageRect(const Rect& r, void* pixels);
112 void copyRect(const Rect& r, int srcX, int srcY);
113
114 // rdr::FdInStreamBlockCallback interface
115 void blockCallback();
116
117 // UserPasswdGetter interface
118 // (overridden to allow a pre-supplied username & password)
119 void getUserPasswd(char** user, char** password);
120
121 // CConn-specific internal interface
122 void autoSelectFormatAndEncoding();
123 void requestNewUpdate();
124 void calculateFullColourPF();
125
126 // The desktop window
127 DesktopWindow* window;
128
129 // Info and Options dialogs
130 OptionsDialog optionsDialog;
131 InfoDialog infoDialog;
132
133 // VNC Viewer options
134 CConnOptions options;
135
136 // Pixel format and encoding
137 PixelFormat serverDefaultPF;
138 PixelFormat fullColourPF;
139 bool sameMachine;
140 bool encodingChange;
141 bool formatChange;
142 int lastUsedEncoding_;
143
144 // Networking and RFB protocol
145 network::Socket* sock;
146 Handle sockEvent;
147 bool reverseConnection;
148 bool requestUpdate;
Pierre Ossmand6d19942009-03-24 12:29:50 +0000149 bool firstUpdate;
Constantin Kaplinsky729598c2006-05-25 05:12:25 +0000150
151 // Debugging/logging
152 std::list<Rect> debugRects;
153 CharArray closeReason_;
154 bool isClosed_;
Constantin Kaplinsky729598c2006-05-25 05:12:25 +0000155 };
156
157 };
158
159};
160
161#endif
162
163