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/SMsgWriter.cxx b/common/rfb/SMsgWriter.cxx
index dacba8a..a12a6d4 100644
--- a/common/rfb/SMsgWriter.cxx
+++ b/common/rfb/SMsgWriter.cxx
@@ -132,13 +132,12 @@
extendedDesktopSizeMsgs.push_back(msg);
}
-bool SMsgWriter::writeSetDesktopName() {
+void SMsgWriter::writeSetDesktopName()
+{
if (!client->supportsEncoding(pseudoEncodingDesktopName))
- return false;
+ throw Exception("Client does not support desktop name changes");
needSetDesktopName = true;
-
- return true;
}
void SMsgWriter::writeCursor()
@@ -151,26 +150,22 @@
needCursor = true;
}
-bool SMsgWriter::writeLEDState()
+void SMsgWriter::writeLEDState()
{
if (!client->supportsEncoding(pseudoEncodingLEDState))
- return false;
+ throw Exception("Client does not support LED state");
if (client->ledState() == ledUnknown)
- return false;
+ throw Exception("Server has not specified LED state");
needLEDState = true;
-
- return true;
}
-bool SMsgWriter::writeQEMUKeyEvent()
+void SMsgWriter::writeQEMUKeyEvent()
{
if (!client->supportsEncoding(pseudoEncodingQEMUKeyEvent))
- return false;
+ throw Exception("Client does not support QEMU key events");
needQEMUKeyEvent = true;
-
- return true;
}
bool SMsgWriter::needFakeUpdate()