Require all SMsgWriter caller to check capabilities
Make the API consisitent by requiring the caller to check what the client
supports before calling any of the write* functions. This avoids the
confusion that the functions might not always do anything.
diff --git a/common/rfb/VNCSConnectionST.cxx b/common/rfb/VNCSConnectionST.cxx
index d936573..a58fd09 100644
--- a/common/rfb/VNCSConnectionST.cxx
+++ b/common/rfb/VNCSConnectionST.cxx
@@ -829,6 +829,9 @@
void VNCSConnectionST::supportsLEDState()
{
+ if (client.ledState() == ledUnknown)
+ return;
+
writer()->writeLEDState();
}
@@ -1157,10 +1160,8 @@
if (state() != RFBSTATE_NORMAL)
return;
- if (!writer()->writeSetDesktopName()) {
- fprintf(stderr, "Client does not support desktop rename\n");
- return;
- }
+ if (client.supportsEncoding(pseudoEncodingDesktopName))
+ writer()->writeSetDesktopName();
}
void VNCSConnectionST::setLEDState(unsigned int ledstate)
@@ -1170,7 +1171,8 @@
client.setLEDState(ledstate);
- writer()->writeLEDState();
+ if (client.supportsLEDState())
+ writer()->writeLEDState();
}
void VNCSConnectionST::setSocketTimeouts()