}
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) {
bi.marks = 1;
bi.blockUntil = 0;
bi.blockTimeout = initialTimeout;
- blm[strDup(name)] = bi;
+ blm[name] = bi;
i = blm.find(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);
}
#include <string.h>
#include <time.h>
#include <map>
+#include <string>
#include <rfb/Configuration.h>
-#include <rfb/util.h>
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;
};
firstUpdate(true), pendingUpdate(false), continuousUpdates(false),
forceNonincremental(true),
framebuffer(NULL), decoder(this),
- serverClipboard(NULL), hasLocalClipboard(false)
+ hasRemoteClipboard(false), hasLocalClipboard(false)
{
}
reader_ = NULL;
delete writer_;
writer_ = NULL;
- strFree(serverClipboard);
- serverClipboard = NULL;
}
void CConnection::setDesktopSize(int w, int h)
{
hasLocalClipboard = false;
- strFree(serverClipboard);
- serverClipboard = NULL;
-
- serverClipboard = strDup(latin1ToUTF8(str).c_str());
+ serverClipboard = latin1ToUTF8(str);
+ hasRemoteClipboard = true;
handleClipboardAnnounce(true);
}
void CConnection::handleClipboardNotify(uint32_t flags)
{
- strFree(serverClipboard);
- serverClipboard = NULL;
+ hasRemoteClipboard = false;
if (flags & rfb::clipboardUTF8) {
hasLocalClipboard = false;
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()
void CConnection::requestClipboard()
{
- if (serverClipboard != NULL) {
- handleClipboardData(serverClipboard);
+ if (hasRemoteClipboard) {
+ handleClipboardData(serverClipboard.c_str());
return;
}
#ifndef __RFB_CCONNECTION_H__
#define __RFB_CCONNECTION_H__
+#include <string>
+
#include <rfb/CMsgHandler.h>
#include <rfb/DecodeManager.h>
#include <rfb/SecurityClient.h>
ModifiablePixelBuffer* framebuffer;
DecodeManager decoder;
- char* serverClipboard;
+ std::string serverClipboard;
+ bool hasRemoteClipboard;
bool hasLocalClipboard;
bool unsolicitedClipboardAttempt;
};
: 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("");
ClientParams::~ClientParams()
{
- delete [] name_;
delete cursor_;
}
void ClientParams::setName(const char* name)
{
- delete [] name_;
- name_ = strDup(name);
+ name_ = name;
}
void ClientParams::setCursor(const Cursor& other)
#define __RFB_CLIENTPARAMS_H__
#include <set>
+#include <string>
#include <stdint.h>
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_; }
ScreenSet screenLayout_;
PixelFormat pf_;
- char* name_;
+ std::string name_;
Cursor* cursor_;
Point cursorPos_;
std::set<int32_t> encodings_;
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_);
}
StringParameter::~StringParameter() {
- strFree(value);
- strFree(def_value);
}
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 {
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
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 {
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);
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;
{
hasLocalClipboard = false;
- strFree(clientClipboard);
- clientClipboard = NULL;
-
- clientClipboard = strDup(latin1ToUTF8(str).c_str());
+ clientClipboard = latin1ToUTF8(str);
+ hasRemoteClipboard = true;
handleClipboardAnnounce(true);
}
void SConnection::handleClipboardNotify(uint32_t flags)
{
- strFree(clientClipboard);
- clientClipboard = NULL;
+ hasRemoteClipboard = false;
if (flags & rfb::clipboardUTF8) {
hasLocalClipboard = false;
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()
void SConnection::requestClipboard()
{
- if (clientClipboard != NULL) {
- handleClipboardData(clientClipboard);
+ if (hasRemoteClipboard) {
+ handleClipboardData(clientClipboard.c_str());
return;
}
reader_ = NULL;
delete writer_;
writer_ = NULL;
- strFree(clientClipboard);
- clientClipboard = NULL;
}
void SConnection::writeFakeColourMap(void)
#ifndef __RFB_SCONNECTION_H__
#define __RFB_SCONNECTION_H__
+#include <string>
+
#include <rdr/InStream.h>
#include <rdr/OutStream.h>
int32_t preferredEncoding;
AccessRights accessRights;
- char* clientClipboard;
+ std::string clientClipboard;
+ bool hasRemoteClipboard;
bool hasLocalClipboard;
bool unsolicitedClipboardAttempt;
};
supportsQEMUKeyEvent(false),
supportsSetDesktopSize(false), supportsFence(false),
supportsContinuousUpdates(false),
- width_(0), height_(0), name_(0),
+ width_(0), height_(0),
ledState_(ledUnknown)
{
setName("");
ServerParams::~ServerParams()
{
- delete [] name_;
delete cursor_;
}
void ServerParams::setName(const char* name)
{
- delete [] name_;
- name_ = strDup(name);
+ name_ = name;
}
void ServerParams::setCursor(const Cursor& other)
#ifndef __RFB_SERVERPARAMS_H__
#define __RFB_SERVERPARAMS_H__
+#include <string>
+
#include <rfb/Cursor.h>
#include <rfb/PixelFormat.h>
#include <rfb/ScreenSet.h>
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_; }
ScreenSet screenLayout_;
PixelFormat pf_;
- char* name_;
+ std::string name_;
Cursor* cursor_;
unsigned int ledState_;
uint32_t clipFlags;
return indices;
}
- valid = parseIndices(value, &configIndices);
+ valid = parseIndices(value.c_str(), &configIndices);
if (!valid) {
return indices;
}
#include <os/os.h>
#include <rfb/Exception.h>
#include <rfb/LogWriter.h>
-#include <rfb/util.h>
#include "fltk/layout.h"
#include "ServerDialog.h"
Fl_Button *button;
Fl_Box *divider;
- usedDir = NULL;
-
x = OUTER_MARGIN;
y = OUTER_MARGIN;
ServerDialog::~ServerDialog()
{
- if (usedDir)
- free(usedDir);
}
{
ServerDialog *dialog = (ServerDialog*)data;
- if (!dialog->usedDir)
- dialog->usedDir = strDup(os::getuserhomedir());
+ if (dialog->usedDir.empty())
+ dialog->usedDir = os::getuserhomedir();
- Fl_File_Chooser* file_chooser = new Fl_File_Chooser(dialog->usedDir, _("TigerVNC configuration (*.tigervnc)"),
+ Fl_File_Chooser* file_chooser = new Fl_File_Chooser(dialog->usedDir.c_str(),
+ _("TigerVNC configuration (*.tigervnc)"),
0, _("Select a TigerVNC configuration file"));
file_chooser->preview(0);
file_chooser->previewButton->hide();
ServerDialog *dialog = (ServerDialog*)data;
const char* servername = dialog->serverName->value();
const char* filename;
- if (!dialog->usedDir)
- dialog->usedDir = strDup(os::getuserhomedir());
+ if (dialog->usedDir.empty())
+ dialog->usedDir = os::getuserhomedir();
- Fl_File_Chooser* file_chooser = new Fl_File_Chooser(dialog->usedDir, _("TigerVNC configuration (*.tigervnc)"),
+ Fl_File_Chooser* file_chooser = new Fl_File_Chooser(dialog->usedDir.c_str(),
+ _("TigerVNC configuration (*.tigervnc)"),
2, _("Save the TigerVNC configuration to file"));
file_chooser->preview(0);
void ServerDialog::updateUsedDir(const char* filename)
{
char * name = strdup(filename);
- usedDir = strdup(dirname(name));
+ usedDir = dirname(name);
free(name);
}
protected:
Fl_Input_Choice *serverName;
std::vector<std::string> serverHistory;
- char *usedDir;
+ std::string usedDir;
};
#endif
#define __RFB_LISTCONNINFO_INCLUDED__
#include <list>
-
-#include <rfb/util.h>
+#include <string>
namespace winvnc {
void addInfo(void* Conn, const char* IP, int Status) {
conn.push_back(Conn);
- IP_address.push_back(rfb::strDup(IP));
+ IP_address.push_back(IP);
status.push_back(Status);
}
void iGetCharInfo(const char* buf[2]) {
- buf[0] = *Ii;
+ buf[0] = Ii->c_str();
switch (*si) {
case 0:
buf[1] = "Full control";
private:
std::list<void*> conn;
- std::list<char*> IP_address;
+ std::list<std::string> IP_address;
std::list<int> status;
std::list<void*>::iterator ci;
- std::list<char*>::iterator Ii;
+ std::list<std::string>::iterator Ii;
std::list<int>::iterator si;
bool disableClients;
};