aboutsummaryrefslogtreecommitdiffstats
path: root/win/winvnc/VNCServerWin32.cxx
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2018-10-08 16:03:01 +0200
committerPierre Ossman <ossman@cendio.se>2018-11-09 17:16:04 +0100
commit025326dd94070ba790e4c1f8596b93ce96fd5be4 (patch)
tree5a4fae7fbeea807df67b0901c268e24e34005928 /win/winvnc/VNCServerWin32.cxx
parentcd7931df76957ccadf0af258ff8515e520a90102 (diff)
downloadtigervnc-025326dd94070ba790e4c1f8596b93ce96fd5be4.tar.gz
tigervnc-025326dd94070ba790e4c1f8596b93ce96fd5be4.zip
Move ListConnInfo to WinVNC directory
It is functionality specific to WinVNC, so move the code there to make things more clear.
Diffstat (limited to 'win/winvnc/VNCServerWin32.cxx')
-rw-r--r--win/winvnc/VNCServerWin32.cxx88
1 files changed, 84 insertions, 4 deletions
diff --git a/win/winvnc/VNCServerWin32.cxx b/win/winvnc/VNCServerWin32.cxx
index 771ef78a..03b1bca7 100644
--- a/win/winvnc/VNCServerWin32.cxx
+++ b/win/winvnc/VNCServerWin32.cxx
@@ -20,6 +20,7 @@
#include <winvnc/VNCServerWin32.h>
#include <winvnc/resource.h>
+#include <winvnc/ListConnInfo.h>
#include <winvnc/STrayIcon.h>
#include <os/Mutex.h>
@@ -239,11 +240,11 @@ bool VNCServerWin32::addNewClient(const char* client) {
return false;
}
-bool VNCServerWin32::getClientsInfo(rfb::ListConnInfo* LCInfo) {
+bool VNCServerWin32::getClientsInfo(ListConnInfo* LCInfo) {
return queueCommand(GetClientsInfo, LCInfo, 0);
}
-bool VNCServerWin32::setClientsStatus(rfb::ListConnInfo* LCInfo) {
+bool VNCServerWin32::setClientsStatus(ListConnInfo* LCInfo) {
return queueCommand(SetClientsStatus, LCInfo, 0);
}
@@ -307,10 +308,10 @@ void VNCServerWin32::processEvent(HANDLE event_) {
sockMgr.addSocket((network::Socket*)commandData, &vncServer);
break;
case GetClientsInfo:
- vncServer.getConnInfo((ListConnInfo*)commandData);
+ getConnInfo((ListConnInfo*)commandData);
break;
case SetClientsStatus:
- vncServer.setConnStatus((ListConnInfo*)commandData);
+ setConnStatus((ListConnInfo*)commandData);
break;
case QueryConnectionComplete:
@@ -339,3 +340,82 @@ void VNCServerWin32::processEvent(HANDLE event_) {
}
}
+void VNCServerWin32::getConnInfo(ListConnInfo * listConn)
+{
+ std::list<network::Socket*> sockets;
+ std::list<network::Socket*>::iterator i;
+
+ listConn->Clear();
+ listConn->setDisable(sockMgr.getDisable(&vncServer));
+
+ vncServer.getSockets(&sockets);
+
+ for (i = sockets.begin(); i != sockets.end(); i++) {
+ rfb::SConnection* conn;
+ int status;
+
+ conn = vncServer.getConnection(*i);
+ if (!conn)
+ continue;
+
+ if (conn->accessCheck(rfb::SConnection::AccessPtrEvents |
+ rfb::SConnection::AccessKeyEvents |
+ rfb::SConnection::AccessView))
+ status = 0;
+ else if (conn->accessCheck(rfb::SConnection::AccessView))
+ status = 1;
+ else
+ status = 2;
+
+ listConn->addInfo((void*)(*i), (*i)->getPeerAddress(), status);
+ }
+}
+
+void VNCServerWin32::setConnStatus(ListConnInfo* listConn)
+{
+ sockMgr.setDisable(&vncServer, listConn->getDisable());
+
+ if (listConn->Empty())
+ return;
+
+ for (listConn->iBegin(); !listConn->iEnd(); listConn->iNext()) {
+ network::Socket* sock;
+ rfb::SConnection* conn;
+ int status;
+
+ sock = (network::Socket*)listConn->iGetConn();
+
+ conn = vncServer.getConnection(sock);
+ if (!conn)
+ continue;
+
+ status = listConn->iGetStatus();
+ if (status == 3) {
+ conn->close(0);
+ } else {
+ rfb::SConnection::AccessRights ar;
+
+ ar = rfb::SConnection::AccessDefault;
+
+ switch (status) {
+ case 0:
+ ar |= rfb::SConnection::AccessPtrEvents |
+ rfb::SConnection::AccessKeyEvents |
+ rfb::SConnection::AccessView;
+ break;
+ case 1:
+ ar |= rfb::SConnection::AccessView;
+ ar &= ~(rfb::SConnection::AccessPtrEvents |
+ rfb::SConnection::AccessKeyEvents);
+ break;
+ case 2:
+ ar &= ~(rfb::SConnection::AccessPtrEvents |
+ rfb::SConnection::AccessKeyEvents |
+ rfb::SConnection::AccessView);
+ break;
+ }
+ conn->setAccessRights(ar);
+ conn->framebufferUpdateRequest(vncServer.getPixelBuffer()->getRect(), false);
+ }
+ }
+}