aboutsummaryrefslogtreecommitdiffstats
path: root/common/rfb/SMsgWriter.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'common/rfb/SMsgWriter.cxx')
-rw-r--r--common/rfb/SMsgWriter.cxx97
1 files changed, 48 insertions, 49 deletions
diff --git a/common/rfb/SMsgWriter.cxx b/common/rfb/SMsgWriter.cxx
index 0c03b51d..f525d25a 100644
--- a/common/rfb/SMsgWriter.cxx
+++ b/common/rfb/SMsgWriter.cxx
@@ -31,7 +31,6 @@
#include <rfb/msgTypes.h>
#include <rfb/fenceTypes.h>
#include <rfb/clipboardTypes.h>
-#include <rfb/Exception.h>
#include <rfb/ClientParams.h>
#include <rfb/UpdateTracker.h>
#include <rfb/Encoder.h>
@@ -94,7 +93,7 @@ void SMsgWriter::writeBell()
void SMsgWriter::writeServerCutText(const char* str)
{
if (strchr(str, '\r') != nullptr)
- throw Exception("Invalid carriage return in clipboard data");
+ throw std::invalid_argument("Invalid carriage return in clipboard data");
std::string latin1(utf8ToLatin1(str));
@@ -111,7 +110,7 @@ void SMsgWriter::writeClipboardCaps(uint32_t caps,
size_t i, count;
if (!client->supportsEncoding(pseudoEncodingExtendedClipboard))
- throw Exception("Client does not support extended clipboard");
+ throw std::logic_error("Client does not support extended clipboard");
count = 0;
for (i = 0;i < 16;i++) {
@@ -137,9 +136,9 @@ void SMsgWriter::writeClipboardCaps(uint32_t caps,
void SMsgWriter::writeClipboardRequest(uint32_t flags)
{
if (!client->supportsEncoding(pseudoEncodingExtendedClipboard))
- throw Exception("Client does not support extended clipboard");
+ throw std::logic_error("Client does not support extended clipboard");
if (!(client->clipboardFlags() & clipboardRequest))
- throw Exception("Client does not support clipboard \"request\" action");
+ throw std::logic_error("Client does not support clipboard \"request\" action");
startMsg(msgTypeServerCutText);
os->pad(3);
@@ -151,9 +150,9 @@ void SMsgWriter::writeClipboardRequest(uint32_t flags)
void SMsgWriter::writeClipboardPeek(uint32_t flags)
{
if (!client->supportsEncoding(pseudoEncodingExtendedClipboard))
- throw Exception("Client does not support extended clipboard");
+ throw std::logic_error("Client does not support extended clipboard");
if (!(client->clipboardFlags() & clipboardPeek))
- throw Exception("Client does not support clipboard \"peek\" action");
+ throw std::logic_error("Client does not support clipboard \"peek\" action");
startMsg(msgTypeServerCutText);
os->pad(3);
@@ -165,9 +164,9 @@ void SMsgWriter::writeClipboardPeek(uint32_t flags)
void SMsgWriter::writeClipboardNotify(uint32_t flags)
{
if (!client->supportsEncoding(pseudoEncodingExtendedClipboard))
- throw Exception("Client does not support extended clipboard");
+ throw std::logic_error("Client does not support extended clipboard");
if (!(client->clipboardFlags() & clipboardNotify))
- throw Exception("Client does not support clipboard \"notify\" action");
+ throw std::logic_error("Client does not support clipboard \"notify\" action");
startMsg(msgTypeServerCutText);
os->pad(3);
@@ -186,9 +185,9 @@ void SMsgWriter::writeClipboardProvide(uint32_t flags,
int i, count;
if (!client->supportsEncoding(pseudoEncodingExtendedClipboard))
- throw Exception("Client does not support extended clipboard");
+ throw std::logic_error("Client does not support extended clipboard");
if (!(client->clipboardFlags() & clipboardProvide))
- throw Exception("Client does not support clipboard \"provide\" action");
+ throw std::logic_error("Client does not support clipboard \"provide\" action");
zos.setUnderlying(&mos);
@@ -215,11 +214,11 @@ void SMsgWriter::writeFence(uint32_t flags, unsigned len,
const uint8_t data[])
{
if (!client->supportsEncoding(pseudoEncodingFence))
- throw Exception("Client does not support fences");
+ throw std::logic_error("Client does not support fences");
if (len > 64)
- throw Exception("Too large fence payload");
+ throw std::out_of_range("Too large fence payload");
if ((flags & ~fenceFlagsSupported) != 0)
- throw Exception("Unknown fence flags");
+ throw std::invalid_argument("Unknown fence flags");
startMsg(msgTypeServerFence);
os->pad(3);
@@ -237,7 +236,7 @@ void SMsgWriter::writeFence(uint32_t flags, unsigned len,
void SMsgWriter::writeEndOfContinuousUpdates()
{
if (!client->supportsEncoding(pseudoEncodingContinuousUpdates))
- throw Exception("Client does not support continuous updates");
+ throw std::logic_error("Client does not support continuous updates");
startMsg(msgTypeEndOfContinuousUpdates);
endMsg();
@@ -249,7 +248,7 @@ void SMsgWriter::writeDesktopSize(uint16_t reason, uint16_t result)
if (!client->supportsEncoding(pseudoEncodingDesktopSize) &&
!client->supportsEncoding(pseudoEncodingExtendedDesktopSize))
- throw Exception("Client does not support desktop size changes");
+ throw std::logic_error("Client does not support desktop size changes");
msg.reason = reason;
msg.result = result;
@@ -260,7 +259,7 @@ void SMsgWriter::writeDesktopSize(uint16_t reason, uint16_t result)
void SMsgWriter::writeSetDesktopName()
{
if (!client->supportsEncoding(pseudoEncodingDesktopName))
- throw Exception("Client does not support desktop name changes");
+ throw std::logic_error("Client does not support desktop name changes");
needSetDesktopName = true;
}
@@ -271,7 +270,7 @@ void SMsgWriter::writeCursor()
!client->supportsEncoding(pseudoEncodingXCursor) &&
!client->supportsEncoding(pseudoEncodingCursorWithAlpha) &&
!client->supportsEncoding(pseudoEncodingVMwareCursor))
- throw Exception("Client does not support local cursor");
+ throw std::logic_error("Client does not support local cursor");
needCursor = true;
}
@@ -279,7 +278,7 @@ void SMsgWriter::writeCursor()
void SMsgWriter::writeCursorPos()
{
if (!client->supportsEncoding(pseudoEncodingVMwareCursorPosition))
- throw Exception("Client does not support cursor position");
+ throw std::logic_error("Client does not support cursor position");
needCursorPos = true;
}
@@ -288,9 +287,9 @@ void SMsgWriter::writeLEDState()
{
if (!client->supportsEncoding(pseudoEncodingLEDState) &&
!client->supportsEncoding(pseudoEncodingVMwareLEDState))
- throw Exception("Client does not support LED state");
+ throw std::logic_error("Client does not support LED state");
if (client->ledState() == ledUnknown)
- throw Exception("Server has not specified LED state");
+ throw std::logic_error("Server has not specified LED state");
needLEDState = true;
}
@@ -298,7 +297,7 @@ void SMsgWriter::writeLEDState()
void SMsgWriter::writeQEMUKeyEvent()
{
if (!client->supportsEncoding(pseudoEncodingQEMUKeyEvent))
- throw Exception("Client does not support QEMU key events");
+ throw std::logic_error("Client does not support QEMU key events");
needQEMUKeyEvent = true;
}
@@ -379,8 +378,8 @@ void SMsgWriter::writeFramebufferUpdateStart(int nRects)
void SMsgWriter::writeFramebufferUpdateEnd()
{
if (nRectsInUpdate != nRectsInHeader && nRectsInHeader)
- throw Exception("SMsgWriter::writeFramebufferUpdateEnd: "
- "nRects out of sync");
+ throw std::logic_error("SMsgWriter::writeFramebufferUpdateEnd: "
+ "nRects out of sync");
if (nRectsInHeader == 0) {
// Send last rect. marker
@@ -405,7 +404,7 @@ void SMsgWriter::writeCopyRect(const Rect& r, int srcX, int srcY)
void SMsgWriter::startRect(const Rect& r, int encoding)
{
if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
- throw Exception("SMsgWriter::startRect: nRects out of sync");
+ throw std::logic_error("SMsgWriter::startRect: nRects out of sync");
os->writeS16(r.tl.x);
os->writeS16(r.tl.y);
@@ -470,7 +469,7 @@ void SMsgWriter::writePseudoRects()
cursor.hotspot().x, cursor.hotspot().y,
bitmap.data(), mask.data());
} else {
- throw Exception("Client does not support local cursor");
+ throw std::logic_error("Client does not support local cursor");
}
needCursor = false;
@@ -482,7 +481,7 @@ void SMsgWriter::writePseudoRects()
if (client->supportsEncoding(pseudoEncodingVMwareCursorPosition)) {
writeSetVMwareCursorPositionRect(cursorPos.x, cursorPos.y);
} else {
- throw Exception("Client does not support cursor position");
+ throw std::logic_error("Client does not support cursor position");
}
needCursorPos = false;
@@ -519,7 +518,7 @@ void SMsgWriter::writeNoDataRects()
// more after this
writeSetDesktopSizeRect(client->width(), client->height());
} else {
- throw Exception("Client does not support desktop size changes");
+ throw std::logic_error("Client does not support desktop size changes");
}
extendedDesktopSizeMsgs.clear();
@@ -529,9 +528,9 @@ void SMsgWriter::writeNoDataRects()
void SMsgWriter::writeSetDesktopSizeRect(int width, int height)
{
if (!client->supportsEncoding(pseudoEncodingDesktopSize))
- throw Exception("Client does not support desktop resize");
+ throw std::logic_error("Client does not support desktop resize");
if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
- throw Exception("SMsgWriter::writeSetDesktopSizeRect: nRects out of sync");
+ throw std::logic_error("SMsgWriter::writeSetDesktopSizeRect: nRects out of sync");
os->writeS16(0);
os->writeS16(0);
@@ -549,9 +548,9 @@ void SMsgWriter::writeExtendedDesktopSizeRect(uint16_t reason,
ScreenSet::const_iterator si;
if (!client->supportsEncoding(pseudoEncodingExtendedDesktopSize))
- throw Exception("Client does not support extended desktop resize");
+ throw std::logic_error("Client does not support extended desktop resize");
if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
- throw Exception("SMsgWriter::writeExtendedDesktopSizeRect: nRects out of sync");
+ throw std::logic_error("SMsgWriter::writeExtendedDesktopSizeRect: nRects out of sync");
os->writeU16(reason);
os->writeU16(result);
@@ -575,9 +574,9 @@ void SMsgWriter::writeExtendedDesktopSizeRect(uint16_t reason,
void SMsgWriter::writeSetDesktopNameRect(const char *name)
{
if (!client->supportsEncoding(pseudoEncodingDesktopName))
- throw Exception("Client does not support desktop rename");
+ throw std::logic_error("Client does not support desktop rename");
if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
- throw Exception("SMsgWriter::writeSetDesktopNameRect: nRects out of sync");
+ throw std::logic_error("SMsgWriter::writeSetDesktopNameRect: nRects out of sync");
os->writeS16(0);
os->writeS16(0);
@@ -594,9 +593,9 @@ void SMsgWriter::writeSetCursorRect(int width, int height,
const uint8_t* mask)
{
if (!client->supportsEncoding(pseudoEncodingCursor))
- throw Exception("Client does not support local cursors");
+ throw std::logic_error("Client does not support local cursors");
if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
- throw Exception("SMsgWriter::writeSetCursorRect: nRects out of sync");
+ throw std::logic_error("SMsgWriter::writeSetCursorRect: nRects out of sync");
os->writeS16(hotspotX);
os->writeS16(hotspotY);
@@ -613,9 +612,9 @@ void SMsgWriter::writeSetXCursorRect(int width, int height,
const uint8_t* mask)
{
if (!client->supportsEncoding(pseudoEncodingXCursor))
- throw Exception("Client does not support local cursors");
+ throw std::logic_error("Client does not support local cursors");
if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
- throw Exception("SMsgWriter::writeSetXCursorRect: nRects out of sync");
+ throw std::logic_error("SMsgWriter::writeSetXCursorRect: nRects out of sync");
os->writeS16(hotspotX);
os->writeS16(hotspotY);
@@ -639,9 +638,9 @@ void SMsgWriter::writeSetCursorWithAlphaRect(int width, int height,
const uint8_t* data)
{
if (!client->supportsEncoding(pseudoEncodingCursorWithAlpha))
- throw Exception("Client does not support local cursors");
+ throw std::logic_error("Client does not support local cursors");
if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
- throw Exception("SMsgWriter::writeSetCursorWithAlphaRect: nRects out of sync");
+ throw std::logic_error("SMsgWriter::writeSetCursorWithAlphaRect: nRects out of sync");
os->writeS16(hotspotX);
os->writeS16(hotspotY);
@@ -667,9 +666,9 @@ void SMsgWriter::writeSetVMwareCursorRect(int width, int height,
const uint8_t* data)
{
if (!client->supportsEncoding(pseudoEncodingVMwareCursor))
- throw Exception("Client does not support local cursors");
+ throw std::logic_error("Client does not support local cursors");
if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
- throw Exception("SMsgWriter::writeSetVMwareCursorRect: nRects out of sync");
+ throw std::logic_error("SMsgWriter::writeSetVMwareCursorRect: nRects out of sync");
os->writeS16(hotspotX);
os->writeS16(hotspotY);
@@ -687,9 +686,9 @@ void SMsgWriter::writeSetVMwareCursorRect(int width, int height,
void SMsgWriter::writeSetVMwareCursorPositionRect(int hotspotX, int hotspotY)
{
if (!client->supportsEncoding(pseudoEncodingVMwareCursorPosition))
- throw Exception("Client does not support cursor position");
+ throw std::logic_error("Client does not support cursor position");
if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
- throw Exception("SMsgWriter::writeSetVMwareCursorRect: nRects out of sync");
+ throw std::logic_error("SMsgWriter::writeSetVMwareCursorRect: nRects out of sync");
os->writeS16(hotspotX);
os->writeS16(hotspotY);
@@ -702,11 +701,11 @@ void SMsgWriter::writeLEDStateRect(uint8_t state)
{
if (!client->supportsEncoding(pseudoEncodingLEDState) &&
!client->supportsEncoding(pseudoEncodingVMwareLEDState))
- throw Exception("Client does not support LED state updates");
+ throw std::logic_error("Client does not support LED state updates");
if (client->ledState() == ledUnknown)
- throw Exception("Server does not support LED state updates");
+ throw std::logic_error("Server does not support LED state updates");
if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
- throw Exception("SMsgWriter::writeLEDStateRect: nRects out of sync");
+ throw std::logic_error("SMsgWriter::writeLEDStateRect: nRects out of sync");
os->writeS16(0);
os->writeS16(0);
@@ -724,9 +723,9 @@ void SMsgWriter::writeLEDStateRect(uint8_t state)
void SMsgWriter::writeQEMUKeyEventRect()
{
if (!client->supportsEncoding(pseudoEncodingQEMUKeyEvent))
- throw Exception("Client does not support QEMU extended key events");
+ throw std::logic_error("Client does not support QEMU extended key events");
if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
- throw Exception("SMsgWriter::writeQEMUKeyEventRect: nRects out of sync");
+ throw std::logic_error("SMsgWriter::writeQEMUKeyEventRect: nRects out of sync");
os->writeS16(0);
os->writeS16(0);