#include <fcntl.h>
#include <errno.h>
+#include <rdr/Exception.h>
+
#include <network/Socket.h>
using namespace network;
#include <stdlib.h>
#include <unistd.h>
+#include <rdr/Exception.h>
+
#include <network/TcpSocket.h>
+
#include <rfb/LogWriter.h>
#include <rfb/Configuration.h>
#include <rfb/util.h>
if (sock == -1) {
if (err == 0)
- throw Exception("No useful address for host");
+ throw std::runtime_error("No useful address for host");
else
throw SocketException("unable to connect to socket", err);
}
parts = rfb::split(&p[1], '/');
if (parts.size() > 2)
- throw Exception("invalid filter specified");
+ throw std::invalid_argument("invalid filter specified");
if (parts[0].empty()) {
// Match any address
if (parts.size() > 1) {
if (family == AF_INET &&
(parts[1].find('.') != std::string::npos)) {
- throw Exception("mask no longer supported for filter, "
- "use prefix instead");
+ throw std::invalid_argument("mask no longer supported for "
+ "filter, use prefix instead");
}
pattern.prefixlen = (unsigned int) atoi(parts[1].c_str());
pattern.prefixlen = 128;
break;
default:
- throw Exception("unknown address family");
+ throw std::runtime_error("unknown address family");
}
}
}
family = pattern.address.u.sa.sa_family;
if (pattern.prefixlen > (family == AF_INET ? 32: 128))
- throw Exception(rfb::format("invalid prefix length for filter address: %u",
- pattern.prefixlen));
+ throw std::invalid_argument(rfb::format("invalid prefix length for "
+ "filter address: %u",
+ pattern.prefixlen));
// Compute mask from address and prefix length
memset (&pattern.mask, 0, sizeof (pattern.mask));
#include <stdlib.h>
#include <stddef.h>
+#include <rdr/Exception.h>
+
#include <network/UnixSocket.h>
+
#include <rfb/LogWriter.h>
using namespace network;
#include <assert.h>
#include <rdr/BufferedInStream.h>
-#include <rdr/Exception.h>
#include <rfb/util.h>
uint8_t* newBuffer;
if (needed > MAX_BUF_SIZE)
- throw Exception(rfb::format("BufferedInStream overrun: requested "
- "size of %lu bytes exceeds maximum "
- "of %lu bytes", (long unsigned)needed,
- (long unsigned)MAX_BUF_SIZE));
+ throw std::out_of_range(rfb::format("BufferedInStream overrun: "
+ "requested size of %lu bytes "
+ "exceeds maximum of %lu "
+ "bytes",
+ (long unsigned)needed,
+ (long unsigned)MAX_BUF_SIZE));
newSize = DEFAULT_BUF_SIZE;
while (newSize < needed)
#endif
#include <rdr/BufferedOutStream.h>
-#include <rdr/Exception.h>
#include <rfb/util.h>
// We'll need to allocate more buffer space...
if (totalNeeded > MAX_BUF_SIZE)
- throw Exception(rfb::format("BufferedOutStream overrun: requested "
- "size of %lu bytes exceeds maximum of "
- "%lu bytes", (long unsigned)totalNeeded,
- (long unsigned)MAX_BUF_SIZE));
+ throw std::out_of_range(rfb::format("BufferedOutStream overrun: "
+ "requested size of %lu bytes "
+ "exceeds maximum of %lu bytes",
+ (long unsigned)totalNeeded,
+ (long unsigned)MAX_BUF_SIZE));
newSize = DEFAULT_BUF_SIZE;
while (newSize < totalNeeded)
#include <algorithm>
#include <rdr/HexInStream.h>
-#include <rdr/Exception.h>
#include <rfb/util.h>
using namespace rdr;
uint8_t* optr = (uint8_t*) end;
for (size_t i=0; i<length; i++) {
if (!rfb::hexToBin((const char*)&iptr[i*2], 2, &optr[i], 1))
- throw Exception("HexInStream: Invalid input data");
+ throw std::runtime_error("HexInStream: Invalid input data");
}
in_stream.setptr(length*2);
#include <stdint.h>
#include <string.h> // for memcpy
-#include <rdr/Exception.h>
+#include <stdexcept>
// Check that callers are using InStream properly,
// useful when writing new protocol handling
inline void setRestorePoint() {
#ifdef RFB_INSTREAM_CHECK
if (restorePoint != nullptr)
- throw Exception("Nested use of input stream restore point");
+ throw std::logic_error("Nested use of input stream restore point");
#endif
restorePoint = ptr;
}
inline void clearRestorePoint() {
#ifdef RFB_INSTREAM_CHECK
if (restorePoint == nullptr)
- throw Exception("Incorrect clearing of input stream restore point");
+ throw std::logic_error("Incorrect clearing of input stream restore point");
#endif
restorePoint = nullptr;
}
inline void gotoRestorePoint() {
#ifdef RFB_INSTREAM_CHECK
if (restorePoint == nullptr)
- throw Exception("Incorrect activation of input stream restore point");
+ throw std::logic_error("Incorrect activation of input stream restore point");
#endif
ptr = restorePoint;
clearRestorePoint();
inline const uint8_t* getptr(size_t length) { check(length);
return ptr; }
inline void setptr(size_t length) { if (length > avail())
- throw Exception("Input stream overflow");
+ throw std::out_of_range("Input stream overflow");
skip(length); }
private:
inline void check(size_t bytes) {
#ifdef RFB_INSTREAM_CHECK
if (bytes > checkedBytes)
- throw Exception("Input stream used without underrun check");
+ throw std::logic_error("Input stream used without underrun check");
checkedBytes -= bytes;
#endif
if (bytes > (size_t)(end - ptr))
- throw Exception("InStream buffer underrun");
+ throw std::out_of_range("InStream buffer underrun");
}
// overrun() is implemented by a derived class to cope with buffer overrun.
#ifndef __RDR_MEMOUTSTREAM_H__
#define __RDR_MEMOUTSTREAM_H__
-#include <rdr/Exception.h>
#include <rdr/OutStream.h>
namespace rdr {
len = (end - start) * 2;
if (len < (size_t)(end - start))
- throw Exception("Overflow in MemOutStream::overrun()");
+ throw std::out_of_range("Overflow in MemOutStream::overrun()");
uint8_t* newStart = new uint8_t[len];
memcpy(newStart, start, ptr - start);
#include <stdint.h>
#include <string.h> // for memcpy
-#include <rdr/Exception.h>
+#include <stdexcept>
+
#include <rdr/InStream.h>
namespace rdr {
inline uint8_t* getptr(size_t length) { check(length); return ptr; }
inline void setptr(size_t length) { if (length > avail())
- throw Exception("Output stream overflow");
+ throw std::out_of_range("Output stream overflow");
ptr += length; }
private:
#include <assert.h>
#include <rdr/ZlibInStream.h>
-#include <rdr/Exception.h>
#include <zlib.h>
using namespace rdr;
{
while (bytesIn > 0) {
if (!hasData(1))
- throw Exception("ZlibInStream: failed to flush remaining stream data");
+ throw std::runtime_error("ZlibInStream: failed to flush remaining stream data");
skip(avail());
}
if (inflateInit(zs) != Z_OK) {
delete zs;
zs = nullptr;
- throw Exception("ZlibInStream: inflateInit failed");
+ throw std::runtime_error("ZlibInStream: inflateInit failed");
}
}
bool ZlibInStream::fillBuffer()
{
if (!underlying)
- throw Exception("ZlibInStream overrun: no underlying stream");
+ throw std::runtime_error("ZlibInStream overrun: no underlying stream");
zs->next_out = (uint8_t*)end;
zs->avail_out = availSpace();
int rc = inflate(zs, Z_SYNC_FLUSH);
if (rc < 0) {
- throw Exception("ZlibInStream: inflate failed");
+ throw std::runtime_error("ZlibInStream: inflate failed");
}
bytesIn -= length - zs->avail_in;
#include <stdio.h>
#include <rdr/ZlibOutStream.h>
-#include <rdr/Exception.h>
#include <rfb/LogWriter.h>
#include <zlib.h>
zs->avail_in = 0;
if (deflateInit(zs, compressLevel) != Z_OK) {
delete zs;
- throw Exception("ZlibOutStream: deflateInit failed");
+ throw std::runtime_error("ZlibOutStream: deflateInit failed");
}
}
int rc;
if (!underlying)
- throw Exception("ZlibOutStream: underlying OutStream has not been set");
+ throw std::runtime_error("ZlibOutStream: underlying OutStream has not been set");
if ((flush == Z_NO_FLUSH) && (zs->avail_in == 0))
return;
if ((rc == Z_BUF_ERROR) && (flush != Z_NO_FLUSH))
break;
- throw Exception("ZlibOutStream: deflate failed");
+ throw std::runtime_error("ZlibOutStream: deflate failed");
}
#ifdef ZLIBOUT_DEBUG
// explicit flush we did above. It should be safe to ignore though
// as the first flush should have left things in a stable state...
if (rc != Z_BUF_ERROR)
- throw Exception("ZlibOutStream: deflateParams failed");
+ throw std::runtime_error("ZlibOutStream: deflateParams failed");
}
compressionLevel = newLevel;
case RFBSTATE_INITIALISATION: return processInitMsg(); break;
case RFBSTATE_NORMAL: return reader_->readMsg(); break;
case RFBSTATE_CLOSING:
- throw Exception("CConnection::processMsg: called while closing");
+ throw std::logic_error("CConnection::processMsg: called while closing");
case RFBSTATE_UNINITIALISED:
- throw Exception("CConnection::processMsg: not initialised yet?");
+ throw std::logic_error("CConnection::processMsg: not initialised yet?");
default:
- throw Exception("CConnection::processMsg: invalid state");
+ throw std::logic_error("CConnection::processMsg: invalid state");
}
}
#include <rfb/fenceTypes.h>
#include <rfb/qemuTypes.h>
#include <rfb/clipboardTypes.h>
-#include <rfb/Exception.h>
#include <rfb/PixelFormat.h>
#include <rfb/Rect.h>
#include <rfb/ServerParams.h>
const ScreenSet& layout)
{
if (!server->supportsSetDesktopSize)
- throw Exception("Server does not support SetDesktopSize");
+ throw std::logic_error("Server does not support SetDesktopSize");
startMsg(msgTypeSetDesktopSize);
os->pad(1);
int x, int y, int w, int h)
{
if (!server->supportsContinuousUpdates)
- throw Exception("Server does not support continuous updates");
+ throw std::logic_error("Server does not support continuous updates");
startMsg(msgTypeEnableContinuousUpdates);
void CMsgWriter::writeFence(uint32_t flags, unsigned len, const uint8_t data[])
{
if (!server->supportsFence)
- throw Exception("Server does not support fences");
+ throw std::logic_error("Server 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(msgTypeClientFence);
os->pad(3);
void CMsgWriter::writeClientCutText(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));
size_t i, count;
if (!(server->clipboardFlags() & clipboardCaps))
- throw Exception("Server does not support clipboard \"caps\" action");
+ throw std::logic_error("Server does not support clipboard \"caps\" action");
count = 0;
for (i = 0;i < 16;i++) {
void CMsgWriter::writeClipboardRequest(uint32_t flags)
{
if (!(server->clipboardFlags() & clipboardRequest))
- throw Exception("Server does not support clipboard \"request\" action");
+ throw std::logic_error("Server does not support clipboard \"request\" action");
startMsg(msgTypeClientCutText);
os->pad(3);
void CMsgWriter::writeClipboardPeek(uint32_t flags)
{
if (!(server->clipboardFlags() & clipboardPeek))
- throw Exception("Server does not support clipboard \"peek\" action");
+ throw std::logic_error("Server does not support clipboard \"peek\" action");
startMsg(msgTypeClientCutText);
os->pad(3);
void CMsgWriter::writeClipboardNotify(uint32_t flags)
{
if (!(server->clipboardFlags() & clipboardNotify))
- throw Exception("Server does not support clipboard \"notify\" action");
+ throw std::logic_error("Server does not support clipboard \"notify\" action");
startMsg(msgTypeClientCutText);
os->pad(3);
int i, count;
if (!(server->clipboardFlags() & clipboardProvide))
- throw Exception("Server does not support clipboard \"provide\" action");
+ throw std::logic_error("Server does not support clipboard \"provide\" action");
zos.setUnderlying(&mos);
std::vector<uint8_t> bBytes(keyLength);
if (!rs.hasData(keyLength))
- throw Exception("failed to generate DH private key");
+ throw std::runtime_error("failed to generate DH private key");
rs.readBytes(bBytes.data(), bBytes.size());
nettle_mpz_set_str_256_u(b, bBytes.size(), bBytes.data());
mpz_powm(k, A, b, p);
uint8_t buf[128];
if (!rs.hasData(128))
- throw Exception("failed to generate random padding");
+ throw std::runtime_error("failed to generate random padding");
rs.readBytes(buf, 128);
if (username.size() >= 64)
- throw Exception("username is too long");
+ throw std::out_of_range("username is too long");
memcpy(buf, username.c_str(), username.size() + 1);
if (password.size() >= 64)
- throw Exception("password is too long");
+ throw std::out_of_range("password is too long");
memcpy(buf + 64, password.c_str(), password.size() + 1);
aes128_encrypt(&aesCtx, 128, buf, buf);
#include <rdr/InStream.h>
#include <rdr/OutStream.h>
#include <rdr/RandomStream.h>
-#include <rfb/Exception.h>
#include <os/os.h>
using namespace rfb;
std::vector<uint8_t> bBytes(8);
if (!rs.hasData(8))
- throw Exception("failed to generate DH private key");
+ throw std::runtime_error("failed to generate DH private key");
rs.readBytes(bBytes.data(), bBytes.size());
nettle_mpz_set_str_256_u(b, bBytes.size(), bBytes.data());
mpz_powm(k, A, b, p);
}
if (!rs.hasData(256 + 64))
- throw Exception("failed to generate random padding");
+ throw std::runtime_error("failed to generate random padding");
rs.readBytes(user, 256);
rs.readBytes(pass, 64);
if (username.size() >= 256)
- throw Exception("username is too long");
+ throw std::out_of_range("username is too long");
memcpy(user, username.c_str(), username.size() + 1);
if (password.size() >= 64)
- throw Exception("password is too long");
+ throw std::out_of_range("password is too long");
memcpy(pass, password.c_str(), password.size() + 1);
// DES-CBC with the original key as IV, and the reversed one as the DES key
{
rdr::RandomStream* rs = (rdr::RandomStream*)ctx;
if (!rs->hasData(length))
- throw Exception("failed to generate random");
+ throw std::runtime_error("failed to generate random");
rs->readBytes(dst, length);
}
if (!rsa_generate_keypair(&clientPublicKey, &clientKey,
&rs, random_func, nullptr, nullptr,
clientKeyLength, 0))
- throw Exception("failed to generate key");
+ throw std::runtime_error("failed to generate key");
clientKeyN = new uint8_t[rsaKeySize];
clientKeyE = new uint8_t[rsaKeySize];
nettle_mpz_get_str_256(rsaKeySize, clientKeyN, clientPublicKey.n);
{
rdr::OutStream* os = cc->getOutStream();
if (!rs.hasData(keySize / 8))
- throw Exception("failed to generate random");
+ throw std::runtime_error("failed to generate random");
rs.readBytes(clientRandom, keySize / 8);
mpz_t x;
mpz_init(x);
}
if (!res) {
mpz_clear(x);
- throw Exception("failed to encrypt random");
+ throw std::runtime_error("failed to encrypt random");
}
uint8_t* buffer = new uint8_t[serverKey.size];
nettle_mpz_get_str_256(serverKey.size, buffer, x);
if (subtype == secTypeRA2UserPass) {
if (username.size() > 255)
- throw Exception("username is too long");
+ throw std::out_of_range("username is too long");
raos->writeU8(username.size());
raos->writeBytes((const uint8_t*)username.data(), username.size());
} else {
}
if (password.size() > 255)
- throw Exception("password is too long");
+ throw std::out_of_range("password is too long");
raos->writeU8(password.size());
raos->writeBytes((const uint8_t*)password.data(), password.size());
raos->flush();
hostsDir = os::getvncstatedir();
if (hostsDir == nullptr) {
- throw Exception("Could not obtain VNC state directory path for "
- "known hosts storage");
+ throw std::runtime_error("Could not obtain VNC state directory "
+ "path for known hosts storage");
}
std::string dbPath;
if (status != 0) {
vlog.error("Unhandled certificate problems: 0x%x", status);
- throw Exception("Unhandled certificate problems");
+ throw std::logic_error("Unhandled certificate problems");
}
if (!hostname_match) {
if (status != 0) {
vlog.error("Unhandled certificate problems: 0x%x", status);
- throw Exception("Unhandled certificate problems");
+ throw std::logic_error("Unhandled certificate problems");
}
if (!hostname_match) {
#include <config.h>
#endif
-#include <rfb/Exception.h>
+#include <stdexcept>
+
#include <rfb/encodings.h>
#include <rfb/ledStates.h>
#include <rfb/clipboardTypes.h>
void ClientParams::setDimensions(int width, int height, const ScreenSet& layout)
{
if (!layout.validate(width, height))
- throw Exception("Attempted to configure an invalid screen layout");
+ throw std::invalid_argument("Attempted to configure an invalid screen layout");
width_ = width;
height_ = height;
pf_ = pf;
if (pf.bpp != 8 && pf.bpp != 16 && pf.bpp != 32)
- throw Exception("setPF: not 8, 16 or 32 bpp?");
+ throw std::invalid_argument("setPF: not 8, 16 or 32 bpp?");
}
void ClientParams::setName(const char* name)
return clipSizes[i];
}
- throw Exception(rfb::format("Invalid clipboard format 0x%x", format));
+ throw std::invalid_argument(rfb::format("Invalid clipboard format 0x%x", format));
}
void ClientParams::setClipboardCaps(uint32_t flags, const uint32_t* lengths)
#include <ctype.h>
#include <string.h>
+#include <stdexcept>
+
#include <os/Mutex.h>
#include <rfb/util.h>
#include <rfb/Configuration.h>
#include <rfb/LogWriter.h>
-#include <rfb/Exception.h>
#define LOCK_CONFIG os::AutoMutex a(mutex)
{
if (!v) {
vlog.error("Default value <null> for %s not allowed",name_);
- throw rfb::Exception("Default value <null> not allowed");
+ throw std::invalid_argument("Default value <null> not allowed");
}
}
LOCK_CONFIG;
if (immutable) return true;
if (!v)
- throw rfb::Exception("setParam(<null>) not allowed");
+ throw std::invalid_argument("setParam(<null>) not allowed");
vlog.debug("set %s(String) to %s", getName(), v);
value = v;
return true;
#include <assert.h>
#include <string.h>
+#include <stdexcept>
+
#include <rfb/Cursor.h>
#include <rfb/LogWriter.h>
-#include <rfb/Exception.h>
using namespace rfb;
r = _r.translate(offset.negate());
if (!r.enclosed_by(buffer.getRect()))
- throw Exception("RenderedCursor: Invalid area requested");
+ throw std::out_of_range("RenderedCursor: Invalid area requested");
return buffer.getBuffer(r, stride);
}
if (!decoder->readRect(r, conn->getInStream(), conn->server, bufferStream))
return false;
} catch (std::exception& e) {
- throw Exception(format("Error reading rect: %s", e.what()));
+ throw std::runtime_error(format("Error reading rect: %s", e.what()));
}
stats[encoding].rects++;
if (threadException != nullptr)
return;
- threadException = new rdr::Exception(format("Exception on worker thread: %s", e.what()));
+ threadException = new std::runtime_error(format("Exception on worker thread: %s", e.what()));
}
void DecodeManager::throwThreadException()
#include <rfb/SMsgWriter.h>
#include <rfb/UpdateTracker.h>
#include <rfb/LogWriter.h>
-#include <rfb/Exception.h>
#include <rfb/util.h>
#include <rfb/RawEncoder.h>
uint8_t* EncodeManager::OffsetPixelBuffer::getBufferRW(const Rect& /*r*/, int* /*stride*/)
{
- throw rfb::Exception("Invalid write attempt to OffsetPixelBuffer");
+ throw std::logic_error("Invalid write attempt to OffsetPixelBuffer");
}
template<class T>
#include <rdr/InStream.h>
#include <rdr/OutStream.h>
#include <rfb/LogWriter.h>
-#include <rfb/Exception.h>
#include <rfb/H264Decoder.h>
#include <rfb/H264DecoderContext.h>
}
ctx = H264DecoderContext::createContext(r);
if (!ctx)
- throw Exception("H264Decoder: Context not be created");
+ throw std::runtime_error("H264Decoder: Context not be created");
contexts.push_back(ctx);
}
if (!ctx->isReady())
- throw Exception("H264Decoder: Context is not ready");
+ throw std::runtime_error("H264Decoder: Context is not ready");
if (reset & resetContext)
ctx->reset();
#include <config.h>
#endif
+#include <stdexcept>
+
#include <os/Mutex.h>
-#include <rfb/Exception.h>
#include <rfb/LogWriter.h>
#include <rfb/H264DecoderContext.h>
H264DecoderContext *ret = new H264DecoderContextType(r);
if (!ret->initCodec())
{
- throw Exception("H264DecoderContext: Unable to create context");
+ throw std::runtime_error("H264DecoderContext: Unable to create context");
}
return ret;
#define FFMPEG_INIT_PACKET_DEPRECATED
#endif
-#include <rfb/Exception.h>
#include <rfb/LogWriter.h>
#include <rfb/PixelBuffer.h>
#include <rfb/H264LibavDecoderContext.h>
{
h264WorkBuffer = (uint8_t*)realloc(h264WorkBuffer, reserve_len);
if (h264WorkBuffer == nullptr) {
- throw Exception("H264LibavDecoderContext: Unable to allocate memory");
+ throw std::bad_alloc();
}
h264WorkBufferLength = reserve_len;
}
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
-#include <rdr/Exception.h>
+
+#include <stdexcept>
+
#include <rfb/util.h>
namespace rfb {
const char* portStart;
if (hi == nullptr)
- throw rdr::Exception("NULL host specified");
+ throw std::invalid_argument("NULL host specified");
// Trim leading whitespace
while(isspace(*hi))
hostStart = &hi[1];
hostEnd = strchr(hostStart, ']');
if (hostEnd == nullptr)
- throw rdr::Exception("unmatched [ in host");
+ throw std::invalid_argument("unmatched [ in host");
portStart = hostEnd + 1;
if (isAllSpace(portStart))
char* end;
if (portStart[0] != ':')
- throw rdr::Exception("invalid port specified");
+ throw std::invalid_argument("invalid port specified");
if (portStart[1] != ':')
*port = strtol(portStart + 1, &end, 10);
else
*port = strtol(portStart + 2, &end, 10);
if (*end != '\0' && ! isAllSpace(end))
- throw rdr::Exception("invalid port specified");
+ throw std::invalid_argument("invalid port specified");
if ((portStart[1] != ':') && (*port < 100))
*port += basePort;
#include <config.h>
#endif
+#include <stdexcept>
+
#include <rfb/JpegCompressor.h>
-#include <rdr/Exception.h>
#include <rfb/Rect.h>
#include <rfb/PixelFormat.h>
#include <rfb/ClientParams.h>
if(setjmp(err->jmpBuffer)) {
// this will execute if libjpeg has an error
- throw rdr::Exception(err->lastError);
+ throw std::runtime_error(err->lastError);
}
jpeg_create_compress(cinfo);
jpeg_abort_compress(cinfo);
if (srcBufIsTemp && srcBuf) delete[] srcBuf;
if (rowPointer) delete[] rowPointer;
- throw rdr::Exception(err->lastError);
+ throw std::runtime_error(err->lastError);
}
cinfo->image_width = w;
void JpegCompressor::writeBytes(const uint8_t* /*data*/, int /*length*/)
{
- throw rdr::Exception("writeBytes() is not valid with a JpegCompressor instance. Use compress() instead.");
+ throw std::logic_error("writeBytes() is not valid with a JpegCompressor instance. Use compress() instead.");
}
if(setjmp(err->jmpBuffer)) {
// this will execute if libjpeg has an error
- throw rdr::Exception(err->lastError);
+ throw std::runtime_error(err->lastError);
}
jpeg_create_decompress(dinfo);
jpeg_abort_decompress(dinfo);
if (dstBufIsTemp && dstBuf) delete[] dstBuf;
if (rowPointer) delete[] rowPointer;
- throw rdr::Exception(err->lastError);
+ throw std::runtime_error(err->lastError);
}
src->pub.next_input_byte = jpegBuf;
#include <string.h>
-#include <rfb/Exception.h>
+#include <stdexcept>
+
#include <rfb/LogWriter.h>
#include <rfb/PixelBuffer.h>
#include <rfb/util.h>
const uint8_t* end;
if (!r.enclosed_by(getRect()))
- throw rfb::Exception(rfb::format("Source rect %dx%d at %d,%d exceeds framebuffer %dx%d",
- r.width(), r.height(),
- r.tl.x, r.tl.y,
- width(), height()));
+ throw std::out_of_range(rfb::format("Source rect %dx%d at %d,%d exceeds framebuffer %dx%d",
+ r.width(), r.height(),
+ r.tl.x, r.tl.y,
+ width(), height()));
data = getBuffer(r, &inStride);
}
if (!r.enclosed_by(getRect()))
- throw rfb::Exception(rfb::format("Source rect %dx%d at %d,%d exceeds framebuffer %dx%d",
- r.width(), r.height(),
- r.tl.x, r.tl.y,
- width(), height()));
+ throw std::out_of_range(rfb::format("Source rect %dx%d at %d,%d exceeds framebuffer %dx%d",
+ r.width(), r.height(),
+ r.tl.x, r.tl.y,
+ width(), height()));
if (stride == 0)
stride = r.width();
void PixelBuffer::setSize(int width, int height)
{
if ((width < 0) || (width > maxPixelBufferWidth))
- throw rfb::Exception(rfb::format("Invalid PixelBuffer width of %d pixels requested", width));
+ throw std::out_of_range(rfb::format("Invalid PixelBuffer width of %d pixels requested", width));
if ((height < 0) || (height > maxPixelBufferHeight))
- throw rfb::Exception(rfb::format("Invalid PixelBuffer height of %d pixels requested", height));
+ throw std::out_of_range(rfb::format("Invalid PixelBuffer height of %d pixels requested", height));
width_ = width;
height_ = height;
int w, h, b;
if (!r.enclosed_by(getRect()))
- throw rfb::Exception(rfb::format("Destination rect %dx%d at %d,%d exceeds framebuffer %dx%d",
- r.width(), r.height(),
- r.tl.x, r.tl.y,
- width(), height()));
+ throw std::out_of_range(rfb::format("Destination rect %dx%d at %d,%d exceeds framebuffer %dx%d",
+ r.width(), r.height(),
+ r.tl.x, r.tl.y,
+ width(), height()));
w = r.width();
h = r.height();
uint8_t* end;
if (!r.enclosed_by(getRect()))
- throw rfb::Exception(rfb::format("Destination rect %dx%d at %d,%d exceeds framebuffer %dx%d",
- r.width(), r.height(),
- r.tl.x, r.tl.y,
- width(), height()));
+ throw std::out_of_range(rfb::format("Destination rect %dx%d at %d,%d exceeds framebuffer %dx%d",
+ r.width(), r.height(),
+ r.tl.x, r.tl.y,
+ width(), height()));
bytesPerPixel = getPF().bpp/8;
drect = rect;
if (!drect.enclosed_by(getRect()))
- throw rfb::Exception(rfb::format("Destination rect %dx%d at %d,%d exceeds framebuffer %dx%d",
- drect.width(), drect.height(),
- drect.tl.x, drect.tl.y,
- width(), height()));
+ throw std::out_of_range(rfb::format("Destination rect %dx%d at %d,%d exceeds framebuffer %dx%d",
+ drect.width(), drect.height(),
+ drect.tl.x, drect.tl.y,
+ width(), height()));
srect = drect.translate(move_by_delta.negate());
if (!srect.enclosed_by(getRect()))
- throw rfb::Exception(rfb::format("Source rect %dx%d at %d,%d exceeds framebuffer %dx%d",
- srect.width(), srect.height(),
- srect.tl.x, srect.tl.y,
- width(), height()));
+ throw std::out_of_range(rfb::format("Source rect %dx%d at %d,%d exceeds framebuffer %dx%d",
+ srect.width(), srect.height(),
+ srect.tl.x, srect.tl.y,
+ width(), height()));
bytesPerPixel = format.bpp/8;
int dstStride;
if (!dest.enclosed_by(getRect()))
- throw rfb::Exception(rfb::format("Destination rect %dx%d at %d,%d exceeds framebuffer %dx%d",
- dest.width(), dest.height(),
- dest.tl.x, dest.tl.y,
- width(), height()));
+ throw std::out_of_range(rfb::format("Destination rect %dx%d at %d,%d exceeds framebuffer %dx%d",
+ dest.width(), dest.height(),
+ dest.tl.x, dest.tl.y,
+ width(), height()));
if (stride == 0)
stride = dest.width();
uint8_t* FullFramePixelBuffer::getBufferRW(const Rect& r, int* stride_)
{
if (!r.enclosed_by(getRect()))
- throw rfb::Exception(rfb::format("Pixel buffer request %dx%d at %d,%d exceeds framebuffer %dx%d",
- r.width(), r.height(),
- r.tl.x, r.tl.y,
- width(), height()));
+ throw std::out_of_range(rfb::format("Pixel buffer request %dx%d at %d,%d exceeds framebuffer %dx%d",
+ r.width(), r.height(),
+ r.tl.x, r.tl.y,
+ width(), height()));
*stride_ = stride;
return &data[(r.tl.x + (r.tl.y * stride)) * (format.bpp/8)];
const uint8_t* FullFramePixelBuffer::getBuffer(const Rect& r, int* stride_) const
{
if (!r.enclosed_by(getRect()))
- throw rfb::Exception(rfb::format("Pixel buffer request %dx%d at %d,%d exceeds framebuffer %dx%d",
- r.width(), r.height(),
- r.tl.x, r.tl.y,
- width(), height()));
+ throw std::out_of_range(rfb::format("Pixel buffer request %dx%d at %d,%d exceeds framebuffer %dx%d",
+ r.width(), r.height(),
+ r.tl.x, r.tl.y,
+ width(), height()));
*stride_ = stride;
return &data[(r.tl.x + (r.tl.y * stride)) * (format.bpp/8)];
uint8_t* data_, int stride_)
{
if ((width < 0) || (width > maxPixelBufferWidth))
- throw rfb::Exception(rfb::format("Invalid PixelBuffer width of %d pixels requested", width));
+ throw std::out_of_range(rfb::format("Invalid PixelBuffer width of %d pixels requested", width));
if ((height < 0) || (height > maxPixelBufferHeight))
- throw rfb::Exception(rfb::format("Invalid PixelBuffer height of %d pixels requested", height));
+ throw std::out_of_range(rfb::format("Invalid PixelBuffer height of %d pixels requested", height));
if ((stride_ < 0) || (stride_ > maxPixelBufferStride) || (stride_ < width))
- throw rfb::Exception(rfb::format("Invalid PixelBuffer stride of %d pixels requested", stride_));
+ throw std::invalid_argument(rfb::format("Invalid PixelBuffer stride of %d pixels requested", stride_));
if ((width != 0) && (height != 0) && (data_ == nullptr))
- throw rfb::Exception(rfb::format("PixelBuffer requested without a valid memory area"));
+ throw std::logic_error(rfb::format("PixelBuffer requested without a valid memory area"));
ModifiablePixelBuffer::setSize(width, height);
stride = stride_;
void FullFramePixelBuffer::setSize(int /*w*/, int /*h*/)
{
// setBuffer() should be used
- throw rfb::Exception("Invalid call to FullFramePixelBuffer::setSize()");
+ throw std::logic_error("Invalid call to FullFramePixelBuffer::setSize()");
}
// -=- Managed pixel buffer class
redShift(rs), greenShift(gs), blueShift(bs)
{
if (!isSane())
- throw Exception("invalid pixel format");
+ throw std::invalid_argument("invalid pixel format");
updateState();
}
case RFBSTATE_INITIALISATION: return processInitMsg(); break;
case RFBSTATE_NORMAL: return reader_->readMsg(); break;
case RFBSTATE_QUERYING:
- throw Exception("SConnection::processMsg: bogus data from client while "
- "querying");
+ throw std::logic_error("SConnection::processMsg: bogus data from "
+ "client while querying");
case RFBSTATE_CLOSING:
- throw Exception("SConnection::processMsg: called while closing");
+ throw std::logic_error("SConnection::processMsg: called while closing");
case RFBSTATE_UNINITIALISED:
- throw Exception("SConnection::processMsg: not initialised yet?");
+ throw std::logic_error("SConnection::processMsg: not initialised yet?");
default:
- throw Exception("SConnection::processMsg: invalid state");
+ throw std::logic_error("SConnection::processMsg: invalid state");
}
}
bool SConnection::accessCheck(AccessRights ar) const
{
if (state_ < RFBSTATE_QUERYING)
- throw Exception("SConnection::accessCheck: invalid state");
+ throw std::logic_error("SConnection::accessCheck: invalid state");
return (accessRights & ar) == ar;
}
void SConnection::approveConnection(bool accept, const char* reason)
{
if (state_ != RFBSTATE_QUERYING)
- throw Exception("SConnection::approveConnection: invalid state");
+ throw std::logic_error("SConnection::approveConnection: invalid state");
if (!client.beforeVersion(3,8) || ssecurity->getType() != secTypeNone) {
if (accept) {
#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>
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));
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++) {
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);
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);
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);
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);
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);
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();
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;
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;
}
!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;
}
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;
}
{
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;
}
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;
}
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
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);
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;
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;
// 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();
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);
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);
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);
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);
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);
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);
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);
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);
{
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);
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);
char password[1024];
if (!valid)
- throw Exception("No password validator configured");
+ throw std::logic_error("No password validator configured");
if (state == 0) {
if (!is->hasData(8))
size_t size = ftell(file);
if (size == 0 || size > MaxKeyFileSize) {
fclose(file);
- throw Exception("size of key file is zero or too big");
+ throw std::runtime_error("size of key file is zero or too big");
}
fseek(file, 0, SEEK_SET);
std::vector<uint8_t> data(size);
loadPKCS8Key(der.data(), der.size());
return;
}
- throw Exception("failed to import key");
+ throw std::runtime_error("failed to import key");
}
void SSecurityRSAAES::loadPKCS1Key(const uint8_t* data, size_t size)
if (!rsa_keypair_from_der(&pub, &serverKey, 0, size, data)) {
rsa_private_key_clear(&serverKey);
rsa_public_key_clear(&pub);
- throw Exception("failed to import key");
+ throw std::runtime_error("failed to import key");
}
serverKeyLength = serverKey.size * 8;
serverKeyN = new uint8_t[serverKey.size];
loadPKCS1Key(i.data, i.length);
return;
failed:
- throw Exception("failed to import key");
+ throw std::runtime_error("failed to import key");
}
bool SSecurityRSAAES::processMsg()
{
rdr::RandomStream* rs = (rdr::RandomStream*)ctx;
if (!rs->hasData(length))
- throw Exception("failed to encrypt random");
+ throw std::runtime_error("failed to encrypt random");
rs->readBytes(dst, length);
}
{
rdr::OutStream* os = sc->getOutStream();
if (!rs.hasData(keySize / 8))
- throw Exception("failed to generate random");
+ throw std::runtime_error("failed to generate random");
rs.readBytes(serverRandom, keySize / 8);
mpz_t x;
mpz_init(x);
}
if (!res) {
mpz_clear(x);
- throw Exception("failed to encrypt random");
+ throw std::runtime_error("failed to encrypt random");
}
uint8_t* buffer = new uint8_t[clientKey.size];
nettle_mpz_get_str_256(clientKey.size, buffer, x);
}
delete valid;
#else
- throw Exception("No password validator configured");
+ throw std::logic_error("No password validator configured");
#endif
}
pg->getVncAuthPasswd(&passwd, &passwdReadOnly);
if (passwd.empty())
- throw Exception("No password configured");
+ throw std::runtime_error("No password configured");
if (password == passwd) {
accessRights = AccessDefault;
if (!sentChallenge) {
rdr::RandomStream rs;
if (!rs.hasData(vncAuthChallengeSize))
- throw Exception("Could not generate random data for VNC auth challenge");
+ throw std::runtime_error("Could not generate random data for VNC auth challenge");
rs.readBytes(challenge, vncAuthChallengeSize);
os->writeBytes(challenge, vncAuthChallengeSize);
os->flush();
pg->getVncAuthPasswd(&passwd, &passwdReadOnly);
if (passwd.empty())
- throw Exception("No password configured");
+ throw std::runtime_error("No password configured");
if (verifyResponse(passwd.c_str())) {
accessRights = AccessDefault;
#include <rfb/CSecurityVeNCrypt.h>
#include <rfb/CSecurityVncAuth.h>
#include <rfb/CSecurityPlain.h>
-#include <rfb/Exception.h>
#include <rfb/Security.h>
#ifdef HAVE_GNUTLS
#include <rfb/CSecurityTLS.h>
}
bail:
- throw Exception("Security type not supported");
+ throw std::invalid_argument("Security type not supported");
}
#include <config.h>
#endif
-#include <rfb/Exception.h>
#include <rfb/Security.h>
#include <rfb/SSecurityNone.h>
#include <rfb/SSecurityStack.h>
}
bail:
- throw Exception("Security type not supported");
+ throw std::invalid_argument("Security type not supported");
}
#include <config.h>
#endif
-#include <rfb/Exception.h>
+#include <stdexcept>
+
#include <rfb/ledStates.h>
#include <rfb/ServerParams.h>
#include <rfb/util.h>
void ServerParams::setDimensions(int width, int height, const ScreenSet& layout)
{
if (!layout.validate(width, height))
- throw Exception("Attempted to configure an invalid screen layout");
+ throw std::invalid_argument("Attempted to configure an invalid screen layout");
width_ = width;
height_ = height;
pf_ = pf;
if (pf.bpp != 8 && pf.bpp != 16 && pf.bpp != 32)
- throw Exception("setPF: not 8, 16 or 32 bpp?");
+ throw std::invalid_argument("setPF: not 8, 16 or 32 bpp?");
}
void ServerParams::setName(const char* name)
return clipSizes[i];
}
- throw Exception(rfb::format("Invalid clipboard format 0x%x", format));
+ throw std::invalid_argument(rfb::format("Invalid clipboard format 0x%x", format));
}
void ServerParams::setClipboardCaps(uint32_t flags, const uint32_t* lengths)
#include <network/Socket.h>
#include <rfb/ComparingUpdateTracker.h>
-#include <rfb/Exception.h>
#include <rfb/KeyRemapper.h>
#include <rfb/KeysymStr.h>
#include <rfb/LogWriter.h>
return;
}
}
- throw rdr::Exception("invalid Socket in VNCServerST");
+ throw std::invalid_argument("invalid Socket in VNCServerST");
}
void VNCServerST::processSocketWriteEvent(network::Socket* sock)
return;
}
}
- throw rdr::Exception("invalid Socket in VNCServerST");
+ throw std::invalid_argument("invalid Socket in VNCServerST");
}
void VNCServerST::blockUpdates()
screenLayout = ScreenSet();
if (desktopStarted)
- throw Exception("setPixelBuffer: null PixelBuffer when desktopStarted?");
+ throw std::logic_error("setPixelBuffer: null PixelBuffer when desktopStarted?");
return;
}
if (!layout.validate(pb->width(), pb->height()))
- throw Exception("setPixelBuffer: invalid screen layout");
+ throw std::invalid_argument("setPixelBuffer: invalid screen layout");
screenLayout = layout;
void VNCServerST::setScreenLayout(const ScreenSet& layout)
{
if (!pb)
- throw Exception("setScreenLayout: new screen layout without a PixelBuffer");
+ throw std::logic_error("setScreenLayout: new screen layout without a PixelBuffer");
if (!layout.validate(pb->width(), pb->height()))
- throw Exception("setScreenLayout: invalid screen layout");
+ throw std::invalid_argument("setScreenLayout: invalid screen layout");
screenLayout = layout;
std::list<VNCSConnectionST*>::iterator ci;
if (strchr(data, '\r') != nullptr)
- throw Exception("Invalid carriage return in clipboard data");
+ throw std::invalid_argument("Invalid carriage return in clipboard data");
for (ci = clipboardRequestors.begin();
ci != clipboardRequestors.end(); ++ci)
// Sanity check
if (screenLayout != layout)
- throw Exception("Desktop configured a different screen layout than requested");
+ throw std::runtime_error("Desktop configured a different screen layout than requested");
// Notify other clients
for (ci = clients.begin(); ci != clients.end(); ++ci) {
slog.debug("starting desktop");
desktop->start();
if (!pb)
- throw Exception("SDesktop::start() did not set a valid PixelBuffer");
+ throw std::logic_error("SDesktop::start() did not set a valid PixelBuffer");
desktopStarted = true;
// The tracker might have accumulated changes whilst we were
// stopped, so flush those out
#include <assert.h>
#include <string.h>
+#include <stdexcept>
+
extern "C" {
#include <rfb/d3des.h>
}
-#include <rdr/Exception.h>
#include <rfb/obfuscate.h>
static unsigned char d3desObfuscationKey[] = {23,82,107,6,35,78,88,7};
char buf[9];
if (len != 8)
- throw rdr::Exception("bad obfuscated password length");
+ throw std::invalid_argument("bad obfuscated password length");
assert(data != nullptr);
{
flush();
if (avail() < needed)
- throw rdr::Exception("Insufficient dummy output buffer");
+ throw std::out_of_range("Insufficient dummy output buffer");
}
CConn::CConn(const char *filename)
try {
cc = new CConn(fn);
- } catch (rdr::Exception& e) {
+ } catch (std::exception& e) {
fprintf(stderr, "Failed to open rfb file: %s\n", e.what());
exit(1);
}
while (true)
cc->processMsg();
} catch (rdr::EndOfStream& e) {
- } catch (rdr::Exception& e) {
+ } catch (std::exception& e) {
fprintf(stderr, "Failed to run rfb file: %s\n", e.what());
exit(1);
}
{
flush();
if (avail() < needed)
- throw rdr::Exception("Insufficient dummy output buffer");
+ throw std::out_of_range("Insufficient dummy output buffer");
}
CConn::CConn(const char *filename)
#include <stdio.h>
+#include <stdexcept>
+
#include <rfb/PixelFormat.h>
-#include <rfb/Exception.h>
static void doTest(bool should_fail, int b, int d, bool e, bool t,
int rm, int gm, int bm, int rs, int gs, int bs)
#ifndef __TXDIALOG_H__
#define __TXDIALOG_H__
+#include <rdr/Exception.h>
+
#include "TXWindow.h"
#include <errno.h>
#include <network/Socket.h>
#include <rfb/LogWriter.h>
-#include <rfb/Exception.h>
#include <x0vncserver/XDesktop.h>
if (!XkbQueryExtension(dpy, &xkbOpcode, &xkbEventBase,
&xkbErrorBase, &major, &minor)) {
vlog.error("XKEYBOARD extension not present");
- throw Exception("XKEYBOARD extension not present");
+ throw std::runtime_error("XKEYBOARD extension not present");
}
XkbSelectEvents(dpy, XkbUseCoreKbd, XkbIndicatorStateNotifyMask,
}
if (!inetd && listeners.empty())
- throw rdr::Exception("No path or port configured for incoming connections");
+ throw std::runtime_error("No path or port configured for incoming connections");
PixelFormat pf = vncGetPixelFormat(scr);
#include <assert.h>
-#include <rfb/Exception.h>
+#include <stdexcept>
#include "parameters.h"
#include "i18n.h"
btstate |= 0x2;
if ((state > 10) || (state < 0))
- throw rfb::Exception(_("Invalid state for 3 button emulation"));
+ throw std::runtime_error(_("Invalid state for 3 button emulation"));
action1 = stateTab[state][btstate][0];
return;
if ((state > 10) || (state < 0))
- throw rfb::Exception(_("Invalid state for 3 button emulation"));
+ throw std::runtime_error(_("Invalid state for 3 button emulation"));
// Timeout shouldn't trigger when there's no timeout action
assert(stateTab[state][4][2] >= 0);
#include <sys/shm.h>
#endif
+#include <stdexcept>
+
#include <FL/Fl.H>
#include <FL/x.H>
#include <rfb/LogWriter.h>
-#include <rdr/Exception.h>
#include "PlatformPixelBuffer.h"
xim = XCreateImage(fl_display, (Visual*)CopyFromParent, 32,
ZPixmap, 0, nullptr, width, height, 32, 0);
if (!xim)
- throw rdr::Exception("XCreateImage");
+ throw std::runtime_error("XCreateImage");
xim->data = (char*)malloc(xim->bytes_per_line * xim->height);
if (!xim->data)
- throw rdr::Exception("malloc");
+ throw std::bad_alloc();
vlog.debug("Using standard XImage");
}
const char* stateDir = os::getvncstatedir();
if (stateDir == nullptr)
- throw Exception(_("Could not determine VNC state directory path"));
+ throw std::runtime_error(_("Could not determine VNC state directory path"));
char filepath[PATH_MAX];
snprintf(filepath, sizeof(filepath), "%s/%s", stateDir, SERVER_HISTORY);
if (len == (sizeof(line) - 1)) {
fclose(f);
- throw Exception(format(_("Failed to read line %d in file %s: %s"),
- lineNr, filepath, _("Line too long")));
+ throw std::runtime_error(format("%s: %s",
+ format(_("Failed to read line %d "
+ "in file %s"),
+ lineNr, filepath).c_str(),
+ _("Line too long")));
}
if ((len > 0) && (line[len-1] == '\n')) {
const char* stateDir = os::getvncstatedir();
if (stateDir == nullptr)
- throw Exception(_("Could not determine VNC state directory path"));
+ throw std::runtime_error(_("Could not determine VNC state directory path"));
char filepath[PATH_MAX];
snprintf(filepath, sizeof(filepath), "%s/%s", stateDir, SERVER_HISTORY);
#include <assert.h>
+#include <stdexcept>
+
#include <ApplicationServices/ApplicationServices.h>
#include <FL/Fl_RGB_Image.H>
#include <FL/Fl_Window.H>
#include <FL/x.H>
-#include <rdr/Exception.h>
-
#include "cocoa.h"
#include "Surface.h"
provider = CGDataProviderCreateWithData(nullptr, data,
w * h * 4, nullptr);
if (!provider)
- throw rdr::Exception("CGDataProviderCreateWithData");
+ throw std::runtime_error("CGDataProviderCreateWithData");
// FIXME: This causes a performance hit, but is necessary to avoid
// artifacts in the edges of the window
kCGRenderingIntentDefault);
CGDataProviderRelease(provider);
if (!image)
- throw rdr::Exception("CGImageCreate");
+ throw std::runtime_error("CGImageCreate");
return image;
}
subimage = CGImageCreateWithImageInRect(image, rect);
if (!subimage)
- throw rdr::Exception("CGImageCreateImageWithImageInRect");
+ throw std::runtime_error("CGImageCreateImageWithImageInRect");
CGContextSaveGState(gc);
bitmap = CGBitmapContextCreate(data, width, height, 8, width*4, srgb,
kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Little);
if (!bitmap)
- throw rdr::Exception("CGBitmapContextCreate");
+ throw std::runtime_error("CGBitmapContextCreate");
return bitmap;
}
#include <assert.h>
#include <stdlib.h>
+#include <stdexcept>
+
#include <FL/Fl_RGB_Image.H>
#include <FL/x.H>
-#include <rdr/Exception.h>
-
#include "Surface.h"
void Surface::clear(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
&templ, 0);
if (!format)
- throw rdr::Exception("XRenderFindFormat");
+ throw std::runtime_error("XRenderFindFormat");
picture = XRenderCreatePicture(fl_display, pixmap, format, 0, nullptr);
ZPixmap, 0, nullptr, width(), height(),
32, 0);
if (!img)
- throw rdr::Exception("XCreateImage");
+ throw std::runtime_error("XCreateImage");
img->data = (char*)malloc(img->bytes_per_line * img->height);
if (!img->data)
- throw rdr::Exception("malloc");
+ throw std::bad_alloc();
// Convert data and pre-multiply alpha
in = (const unsigned char*)image->data()[0];
#include <rfb/CMsgWriter.h>
#include <rfb/LogWriter.h>
-#include <rfb/Exception.h>
#include <rfb/KeysymStr.h>
#include <rfb/ledStates.h>
#include <rfb/util.h>
xkb = XkbGetMap(fl_display, 0, XkbUseCoreKbd);
if (!xkb)
- throw rfb::Exception("XkbGetMap");
+ throw std::runtime_error("XkbGetMap");
status = XkbGetNames(fl_display, XkbKeyNamesMask, xkb);
if (status != Success)
- throw rfb::Exception("XkbGetNames");
+ throw std::runtime_error("XkbGetNames");
memset(code_map_keycode_to_qnum, 0, sizeof(code_map_keycode_to_qnum));
for (KeyCode keycode = xkb->min_key_code;
#include <math.h>
+#include <stdexcept>
+
#define XK_MISCELLANY
#include <rfb/keysymdef.h>
-#include <rfb/Exception.h>
#include <rfb/LogWriter.h>
#include "i18n.h"
// If window is registered as touch we can not receive gestures,
// this should not happen
if (IsTouchWindow(hWnd, nullptr))
- throw rfb::Exception(_("Window is registered for touch instead of gestures"));
+ throw std::runtime_error(_("Window is registered for touch instead of gestures"));
// We will not receive any touch/gesture events if this service
// isn't running - Logging is enough
wchar_t name[buffersize];
unsigned size = fl_utf8towc(_name, strlen(_name)+1, name, buffersize);
if (size >= buffersize)
- throw Exception(_("The name of the parameter is too large"));
+ throw std::invalid_argument(_("The name of the parameter is too large"));
char encodingBuffer[buffersize];
if (!encodeValue(_value, encodingBuffer, buffersize))
- throw Exception(_("The parameter is too large"));
+ throw std::invalid_argument(_("The parameter is too large"));
wchar_t value[buffersize];
size = fl_utf8towc(encodingBuffer, strlen(encodingBuffer)+1, value, buffersize);
if (size >= buffersize)
- throw Exception(_("The parameter is too large"));
+ throw std::invalid_argument(_("The parameter is too large"));
LONG res = RegSetValueExW(*hKey, name, 0, REG_SZ, (BYTE*)&value, (wcslen(value)+1)*2);
if (res != ERROR_SUCCESS)
unsigned size = fl_utf8towc(_name, strlen(_name)+1, name, buffersize);
if (size >= buffersize)
- throw Exception(_("The name of the parameter is too large"));
+ throw std::out_of_range(_("The name of the parameter is too large"));
LONG res = RegSetValueExW(*hKey, name, 0, REG_DWORD, (BYTE*)&value, sizeof(DWORD));
if (res != ERROR_SUCCESS)
unsigned size = fl_utf8towc(_name, strlen(_name)+1, name, buffersize);
if (size >= buffersize)
- throw Exception(_("The name of the parameter is too large"));
+ throw std::out_of_range(_("The name of the parameter is too large"));
value = new WCHAR[destSize];
valuesize = destSize;
delete [] value;
if (size >= destSize) {
delete [] utf8val;
- throw Exception(_("The parameter is too large"));
+ throw std::out_of_range(_("The parameter is too large"));
}
bool ret = decodeValue(utf8val, dest, destSize);
delete [] utf8val;
if (!ret)
- throw Exception(_("Invalid format or too large value"));
+ throw std::invalid_argument(_("Invalid format or too large value"));
return true;
}
unsigned size = fl_utf8towc(_name, strlen(_name)+1, name, buffersize);
if (size >= buffersize)
- throw Exception(_("The name of the parameter is too large"));
+ throw std::out_of_range(_("The name of the parameter is too large"));
LONG res = RegQueryValueExW(*hKey, name, nullptr, nullptr, (LPBYTE)&value, &dwordsize);
if (res != ERROR_SUCCESS){
unsigned size = fl_utf8towc(_name, strlen(_name)+1, name, buffersize);
if (size >= buffersize)
- throw Exception(_("The name of the parameter is too large"));
+ throw std::out_of_range(_("The name of the parameter is too large"));
LONG res = RegDeleteValueW(*hKey, name);
if (res != ERROR_SUCCESS) {
setKeyString("ServerName", servername, &hKey);
} catch (std::exception& e) {
RegCloseKey(hKey);
- throw Exception(format(_("Failed to save \"%s\": %s"),
- "ServerName", e.what()));
+ throw std::runtime_error(format(_("Failed to save \"%s\": %s"),
+ "ServerName", e.what()));
}
for (size_t i = 0; i < sizeof(parameterArray)/sizeof(VoidParameter*); i++) {
} else if (dynamic_cast<BoolParameter*>(parameterArray[i]) != nullptr) {
setKeyInt(parameterArray[i]->getName(), (int)*(BoolParameter*)parameterArray[i], &hKey);
} else {
- throw Exception(_("Unknown parameter type"));
+ throw std::logic_error(_("Unknown parameter type"));
}
} catch (std::exception& e) {
RegCloseKey(hKey);
- throw Exception(format(_("Failed to save \"%s\": %s"),
- parameterArray[i]->getName(), e.what()));
+ throw std::runtime_error(format(_("Failed to save \"%s\": %s"),
+ parameterArray[i]->getName(),
+ e.what()));
}
}
removeValue(readOnlyParameterArray[i]->getName(), &hKey);
} catch (std::exception& e) {
RegCloseKey(hKey);
- throw Exception(format(_("Failed to remove \"%s\": %s"),
- readOnlyParameterArray[i]->getName(),
- e.what()));
+ throw std::runtime_error(format(_("Failed to remove \"%s\": %s"),
+ readOnlyParameterArray[i]->getName(),
+ e.what()));
}
}
if (getKeyInt(parameters[i]->getName(), &intValue, hKey))
((BoolParameter*)parameters[i])->setParam(intValue);
} else {
- throw Exception(_("Unknown parameter type"));
+ throw std::logic_error(_("Unknown parameter type"));
}
} catch(std::exception& e) {
// Just ignore this entry and continue with the rest
const char* configDir = os::getvncconfigdir();
if (configDir == nullptr)
- throw Exception(_("Could not determine VNC config directory path"));
+ throw std::runtime_error(_("Could not determine VNC config directory path"));
snprintf(filepath, sizeof(filepath), "%s/default.tigervnc", configDir);
} else {
if (!encodeValue(servername, encodingBuffer, buffersize)) {
fclose(f);
- throw Exception(format(_("Failed to save \"%s\": %s"),
- "ServerName",
- _("Could not encode parameter")));
+ throw std::runtime_error(format(_("Failed to save \"%s\": %s"),
+ "ServerName",
+ _("Could not encode parameter")));
}
fprintf(f, "ServerName=%s\n", encodingBuffer);
if (!encodeValue(*(StringParameter*)param,
encodingBuffer, buffersize)) {
fclose(f);
- throw Exception(format(_("Failed to save \"%s\": %s"),
- param->getName(),
- _("Could not encode parameter")));
+ throw std::runtime_error(format(_("Failed to save \"%s\": %s"),
+ param->getName(),
+ _("Could not encode parameter")));
}
fprintf(f, "%s=%s\n", ((StringParameter*)param)->getName(), encodingBuffer);
} else if (dynamic_cast<IntParameter*>(param) != nullptr) {
fprintf(f, "%s=%d\n", ((BoolParameter*)param)->getName(), (int)*(BoolParameter*)param);
} else {
fclose(f);
- throw Exception(format(_("Failed to save \"%s\": %s"),
- param->getName(),
- _("Unknown parameter type")));
+ throw std::logic_error(format(_("Failed to save \"%s\": %s"),
+ param->getName(),
+ _("Unknown parameter type")));
}
}
fclose(f);
if (dynamic_cast<StringParameter*>(parameters[i]) != nullptr) {
if (strcasecmp(line, ((StringParameter*)parameters[i])->getName()) == 0) {
if(!decodeValue(value, decodingBuffer, sizeof(decodingBuffer)))
- throw Exception(_("Invalid format or too large value"));
+ throw std::runtime_error(_("Invalid format or too large value"));
((StringParameter*)parameters[i])->setParam(decodingBuffer);
return false;
}
}
} else {
- throw Exception(_("Unknown parameter type"));
+ throw std::logic_error(_("Unknown parameter type"));
}
}
const char* configDir = os::getvncconfigdir();
if (configDir == nullptr)
- throw Exception(_("Could not determine VNC config directory path"));
+ throw std::runtime_error(_("Could not determine VNC config directory path"));
snprintf(filepath, sizeof(filepath), "%s/default.tigervnc", configDir);
} else {
if (strlen(line) == (sizeof(line) - 1)) {
fclose(f);
- throw Exception(format(_("Failed to read line %d in file %s: %s"),
- lineNr, filepath, _("Line too long")));
+ throw std::runtime_error(format("%s: %s",
+ format(_("Failed to read line %d "
+ "in file \"%s\""),
+ lineNr, filepath).c_str(),
+ _("Line too long")));
}
// Make sure that the first line of the file has the file identifier string
continue;
fclose(f);
- throw Exception(format(_("Configuration file %s is in an invalid "
- "format"), filepath));
+ throw std::runtime_error(format(_("Configuration file %s is in "
+ "an invalid format"),
+ filepath));
}
// Skip empty lines and comments
if (strcasecmp(line, "ServerName") == 0) {
if(!decodeValue(value, decodingBuffer, sizeof(decodingBuffer)))
- throw Exception(_("Invalid format or too large value"));
+ throw std::runtime_error(_("Invalid format or too large value"));
snprintf(servername, sizeof(decodingBuffer), "%s", decodingBuffer);
invalidParameterName = false;
#include <rfb/Hostname.h>
#include <rfb/LogWriter.h>
#include <rfb/Timer.h>
-#include <rfb/Exception.h>
#include <rdr/Exception.h>
#include <network/TcpSocket.h>
#include <os/os.h>
createTcpListeners(&listeners, nullptr, port);
if (listeners.empty())
- throw Exception(_("Unable to listen for incoming connections"));
+ throw std::runtime_error(_("Unable to listen for incoming connections"));
vlog.info(_("Listening on port %d"), port);
if (!isServiceProcess())
return;
if (!token.canImpersonate())
- throw rdr::Exception("Cannot impersonate unsafe or null token");
+ throw std::runtime_error("Cannot impersonate unsafe or null token");
if (!ImpersonateLoggedOnUser(token)) {
DWORD err = GetLastError();
if (err != ERROR_CALL_NOT_IMPLEMENTED)
uint8_t* new_data = nullptr;
if (!pf.trueColour)
- throw rfb::Exception("palette format not supported");
+ throw std::invalid_argument("palette format not supported");
format = pf;
bits = bits >> 1;
}
if (depth > bpp)
- throw Exception("Bad DIBSection format (depth exceeds bpp)");
+ throw std::runtime_error("Bad DIBSection format (depth exceeds bpp)");
format = PixelFormat(bpp, depth, false, true,
redMax, greenMax, blueMax,
break;
default:
vlog.error("bits per pixel %u not supported", bi.bmiHeader.biBitCount);
- throw rdr::Exception("unknown bits per pixel specified");
+ throw std::invalid_argument("unknown bits per pixel specified");
};
break;
case BI_BITFIELDS:
int capabilities = GetDeviceCaps(device, RASTERCAPS);
if (!(capabilities & RC_BITBLT)) {
- throw Exception("device does not support BitBlt");
+ throw std::invalid_argument("device does not support BitBlt");
}
if (!(capabilities & RC_DI_BITMAP)) {
- throw Exception("device does not support GetDIBits");
+ throw std::invalid_argument("device does not support GetDIBits");
}
/*
if (GetDeviceCaps(device, PLANES) != 1) {
- throw Exception("device does not support planar displays");
+ throw std::invalid_argument("device does not support planar displays");
}
*/
if (!GetObject(iconInfo.hbmMask, sizeof(BITMAP), &maskInfo))
throw rdr::Win32Exception("GetObject() failed", GetLastError());
if (maskInfo.bmPlanes != 1)
- throw rdr::Exception("unsupported multi-plane cursor");
+ throw std::invalid_argument("unsupported multi-plane cursor");
if (maskInfo.bmBitsPixel != 1)
- throw rdr::Exception("unsupported cursor mask format");
+ throw std::invalid_argument("unsupported cursor mask format");
width = maskInfo.bmWidth;
height = maskInfo.bmHeight;
if ((bi.bV5RedMask != ((unsigned)0xff << ridx*8)) ||
(bi.bV5GreenMask != ((unsigned)0xff << gidx*8)) ||
(bi.bV5BlueMask != ((unsigned)0xff << bidx*8)))
- throw rdr::Exception("unsupported cursor colour format");
+ throw std::invalid_argument("unsupported cursor colour format");
uint8_t* rwbuffer = buffer.data();
for (int y = 0; y < height; y++) {
BOOL trans;
int result = GetDlgItemInt(handle, id, &trans, TRUE);
if (!trans)
- throw rdr::Exception("unable to read dialog Int");
+ throw std::runtime_error("unable to read dialog Int");
return result;
}
const char* Dialog::getItemString(int id) {
#include <windows.h>
+#include <stdexcept>
+
#include <rfb_win32/EventManager.h>
-#include <rdr/Exception.h>
#include <rfb/LogWriter.h>
using namespace rfb;
return;
}
}
- throw rdr::Exception("Event not registered");
+ throw std::runtime_error("Event not registered");
}
std::vector<char> expanded(required);
length = ExpandEnvironmentStrings(str.c_str(), expanded.data(), required);
if (required<length)
- throw rdr::Exception("unable to expand environment strings");
+ throw std::runtime_error("unable to expand environment strings");
return expanded.data();
} else {
return "";
}
}
default:
- throw rdr::Exception("unsupported registry type");
+ throw std::logic_error("unsupported registry type");
}
}
#include <rfb_win32/MonitorInfo.h>
#include <rfb_win32/SDisplayCorePolling.h>
#include <rfb_win32/SDisplayCoreWMHooks.h>
-#include <rfb/Exception.h>
#include <rfb/LogWriter.h>
#include <rfb/ledStates.h>
// Currently, we just check whether we're in the console session, and
// fail if not
if (!inConsoleSession())
- throw rdr::Exception("Console is not session zero - oreconnect to restore Console sessin");
+ throw std::runtime_error("Console is not session zero - oreconnect to restore Console sessin");
// Switch to the current input desktop
if (rfb::win32::desktopChangeRequired()) {
if (!rfb::win32::changeDesktop())
- throw rdr::Exception("unable to switch into input desktop");
+ throw std::runtime_error("unable to switch into input desktop");
}
// Initialise the change tracker and clipper
} catch (std::exception& e) {
delete core; core = nullptr;
if (tryMethod == 0)
- throw rdr::Exception("unable to access desktop");
+ throw std::runtime_error("unable to access desktop");
tryMethod--;
vlog.error("%s", e.what());
}
}
return;
}
- throw rdr::Exception("No such event");
+ throw std::runtime_error("No such event");
}
consolePollTimer(getHandle(), consolePollTimerId),
pollConsoles(false) {
if (!hooks.setEvent(display->getUpdateEvent()))
- throw rdr::Exception("hook subsystem failed to initialise");
+ throw std::runtime_error("hook subsystem failed to initialise");
poller.setUpdateTracker(updateTracker);
cursorTimer.start(20);
consolePollTimer.start(200);
PSID Sid::copySID(const PSID sid) {
if (!IsValidSid(sid))
- throw rdr::Exception("invalid SID in copyPSID");
+ throw std::invalid_argument("invalid SID in copyPSID");
PSID buf = (PSID)new uint8_t[GetLengthSid(sid)];
if (!CopySid(GetLengthSid(sid), buf, sid))
throw rdr::Win32Exception("CopySid failed", GetLastError());
void Sid::setSID(const PSID sid) {
if (!IsValidSid(sid))
- throw rdr::Exception("invalid SID in copyPSID");
+ throw std::invalid_argument("invalid SID in copyPSID");
resize(GetLengthSid(sid));
if (!CopySid(GetLengthSid(sid), data(), sid))
throw rdr::Win32Exception("CopySid failed", GetLastError());
#include <winsock2.h>
#include <list>
+#include <rdr/Exception.h>
+
#include <network/Socket.h>
#include <rfb/LogWriter.h>
// addEvent is the last thing we do, so that the event is NOT registered if previous steps fail
if (!event || !addEvent(event, this))
- throw rdr::Exception("Unable to add listener");
+ throw std::runtime_error("Unable to add listener");
} catch (std::exception& e) {
if (event)
WSACloseEvent(event);
return;
}
}
- throw rdr::Exception("Listener not registered");
+ throw std::runtime_error("Listener not registered");
}
return;
}
}
- throw rdr::Exception("Socket not registered");
+ throw std::runtime_error("Socket not registered");
}
bool SocketManager::getDisable(VNCServer* srvr)
return i->second.disable;
}
}
- throw rdr::Exception("Listener not registered");
+ throw std::runtime_error("Listener not registered");
}
void SocketManager::setDisable(VNCServer* srvr, bool disable)
}
}
if (!found)
- throw rdr::Exception("Listener not registered");
+ throw std::runtime_error("Listener not registered");
}
int SocketManager::checkTimeouts() {
UINT length = 0;
if (!VerQueryValue(buf, infoName.c_str(), (void**)&buffer, &length)) {
printf("unable to find %s version string", infoName.c_str());
- throw rdr::Exception("VerQueryValue failed");
+ throw std::runtime_error("VerQueryValue failed");
}
return buffer;
}
if (bits)
strcat(pattern, ".");
if (parts[j].size() > 3)
- throw rdr::Exception("Invalid IP address part");
+ throw std::invalid_argument("Invalid IP address part");
if (!parts[j].empty()) {
strcat(pattern, parts[j].c_str());
bits += 8;
countdown = timeout;
try {
if (desktopChangeRequired() && !changeDesktop())
- throw rdr::Exception("changeDesktop failed");
+ throw std::runtime_error("changeDesktop failed");
approve = Dialog::showDialog(MAKEINTRESOURCE(IDD_QUERY_CONNECT));
server->queryConnectionComplete();
} catch (...) {
if (host != nullptr) {
HWND hwnd = FindWindow(nullptr, "winvnc::IPC_Interface");
if (!hwnd)
- throw rdr::Exception("Unable to locate existing VNC Server.");
+ throw std::runtime_error("Unable to locate existing VNC Server.");
COPYDATASTRUCT copyData;
copyData.dwData = 1; // *** AddNewClient
copyData.cbData = strlen(host);
runServer = false;
HWND hwnd = FindWindow(nullptr, "winvnc::IPC_Interface");
if (!hwnd)
- throw rdr::Exception("Unable to locate existing VNC Server.");
+ throw std::runtime_error("Unable to locate existing VNC Server.");
COPYDATASTRUCT copyData;
copyData.dwData = 2; // *** DisconnectClients
copyData.lpData = nullptr;