aboutsummaryrefslogtreecommitdiffstats
path: root/common/rfb/CConnection.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'common/rfb/CConnection.cxx')
-rw-r--r--common/rfb/CConnection.cxx77
1 files changed, 35 insertions, 42 deletions
diff --git a/common/rfb/CConnection.cxx b/common/rfb/CConnection.cxx
index 27942764..521649ac 100644
--- a/common/rfb/CConnection.cxx
+++ b/common/rfb/CConnection.cxx
@@ -52,14 +52,14 @@ CConnection::CConnection()
supportsDesktopResize(false), supportsLEDState(false),
is(0), os(0), reader_(0), writer_(0),
shared(false),
- state_(RFBSTATE_UNINITIALISED), serverName(strDup("")),
+ state_(RFBSTATE_UNINITIALISED),
pendingPFChange(false), preferredEncoding(encodingTight),
compressLevel(2), qualityLevel(-1),
formatChange(false), encodingChange(false),
firstUpdate(true), pendingUpdate(false), continuousUpdates(false),
forceNonincremental(true),
framebuffer(NULL), decoder(this),
- serverClipboard(NULL), hasLocalClipboard(false)
+ hasRemoteClipboard(false), hasLocalClipboard(false)
{
}
@@ -72,7 +72,7 @@ void CConnection::setServerName(const char* name_)
{
if (name_ == NULL)
name_ = "";
- serverName.replaceBuf(strDup(name_));
+ serverName = name_;
}
void CConnection::setStreams(rdr::InStream* is_, rdr::OutStream* os_)
@@ -93,10 +93,10 @@ void CConnection::setFramebuffer(ModifiablePixelBuffer* fb)
if ((framebuffer != NULL) && (fb != NULL)) {
Rect rect;
- const rdr::U8* data;
+ const uint8_t* data;
int stride;
- const rdr::U8 black[4] = { 0, 0, 0, 0 };
+ const uint8_t black[4] = { 0, 0, 0, 0 };
// Copy still valid area
@@ -210,7 +210,7 @@ bool CConnection::processSecurityTypesMsg()
int secType = secTypeInvalid;
- std::list<rdr::U8> secTypes;
+ std::list<uint8_t> secTypes;
secTypes = security.GetEnabledSecTypes();
if (server.isVersion(3,3)) {
@@ -225,7 +225,7 @@ bool CConnection::processSecurityTypesMsg()
state_ = RFBSTATE_SECURITY_REASON;
return true;
} else if (secType == secTypeNone || secType == secTypeVncAuth) {
- std::list<rdr::U8>::iterator i;
+ std::list<uint8_t>::iterator i;
for (i = secTypes.begin(); i != secTypes.end(); i++)
if (*i == secType) {
secType = *i;
@@ -259,10 +259,10 @@ bool CConnection::processSecurityTypesMsg()
return true;
}
- std::list<rdr::U8>::iterator j;
+ std::list<uint8_t>::iterator j;
for (int i = 0; i < nServerSecTypes; i++) {
- rdr::U8 serverSecType = is->readU8();
+ uint8_t serverSecType = is->readU8();
vlog.debug("Server offers security type %s(%d)",
secTypeName(serverSecType), serverSecType);
@@ -355,17 +355,17 @@ bool CConnection::processSecurityReasonMsg()
is->setRestorePoint();
- rdr::U32 len = is->readU32();
+ uint32_t len = is->readU32();
if (!is->hasDataOrRestore(len))
return false;
is->clearRestorePoint();
- CharArray reason(len + 1);
- is->readBytes(reason.buf, len);
- reason.buf[len] = '\0';
+ std::vector<char> reason(len + 1);
+ is->readBytes(reason.data(), len);
+ reason[len] = '\0';
state_ = RFBSTATE_INVALID;
- throw AuthFailureException(reason.buf);
+ throw AuthFailureException(reason.data());
}
bool CConnection::processInitMsg()
@@ -405,8 +405,6 @@ void CConnection::close()
reader_ = NULL;
delete writer_;
writer_ = NULL;
- strFree(serverClipboard);
- serverClipboard = NULL;
}
void CConnection::setDesktopSize(int w, int h)
@@ -545,18 +543,16 @@ void CConnection::serverCutText(const char* str)
{
hasLocalClipboard = false;
- strFree(serverClipboard);
- serverClipboard = NULL;
-
serverClipboard = latin1ToUTF8(str);
+ hasRemoteClipboard = true;
handleClipboardAnnounce(true);
}
-void CConnection::handleClipboardCaps(rdr::U32 flags,
- const rdr::U32* lengths)
+void CConnection::handleClipboardCaps(uint32_t flags,
+ const uint32_t* lengths)
{
- rdr::U32 sizes[] = { 0 };
+ uint32_t sizes[] = { 0 };
CMsgHandler::handleClipboardCaps(flags, lengths);
@@ -568,7 +564,7 @@ void CConnection::handleClipboardCaps(rdr::U32 flags,
sizes);
}
-void CConnection::handleClipboardRequest(rdr::U32 flags)
+void CConnection::handleClipboardRequest(uint32_t flags)
{
if (!(flags & rfb::clipboardUTF8)) {
vlog.debug("Ignoring clipboard request for unsupported formats 0x%x", flags);
@@ -587,10 +583,9 @@ void CConnection::handleClipboardPeek()
writer()->writeClipboardNotify(hasLocalClipboard ? rfb::clipboardUTF8 : 0);
}
-void CConnection::handleClipboardNotify(rdr::U32 flags)
+void CConnection::handleClipboardNotify(uint32_t flags)
{
- strFree(serverClipboard);
- serverClipboard = NULL;
+ hasRemoteClipboard = false;
if (flags & rfb::clipboardUTF8) {
hasLocalClipboard = false;
@@ -600,22 +595,20 @@ void CConnection::handleClipboardNotify(rdr::U32 flags)
}
}
-void CConnection::handleClipboardProvide(rdr::U32 flags,
+void CConnection::handleClipboardProvide(uint32_t flags,
const size_t* lengths,
- const rdr::U8* const* data)
+ const uint8_t* const* data)
{
if (!(flags & rfb::clipboardUTF8)) {
vlog.debug("Ignoring clipboard provide with unsupported formats 0x%x", flags);
return;
}
- strFree(serverClipboard);
- serverClipboard = NULL;
-
serverClipboard = convertLF((const char*)data[0], lengths[0]);
+ hasRemoteClipboard = true;
// FIXME: Should probably verify that this data was actually requested
- handleClipboardData(serverClipboard);
+ handleClipboardData(serverClipboard.c_str());
}
void CConnection::authSuccess()
@@ -645,8 +638,8 @@ void CConnection::handleClipboardData(const char* /*data*/)
void CConnection::requestClipboard()
{
- if (serverClipboard != NULL) {
- handleClipboardData(serverClipboard);
+ if (hasRemoteClipboard) {
+ handleClipboardData(serverClipboard.c_str());
return;
}
@@ -681,9 +674,9 @@ void CConnection::announceClipboard(bool available)
void CConnection::sendClipboardData(const char* data)
{
if (server.clipboardFlags() & rfb::clipboardProvide) {
- CharArray filtered(convertCRLF(data));
- size_t sizes[1] = { strlen(filtered.buf) + 1 };
- const rdr::U8* data[1] = { (const rdr::U8*)filtered.buf };
+ std::string filtered(convertCRLF(data));
+ size_t sizes[1] = { filtered.size() + 1 };
+ const uint8_t* data[1] = { (const uint8_t*)filtered.c_str() };
if (unsolicitedClipboardAttempt) {
unsolicitedClipboardAttempt = false;
@@ -697,9 +690,9 @@ void CConnection::sendClipboardData(const char* data)
writer()->writeClipboardProvide(rfb::clipboardUTF8, sizes, data);
} else {
- CharArray latin1(utf8ToLatin1(data));
+ std::string latin1(utf8ToLatin1(data));
- writer()->writeClientCutText(latin1.buf);
+ writer()->writeClientCutText(latin1.c_str());
}
}
@@ -747,14 +740,14 @@ void CConnection::setQualityLevel(int level)
void CConnection::setPF(const PixelFormat& pf)
{
- if (server.pf().equal(pf) && !formatChange)
+ if (server.pf() == pf && !formatChange)
return;
nextPF = pf;
formatChange = true;
}
-void CConnection::fence(rdr::U32 flags, unsigned len, const char data[])
+void CConnection::fence(uint32_t flags, unsigned len, const char data[])
{
CMsgHandler::fence(flags, len, data);
@@ -819,7 +812,7 @@ void CConnection::requestNewUpdate()
void CConnection::updateEncodings()
{
- std::list<rdr::U32> encodings;
+ std::list<uint32_t> encodings;
if (supportsLocalCursor) {
encodings.push_back(pseudoEncodingCursorWithAlpha);