Remove QueryConnectionHandler
Make things simpler by making this a part of the SDesktop interface
that always needs to be implemented.
diff --git a/win/rfb_win32/SDisplay.cxx b/win/rfb_win32/SDisplay.cxx
index 9b2cbb0..afb72ad 100644
--- a/win/rfb_win32/SDisplay.cxx
+++ b/win/rfb_win32/SDisplay.cxx
@@ -20,6 +20,8 @@
//
// The SDisplay class encapsulates a particular system display.
+#include <assert.h>
+
#include <rfb_win32/SDisplay.h>
#include <rfb_win32/Service.h>
#include <rfb_win32/TsSessions.h>
@@ -66,7 +68,7 @@
: server(0), pb(0), device(0),
core(0), ptr(0), kbd(0), clipboard(0),
inputs(0), monitor(0), cleanDesktop(0), cursor(0),
- statusLocation(0), ledState(0)
+ statusLocation(0), queryConnectionHandler(0), ledState(0)
{
updateEvent.h = CreateEvent(0, TRUE, FALSE, 0);
}
@@ -139,6 +141,20 @@
}
+void SDisplay::queryConnection(network::Socket* sock,
+ const char* userName)
+{
+ assert(server != NULL);
+
+ if (queryConnectionHandler) {
+ queryConnectionHandler->queryConnection(sock, userName);
+ return;
+ }
+
+ server->approveConnection(sock, true);
+}
+
+
void SDisplay::startCore() {
// Currently, we just check whether we're in the console session, and
diff --git a/win/rfb_win32/SDisplay.h b/win/rfb_win32/SDisplay.h
index c1d5c1e..76ddf50 100644
--- a/win/rfb_win32/SDisplay.h
+++ b/win/rfb_win32/SDisplay.h
@@ -52,6 +52,13 @@
virtual const char* methodName() const = 0;
};
+ class QueryConnectionHandler {
+ public:
+ virtual ~QueryConnectionHandler() {}
+ virtual void queryConnection(network::Socket* sock,
+ const char* userName) = 0;
+ };
+
class SDisplay : public SDesktop,
WMMonitor::Notifier,
Clipboard::Notifier,
@@ -65,6 +72,8 @@
virtual void start(VNCServer* vs);
virtual void stop();
+ virtual void queryConnection(network::Socket* sock,
+ const char* userName);
virtual void pointerEvent(const Point& pos, int buttonmask);
virtual void keyEvent(rdr::U32 keysym, rdr::U32 keycode, bool down);
virtual void clientCutText(const char* str, int len);
@@ -86,6 +95,12 @@
void setStatusLocation(bool* status) {statusLocation = status;}
+ // -=- Set handler for incoming connections
+
+ void setQueryConnectionHandler(QueryConnectionHandler* qch) {
+ queryConnectionHandler = qch;
+ }
+
static IntParameter updateMethod;
static BoolParameter disableLocalInputs;
static StringParameter disconnectAction;
@@ -150,6 +165,9 @@
// -=- Where to write the active/inactive indicator to
bool* statusLocation;
+ // -=- Whom to query incoming connections
+ QueryConnectionHandler* queryConnectionHandler;
+
unsigned ledState;
};
diff --git a/win/winvnc/VNCServerWin32.cxx b/win/winvnc/VNCServerWin32.cxx
index 93bf5c0..771ef78 100644
--- a/win/winvnc/VNCServerWin32.cxx
+++ b/win/winvnc/VNCServerWin32.cxx
@@ -71,9 +71,7 @@
// Initialise the desktop
desktop.setStatusLocation(&isDesktopStarted);
-
- // Initialise the VNC server
- vncServer.setQueryConnectionHandler(this);
+ desktop.setQueryConnectionHandler(this);
// Register the desktop's event to be handled
sockMgr.addEvent(desktop.getUpdateEvent(), &desktop);
diff --git a/win/winvnc/VNCServerWin32.h b/win/winvnc/VNCServerWin32.h
index 58c3f6c..bd0cbbb 100644
--- a/win/winvnc/VNCServerWin32.h
+++ b/win/winvnc/VNCServerWin32.h
@@ -39,7 +39,7 @@
class STrayIconThread;
- class VNCServerWin32 : rfb::VNCServerST::QueryConnectionHandler,
+ class VNCServerWin32 : rfb::win32::QueryConnectionHandler,
rfb::win32::SocketManager::AddressChangeNotifier,
rfb::win32::RegConfig::Callback,
rfb::win32::EventHandler {
@@ -78,7 +78,7 @@
bool setClientsStatus(rfb::ListConnInfo* LCInfo);
protected:
- // VNCServerST::QueryConnectionHandler interface
+ // QueryConnectionHandler interface
// Callback used to prompt user to accept or reject a connection.
// CALLBACK IN VNCServerST "HOST" THREAD
virtual void queryConnection(network::Socket* sock,