Remove indirect capability attributes
Better to check the actual list of supported encodings directly.
Makes parts more readable, and no risk of getting out of sync.
diff --git a/common/rfb/ClientParams.cxx b/common/rfb/ClientParams.cxx
index 6209f4d..7838407 100644
--- a/common/rfb/ClientParams.cxx
+++ b/common/rfb/ClientParams.cxx
@@ -26,14 +26,6 @@
ClientParams::ClientParams()
: majorVersion(0), minorVersion(0),
- useCopyRect(false),
- supportsLocalCursor(false), supportsLocalXCursor(false),
- supportsLocalCursorWithAlpha(false),
- supportsDesktopResize(false), supportsExtendedDesktopSize(false),
- supportsDesktopRename(false), supportsLastRect(false),
- supportsLEDState(false), supportsQEMUKeyEvent(false),
- supportsSetDesktopSize(false), supportsFence(false),
- supportsContinuousUpdates(false),
compressLevel(2), qualityLevel(-1), fineQualityLevel(-1),
subsampling(subsampleUndefined),
width_(0), height_(0), name_(0),
@@ -93,14 +85,6 @@
void ClientParams::setEncodings(int nEncodings, const rdr::S32* encodings)
{
- useCopyRect = false;
- supportsLocalCursor = false;
- supportsLocalCursorWithAlpha = false;
- supportsDesktopResize = false;
- supportsExtendedDesktopSize = false;
- supportsLocalXCursor = false;
- supportsLastRect = false;
- supportsQEMUKeyEvent = false;
compressLevel = -1;
qualityLevel = -1;
fineQualityLevel = -1;
@@ -111,42 +95,6 @@
for (int i = nEncodings-1; i >= 0; i--) {
switch (encodings[i]) {
- case encodingCopyRect:
- useCopyRect = true;
- break;
- case pseudoEncodingCursor:
- supportsLocalCursor = true;
- break;
- case pseudoEncodingXCursor:
- supportsLocalXCursor = true;
- break;
- case pseudoEncodingCursorWithAlpha:
- supportsLocalCursorWithAlpha = true;
- break;
- case pseudoEncodingDesktopSize:
- supportsDesktopResize = true;
- break;
- case pseudoEncodingExtendedDesktopSize:
- supportsExtendedDesktopSize = true;
- break;
- case pseudoEncodingDesktopName:
- supportsDesktopRename = true;
- break;
- case pseudoEncodingLastRect:
- supportsLastRect = true;
- break;
- case pseudoEncodingLEDState:
- supportsLEDState = true;
- break;
- case pseudoEncodingQEMUKeyEvent:
- supportsQEMUKeyEvent = true;
- break;
- case pseudoEncodingFence:
- supportsFence = true;
- break;
- case pseudoEncodingContinuousUpdates:
- supportsContinuousUpdates = true;
- break;
case pseudoEncodingSubsamp1X:
subsampling = subsampleNone;
break;
@@ -179,8 +127,7 @@
encodings[i] <= pseudoEncodingFineQualityLevel100)
fineQualityLevel = encodings[i] - pseudoEncodingFineQualityLevel0;
- if (encodings[i] > 0)
- encodings_.insert(encodings[i]);
+ encodings_.insert(encodings[i]);
}
}
@@ -188,3 +135,35 @@
{
ledState_ = state;
}
+
+bool ClientParams::supportsLocalCursor() const
+{
+ if (supportsEncoding(pseudoEncodingCursorWithAlpha))
+ return true;
+ if (supportsEncoding(pseudoEncodingCursor))
+ return true;
+ if (supportsEncoding(pseudoEncodingXCursor))
+ return true;
+ return false;
+}
+
+bool ClientParams::supportsLEDState() const
+{
+ if (supportsEncoding(pseudoEncodingLEDState))
+ return true;
+ return false;
+}
+
+bool ClientParams::supportsFence() const
+{
+ if (supportsEncoding(pseudoEncodingFence))
+ return true;
+ return false;
+}
+
+bool ClientParams::supportsContinuousUpdates() const
+{
+ if (supportsEncoding(pseudoEncodingContinuousUpdates))
+ return true;
+ return false;
+}
diff --git a/common/rfb/ClientParams.h b/common/rfb/ClientParams.h
index 6b36895..63d4e19 100644
--- a/common/rfb/ClientParams.h
+++ b/common/rfb/ClientParams.h
@@ -84,21 +84,12 @@
unsigned int ledState() { return ledState_; }
void setLEDState(unsigned int state);
- bool useCopyRect;
-
- bool supportsLocalCursor;
- bool supportsLocalXCursor;
- bool supportsLocalCursorWithAlpha;
- bool supportsDesktopResize;
- bool supportsExtendedDesktopSize;
- bool supportsDesktopRename;
- bool supportsLastRect;
- bool supportsLEDState;
- bool supportsQEMUKeyEvent;
-
- bool supportsSetDesktopSize;
- bool supportsFence;
- bool supportsContinuousUpdates;
+ // Wrappers to check for functionality rather than specific
+ // encodings
+ bool supportsLocalCursor() const;
+ bool supportsLEDState() const;
+ bool supportsFence() const;
+ bool supportsContinuousUpdates() const;
int compressLevel;
int qualityLevel;
diff --git a/common/rfb/EncodeManager.cxx b/common/rfb/EncodeManager.cxx
index 9288668..735be07 100644
--- a/common/rfb/EncodeManager.cxx
+++ b/common/rfb/EncodeManager.cxx
@@ -325,7 +325,7 @@
changed = changed_;
- if (!conn->client.useCopyRect)
+ if (!conn->client.supportsEncoding(encodingCopyRect))
changed.assign_union(copied);
/*
@@ -337,7 +337,7 @@
changed.assign_subtract(renderedCursor->getEffectiveRect());
}
- if (conn->client.supportsLastRect)
+ if (conn->client.supportsEncoding(pseudoEncodingLastRect))
nRects = 0xFFFF;
else {
nRects = copied.numRects();
@@ -347,14 +347,14 @@
conn->writer()->writeFramebufferUpdateStart(nRects);
- if (conn->client.useCopyRect)
+ if (conn->client.supportsEncoding(encodingCopyRect))
writeCopyRects(copied, copyDelta);
/*
* We start by searching for solid rects, which are then removed
* from the changed region.
*/
- if (conn->client.supportsLastRect)
+ if (conn->client.supportsEncoding(pseudoEncodingLastRect))
writeSolidRects(&changed, pb);
writeRects(changed, pb);
diff --git a/common/rfb/SMsgHandler.cxx b/common/rfb/SMsgHandler.cxx
index f0e277c..be88433 100644
--- a/common/rfb/SMsgHandler.cxx
+++ b/common/rfb/SMsgHandler.cxx
@@ -19,6 +19,7 @@
#include <rfb/Exception.h>
#include <rfb/SMsgHandler.h>
#include <rfb/ScreenSet.h>
+#include <rfb/encodings.h>
using namespace rfb;
@@ -44,22 +45,22 @@
bool firstFence, firstContinuousUpdates, firstLEDState,
firstQEMUKeyEvent;
- firstFence = !client.supportsFence;
- firstContinuousUpdates = !client.supportsContinuousUpdates;
- firstLEDState = !client.supportsLEDState;
- firstQEMUKeyEvent = !client.supportsQEMUKeyEvent;
+ firstFence = !client.supportsFence();
+ firstContinuousUpdates = !client.supportsContinuousUpdates();
+ firstLEDState = !client.supportsLEDState();
+ firstQEMUKeyEvent = !client.supportsEncoding(pseudoEncodingQEMUKeyEvent);
client.setEncodings(nEncodings, encodings);
supportsLocalCursor();
- if (client.supportsFence && firstFence)
+ if (client.supportsFence() && firstFence)
supportsFence();
- if (client.supportsContinuousUpdates && firstContinuousUpdates)
+ if (client.supportsContinuousUpdates() && firstContinuousUpdates)
supportsContinuousUpdates();
- if (client.supportsLEDState && firstLEDState)
+ if (client.supportsLEDState() && firstLEDState)
supportsLEDState();
- if (client.supportsQEMUKeyEvent && firstQEMUKeyEvent)
+ if (client.supportsEncoding(pseudoEncodingQEMUKeyEvent) && firstQEMUKeyEvent)
supportsQEMUKeyEvent();
}
diff --git a/common/rfb/SMsgWriter.cxx b/common/rfb/SMsgWriter.cxx
index bcc848f..f4c968e 100644
--- a/common/rfb/SMsgWriter.cxx
+++ b/common/rfb/SMsgWriter.cxx
@@ -90,7 +90,7 @@
void SMsgWriter::writeFence(rdr::U32 flags, unsigned len, const char data[])
{
- if (!client->supportsFence)
+ if (!client->supportsEncoding(pseudoEncodingFence))
throw Exception("Client does not support fences");
if (len > 64)
throw Exception("Too large fence payload");
@@ -112,7 +112,7 @@
void SMsgWriter::writeEndOfContinuousUpdates()
{
- if (!client->supportsContinuousUpdates)
+ if (!client->supportsEncoding(pseudoEncodingContinuousUpdates))
throw Exception("Client does not support continuous updates");
startMsg(msgTypeEndOfContinuousUpdates);
@@ -120,7 +120,7 @@
}
bool SMsgWriter::writeSetDesktopSize() {
- if (!client->supportsDesktopResize)
+ if (!client->supportsEncoding(pseudoEncodingDesktopSize))
return false;
needSetDesktopSize = true;
@@ -129,7 +129,7 @@
}
bool SMsgWriter::writeExtendedDesktopSize() {
- if (!client->supportsExtendedDesktopSize)
+ if (!client->supportsEncoding(pseudoEncodingExtendedDesktopSize))
return false;
needExtendedDesktopSize = true;
@@ -142,7 +142,7 @@
const ScreenSet& layout) {
ExtendedDesktopSizeMsg msg;
- if (!client->supportsExtendedDesktopSize)
+ if (!client->supportsEncoding(pseudoEncodingExtendedDesktopSize))
return false;
msg.reason = reason;
@@ -157,7 +157,7 @@
}
bool SMsgWriter::writeSetDesktopName() {
- if (!client->supportsDesktopRename)
+ if (!client->supportsEncoding(pseudoEncodingDesktopName))
return false;
needSetDesktopName = true;
@@ -167,7 +167,7 @@
bool SMsgWriter::writeSetCursor()
{
- if (!client->supportsLocalCursor)
+ if (!client->supportsEncoding(pseudoEncodingCursor))
return false;
needSetCursor = true;
@@ -177,7 +177,7 @@
bool SMsgWriter::writeSetXCursor()
{
- if (!client->supportsLocalXCursor)
+ if (!client->supportsEncoding(pseudoEncodingXCursor))
return false;
needSetXCursor = true;
@@ -187,7 +187,7 @@
bool SMsgWriter::writeSetCursorWithAlpha()
{
- if (!client->supportsLocalCursorWithAlpha)
+ if (!client->supportsEncoding(pseudoEncodingCursorWithAlpha))
return false;
needSetCursorWithAlpha = true;
@@ -197,7 +197,7 @@
bool SMsgWriter::writeLEDState()
{
- if (!client->supportsLEDState)
+ if (!client->supportsEncoding(pseudoEncodingLEDState))
return false;
if (client->ledState() == ledUnknown)
return false;
@@ -209,7 +209,7 @@
bool SMsgWriter::writeQEMUKeyEvent()
{
- if (!client->supportsQEMUKeyEvent)
+ if (!client->supportsEncoding(pseudoEncodingQEMUKeyEvent))
return false;
needQEMUKeyEvent = true;
@@ -437,7 +437,7 @@
void SMsgWriter::writeSetDesktopSizeRect(int width, int height)
{
- if (!client->supportsDesktopResize)
+ if (!client->supportsEncoding(pseudoEncodingDesktopSize))
throw Exception("Client does not support desktop resize");
if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
throw Exception("SMsgWriter::writeSetDesktopSizeRect: nRects out of sync");
@@ -457,7 +457,7 @@
{
ScreenSet::const_iterator si;
- if (!client->supportsExtendedDesktopSize)
+ if (!client->supportsEncoding(pseudoEncodingExtendedDesktopSize))
throw Exception("Client does not support extended desktop resize");
if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
throw Exception("SMsgWriter::writeExtendedDesktopSizeRect: nRects out of sync");
@@ -483,7 +483,7 @@
void SMsgWriter::writeSetDesktopNameRect(const char *name)
{
- if (!client->supportsDesktopRename)
+ if (!client->supportsEncoding(pseudoEncodingDesktopName))
throw Exception("Client does not support desktop rename");
if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
throw Exception("SMsgWriter::writeSetDesktopNameRect: nRects out of sync");
@@ -500,7 +500,7 @@
int hotspotX, int hotspotY,
const void* data, const void* mask)
{
- if (!client->supportsLocalCursor)
+ if (!client->supportsEncoding(pseudoEncodingCursor))
throw Exception("Client does not support local cursors");
if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
throw Exception("SMsgWriter::writeSetCursorRect: nRects out of sync");
@@ -518,7 +518,7 @@
int hotspotX, int hotspotY,
const void* data, const void* mask)
{
- if (!client->supportsLocalXCursor)
+ if (!client->supportsEncoding(pseudoEncodingXCursor))
throw Exception("Client does not support local cursors");
if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
throw Exception("SMsgWriter::writeSetXCursorRect: nRects out of sync");
@@ -544,7 +544,7 @@
int hotspotX, int hotspotY,
const rdr::U8* data)
{
- if (!client->supportsLocalCursorWithAlpha)
+ if (!client->supportsEncoding(pseudoEncodingCursorWithAlpha))
throw Exception("Client does not support local cursors");
if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
throw Exception("SMsgWriter::writeSetCursorWithAlphaRect: nRects out of sync");
@@ -570,7 +570,7 @@
void SMsgWriter::writeLEDStateRect(rdr::U8 state)
{
- if (!client->supportsLEDState)
+ if (!client->supportsEncoding(pseudoEncodingLEDState))
throw Exception("Client does not support LED state updates");
if (client->ledState() == ledUnknown)
throw Exception("Server does not support LED state updates");
@@ -587,7 +587,7 @@
void SMsgWriter::writeQEMUKeyEventRect()
{
- if (!client->supportsQEMUKeyEvent)
+ if (!client->supportsEncoding(pseudoEncodingQEMUKeyEvent))
throw Exception("Client does not support QEMU extended key events");
if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
throw Exception("SMsgWriter::writeQEMUKeyEventRect: nRects out of sync");
diff --git a/common/rfb/VNCSConnectionST.cxx b/common/rfb/VNCSConnectionST.cxx
index 34bb1e8..15b2f9a 100644
--- a/common/rfb/VNCSConnectionST.cxx
+++ b/common/rfb/VNCSConnectionST.cxx
@@ -385,8 +385,7 @@
if (state() != RFBSTATE_NORMAL)
return false;
- if (!client.supportsLocalCursorWithAlpha &&
- !client.supportsLocalCursor && !client.supportsLocalXCursor)
+ if (!client.supportsLocalCursor())
return true;
if (!server->cursorPos.equals(pointerEventPos) &&
(time(0) - pointerEventTime) > 0)
@@ -572,7 +571,7 @@
// Lock key heuristics
// (only for clients that do not support the LED state extension)
- if (!client.supportsLEDState) {
+ if (!client.supportsLEDState()) {
// Always ignore ScrollLock as we don't have a heuristic
// for that
if (keysym == XK_Scroll_Lock) {
@@ -787,7 +786,7 @@
{
Rect rect;
- if (!client.supportsFence || !client.supportsContinuousUpdates)
+ if (!client.supportsFence() || !client.supportsContinuousUpdates())
throw Exception("Client tried to enable continuous updates when not allowed");
continuousUpdates = enable;
@@ -803,7 +802,7 @@
}
// supportsLocalCursor() is called whenever the status of
-// client.supportsLocalCursor has changed. If the client does now support local
+// client.supportsLocalCursor() has changed. If the client does now support local
// cursor, we make sure that the old server-side rendered cursor is cleaned up
// and the cursor is sent to the client.
@@ -825,7 +824,7 @@
{
// We refuse to use continuous updates if we cannot monitor the buffer
// usage using fences.
- if (!client.supportsFence)
+ if (!client.supportsFence())
return;
writer()->writeEndOfContinuousUpdates();
@@ -868,7 +867,7 @@
{
char type;
- if (!client.supportsFence)
+ if (!client.supportsFence())
return;
congestion.updatePosition(sock->outStream().length());
@@ -895,7 +894,7 @@
if (sock->outStream().bufferUsage() > 0)
return true;
- if (!client.supportsFence)
+ if (!client.supportsFence())
return false;
congestion.updatePosition(sock->outStream().length());