aboutsummaryrefslogtreecommitdiffstats
path: root/common/rfb/VNCSConnectionST.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'common/rfb/VNCSConnectionST.cxx')
-rw-r--r--common/rfb/VNCSConnectionST.cxx83
1 files changed, 41 insertions, 42 deletions
diff --git a/common/rfb/VNCSConnectionST.cxx b/common/rfb/VNCSConnectionST.cxx
index a354f636..2d77fae6 100644
--- a/common/rfb/VNCSConnectionST.cxx
+++ b/common/rfb/VNCSConnectionST.cxx
@@ -22,7 +22,12 @@
#include <config.h>
#endif
-#include <rdr/Exception.h>
+#include <core/LogWriter.h>
+#include <core/string.h>
+#include <core/time.h>
+
+#include <rdr/FdInStream.h>
+#include <rdr/FdOutStream.h>
#include <network/TcpSocket.h>
@@ -31,12 +36,12 @@
#include <rfb/Exception.h>
#include <rfb/KeyRemapper.h>
#include <rfb/KeysymStr.h>
-#include <rfb/LogWriter.h>
#include <rfb/Security.h>
#include <rfb/ServerCore.h>
#include <rfb/SMsgWriter.h>
#include <rfb/VNCServerST.h>
#include <rfb/VNCSConnectionST.h>
+#include <rfb/encodings.h>
#include <rfb/screenTypes.h>
#include <rfb/fenceTypes.h>
#include <rfb/ledStates.h>
@@ -44,13 +49,12 @@
#define XK_MISCELLANY
#define XK_XKB_KEYS
#include <rfb/keysymdef.h>
-#include <rfb/util.h>
using namespace rfb;
-static LogWriter vlog("VNCSConnST");
+static core::LogWriter vlog("VNCSConnST");
-static Cursor emptyCursor(0, 0, Point(0, 0), nullptr);
+static Cursor emptyCursor(0, 0, {0, 0}, nullptr);
VNCSConnectionST::VNCSConnectionST(VNCServerST* server_, network::Socket *s,
bool reverse, AccessRights ar)
@@ -71,9 +75,9 @@ VNCSConnectionST::VNCSConnectionST(VNCServerST* server_, network::Socket *s,
if (rfb::Server::idleTimeout) {
// minimum of 15 seconds while authenticating
if (rfb::Server::idleTimeout < 15)
- idleTimer.start(secsToMillis(15));
+ idleTimer.start(core::secsToMillis(15));
else
- idleTimer.start(secsToMillis(rfb::Server::idleTimeout));
+ idleTimer.start(core::secsToMillis(rfb::Server::idleTimeout));
}
}
@@ -216,11 +220,11 @@ void VNCSConnectionST::pixelBufferChange()
//updates.intersect(server->pb->getRect());
//
//if (server->pb->width() > client.width())
- // updates.add_changed(Rect(client.width(), 0, server->pb->width(),
- // server->pb->height()));
+ // updates.add_changed({client.width(), 0, server->pb->width(),
+ // server->pb->height()});
//if (server->pb->height() > client.height())
- // updates.add_changed(Rect(0, client.height(), client.width(),
- // server->pb->height()));
+ // updates.add_changed({0, client.height(), client.width(),
+ // server->pb->height()});
damagedCursorRegion.assign_intersect(server->getPixelBuffer()->getRect());
@@ -236,7 +240,7 @@ void VNCSConnectionST::pixelBufferChange()
}
// Drop any lossy tracking that is now outside the framebuffer
- encodeManager.pruneLosslessRefresh(Region(server->getPixelBuffer()->getRect()));
+ encodeManager.pruneLosslessRefresh(server->getPixelBuffer()->getRect());
}
// Just update the whole screen at the moment because we're too lazy to
// work out what's actually changed.
@@ -310,8 +314,6 @@ void VNCSConnectionST::requestClipboardOrClose()
{
try {
if (state() != RFBSTATE_NORMAL) return;
- if (!accessCheck(AccessCutText)) return;
- if (!rfb::Server::acceptCutText) return;
requestClipboard();
} catch(std::exception& e) {
close(e.what());
@@ -322,8 +324,6 @@ void VNCSConnectionST::announceClipboardOrClose(bool available)
{
try {
if (state() != RFBSTATE_NORMAL) return;
- if (!accessCheck(AccessCutText)) return;
- if (!rfb::Server::sendCutText) return;
announceClipboard(available);
} catch(std::exception& e) {
close(e.what());
@@ -334,8 +334,6 @@ void VNCSConnectionST::sendClipboardDataOrClose(const char* data)
{
try {
if (state() != RFBSTATE_NORMAL) return;
- if (!accessCheck(AccessCutText)) return;
- if (!rfb::Server::sendCutText) return;
sendClipboardData(data);
} catch(std::exception& e) {
close(e.what());
@@ -421,7 +419,7 @@ void VNCSConnectionST::approveConnectionOrClose(bool accept,
void VNCSConnectionST::authSuccess()
{
if (rfb::Server::idleTimeout)
- idleTimer.start(secsToMillis(rfb::Server::idleTimeout));
+ idleTimer.start(core::secsToMillis(rfb::Server::idleTimeout));
// - Set the connection parameters appropriately
client.setDimensions(server->getPixelBuffer()->width(),
@@ -448,7 +446,7 @@ void VNCSConnectionST::queryConnection(const char* userName)
void VNCSConnectionST::clientInit(bool shared)
{
if (rfb::Server::idleTimeout)
- idleTimer.start(secsToMillis(rfb::Server::idleTimeout));
+ idleTimer.start(core::secsToMillis(rfb::Server::idleTimeout));
if (rfb::Server::alwaysShared || reverseConnection) shared = true;
if (!accessCheck(AccessNonShared)) shared = true;
if (rfb::Server::neverShared) shared = false;
@@ -463,15 +461,16 @@ void VNCSConnectionST::setPixelFormat(const PixelFormat& pf)
pf.print(buffer, 256);
vlog.info("Client pixel format %s", buffer);
setCursor();
+ encodeManager.forceRefresh(server->getPixelBuffer()->getRect());
}
-void VNCSConnectionST::pointerEvent(const Point& pos, uint16_t buttonMask)
+void VNCSConnectionST::pointerEvent(const core::Point& pos,
+ uint16_t buttonMask)
{
if (rfb::Server::idleTimeout)
- idleTimer.start(secsToMillis(rfb::Server::idleTimeout));
+ idleTimer.start(core::secsToMillis(rfb::Server::idleTimeout));
pointerEventTime = time(nullptr);
if (!accessCheck(AccessPtrEvents)) return;
- if (!rfb::Server::acceptPointerEvents) return;
pointerEventPos = pos;
server->pointerEvent(this, pointerEventPos, buttonMask);
}
@@ -502,8 +501,10 @@ void VNCSConnectionST::keyEvent(uint32_t keysym, uint32_t keycode, bool down) {
uint32_t lookup;
if (rfb::Server::idleTimeout)
- idleTimer.start(secsToMillis(rfb::Server::idleTimeout));
+ idleTimer.start(core::secsToMillis(rfb::Server::idleTimeout));
if (!accessCheck(AccessKeyEvents)) return;
+ // FIXME: This check isn't strictly needed, but we get a lot of
+ // confusing debug logging without it
if (!rfb::Server::acceptKeyEvents) return;
if (down)
@@ -605,27 +606,28 @@ void VNCSConnectionST::keyEvent(uint32_t keysym, uint32_t keycode, bool down) {
server->keyEvent(keysym, keycode, down);
}
-void VNCSConnectionST::framebufferUpdateRequest(const Rect& r,bool incremental)
+void VNCSConnectionST::framebufferUpdateRequest(const core::Rect& r,
+ bool incremental)
{
- Rect safeRect;
+ core::Rect safeRect;
if (!accessCheck(AccessView)) return;
SConnection::framebufferUpdateRequest(r, incremental);
// Check that the client isn't sending crappy requests
- if (!r.enclosed_by(Rect(0, 0, client.width(), client.height()))) {
+ if (!r.enclosed_by({0, 0, client.width(), client.height()})) {
vlog.error("FramebufferUpdateRequest %dx%d at %d,%d exceeds framebuffer %dx%d",
r.width(), r.height(), r.tl.x, r.tl.y,
client.width(), client.height());
- safeRect = r.intersect(Rect(0, 0, client.width(), client.height()));
+ safeRect = r.intersect({0, 0, client.width(), client.height()});
} else {
safeRect = r;
}
// Just update the requested region.
// Framebuffer update will be sent a bit later, see processMessages().
- Region reqRgn(safeRect);
+ core::Region reqRgn(safeRect);
if (!incremental || !continuousUpdates)
requested.assign_union(reqRgn);
@@ -656,8 +658,7 @@ void VNCSConnectionST::setDesktopSize(int fb_width, int fb_height,
layout.print(buffer, sizeof(buffer));
vlog.debug("%s", buffer);
- if (!accessCheck(AccessSetDesktopSize) ||
- !rfb::Server::acceptSetDesktopSize) {
+ if (!accessCheck(AccessSetDesktopSize)) {
vlog.debug("Rejecting unauthorized framebuffer resize request");
result = resultProhibited;
} else {
@@ -716,7 +717,10 @@ void VNCSConnectionST::fence(uint32_t flags, unsigned len, const uint8_t data[])
void VNCSConnectionST::enableContinuousUpdates(bool enable,
int x, int y, int w, int h)
{
- Rect rect;
+ core::Rect rect;
+
+ if (!accessCheck(AccessView))
+ return;
if (!client.supportsFence() || !client.supportsContinuousUpdates())
throw protocol_error("Client tried to enable continuous updates when not allowed");
@@ -735,21 +739,16 @@ void VNCSConnectionST::enableContinuousUpdates(bool enable,
void VNCSConnectionST::handleClipboardRequest()
{
- if (!accessCheck(AccessCutText)) return;
server->handleClipboardRequest(this);
}
void VNCSConnectionST::handleClipboardAnnounce(bool available)
{
- if (!accessCheck(AccessCutText)) return;
- if (!rfb::Server::acceptCutText) return;
server->handleClipboardAnnounce(this, available);
}
void VNCSConnectionST::handleClipboardData(const char* data)
{
- if (!accessCheck(AccessCutText)) return;
- if (!rfb::Server::acceptCutText) return;
server->handleClipboardData(this, data);
}
@@ -790,7 +789,7 @@ void VNCSConnectionST::supportsLEDState()
writer()->writeLEDState();
}
-void VNCSConnectionST::handleTimeout(Timer* t)
+void VNCSConnectionST::handleTimeout(core::Timer* t)
{
try {
if ((t == &congestionTimer) ||
@@ -921,7 +920,7 @@ void VNCSConnectionST::writeNoDataUpdate()
void VNCSConnectionST::writeDataUpdate()
{
- Region req;
+ core::Region req;
UpdateInfo ui;
bool needNewUpdateInfo;
const RenderedCursor *cursor;
@@ -946,7 +945,7 @@ void VNCSConnectionST::writeDataUpdate()
// destination will be wrong, so add it to the changed region.
if (!ui.copied.is_empty() && !damagedCursorRegion.is_empty()) {
- Region bogusCopiedCursor;
+ core::Region bogusCopiedCursor;
bogusCopiedCursor = damagedCursorRegion;
bogusCopiedCursor.translate(ui.copy_delta);
@@ -993,7 +992,7 @@ void VNCSConnectionST::writeDataUpdate()
cursor = nullptr;
if (needRenderedCursor()) {
- Rect renderedCursorRect;
+ core::Rect renderedCursorRect;
cursor = server->getRenderedCursor();
renderedCursorRect = cursor->getEffectiveRect();
@@ -1033,7 +1032,7 @@ void VNCSConnectionST::writeDataUpdate()
void VNCSConnectionST::writeLosslessRefresh()
{
- Region req, pending;
+ core::Region req, pending;
const RenderedCursor *cursor;
int nextRefresh, nextUpdate;