diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/rfb/Blacklist.cxx | 13 | ||||
-rw-r--r-- | common/rfb/Blacklist.h | 9 | ||||
-rw-r--r-- | common/rfb/CConnection.cxx | 26 | ||||
-rw-r--r-- | common/rfb/CConnection.h | 5 | ||||
-rw-r--r-- | common/rfb/ClientParams.cxx | 6 | ||||
-rw-r--r-- | common/rfb/ClientParams.h | 5 | ||||
-rw-r--r-- | common/rfb/Configuration.cxx | 13 | ||||
-rw-r--r-- | common/rfb/Configuration.h | 4 | ||||
-rw-r--r-- | common/rfb/KeyRemapper.cxx | 2 | ||||
-rw-r--r-- | common/rfb/SConnection.cxx | 27 | ||||
-rw-r--r-- | common/rfb/SConnection.h | 5 | ||||
-rw-r--r-- | common/rfb/ServerParams.cxx | 6 | ||||
-rw-r--r-- | common/rfb/ServerParams.h | 6 |
13 files changed, 50 insertions, 77 deletions
diff --git a/common/rfb/Blacklist.cxx b/common/rfb/Blacklist.cxx index f052eafb..12a54c45 100644 --- a/common/rfb/Blacklist.cxx +++ b/common/rfb/Blacklist.cxx @@ -45,11 +45,6 @@ Blacklist::Blacklist() { } Blacklist::~Blacklist() { - // Free the map keys - BlacklistMap::iterator i; - for (i=blm.begin(); i!=blm.end(); i++) { - strFree((char*)(*i).first); - } } bool Blacklist::isBlackmarked(const char* name) { @@ -65,7 +60,7 @@ bool Blacklist::isBlackmarked(const char* name) { bi.marks = 1; bi.blockUntil = 0; bi.blockTimeout = initialTimeout; - blm[strDup(name)] = bi; + blm[name] = bi; i = blm.find(name); } @@ -92,9 +87,5 @@ bool Blacklist::isBlackmarked(const char* name) { } void Blacklist::clearBlackmark(const char* name) { - BlacklistMap::iterator i = blm.find(name); - if (i != blm.end()) { - strFree((char*)(*i).first); - blm.erase(i); - } + blm.erase(name); } diff --git a/common/rfb/Blacklist.h b/common/rfb/Blacklist.h index 45e36a0e..c1699f29 100644 --- a/common/rfb/Blacklist.h +++ b/common/rfb/Blacklist.h @@ -30,9 +30,9 @@ #include <string.h> #include <time.h> #include <map> +#include <string> #include <rfb/Configuration.h> -#include <rfb/util.h> namespace rfb { @@ -68,17 +68,12 @@ namespace rfb { void clearBlackmark(const char* name); protected: - struct ltStr { - bool operator()(const char* s1, const char* s2) const { - return strcmp(s1, s2) < 0; - }; - }; struct BlacklistInfo { int marks; time_t blockUntil; unsigned int blockTimeout; }; - typedef std::map<const char*,BlacklistInfo,ltStr> BlacklistMap; + typedef std::map<std::string,BlacklistInfo> BlacklistMap; BlacklistMap blm; }; diff --git a/common/rfb/CConnection.cxx b/common/rfb/CConnection.cxx index 79adec5c..56429c98 100644 --- a/common/rfb/CConnection.cxx +++ b/common/rfb/CConnection.cxx @@ -59,7 +59,7 @@ CConnection::CConnection() firstUpdate(true), pendingUpdate(false), continuousUpdates(false), forceNonincremental(true), framebuffer(NULL), decoder(this), - serverClipboard(NULL), hasLocalClipboard(false) + hasRemoteClipboard(false), hasLocalClipboard(false) { } @@ -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,10 +543,8 @@ void CConnection::serverCutText(const char* str) { hasLocalClipboard = false; - strFree(serverClipboard); - serverClipboard = NULL; - - serverClipboard = strDup(latin1ToUTF8(str).c_str()); + serverClipboard = latin1ToUTF8(str); + hasRemoteClipboard = true; handleClipboardAnnounce(true); } @@ -589,8 +585,7 @@ void CConnection::handleClipboardPeek() void CConnection::handleClipboardNotify(uint32_t flags) { - strFree(serverClipboard); - serverClipboard = NULL; + hasRemoteClipboard = false; if (flags & rfb::clipboardUTF8) { hasLocalClipboard = false; @@ -609,14 +604,11 @@ void CConnection::handleClipboardProvide(uint32_t flags, return; } - strFree(serverClipboard); - serverClipboard = NULL; - - std::string filtered(convertLF((const char*)data[0], lengths[0])); - serverClipboard = strDup(filtered.c_str()); + 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() @@ -646,8 +638,8 @@ void CConnection::handleClipboardData(const char* /*data*/) void CConnection::requestClipboard() { - if (serverClipboard != NULL) { - handleClipboardData(serverClipboard); + if (hasRemoteClipboard) { + handleClipboardData(serverClipboard.c_str()); return; } diff --git a/common/rfb/CConnection.h b/common/rfb/CConnection.h index 0cf47962..71da175e 100644 --- a/common/rfb/CConnection.h +++ b/common/rfb/CConnection.h @@ -24,6 +24,8 @@ #ifndef __RFB_CCONNECTION_H__ #define __RFB_CCONNECTION_H__ +#include <string> + #include <rfb/CMsgHandler.h> #include <rfb/DecodeManager.h> #include <rfb/SecurityClient.h> @@ -292,7 +294,8 @@ namespace rfb { ModifiablePixelBuffer* framebuffer; DecodeManager decoder; - char* serverClipboard; + std::string serverClipboard; + bool hasRemoteClipboard; bool hasLocalClipboard; bool unsolicitedClipboardAttempt; }; diff --git a/common/rfb/ClientParams.cxx b/common/rfb/ClientParams.cxx index 572e2d82..ade99018 100644 --- a/common/rfb/ClientParams.cxx +++ b/common/rfb/ClientParams.cxx @@ -34,7 +34,7 @@ ClientParams::ClientParams() : majorVersion(0), minorVersion(0), compressLevel(2), qualityLevel(-1), fineQualityLevel(-1), subsampling(subsampleUndefined), - width_(0), height_(0), name_(0), + width_(0), height_(0), cursorPos_(0, 0), ledState_(ledUnknown) { setName(""); @@ -49,7 +49,6 @@ ClientParams::ClientParams() ClientParams::~ClientParams() { - delete [] name_; delete cursor_; } @@ -80,8 +79,7 @@ void ClientParams::setPF(const PixelFormat& pf) void ClientParams::setName(const char* name) { - delete [] name_; - name_ = strDup(name); + name_ = name; } void ClientParams::setCursor(const Cursor& other) diff --git a/common/rfb/ClientParams.h b/common/rfb/ClientParams.h index 0f4171cc..ea86ea78 100644 --- a/common/rfb/ClientParams.h +++ b/common/rfb/ClientParams.h @@ -24,6 +24,7 @@ #define __RFB_CLIENTPARAMS_H__ #include <set> +#include <string> #include <stdint.h> @@ -72,7 +73,7 @@ namespace rfb { const PixelFormat& pf() const { return pf_; } void setPF(const PixelFormat& pf); - const char* name() const { return name_; } + const char* name() const { return name_.c_str(); } void setName(const char* name); const Cursor& cursor() const { return *cursor_; } @@ -113,7 +114,7 @@ namespace rfb { ScreenSet screenLayout_; PixelFormat pf_; - char* name_; + std::string name_; Cursor* cursor_; Point cursorPos_; std::set<int32_t> encodings_; diff --git a/common/rfb/Configuration.cxx b/common/rfb/Configuration.cxx index 0fc2bde6..1c215c7f 100644 --- a/common/rfb/Configuration.cxx +++ b/common/rfb/Configuration.cxx @@ -372,7 +372,7 @@ IntParameter::operator int() const { StringParameter::StringParameter(const char* name_, const char* desc_, const char* v, ConfigurationObject co) - : VoidParameter(name_, desc_, co), value(strDup(v)), def_value(strDup(v)) + : VoidParameter(name_, desc_, co), value(v), def_value(v) { if (!v) { vlog.error("Default value <null> for %s not allowed",name_); @@ -381,8 +381,6 @@ StringParameter::StringParameter(const char* name_, const char* desc_, } StringParameter::~StringParameter() { - strFree(value); - strFree(def_value); } bool StringParameter::setParam(const char* v) { @@ -391,9 +389,8 @@ bool StringParameter::setParam(const char* v) { if (!v) throw rfb::Exception("setParam(<null>) not allowed"); vlog.debug("set %s(String) to %s", getName(), v); - CharArray oldValue(value); - value = strDup(v); - return value != 0; + value = v; + return true; } std::string StringParameter::getDefaultStr() const { @@ -402,11 +399,11 @@ std::string StringParameter::getDefaultStr() const { std::string StringParameter::getValueStr() const { LOCK_CONFIG; - return std::string(value); + return value; } StringParameter::operator const char *() const { - return value; + return value.c_str(); } // -=- BinaryParameter diff --git a/common/rfb/Configuration.h b/common/rfb/Configuration.h index eef89d93..d73d8005 100644 --- a/common/rfb/Configuration.h +++ b/common/rfb/Configuration.h @@ -250,8 +250,8 @@ namespace rfb { virtual std::string getValueStr() const; operator const char*() const; protected: - char* value; - char* def_value; + std::string value; + std::string def_value; }; class BinaryParameter : public VoidParameter { diff --git a/common/rfb/KeyRemapper.cxx b/common/rfb/KeyRemapper.cxx index 731eb256..762eb413 100644 --- a/common/rfb/KeyRemapper.cxx +++ b/common/rfb/KeyRemapper.cxx @@ -87,7 +87,7 @@ class KeyMapParameter : public StringParameter { public: KeyMapParameter() : StringParameter("RemapKeys", "Comma-separated list of incoming keysyms to remap. Mappings are expressed as two hex values, prefixed by 0x, and separated by ->", "") { - setParam(value); + KeyRemapper::defInstance.setMapping(""); } bool setParam(const char* v) { KeyRemapper::defInstance.setMapping(v); diff --git a/common/rfb/SConnection.cxx b/common/rfb/SConnection.cxx index 244fb324..a1755cb4 100644 --- a/common/rfb/SConnection.cxx +++ b/common/rfb/SConnection.cxx @@ -60,7 +60,8 @@ SConnection::SConnection() is(0), os(0), reader_(0), writer_(0), ssecurity(0), authFailureTimer(this, &SConnection::handleAuthFailureTimeout), state_(RFBSTATE_UNINITIALISED), preferredEncoding(encodingRaw), - accessRights(0x0000), clientClipboard(NULL), hasLocalClipboard(false), + accessRights(0x0000), hasRemoteClipboard(false), + hasLocalClipboard(false), unsolicitedClipboardAttempt(false) { defaultMajorVersion = 3; @@ -380,10 +381,8 @@ void SConnection::clientCutText(const char* str) { hasLocalClipboard = false; - strFree(clientClipboard); - clientClipboard = NULL; - - clientClipboard = strDup(latin1ToUTF8(str).c_str()); + clientClipboard = latin1ToUTF8(str); + hasRemoteClipboard = true; handleClipboardAnnounce(true); } @@ -409,8 +408,7 @@ void SConnection::handleClipboardPeek() void SConnection::handleClipboardNotify(uint32_t flags) { - strFree(clientClipboard); - clientClipboard = NULL; + hasRemoteClipboard = false; if (flags & rfb::clipboardUTF8) { hasLocalClipboard = false; @@ -429,14 +427,11 @@ void SConnection::handleClipboardProvide(uint32_t flags, return; } - strFree(clientClipboard); - clientClipboard = NULL; - - std::string filtered(convertLF((const char*)data[0], lengths[0])); - clientClipboard = strDup(filtered.c_str()); + clientClipboard = convertLF((const char*)data[0], lengths[0]); + hasRemoteClipboard = true; // FIXME: Should probably verify that this data was actually requested - handleClipboardData(clientClipboard); + handleClipboardData(clientClipboard.c_str()); } void SConnection::supportsQEMUKeyEvent() @@ -554,8 +549,8 @@ void SConnection::handleClipboardData(const char* /*data*/) void SConnection::requestClipboard() { - if (clientClipboard != NULL) { - handleClipboardData(clientClipboard); + if (hasRemoteClipboard) { + handleClipboardData(clientClipboard.c_str()); return; } @@ -624,8 +619,6 @@ void SConnection::cleanup() reader_ = NULL; delete writer_; writer_ = NULL; - strFree(clientClipboard); - clientClipboard = NULL; } void SConnection::writeFakeColourMap(void) diff --git a/common/rfb/SConnection.h b/common/rfb/SConnection.h index 54acdd9c..08574069 100644 --- a/common/rfb/SConnection.h +++ b/common/rfb/SConnection.h @@ -24,6 +24,8 @@ #ifndef __RFB_SCONNECTION_H__ #define __RFB_SCONNECTION_H__ +#include <string> + #include <rdr/InStream.h> #include <rdr/OutStream.h> @@ -263,7 +265,8 @@ namespace rfb { int32_t preferredEncoding; AccessRights accessRights; - char* clientClipboard; + std::string clientClipboard; + bool hasRemoteClipboard; bool hasLocalClipboard; bool unsolicitedClipboardAttempt; }; diff --git a/common/rfb/ServerParams.cxx b/common/rfb/ServerParams.cxx index 62fbde91..6af446c2 100644 --- a/common/rfb/ServerParams.cxx +++ b/common/rfb/ServerParams.cxx @@ -33,7 +33,7 @@ ServerParams::ServerParams() supportsQEMUKeyEvent(false), supportsSetDesktopSize(false), supportsFence(false), supportsContinuousUpdates(false), - width_(0), height_(0), name_(0), + width_(0), height_(0), ledState_(ledUnknown) { setName(""); @@ -46,7 +46,6 @@ ServerParams::ServerParams() ServerParams::~ServerParams() { - delete [] name_; delete cursor_; } @@ -77,8 +76,7 @@ void ServerParams::setPF(const PixelFormat& pf) void ServerParams::setName(const char* name) { - delete [] name_; - name_ = strDup(name); + name_ = name; } void ServerParams::setCursor(const Cursor& other) diff --git a/common/rfb/ServerParams.h b/common/rfb/ServerParams.h index 4feacf18..791e3e7f 100644 --- a/common/rfb/ServerParams.h +++ b/common/rfb/ServerParams.h @@ -23,6 +23,8 @@ #ifndef __RFB_SERVERPARAMS_H__ #define __RFB_SERVERPARAMS_H__ +#include <string> + #include <rfb/Cursor.h> #include <rfb/PixelFormat.h> #include <rfb/ScreenSet.h> @@ -60,7 +62,7 @@ namespace rfb { const PixelFormat& pf() const { return pf_; } void setPF(const PixelFormat& pf); - const char* name() const { return name_; } + const char* name() const { return name_.c_str(); } void setName(const char* name); const Cursor& cursor() const { return *cursor_; } @@ -85,7 +87,7 @@ namespace rfb { ScreenSet screenLayout_; PixelFormat pf_; - char* name_; + std::string name_; Cursor* cursor_; unsigned int ledState_; uint32_t clipFlags; |