Split out ServerParams from ConnParams
We need to track different things in the server and client, so
separate things to two independent structures to keep things more
clear.
diff --git a/common/rfb/CConnection.cxx b/common/rfb/CConnection.cxx
index 7146abc..a503a2c 100644
--- a/common/rfb/CConnection.cxx
+++ b/common/rfb/CConnection.cxx
@@ -146,32 +146,33 @@
throw Exception("reading version failed: not an RFB server?");
}
- cp.setVersion(majorVersion, minorVersion);
+ server.setVersion(majorVersion, minorVersion);
vlog.info("Server supports RFB protocol version %d.%d",
- cp.majorVersion, cp.minorVersion);
+ server.majorVersion, server.minorVersion);
// The only official RFB protocol versions are currently 3.3, 3.7 and 3.8
- if (cp.beforeVersion(3,3)) {
+ if (server.beforeVersion(3,3)) {
vlog.error("Server gave unsupported RFB protocol version %d.%d",
- cp.majorVersion, cp.minorVersion);
+ server.majorVersion, server.minorVersion);
state_ = RFBSTATE_INVALID;
throw Exception("Server gave unsupported RFB protocol version %d.%d",
- cp.majorVersion, cp.minorVersion);
- } else if (useProtocol3_3 || cp.beforeVersion(3,7)) {
- cp.setVersion(3,3);
- } else if (cp.afterVersion(3,8)) {
- cp.setVersion(3,8);
+ server.majorVersion, server.minorVersion);
+ } else if (useProtocol3_3 || server.beforeVersion(3,7)) {
+ server.setVersion(3,3);
+ } else if (server.afterVersion(3,8)) {
+ server.setVersion(3,8);
}
- sprintf(verStr, "RFB %03d.%03d\n", cp.majorVersion, cp.minorVersion);
+ sprintf(verStr, "RFB %03d.%03d\n",
+ server.majorVersion, server.minorVersion);
os->writeBytes(verStr, 12);
os->flush();
state_ = RFBSTATE_SECURITY_TYPES;
vlog.info("Using RFB protocol version %d.%d",
- cp.majorVersion, cp.minorVersion);
+ server.majorVersion, server.minorVersion);
}
@@ -184,7 +185,7 @@
std::list<rdr::U8> secTypes;
secTypes = security.GetEnabledSecTypes();
- if (cp.isVersion(3,3)) {
+ if (server.isVersion(3,3)) {
// legacy 3.3 server may only offer "vnc authentication" or "none"
@@ -267,7 +268,7 @@
{
vlog.debug("processing security result message");
int result;
- if (cp.beforeVersion(3,8) && csecurity->getType() == secTypeNone) {
+ if (server.beforeVersion(3,8) && csecurity->getType() == secTypeNone) {
result = secResultOK;
} else {
if (!is->checkNoWait(1)) return;
@@ -287,7 +288,7 @@
throw Exception("Unknown security result from server");
}
state_ = RFBSTATE_INVALID;
- if (cp.beforeVersion(3,8))
+ if (server.beforeVersion(3,8))
throw AuthFailureException();
CharArray reason(is->readString());
throw AuthFailureException(reason.buf);
@@ -311,7 +312,7 @@
{
state_ = RFBSTATE_INITIALISATION;
reader_ = new CMsgReader(this, is);
- writer_ = new CMsgWriter(&cp, os);
+ writer_ = new CMsgWriter(&server, os);
vlog.debug("Authentication success!");
authSuccess();
writer_->writeClientInit(shared);
diff --git a/common/rfb/CMakeLists.txt b/common/rfb/CMakeLists.txt
index b8d0813..6b8be3b 100644
--- a/common/rfb/CMakeLists.txt
+++ b/common/rfb/CMakeLists.txt
@@ -43,6 +43,7 @@
SMsgReader.cxx
SMsgWriter.cxx
ServerCore.cxx
+ ServerParams.cxx
Security.cxx
SecurityServer.cxx
SecurityClient.cxx
diff --git a/common/rfb/CMsgHandler.cxx b/common/rfb/CMsgHandler.cxx
index 03e66e8..4289cbf 100644
--- a/common/rfb/CMsgHandler.cxx
+++ b/common/rfb/CMsgHandler.cxx
@@ -34,44 +34,44 @@
void CMsgHandler::setDesktopSize(int width, int height)
{
- cp.setDimensions(width, height);
+ server.setDimensions(width, height);
}
void CMsgHandler::setExtendedDesktopSize(unsigned reason, unsigned result,
int width, int height,
const ScreenSet& layout)
{
- cp.supportsSetDesktopSize = true;
+ server.supportsSetDesktopSize = true;
if ((reason == reasonClient) && (result != resultSuccess))
return;
- cp.setDimensions(width, height, layout);
+ server.setDimensions(width, height, layout);
}
void CMsgHandler::setPixelFormat(const PixelFormat& pf)
{
- cp.setPF(pf);
+ server.setPF(pf);
}
void CMsgHandler::setName(const char* name)
{
- cp.setName(name);
+ server.setName(name);
}
void CMsgHandler::fence(rdr::U32 flags, unsigned len, const char data[])
{
- cp.supportsFence = true;
+ server.supportsFence = true;
}
void CMsgHandler::endOfContinuousUpdates()
{
- cp.supportsContinuousUpdates = true;
+ server.supportsContinuousUpdates = true;
}
void CMsgHandler::supportsQEMUKeyEvent()
{
- cp.supportsQEMUKeyEvent = true;
+ server.supportsQEMUKeyEvent = true;
}
void CMsgHandler::framebufferUpdateStart()
@@ -84,5 +84,5 @@
void CMsgHandler::setLEDState(unsigned int state)
{
- cp.setLEDState(state);
+ server.setLEDState(state);
}
diff --git a/common/rfb/CMsgHandler.h b/common/rfb/CMsgHandler.h
index 903ee15..55241da 100644
--- a/common/rfb/CMsgHandler.h
+++ b/common/rfb/CMsgHandler.h
@@ -26,7 +26,7 @@
#include <rdr/types.h>
#include <rfb/Pixel.h>
-#include <rfb/ConnParams.h>
+#include <rfb/ServerParams.h>
#include <rfb/Rect.h>
#include <rfb/ScreenSet.h>
@@ -43,7 +43,7 @@
// derived class should override these methods as desired. Note that for
// the setDesktopSize(), setExtendedDesktopSize(), setPixelFormat() and
// setName() methods, a derived class should call on to CMsgHandler's
- // methods to set the members of cp appropriately.
+ // methods to set the members of "server" appropriately.
virtual void setDesktopSize(int w, int h);
virtual void setExtendedDesktopSize(unsigned reason, unsigned result,
@@ -72,7 +72,7 @@
virtual void setLEDState(unsigned int state);
- ConnParams cp;
+ ServerParams server;
};
}
#endif
diff --git a/common/rfb/CMsgReader.cxx b/common/rfb/CMsgReader.cxx
index 7502df6..3ce7473 100644
--- a/common/rfb/CMsgReader.cxx
+++ b/common/rfb/CMsgReader.cxx
@@ -192,10 +192,11 @@
void CMsgReader::readRect(const Rect& r, int encoding)
{
- if ((r.br.x > handler->cp.width()) || (r.br.y > handler->cp.height())) {
+ if ((r.br.x > handler->server.width()) ||
+ (r.br.y > handler->server.height())) {
fprintf(stderr, "Rect too big: %dx%d at %d,%d exceeds %dx%d\n",
r.width(), r.height(), r.tl.x, r.tl.y,
- handler->cp.width(), handler->cp.height());
+ handler->server.width(), handler->server.height());
throw Exception("Rect too big");
}
@@ -269,7 +270,7 @@
if (width > maxCursorSize || height > maxCursorSize)
throw Exception("Too big cursor");
- int data_len = width * height * (handler->cp.pf().bpp/8);
+ int data_len = width * height * (handler->server.pf().bpp/8);
int mask_len = ((width+7)/8) * height;
rdr::U8Array data(data_len);
rdr::U8Array mask(mask_len);
@@ -290,14 +291,14 @@
int byte = y * maskBytesPerRow + x / 8;
int bit = 7 - x % 8;
- handler->cp.pf().rgbFromBuffer(out, in, 1);
+ handler->server.pf().rgbFromBuffer(out, in, 1);
if (mask.buf[byte] & (1 << bit))
out[3] = 255;
else
out[3] = 0;
- in += handler->cp.pf().bpp/8;
+ in += handler->server.pf().bpp/8;
out += 4;
}
}
@@ -321,10 +322,10 @@
encoding = is->readS32();
- origPF = handler->cp.pf();
- handler->cp.setPF(rgbaPF);
+ origPF = handler->server.pf();
+ handler->server.setPF(rgbaPF);
handler->readAndDecodeRect(pb.getRect(), encoding, &pb);
- handler->cp.setPF(origPF);
+ handler->server.setPF(origPF);
// On-wire data has pre-multiplied alpha, but we store it
// non-pre-multiplied
diff --git a/common/rfb/CMsgWriter.cxx b/common/rfb/CMsgWriter.cxx
index 97c3336..5585652 100644
--- a/common/rfb/CMsgWriter.cxx
+++ b/common/rfb/CMsgWriter.cxx
@@ -25,14 +25,14 @@
#include <rfb/Exception.h>
#include <rfb/PixelFormat.h>
#include <rfb/Rect.h>
-#include <rfb/ConnParams.h>
+#include <rfb/ServerParams.h>
#include <rfb/Decoder.h>
#include <rfb/CMsgWriter.h>
using namespace rfb;
-CMsgWriter::CMsgWriter(ConnParams* cp_, rdr::OutStream* os_)
- : cp(cp_), os(os_)
+CMsgWriter::CMsgWriter(ServerParams* server_, rdr::OutStream* os_)
+ : server(server_), os(os_)
{
}
@@ -72,18 +72,18 @@
int nEncodings = 0;
rdr::U32 encodings[encodingMax+3];
- if (cp->supportsLocalCursor) {
+ if (server->supportsLocalCursor) {
encodings[nEncodings++] = pseudoEncodingCursorWithAlpha;
encodings[nEncodings++] = pseudoEncodingCursor;
encodings[nEncodings++] = pseudoEncodingXCursor;
}
- if (cp->supportsDesktopResize)
+ if (server->supportsDesktopResize)
encodings[nEncodings++] = pseudoEncodingDesktopSize;
- if (cp->supportsExtendedDesktopSize)
+ if (server->supportsExtendedDesktopSize)
encodings[nEncodings++] = pseudoEncodingExtendedDesktopSize;
- if (cp->supportsDesktopRename)
+ if (server->supportsDesktopRename)
encodings[nEncodings++] = pseudoEncodingDesktopName;
- if (cp->supportsLEDState)
+ if (server->supportsLEDState)
encodings[nEncodings++] = pseudoEncodingLEDState;
encodings[nEncodings++] = pseudoEncodingLastRect;
@@ -132,10 +132,10 @@
}
}
- if (cp->compressLevel >= 0 && cp->compressLevel <= 9)
- encodings[nEncodings++] = pseudoEncodingCompressLevel0 + cp->compressLevel;
- if (cp->qualityLevel >= 0 && cp->qualityLevel <= 9)
- encodings[nEncodings++] = pseudoEncodingQualityLevel0 + cp->qualityLevel;
+ if (server->compressLevel >= 0 && server->compressLevel <= 9)
+ encodings[nEncodings++] = pseudoEncodingCompressLevel0 + server->compressLevel;
+ if (server->qualityLevel >= 0 && server->qualityLevel <= 9)
+ encodings[nEncodings++] = pseudoEncodingQualityLevel0 + server->qualityLevel;
writeSetEncodings(nEncodings, encodings);
}
@@ -143,7 +143,7 @@
void CMsgWriter::writeSetDesktopSize(int width, int height,
const ScreenSet& layout)
{
- if (!cp->supportsSetDesktopSize)
+ if (!server->supportsSetDesktopSize)
throw Exception("Server does not support SetDesktopSize");
startMsg(msgTypeSetDesktopSize);
@@ -182,7 +182,7 @@
void CMsgWriter::writeEnableContinuousUpdates(bool enable,
int x, int y, int w, int h)
{
- if (!cp->supportsContinuousUpdates)
+ if (!server->supportsContinuousUpdates)
throw Exception("Server does not support continuous updates");
startMsg(msgTypeEnableContinuousUpdates);
@@ -199,7 +199,7 @@
void CMsgWriter::writeFence(rdr::U32 flags, unsigned len, const char data[])
{
- if (!cp->supportsFence)
+ if (!server->supportsFence)
throw Exception("Server does not support fences");
if (len > 64)
throw Exception("Too large fence payload");
@@ -219,7 +219,7 @@
void CMsgWriter::writeKeyEvent(rdr::U32 keysym, rdr::U32 keycode, bool down)
{
- if (!cp->supportsQEMUKeyEvent || !keycode) {
+ if (!server->supportsQEMUKeyEvent || !keycode) {
/* This event isn't meaningful without a valid keysym */
if (!keysym)
return;
@@ -245,8 +245,8 @@
Point p(pos);
if (p.x < 0) p.x = 0;
if (p.y < 0) p.y = 0;
- if (p.x >= cp->width()) p.x = cp->width() - 1;
- if (p.y >= cp->height()) p.y = cp->height() - 1;
+ if (p.x >= server->width()) p.x = server->width() - 1;
+ if (p.y >= server->height()) p.y = server->height() - 1;
startMsg(msgTypePointerEvent);
os->writeU8(buttonMask);
diff --git a/common/rfb/CMsgWriter.h b/common/rfb/CMsgWriter.h
index 1322186..1f4b92d 100644
--- a/common/rfb/CMsgWriter.h
+++ b/common/rfb/CMsgWriter.h
@@ -30,14 +30,14 @@
namespace rfb {
class PixelFormat;
- class ConnParams;
+ class ServerParams;
struct ScreenSet;
struct Point;
struct Rect;
class CMsgWriter {
public:
- CMsgWriter(ConnParams* cp, rdr::OutStream* os);
+ CMsgWriter(ServerParams* server, rdr::OutStream* os);
virtual ~CMsgWriter();
void writeClientInit(bool shared);
@@ -60,7 +60,7 @@
void startMsg(int type);
void endMsg();
- ConnParams* cp;
+ ServerParams* server;
rdr::OutStream* os;
};
}
diff --git a/common/rfb/CopyRectDecoder.cxx b/common/rfb/CopyRectDecoder.cxx
index 23949a8..ecf5032 100644
--- a/common/rfb/CopyRectDecoder.cxx
+++ b/common/rfb/CopyRectDecoder.cxx
@@ -32,7 +32,7 @@
}
void CopyRectDecoder::readRect(const Rect& r, rdr::InStream* is,
- const ConnParams& cp, rdr::OutStream* os)
+ const ServerParams& server, rdr::OutStream* os)
{
os->copyBytes(is, 4);
}
@@ -41,21 +41,21 @@
void CopyRectDecoder::getAffectedRegion(const Rect& rect,
const void* buffer,
size_t buflen,
- const ConnParams& cp,
+ const ServerParams& server,
Region* region)
{
rdr::MemInStream is(buffer, buflen);
int srcX = is.readU16();
int srcY = is.readU16();
- Decoder::getAffectedRegion(rect, buffer, buflen, cp, region);
+ Decoder::getAffectedRegion(rect, buffer, buflen, server, region);
region->assign_union(Region(rect.translate(Point(srcX-rect.tl.x,
srcY-rect.tl.y))));
}
void CopyRectDecoder::decodeRect(const Rect& r, const void* buffer,
- size_t buflen, const ConnParams& cp,
+ size_t buflen, const ServerParams& server,
ModifiablePixelBuffer* pb)
{
rdr::MemInStream is(buffer, buflen);
diff --git a/common/rfb/CopyRectDecoder.h b/common/rfb/CopyRectDecoder.h
index 1d2ce53..546266e 100644
--- a/common/rfb/CopyRectDecoder.h
+++ b/common/rfb/CopyRectDecoder.h
@@ -27,12 +27,12 @@
CopyRectDecoder();
virtual ~CopyRectDecoder();
virtual void readRect(const Rect& r, rdr::InStream* is,
- const ConnParams& cp, rdr::OutStream* os);
+ const ServerParams& server, rdr::OutStream* os);
virtual void getAffectedRegion(const Rect& rect, const void* buffer,
- size_t buflen, const ConnParams& cp,
+ size_t buflen, const ServerParams& server,
Region* region);
virtual void decodeRect(const Rect& r, const void* buffer,
- size_t buflen, const ConnParams& cp,
+ size_t buflen, const ServerParams& server,
ModifiablePixelBuffer* pb);
};
}
diff --git a/common/rfb/DecodeManager.cxx b/common/rfb/DecodeManager.cxx
index c509db0..98b6e79 100644
--- a/common/rfb/DecodeManager.cxx
+++ b/common/rfb/DecodeManager.cxx
@@ -132,9 +132,9 @@
if (threads.empty()) {
bufferStream = freeBuffers.front();
bufferStream->clear();
- decoder->readRect(r, conn->getInStream(), conn->cp, bufferStream);
+ decoder->readRect(r, conn->getInStream(), conn->server, bufferStream);
decoder->decodeRect(r, bufferStream->data(), bufferStream->length(),
- conn->cp, pb);
+ conn->server, pb);
return;
}
@@ -155,7 +155,7 @@
// Read the rect
bufferStream->clear();
- decoder->readRect(r, conn->getInStream(), conn->cp, bufferStream);
+ decoder->readRect(r, conn->getInStream(), conn->server, bufferStream);
// Then try to put it on the queue
entry = new QueueEntry;
@@ -164,12 +164,12 @@
entry->rect = r;
entry->encoding = encoding;
entry->decoder = decoder;
- entry->cp = &conn->cp;
+ entry->server = &conn->server;
entry->pb = pb;
entry->bufferStream = bufferStream;
decoder->getAffectedRegion(r, bufferStream->data(),
- bufferStream->length(), conn->cp,
+ bufferStream->length(), conn->server,
&entry->affectedRegion);
queueMutex->lock();
@@ -276,7 +276,7 @@
try {
entry->decoder->decodeRect(entry->rect, entry->bufferStream->data(),
entry->bufferStream->length(),
- *entry->cp, entry->pb);
+ *entry->server, entry->pb);
} catch (rdr::Exception& e) {
manager->setThreadException(e);
} catch(...) {
@@ -346,7 +346,7 @@
(*iter2)->rect,
(*iter2)->bufferStream->data(),
(*iter2)->bufferStream->length(),
- *entry->cp))
+ *entry->server))
goto next;
}
}
diff --git a/common/rfb/DecodeManager.h b/common/rfb/DecodeManager.h
index 2098063..058d824 100644
--- a/common/rfb/DecodeManager.h
+++ b/common/rfb/DecodeManager.h
@@ -65,7 +65,7 @@
Rect rect;
int encoding;
Decoder* decoder;
- const ConnParams* cp;
+ const ServerParams* server;
ModifiablePixelBuffer* pb;
rdr::MemOutStream* bufferStream;
Region affectedRegion;
diff --git a/common/rfb/Decoder.cxx b/common/rfb/Decoder.cxx
index 370e1f9..9827a73 100644
--- a/common/rfb/Decoder.cxx
+++ b/common/rfb/Decoder.cxx
@@ -38,7 +38,7 @@
}
void Decoder::getAffectedRegion(const Rect& rect, const void* buffer,
- size_t buflen, const ConnParams& cp,
+ size_t buflen, const ServerParams& server,
Region* region)
{
region->reset(rect);
@@ -47,7 +47,7 @@
bool Decoder::doRectsConflict(const Rect& rectA, const void* bufferA,
size_t buflenA, const Rect& rectB,
const void* bufferB, size_t buflenB,
- const ConnParams& cp)
+ const ServerParams& server)
{
return false;
}
diff --git a/common/rfb/Decoder.h b/common/rfb/Decoder.h
index 86ee4ef..e074f3e 100644
--- a/common/rfb/Decoder.h
+++ b/common/rfb/Decoder.h
@@ -25,7 +25,7 @@
}
namespace rfb {
- class ConnParams;
+ class ServerParams;
class ModifiablePixelBuffer;
class Region;
@@ -53,7 +53,7 @@
// make it easier to decode. This function will always be called in
// a serial manner on the main thread.
virtual void readRect(const Rect& r, rdr::InStream* is,
- const ConnParams& cp, rdr::OutStream* os)=0;
+ const ServerParams& server, rdr::OutStream* os)=0;
// These functions will be called from any of the worker threads.
// A lock will be held whilst these are called so it is safe to
@@ -63,7 +63,7 @@
// be either read from or written do when decoding this rect. The
// default implementation simply returns the given rectangle.
virtual void getAffectedRegion(const Rect& rect, const void* buffer,
- size_t buflen, const ConnParams& cp,
+ size_t buflen, const ServerParams& server,
Region* region);
// doesRectsConflict() determines if two rectangles must be decoded
@@ -75,14 +75,14 @@
const Rect& rectB,
const void* bufferB,
size_t buflenB,
- const ConnParams& cp);
+ const ServerParams& server);
// decodeRect() decodes the given rectangle with data from the
// given buffer, onto the ModifiablePixelBuffer. The PixelFormat of
// the PixelBuffer might not match the ConnParams and it is up to
// the decoder to do any necessary conversion.
virtual void decodeRect(const Rect& r, const void* buffer,
- size_t buflen, const ConnParams& cp,
+ size_t buflen, const ServerParams& server,
ModifiablePixelBuffer* pb)=0;
public:
diff --git a/common/rfb/HextileDecoder.cxx b/common/rfb/HextileDecoder.cxx
index eae0040..742dfb2 100644
--- a/common/rfb/HextileDecoder.cxx
+++ b/common/rfb/HextileDecoder.cxx
@@ -20,7 +20,7 @@
#include <rdr/MemInStream.h>
#include <rdr/OutStream.h>
-#include <rfb/ConnParams.h>
+#include <rfb/ServerParams.h>
#include <rfb/PixelBuffer.h>
#include <rfb/HextileDecoder.h>
@@ -45,12 +45,12 @@
}
void HextileDecoder::readRect(const Rect& r, rdr::InStream* is,
- const ConnParams& cp, rdr::OutStream* os)
+ const ServerParams& server, rdr::OutStream* os)
{
Rect t;
size_t bytesPerPixel;
- bytesPerPixel = cp.pf().bpp/8;
+ bytesPerPixel = server.pf().bpp/8;
for (t.tl.y = r.tl.y; t.tl.y < r.br.y; t.tl.y += 16) {
@@ -91,11 +91,11 @@
}
void HextileDecoder::decodeRect(const Rect& r, const void* buffer,
- size_t buflen, const ConnParams& cp,
+ size_t buflen, const ServerParams& server,
ModifiablePixelBuffer* pb)
{
rdr::MemInStream is(buffer, buflen);
- const PixelFormat& pf = cp.pf();
+ const PixelFormat& pf = server.pf();
switch (pf.bpp) {
case 8: hextileDecode8 (r, &is, pf, pb); break;
case 16: hextileDecode16(r, &is, pf, pb); break;
diff --git a/common/rfb/HextileDecoder.h b/common/rfb/HextileDecoder.h
index bdc76bc..b8515bf 100644
--- a/common/rfb/HextileDecoder.h
+++ b/common/rfb/HextileDecoder.h
@@ -27,9 +27,9 @@
HextileDecoder();
virtual ~HextileDecoder();
virtual void readRect(const Rect& r, rdr::InStream* is,
- const ConnParams& cp, rdr::OutStream* os);
+ const ServerParams& server, rdr::OutStream* os);
virtual void decodeRect(const Rect& r, const void* buffer,
- size_t buflen, const ConnParams& cp,
+ size_t buflen, const ServerParams& server,
ModifiablePixelBuffer* pb);
};
}
diff --git a/common/rfb/RREDecoder.cxx b/common/rfb/RREDecoder.cxx
index 218c9b0..70a7ddb 100644
--- a/common/rfb/RREDecoder.cxx
+++ b/common/rfb/RREDecoder.cxx
@@ -20,7 +20,7 @@
#include <rdr/MemInStream.h>
#include <rdr/OutStream.h>
-#include <rfb/ConnParams.h>
+#include <rfb/ServerParams.h>
#include <rfb/PixelBuffer.h>
#include <rfb/RREDecoder.h>
@@ -45,22 +45,22 @@
}
void RREDecoder::readRect(const Rect& r, rdr::InStream* is,
- const ConnParams& cp, rdr::OutStream* os)
+ const ServerParams& server, rdr::OutStream* os)
{
rdr::U32 numRects;
numRects = is->readU32();
os->writeU32(numRects);
- os->copyBytes(is, cp.pf().bpp/8 + numRects * (cp.pf().bpp/8 + 8));
+ os->copyBytes(is, server.pf().bpp/8 + numRects * (server.pf().bpp/8 + 8));
}
void RREDecoder::decodeRect(const Rect& r, const void* buffer,
- size_t buflen, const ConnParams& cp,
+ size_t buflen, const ServerParams& server,
ModifiablePixelBuffer* pb)
{
rdr::MemInStream is(buffer, buflen);
- const PixelFormat& pf = cp.pf();
+ const PixelFormat& pf = server.pf();
switch (pf.bpp) {
case 8: rreDecode8 (r, &is, pf, pb); break;
case 16: rreDecode16(r, &is, pf, pb); break;
diff --git a/common/rfb/RREDecoder.h b/common/rfb/RREDecoder.h
index f89fef4..f47edda 100644
--- a/common/rfb/RREDecoder.h
+++ b/common/rfb/RREDecoder.h
@@ -27,9 +27,9 @@
RREDecoder();
virtual ~RREDecoder();
virtual void readRect(const Rect& r, rdr::InStream* is,
- const ConnParams& cp, rdr::OutStream* os);
+ const ServerParams& server, rdr::OutStream* os);
virtual void decodeRect(const Rect& r, const void* buffer,
- size_t buflen, const ConnParams& cp,
+ size_t buflen, const ServerParams& server,
ModifiablePixelBuffer* pb);
};
}
diff --git a/common/rfb/RawDecoder.cxx b/common/rfb/RawDecoder.cxx
index ec0c68e..6123504 100644
--- a/common/rfb/RawDecoder.cxx
+++ b/common/rfb/RawDecoder.cxx
@@ -19,7 +19,7 @@
#include <assert.h>
#include <rdr/OutStream.h>
-#include <rfb/ConnParams.h>
+#include <rfb/ServerParams.h>
#include <rfb/PixelBuffer.h>
#include <rfb/RawDecoder.h>
@@ -34,15 +34,15 @@
}
void RawDecoder::readRect(const Rect& r, rdr::InStream* is,
- const ConnParams& cp, rdr::OutStream* os)
+ const ServerParams& server, rdr::OutStream* os)
{
- os->copyBytes(is, r.area() * (cp.pf().bpp/8));
+ os->copyBytes(is, r.area() * (server.pf().bpp/8));
}
void RawDecoder::decodeRect(const Rect& r, const void* buffer,
- size_t buflen, const ConnParams& cp,
+ size_t buflen, const ServerParams& server,
ModifiablePixelBuffer* pb)
{
- assert(buflen >= (size_t)r.area() * (cp.pf().bpp/8));
- pb->imageRect(cp.pf(), r, buffer);
+ assert(buflen >= (size_t)r.area() * (server.pf().bpp/8));
+ pb->imageRect(server.pf(), r, buffer);
}
diff --git a/common/rfb/RawDecoder.h b/common/rfb/RawDecoder.h
index 21ea738..4ab8071 100644
--- a/common/rfb/RawDecoder.h
+++ b/common/rfb/RawDecoder.h
@@ -26,9 +26,9 @@
RawDecoder();
virtual ~RawDecoder();
virtual void readRect(const Rect& r, rdr::InStream* is,
- const ConnParams& cp, rdr::OutStream* os);
+ const ServerParams& server, rdr::OutStream* os);
virtual void decodeRect(const Rect& r, const void* buffer,
- size_t buflen, const ConnParams& cp,
+ size_t buflen, const ServerParams& server,
ModifiablePixelBuffer* pb);
};
}
diff --git a/common/rfb/ServerParams.cxx b/common/rfb/ServerParams.cxx
new file mode 100644
index 0000000..4ee25a8
--- /dev/null
+++ b/common/rfb/ServerParams.cxx
@@ -0,0 +1,90 @@
+/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
+ * Copyright (C) 2011 D. R. Commander. All Rights Reserved.
+ * Copyright 2014-2018 Pierre Ossman for Cendio AB
+ *
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this software; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ * USA.
+ */
+#include <rfb/Exception.h>
+#include <rfb/ledStates.h>
+#include <rfb/ServerParams.h>
+
+using namespace rfb;
+
+ServerParams::ServerParams()
+ : 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),
+ width_(0), height_(0), name_(0),
+ ledState_(ledUnknown)
+{
+ setName("");
+ cursor_ = new Cursor(0, 0, Point(), NULL);
+}
+
+ServerParams::~ServerParams()
+{
+ delete [] name_;
+ delete cursor_;
+}
+
+void ServerParams::setDimensions(int width, int height)
+{
+ ScreenSet layout;
+ layout.add_screen(rfb::Screen(0, 0, 0, width, height, 0));
+ setDimensions(width, height, layout);
+}
+
+void ServerParams::setDimensions(int width, int height, const ScreenSet& layout)
+{
+ if (!layout.validate(width, height))
+ throw Exception("Attempted to configure an invalid screen layout");
+
+ width_ = width;
+ height_ = height;
+ screenLayout_ = layout;
+}
+
+void ServerParams::setPF(const PixelFormat& pf)
+{
+ pf_ = pf;
+
+ if (pf.bpp != 8 && pf.bpp != 16 && pf.bpp != 32)
+ throw Exception("setPF: not 8, 16 or 32 bpp?");
+}
+
+void ServerParams::setName(const char* name)
+{
+ delete [] name_;
+ name_ = strDup(name);
+}
+
+void ServerParams::setCursor(const Cursor& other)
+{
+ delete cursor_;
+ cursor_ = new Cursor(other);
+}
+
+void ServerParams::setLEDState(unsigned int state)
+{
+ ledState_ = state;
+}
diff --git a/common/rfb/ServerParams.h b/common/rfb/ServerParams.h
new file mode 100644
index 0000000..4554f09
--- /dev/null
+++ b/common/rfb/ServerParams.h
@@ -0,0 +1,103 @@
+/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
+ * Copyright 2014-2018 Pierre Ossman for Cendio AB
+ *
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this software; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ * USA.
+ */
+//
+// ServerParams - structure describing the current state of the remote server
+//
+
+#ifndef __RFB_SERVERPARAMS_H__
+#define __RFB_SERVERPARAMS_H__
+
+#include <rfb/Cursor.h>
+#include <rfb/PixelFormat.h>
+#include <rfb/ScreenSet.h>
+
+namespace rfb {
+
+ class ServerParams {
+ public:
+ ServerParams();
+ ~ServerParams();
+
+ int majorVersion;
+ int minorVersion;
+
+ void setVersion(int major, int minor) {
+ majorVersion = major; minorVersion = minor;
+ }
+ bool isVersion(int major, int minor) const {
+ return majorVersion == major && minorVersion == minor;
+ }
+ bool beforeVersion(int major, int minor) const {
+ return (majorVersion < major ||
+ (majorVersion == major && minorVersion < minor));
+ }
+ bool afterVersion(int major, int minor) const {
+ return !beforeVersion(major,minor+1);
+ }
+
+ const int width() const { return width_; }
+ const int height() const { return height_; }
+ const ScreenSet& screenLayout() const { return screenLayout_; }
+ void setDimensions(int width, int height);
+ void setDimensions(int width, int height, const ScreenSet& layout);
+
+ const PixelFormat& pf() const { return pf_; }
+ void setPF(const PixelFormat& pf);
+
+ const char* name() const { return name_; }
+ void setName(const char* name);
+
+ const Cursor& cursor() const { return *cursor_; }
+ void setCursor(const Cursor& cursor);
+
+ 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;
+
+ int compressLevel;
+ int qualityLevel;
+
+ private:
+
+ int width_;
+ int height_;
+ ScreenSet screenLayout_;
+
+ PixelFormat pf_;
+ char* name_;
+ Cursor* cursor_;
+ unsigned int ledState_;
+ };
+}
+#endif
diff --git a/common/rfb/TightDecoder.cxx b/common/rfb/TightDecoder.cxx
index cc786f5..fad4731 100644
--- a/common/rfb/TightDecoder.cxx
+++ b/common/rfb/TightDecoder.cxx
@@ -25,7 +25,7 @@
#include <rdr/MemInStream.h>
#include <rdr/OutStream.h>
-#include <rfb/ConnParams.h>
+#include <rfb/ServerParams.h>
#include <rfb/Exception.h>
#include <rfb/PixelBuffer.h>
#include <rfb/TightConstants.h>
@@ -55,7 +55,7 @@
}
void TightDecoder::readRect(const Rect& r, rdr::InStream* is,
- const ConnParams& cp, rdr::OutStream* os)
+ const ServerParams& server, rdr::OutStream* os)
{
rdr::U8 comp_ctl;
@@ -66,10 +66,10 @@
// "Fill" compression type.
if (comp_ctl == tightFill) {
- if (cp.pf().is888())
+ if (server.pf().is888())
os->copyBytes(is, 3);
else
- os->copyBytes(is, cp.pf().bpp/8);
+ os->copyBytes(is, server.pf().bpp/8);
return;
}
@@ -106,13 +106,13 @@
palSize = is->readU8() + 1;
os->writeU8(palSize - 1);
- if (cp.pf().is888())
+ if (server.pf().is888())
os->copyBytes(is, palSize * 3);
else
- os->copyBytes(is, palSize * cp.pf().bpp/8);
+ os->copyBytes(is, palSize * server.pf().bpp/8);
break;
case tightFilterGradient:
- if (cp.pf().bpp == 8)
+ if (server.pf().bpp == 8)
throw Exception("TightDecoder: invalid BPP for gradient filter");
break;
case tightFilterCopy:
@@ -129,10 +129,10 @@
rowSize = (r.width() + 7) / 8;
else
rowSize = r.width();
- } else if (cp.pf().is888()) {
+ } else if (server.pf().is888()) {
rowSize = r.width() * 3;
} else {
- rowSize = r.width() * cp.pf().bpp/8;
+ rowSize = r.width() * server.pf().bpp/8;
}
dataSize = r.height() * rowSize;
@@ -154,7 +154,7 @@
const Rect& rectB,
const void* bufferB,
size_t buflenB,
- const ConnParams& cp)
+ const ServerParams& server)
{
rdr::U8 comp_ctl_a, comp_ctl_b;
@@ -177,11 +177,11 @@
}
void TightDecoder::decodeRect(const Rect& r, const void* buffer,
- size_t buflen, const ConnParams& cp,
+ size_t buflen, const ServerParams& server,
ModifiablePixelBuffer* pb)
{
const rdr::U8* bufptr;
- const PixelFormat& pf = cp.pf();
+ const PixelFormat& pf = server.pf();
rdr::U8 comp_ctl;
diff --git a/common/rfb/TightDecoder.h b/common/rfb/TightDecoder.h
index 6eb93d2..28b6c30 100644
--- a/common/rfb/TightDecoder.h
+++ b/common/rfb/TightDecoder.h
@@ -32,16 +32,16 @@
TightDecoder();
virtual ~TightDecoder();
virtual void readRect(const Rect& r, rdr::InStream* is,
- const ConnParams& cp, rdr::OutStream* os);
+ const ServerParams& server, rdr::OutStream* os);
virtual bool doRectsConflict(const Rect& rectA,
const void* bufferA,
size_t buflenA,
const Rect& rectB,
const void* bufferB,
size_t buflenB,
- const ConnParams& cp);
+ const ServerParams& server);
virtual void decodeRect(const Rect& r, const void* buffer,
- size_t buflen, const ConnParams& cp,
+ size_t buflen, const ServerParams& server,
ModifiablePixelBuffer* pb);
private:
diff --git a/common/rfb/ZRLEDecoder.cxx b/common/rfb/ZRLEDecoder.cxx
index 1dfb72a..9d1ff6b 100644
--- a/common/rfb/ZRLEDecoder.cxx
+++ b/common/rfb/ZRLEDecoder.cxx
@@ -21,7 +21,7 @@
#include <rdr/MemInStream.h>
#include <rdr/OutStream.h>
-#include <rfb/ConnParams.h>
+#include <rfb/ServerParams.h>
#include <rfb/PixelBuffer.h>
#include <rfb/ZRLEDecoder.h>
@@ -72,7 +72,7 @@
}
void ZRLEDecoder::readRect(const Rect& r, rdr::InStream* is,
- const ConnParams& cp, rdr::OutStream* os)
+ const ServerParams& server, rdr::OutStream* os)
{
rdr::U32 len;
@@ -82,11 +82,11 @@
}
void ZRLEDecoder::decodeRect(const Rect& r, const void* buffer,
- size_t buflen, const ConnParams& cp,
+ size_t buflen, const ServerParams& server,
ModifiablePixelBuffer* pb)
{
rdr::MemInStream is(buffer, buflen);
- const rfb::PixelFormat& pf = cp.pf();
+ const rfb::PixelFormat& pf = server.pf();
switch (pf.bpp) {
case 8: zrleDecode8 (r, &is, &zis, pf, pb); break;
case 16: zrleDecode16(r, &is, &zis, pf, pb); break;
diff --git a/common/rfb/ZRLEDecoder.h b/common/rfb/ZRLEDecoder.h
index 1e33851..a530586 100644
--- a/common/rfb/ZRLEDecoder.h
+++ b/common/rfb/ZRLEDecoder.h
@@ -28,9 +28,9 @@
ZRLEDecoder();
virtual ~ZRLEDecoder();
virtual void readRect(const Rect& r, rdr::InStream* is,
- const ConnParams& cp, rdr::OutStream* os);
+ const ServerParams& server, rdr::OutStream* os);
virtual void decodeRect(const Rect& r, const void* buffer,
- size_t buflen, const ConnParams& cp,
+ size_t buflen, const ServerParams& server,
ModifiablePixelBuffer* pb);
private:
rdr::ZlibInStream zis;