aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2018-10-05 17:11:25 +0200
committerPierre Ossman <ossman@cendio.se>2018-10-10 13:07:19 +0200
commiteef6c9ad834974c7f1f124a6a9984f01c9d0690e (patch)
tree558e4e694a4cedc4d42badd43dd3d8a8fc8ccd95 /common
parente6aab2465493d6088c5218d888d9b77d069e514c (diff)
downloadtigervnc-eef6c9ad834974c7f1f124a6a9984f01c9d0690e.tar.gz
tigervnc-eef6c9ad834974c7f1f124a6a9984f01c9d0690e.zip
Remove QueryConnectionHandler
Make things simpler by making this a part of the SDesktop interface that always needs to be implemented.
Diffstat (limited to 'common')
-rw-r--r--common/rfb/SDesktop.h18
-rw-r--r--common/rfb/VNCSConnectionST.cxx5
-rw-r--r--common/rfb/VNCServer.h10
-rw-r--r--common/rfb/VNCServerST.cxx8
-rw-r--r--common/rfb/VNCServerST.h41
5 files changed, 42 insertions, 40 deletions
diff --git a/common/rfb/SDesktop.h b/common/rfb/SDesktop.h
index 717ddbc9..61182469 100644
--- a/common/rfb/SDesktop.h
+++ b/common/rfb/SDesktop.h
@@ -44,6 +44,8 @@
#include <rfb/screenTypes.h>
#include <rfb/util.h>
+namespace network { class Socket; }
+
namespace rfb {
class VNCServer;
@@ -56,14 +58,22 @@ namespace rfb {
// set via the VNCServer's setPixelBuffer() method by the time this call
// returns.
- virtual void start(VNCServer* __unused_attr vs) {}
+ virtual void start(VNCServer* vs) = 0;
// stop() is called by the server when there are no longer any
// authenticated clients, and therefore the desktop can cease any
// expensive tasks. No further calls to the VNCServer passed to start()
// can be made once stop has returned.
- virtual void stop() {}
+ virtual void stop() = 0;
+
+ // queryConnection() is called when a connection has been
+ // successfully authenticated. The sock and userName arguments
+ // identify the socket and the name of the authenticated user, if
+ // any. At some point later VNCServer::approveConnection() should
+ // be called to either accept or reject the client.
+ virtual void queryConnection(network::Socket* sock,
+ const char* userName) = 0;
// setScreenLayout() requests to reconfigure the framebuffer and/or
// the layout of screens.
@@ -112,6 +122,10 @@ namespace rfb {
server->setPixelBuffer(0);
server = 0;
}
+ virtual void queryConnection(network::Socket* sock,
+ const char* userName) {
+ server->approveConnection(sock, true, NULL);
+ }
protected:
VNCServer* server;
diff --git a/common/rfb/VNCSConnectionST.cxx b/common/rfb/VNCSConnectionST.cxx
index cfefcca1..f4c6d07a 100644
--- a/common/rfb/VNCSConnectionST.cxx
+++ b/common/rfb/VNCSConnectionST.cxx
@@ -414,8 +414,6 @@ void VNCSConnectionST::authSuccess()
{
lastEventTime = time(0);
- server->startDesktop();
-
// - Set the connection parameters appropriately
cp.width = server->pb->width();
cp.height = server->pb->height();
@@ -440,6 +438,9 @@ void VNCSConnectionST::queryConnection(const char* userName)
CharArray name; name.buf = sock->getPeerAddress();
server->blHosts->clearBlackmark(name.buf);
+ // - Prepare the desktop that we might be making calls
+ server->startDesktop();
+
// - Special case to provide a more useful error message
if (rfb::Server::neverShared && !rfb::Server::disconnectClients &&
server->authClientCount() > 0) {
diff --git a/common/rfb/VNCServer.h b/common/rfb/VNCServer.h
index c5335ad2..4f6f0211 100644
--- a/common/rfb/VNCServer.h
+++ b/common/rfb/VNCServer.h
@@ -26,6 +26,8 @@
#include <rfb/SSecurity.h>
#include <rfb/ScreenSet.h>
+namespace network { class Socket; }
+
namespace rfb {
class VNCServer : public UpdateTracker {
@@ -59,6 +61,14 @@ namespace rfb {
// bell() tells the server that it should make all clients make a bell sound.
virtual void bell() = 0;
+ // approveConnection() is called some time after
+ // SDesktop::queryConnection() has been called, to accept or reject
+ // the connection. The accept argument should be true for
+ // acceptance, or false for rejection, in which case a string
+ // reason may also be given.
+ virtual void approveConnection(network::Socket* sock, bool accept,
+ const char* reason = NULL) = 0;
+
// - Close all currently-connected clients, by calling
// their close() method with the supplied reason.
virtual void closeClients(const char* reason) = 0;
diff --git a/common/rfb/VNCServerST.cxx b/common/rfb/VNCServerST.cxx
index 8cc04f74..7e36876c 100644
--- a/common/rfb/VNCServerST.cxx
+++ b/common/rfb/VNCServerST.cxx
@@ -80,7 +80,7 @@ VNCServerST::VNCServerST(const char* name_, SDesktop* desktop_)
name(strDup(name_)), pointerClient(0), comparer(0),
cursor(new Cursor(0, 0, Point(), NULL)),
renderedCursorInvalid(false),
- queryConnectionHandler(0), keyRemapper(&KeyRemapper::defInstance),
+ keyRemapper(&KeyRemapper::defInstance),
lastConnectionTime(0), disableclients(false),
frameTimer(this)
{
@@ -534,6 +534,12 @@ bool VNCServerST::handleTimeout(Timer* t)
return false;
}
+void VNCServerST::queryConnection(network::Socket* sock,
+ const char* userName)
+{
+ desktop->queryConnection(sock, userName);
+}
+
// -=- Internal methods
void VNCServerST::startDesktop()
diff --git a/common/rfb/VNCServerST.h b/common/rfb/VNCServerST.h
index 30a9c9ff..6ab1b208 100644
--- a/common/rfb/VNCServerST.h
+++ b/common/rfb/VNCServerST.h
@@ -95,6 +95,11 @@ namespace rfb {
virtual void setScreenLayout(const ScreenSet& layout);
virtual PixelBuffer* getPixelBuffer() const { return pb; }
virtual void serverCutText(const char* str, int len);
+
+ virtual void approveConnection(network::Socket* sock, bool accept,
+ const char* reason);
+ virtual void closeClients(const char* reason) {closeClients(reason, 0);}
+
virtual void add_changed(const Region &region);
virtual void add_copied(const Region &dest, const Point &delta);
virtual void setCursor(int width, int height, const Point& hotspot,
@@ -104,10 +109,6 @@ namespace rfb {
virtual void bell();
- // - Close all currently-connected clients, by calling
- // their close() method with the supplied reason.
- virtual void closeClients(const char* reason) {closeClients(reason, 0);}
-
// VNCServerST-only methods
// closeClients() closes all RFB sessions, except the specified one (if
@@ -128,42 +129,13 @@ namespace rfb {
// clients
virtual void setName(const char* name_);
- // A QueryConnectionHandler, if supplied, is passed details of incoming
- // connections to approve, reject, or query the user about.
- //
// queryConnection() is called when a connection has been
// successfully authenticated. The sock and userName arguments identify
// the socket and the name of the authenticated user, if any.
// approveConnection() must be called some time later to accept or reject
// the connection.
- struct QueryConnectionHandler {
- virtual ~QueryConnectionHandler() {}
- virtual void queryConnection(network::Socket* sock,
- const char* userName) = 0;
- };
- void setQueryConnectionHandler(QueryConnectionHandler* qch) {
- queryConnectionHandler = qch;
- }
-
- // queryConnection is called as described above, and either passes the
- // request on to the registered handler, or accepts the connection if
- // no handler has been specified.
virtual void queryConnection(network::Socket* sock,
- const char* userName) {
- if (queryConnectionHandler) {
- queryConnectionHandler->queryConnection(sock, userName);
- return;
- }
- approveConnection(sock, true, NULL);
- }
-
- // approveConnection() is called by the active QueryConnectionHandler,
- // some time after queryConnection() has returned with PENDING, to accept
- // or reject the connection. The accept argument should be true for
- // acceptance, or false for rejection, in which case a string reason may
- // also be given.
- void approveConnection(network::Socket* sock, bool accept,
- const char* reason);
+ const char* userName);
// setBlacklist() is called to replace the VNCServerST's internal
// Blacklist instance with another instance. This allows a single
@@ -231,7 +203,6 @@ namespace rfb {
bool getComparerState();
- QueryConnectionHandler* queryConnectionHandler;
KeyRemapper* keyRemapper;
time_t lastUserInputTime;