refactor: use std::string in place of String

basedon: https://github.com/debauchee/barrier/pull/709
This commit is contained in:
sithlord48
2025-01-05 19:55:07 -05:00
committed by Nick Bolton
parent 42a17726d9
commit 3991e0c1a1
223 changed files with 1415 additions and 1385 deletions

View File

@ -211,7 +211,7 @@ void MSWindowsClientTaskBarReceiver::copyLog() const
{
if (m_logBuffer != NULL) {
// collect log buffer
String data;
std::string data;
for (BufferedLogOutputter::const_iterator index = m_logBuffer->begin(); index != m_logBuffer->end(); ++index) {
data += *index;
data += "\n";

View File

@ -238,7 +238,7 @@ void MSWindowsServerTaskBarReceiver::copyLog() const
{
if (m_logBuffer != NULL) {
// collect log buffer
String data;
std::string data;
for (BufferedLogOutputter::const_iterator index = m_logBuffer->begin(); index != m_logBuffer->end(); ++index) {
data += *index;
data += "\n";

View File

@ -18,8 +18,8 @@
#pragma once
#include "base/String.h"
#include "common/IInterface.h"
#include <string>
//! Interface for architecture dependent daemonizing
/*!

View File

@ -18,7 +18,6 @@
#pragma once
#include "base/String.h"
#include "common/IInterface.h"
#include "common/stdstring.h"
@ -93,12 +92,12 @@ public:
/*
Returns the user's profile directory.
*/
virtual void setProfileDirectory(const String &s) = 0;
virtual void setProfileDirectory(const std::string &s) = 0;
//@}
//! Set the user's plugin directory
/*
Returns the user's plugin directory.
*/
virtual void setPluginDirectory(const String &s) = 0;
virtual void setPluginDirectory(const std::string &s) = 0;
};

View File

@ -18,9 +18,10 @@
#pragma once
#include "base/String.h"
#include "common/IInterface.h"
#include <string>
class IScreen;
class INode;
@ -91,7 +92,7 @@ public:
*/
virtual std::string getToolTip() const = 0;
virtual void updateStatus(INode *, const String &errorMsg) = 0;
virtual void updateStatus(INode *, const std::string &errorMsg) = 0;
virtual void cleanup()
{

View File

@ -146,12 +146,12 @@ std::string ArchFileUnix::concatPath(const std::string &prefix, const std::strin
return path;
}
void ArchFileUnix::setProfileDirectory(const String &s)
void ArchFileUnix::setProfileDirectory(const std::string &s)
{
m_profileDirectory = s;
}
void ArchFileUnix::setPluginDirectory(const String &s)
void ArchFileUnix::setPluginDirectory(const std::string &s)
{
m_pluginDirectory = s;
}

View File

@ -38,10 +38,10 @@ public:
virtual std::string getPluginDirectory();
virtual std::string getProfileDirectory();
virtual std::string concatPath(const std::string &prefix, const std::string &suffix);
virtual void setProfileDirectory(const String &s);
virtual void setPluginDirectory(const String &s);
virtual void setProfileDirectory(const std::string &s);
virtual void setPluginDirectory(const std::string &s);
private:
String m_profileDirectory;
String m_pluginDirectory;
std::string m_profileDirectory;
std::string m_pluginDirectory;
};

View File

@ -143,7 +143,7 @@ std::string ArchFileWindows::getPluginDirectory()
std::string ArchFileWindows::getProfileDirectory()
{
String dir;
std::string dir;
if (!m_profileDirectory.empty()) {
dir = m_profileDirectory;
} else {
@ -173,12 +173,12 @@ std::string ArchFileWindows::concatPath(const std::string &prefix, const std::st
return path;
}
void ArchFileWindows::setProfileDirectory(const String &s)
void ArchFileWindows::setProfileDirectory(const std::string &s)
{
m_profileDirectory = s;
}
void ArchFileWindows::setPluginDirectory(const String &s)
void ArchFileWindows::setPluginDirectory(const std::string &s)
{
m_pluginDirectory = s;
}

View File

@ -38,10 +38,10 @@ public:
virtual std::string getPluginDirectory();
virtual std::string getProfileDirectory();
virtual std::string concatPath(const std::string &prefix, const std::string &suffix);
virtual void setProfileDirectory(const String &s);
virtual void setPluginDirectory(const String &s);
virtual void setProfileDirectory(const std::string &s);
virtual void setPluginDirectory(const std::string &s);
private:
String m_profileDirectory;
String m_pluginDirectory;
std::string m_profileDirectory;
std::string m_pluginDirectory;
};

View File

@ -384,7 +384,7 @@ void ArchMiscWindows::wakeupDisplay()
bool ArchMiscWindows::wasLaunchedAsService()
{
String name;
std::string name;
if (!getParentProcessName(name)) {
LOG((CLOG_ERR "cannot determine if process was launched as service"));
return false;
@ -393,7 +393,7 @@ bool ArchMiscWindows::wasLaunchedAsService()
return (name == SERVICE_LAUNCHER);
}
bool ArchMiscWindows::getParentProcessName(String &name)
bool ArchMiscWindows::getParentProcessName(std::string &name)
{
PROCESSENTRY32 parentEntry;
if (!getParentProcessEntry(parentEntry)) {

View File

@ -18,7 +18,6 @@
#pragma once
#include "base/String.h"
#include "common/stdset.h"
#include "common/stdstring.h"
@ -164,7 +163,7 @@ public:
static bool wasLaunchedAsService();
//! Returns true if we got the parent process name.
static bool getParentProcessName(String &name);
static bool getParentProcessName(std::string &name);
static HINSTANCE instanceWin32();

View File

@ -510,7 +510,7 @@ double EventQueue::getNextTimerTimeout() const
return m_timerQueue.top();
}
Event::Type EventQueue::getRegisteredType(const String &name) const
Event::Type EventQueue::getRegisteredType(const std::string &name) const
{
NameMap::const_iterator found = m_nameMap.find(name);
if (found != m_nameMap.end())

View File

@ -63,7 +63,7 @@ public:
virtual bool isEmpty() const;
virtual IEventJob *getHandler(Event::Type type, void *target) const;
virtual const char *getTypeName(Event::Type type);
virtual Event::Type getRegisteredType(const String &name) const;
virtual Event::Type getRegisteredType(const std::string &name) const;
void *getSystemTarget();
virtual void waitForReady() const;
@ -107,7 +107,7 @@ private:
using EventTable = std::map<UInt32, Event>;
using EventIDList = std::vector<UInt32>;
using TypeMap = std::map<Event::Type, const char *>;
using NameMap = std::map<String, Event::Type>;
using NameMap = std::map<std::string, Event::Type>;
using TypeHandlerTable = std::map<Event::Type, IEventJob *>;
using HandlerTable = std::map<void *, TypeHandlerTable>;

View File

@ -19,8 +19,8 @@
#pragma once
#include "base/Event.h"
#include "base/String.h"
#include "common/IInterface.h"
#include <string>
class IEventJob;
class IEventQueueBuffer;
@ -211,7 +211,7 @@ public:
/*!
Returns the registered type for an event for a given name.
*/
virtual Event::Type getRegisteredType(const String &name) const = 0;
virtual Event::Type getRegisteredType(const std::string &name) const = 0;
//! Get the system event type target
/*!

View File

@ -26,7 +26,7 @@ namespace filesystem {
#ifdef SYSAPI_WIN32
std::wstring path(const String &filePath)
std::wstring path(const std::string &filePath)
{
std::wstring result;
@ -40,7 +40,7 @@ std::wstring path(const String &filePath)
}
#else
std::string path(const String &filePath)
std::string path(const std::string &filePath)
{
return filePath;
}

View File

@ -16,16 +16,17 @@
*/
#pragma once
#include "String.h"
#include <common/common.h>
#include <string>
namespace deskflow {
namespace filesystem {
#ifdef SYSAPI_WIN32
std::wstring path(const String &filePath);
std::wstring path(const std::string &filePath);
#else
std::string path(const String &filePath);
std::string path(const std::string &filePath);
#endif
} // namespace filesystem

View File

@ -30,20 +30,21 @@
#include <iomanip>
#include <sstream>
#include <stdio.h>
#include <string>
namespace deskflow {
namespace string {
String format(const char *fmt, ...)
std::string format(const char *fmt, ...)
{
va_list args;
va_start(args, fmt);
String result = vformat(fmt, args);
std::string result = vformat(fmt, args);
va_end(args);
return result;
}
String vformat(const char *fmt, va_list args)
std::string vformat(const char *fmt, va_list args)
{
// find highest indexed substitution and the locations of substitutions
std::vector<size_t> pos;
@ -108,7 +109,7 @@ String vformat(const char *fmt, va_list args)
}
// substitute
String result;
std::string result;
result.reserve(resultLength);
size_t src = 0;
for (int i = 0; i < n; ++i) {
@ -121,12 +122,12 @@ String vformat(const char *fmt, va_list args)
return result;
}
String sprintf(const char *fmt, ...)
std::string sprintf(const char *fmt, ...)
{
char tmp[1024];
char *buffer = tmp;
int len = (int)(sizeof(tmp) / sizeof(tmp[0]));
String result;
std::string result;
while (buffer != NULL) {
// try printing into the buffer
va_list args;
@ -156,27 +157,27 @@ String sprintf(const char *fmt, ...)
return result;
}
void findReplaceAll(String &subject, const String &find, const String &replace)
void findReplaceAll(std::string &subject, const std::string &find, const std::string &replace)
{
size_t pos = 0;
while ((pos = subject.find(find, pos)) != String::npos) {
while ((pos = subject.find(find, pos)) != std::string::npos) {
subject.replace(pos, find.length(), replace);
pos += replace.length();
}
}
String removeFileExt(String filename)
std::string removeFileExt(std::string filename)
{
size_t dot = filename.find_last_of('.');
if (dot == String::npos) {
if (dot == std::string::npos) {
return filename;
}
return filename.substr(0, dot);
}
void toHex(String &subject, int width, const char fill)
void toHex(std::string &subject, int width, const char fill)
{
std::stringstream ss;
ss << std::hex;
@ -187,24 +188,24 @@ void toHex(String &subject, int width, const char fill)
subject = ss.str();
}
void uppercase(String &subject)
void uppercase(std::string &subject)
{
std::transform(subject.begin(), subject.end(), subject.begin(), ::toupper);
}
void removeChar(String &subject, const char c)
void removeChar(std::string &subject, const char c)
{
subject.erase(std::remove(subject.begin(), subject.end(), c), subject.end());
}
String sizeTypeToString(size_t n)
std::string sizeTypeToString(size_t n)
{
std::stringstream ss;
ss << n;
return ss.str();
}
size_t stringToSizeType(String string)
size_t stringToSizeType(std::string string)
{
std::istringstream iss(string);
size_t value;
@ -212,13 +213,13 @@ size_t stringToSizeType(String string)
return value;
}
std::vector<String> splitString(String string, const char c)
std::vector<std::string> splitString(std::string string, const char c)
{
std::vector<String> results;
std::vector<std::string> results;
size_t head = 0;
size_t separator = string.find(c);
while (separator != String::npos) {
while (separator != std::string::npos) {
if (head != separator) {
results.push_back(string.substr(head, separator - head));
}
@ -237,31 +238,31 @@ std::vector<String> splitString(String string, const char c)
// CaselessCmp
//
bool CaselessCmp::cmpEqual(const String::value_type &a, const String::value_type &b)
bool CaselessCmp::operator()(const std::string &a, const std::string &b) const
{
// should use std::tolower but not in all versions of libstdc++ have it
return tolower(a) == tolower(b);
return less(a, b);
}
bool CaselessCmp::cmpLess(const String::value_type &a, const String::value_type &b)
bool CaselessCmp::less(const std::string &a, const std::string &b)
{
return std::lexicographical_compare(a.begin(), a.end(), b.begin(), b.end(), &deskflow::string::CaselessCmp::cmpLess);
}
bool CaselessCmp::equal(const std::string &a, const std::string &b)
{
return !(less(a, b) || less(b, a));
}
bool CaselessCmp::cmpLess(const std::string::value_type &a, const std::string::value_type &b)
{
// should use std::tolower but not in all versions of libstdc++ have it
return tolower(a) < tolower(b);
}
bool CaselessCmp::less(const String &a, const String &b)
bool CaselessCmp::cmpEqual(const std::string::value_type &a, const std::string::value_type &b)
{
return std::lexicographical_compare(a.begin(), a.end(), b.begin(), b.end(), &deskflow::string::CaselessCmp::cmpLess);
}
bool CaselessCmp::equal(const String &a, const String &b)
{
return !(less(a, b) || less(b, a));
}
bool CaselessCmp::operator()(const String &a, const String &b) const
{
return less(a, b);
// should use std::tolower but not in all versions of libstdc++ have it
return tolower(a) == tolower(b);
}
} // namespace string

View File

@ -24,12 +24,9 @@
#include <stdarg.h>
#include <vector>
// use standard C++ string class for our string class
using String = std::string;
namespace deskflow {
//! String utilities
//! std::string utilities
/*!
Provides functions for string manipulation.
*/
@ -45,67 +42,67 @@ characters and conversion specifications introduced by `\%':
All arguments in the variable list are const char*. Positional
elements are indexed from 1.
*/
String format(const char *fmt, ...);
std::string format(const char *fmt, ...);
//! Format positional arguments
/*!
Same as format() except takes va_list.
*/
String vformat(const char *fmt, va_list);
std::string vformat(const char *fmt, va_list);
//! Print a string using sprintf-style formatting
/*!
Equivalent to sprintf() except the result is returned as a String.
*/
String sprintf(const char *fmt, ...);
std::string sprintf(const char *fmt, ...);
//! Find and replace all
/*!
Finds \c find inside \c subject and replaces it with \c replace
*/
void findReplaceAll(String &subject, const String &find, const String &replace);
void findReplaceAll(std::string &subject, const std::string &find, const std::string &replace);
//! Remove file extension
/*!
Finds the last dot and remove all characters from the dot to the end
*/
String removeFileExt(String filename);
std::string removeFileExt(std::string filename);
//! Convert into hexdecimal
/*!
Convert each character in \c subject into hexdecimal form with \c width
*/
void toHex(String &subject, int width, const char fill = '0');
void toHex(std::string &subject, int width, const char fill = '0');
//! Convert to all uppercase
/*!
Convert each character in \c subject to uppercase
*/
void uppercase(String &subject);
void uppercase(std::string &subject);
//! Remove all specific char in suject
/*!
Remove all specific \c c in \c suject
*/
void removeChar(String &subject, const char c);
void removeChar(std::string &subject, const char c);
//! Convert a size type to a string
/*!
Convert an size type to a string
*/
String sizeTypeToString(size_t n);
std::string sizeTypeToString(size_t n);
//! Convert a string to a size type
/*!
Convert an a \c string to an size type
*/
size_t stringToSizeType(String string);
size_t stringToSizeType(std::string string);
//! Split a string into substrings
/*!
Split a \c string that separated by a \c c into substrings
*/
std::vector<String> splitString(String string, const char c);
std::vector<std::string> splitString(std::string string, const char c);
//! Case-insensitive comparisons
/*!
@ -115,19 +112,19 @@ class CaselessCmp
{
public:
//! Same as less()
bool operator()(const String &a, const String &b) const;
bool operator()(const std::string &a, const std::string &b) const;
//! Returns true iff \c a is lexicographically less than \c b
static bool less(const String &a, const String &b);
static bool less(const std::string &a, const std::string &b);
//! Returns true iff \c a is lexicographically equal to \c b
static bool equal(const String &a, const String &b);
static bool equal(const std::string &a, const std::string &b);
//! Returns true iff \c a is lexicographically less than \c b
static bool cmpLess(const String::value_type &a, const String::value_type &b);
static bool cmpLess(const std::string::value_type &a, const std::string::value_type &b);
//! Returns true iff \c a is lexicographically equal to \c b
static bool cmpEqual(const String::value_type &a, const String::value_type &b);
static bool cmpEqual(const std::string::value_type &a, const std::string::value_type &b);
};
} // namespace string

View File

@ -84,7 +84,7 @@ inline static void setError(bool *errors)
UInt32 Unicode::s_invalid = 0x0000ffff;
UInt32 Unicode::s_replacement = 0x0000fffd;
bool Unicode::isUTF8(const String &src)
bool Unicode::isUTF8(const std::string &src)
{
// convert and test each character
const UInt8 *data = reinterpret_cast<const UInt8 *>(src.c_str());
@ -96,14 +96,14 @@ bool Unicode::isUTF8(const String &src)
return true;
}
String Unicode::UTF8ToUCS2(const String &src, bool *errors)
std::string Unicode::UTF8ToUCS2(const std::string &src, bool *errors)
{
// default to success
resetError(errors);
// get size of input string and reserve some space in output
UInt32 n = (UInt32)src.size();
String dst;
std::string dst;
dst.reserve(2 * n);
// convert each character
@ -123,14 +123,14 @@ String Unicode::UTF8ToUCS2(const String &src, bool *errors)
return dst;
}
String Unicode::UTF8ToUCS4(const String &src, bool *errors)
std::string Unicode::UTF8ToUCS4(const std::string &src, bool *errors)
{
// default to success
resetError(errors);
// get size of input string and reserve some space in output
UInt32 n = (UInt32)src.size();
String dst;
std::string dst;
dst.reserve(4 * n);
// convert each character
@ -146,14 +146,14 @@ String Unicode::UTF8ToUCS4(const String &src, bool *errors)
return dst;
}
String Unicode::UTF8ToUTF16(const String &src, bool *errors)
std::string Unicode::UTF8ToUTF16(const std::string &src, bool *errors)
{
// default to success
resetError(errors);
// get size of input string and reserve some space in output
UInt32 n = (UInt32)src.size();
String dst;
std::string dst;
dst.reserve(2 * n);
// convert each character
@ -181,14 +181,14 @@ String Unicode::UTF8ToUTF16(const String &src, bool *errors)
return dst;
}
String Unicode::UTF8ToUTF32(const String &src, bool *errors)
std::string Unicode::UTF8ToUTF32(const std::string &src, bool *errors)
{
// default to success
resetError(errors);
// get size of input string and reserve some space in output
UInt32 n = (UInt32)src.size();
String dst;
std::string dst;
dst.reserve(4 * n);
// convert each character
@ -207,7 +207,7 @@ String Unicode::UTF8ToUTF32(const String &src, bool *errors)
return dst;
}
String Unicode::UTF8ToText(const String &src, bool *errors)
std::string Unicode::UTF8ToText(const std::string &src, bool *errors)
{
// default to success
resetError(errors);
@ -220,7 +220,7 @@ String Unicode::UTF8ToText(const String &src, bool *errors)
int len = ARCH->convStringWCToMB(NULL, tmp, size, errors);
char *mbs = new char[len + 1];
ARCH->convStringWCToMB(mbs, tmp, size, errors);
String text(mbs, len);
std::string text(mbs, len);
// clean up
delete[] mbs;
@ -229,7 +229,7 @@ String Unicode::UTF8ToText(const String &src, bool *errors)
return text;
}
String Unicode::UCS2ToUTF8(const String &src, bool *errors)
std::string Unicode::UCS2ToUTF8(const std::string &src, bool *errors)
{
// default to success
resetError(errors);
@ -239,7 +239,7 @@ String Unicode::UCS2ToUTF8(const String &src, bool *errors)
return doUCS2ToUTF8(reinterpret_cast<const UInt8 *>(src.data()), n, errors);
}
String Unicode::UCS4ToUTF8(const String &src, bool *errors)
std::string Unicode::UCS4ToUTF8(const std::string &src, bool *errors)
{
// default to success
resetError(errors);
@ -249,7 +249,7 @@ String Unicode::UCS4ToUTF8(const String &src, bool *errors)
return doUCS4ToUTF8(reinterpret_cast<const UInt8 *>(src.data()), n, errors);
}
String Unicode::UTF16ToUTF8(const String &src, bool *errors)
std::string Unicode::UTF16ToUTF8(const std::string &src, bool *errors)
{
// default to success
resetError(errors);
@ -259,7 +259,7 @@ String Unicode::UTF16ToUTF8(const String &src, bool *errors)
return doUTF16ToUTF8(reinterpret_cast<const UInt8 *>(src.data()), n, errors);
}
String Unicode::UTF32ToUTF8(const String &src, bool *errors)
std::string Unicode::UTF32ToUTF8(const std::string &src, bool *errors)
{
// default to success
resetError(errors);
@ -269,7 +269,7 @@ String Unicode::UTF32ToUTF8(const String &src, bool *errors)
return doUTF32ToUTF8(reinterpret_cast<const UInt8 *>(src.data()), n, errors);
}
String Unicode::textToUTF8(const String &src, bool *errors, IArchString::EWideCharEncoding encoding)
std::string Unicode::textToUTF8(const std::string &src, bool *errors, IArchString::EWideCharEncoding encoding)
{
// default to success
resetError(errors);
@ -281,7 +281,7 @@ String Unicode::textToUTF8(const String &src, bool *errors, IArchString::EWideCh
ARCH->convStringMBToWC(wcs, src.c_str(), n, errors);
// convert to UTF8
String utf8 = wideCharToUTF8(wcs, len, errors, encoding);
std::string utf8 = wideCharToUTF8(wcs, len, errors, encoding);
// clean up
delete[] wcs;
@ -289,10 +289,10 @@ String Unicode::textToUTF8(const String &src, bool *errors, IArchString::EWideCh
return utf8;
}
wchar_t *Unicode::UTF8ToWideChar(const String &src, UInt32 &size, bool *errors)
wchar_t *Unicode::UTF8ToWideChar(const std::string &src, UInt32 &size, bool *errors)
{
// convert to platform's wide character encoding
String tmp;
std::string tmp;
switch (ARCH->getWideCharEncoding()) {
case IArchString::kUCS2:
tmp = UTF8ToUCS2(src, errors);
@ -324,7 +324,8 @@ wchar_t *Unicode::UTF8ToWideChar(const String &src, UInt32 &size, bool *errors)
return dst;
}
String Unicode::wideCharToUTF8(const wchar_t *src, UInt32 size, bool *errors, IArchString::EWideCharEncoding encoding)
std::string
Unicode::wideCharToUTF8(const wchar_t *src, UInt32 size, bool *errors, IArchString::EWideCharEncoding encoding)
{
if (encoding == IArchString::kPlatformDetermined) {
encoding = ARCH->getWideCharEncoding();
@ -347,14 +348,14 @@ String Unicode::wideCharToUTF8(const wchar_t *src, UInt32 size, bool *errors, IA
default:
assert(0 && "unknown wide character encoding");
return String();
return std::string();
}
}
String Unicode::doUCS2ToUTF8(const UInt8 *data, UInt32 n, bool *errors)
std::string Unicode::doUCS2ToUTF8(const UInt8 *data, UInt32 n, bool *errors)
{
// make some space
String dst;
std::string dst;
dst.reserve(n);
// check if first character is 0xfffe or 0xfeff
@ -387,10 +388,10 @@ String Unicode::doUCS2ToUTF8(const UInt8 *data, UInt32 n, bool *errors)
return dst;
}
String Unicode::doUCS4ToUTF8(const UInt8 *data, UInt32 n, bool *errors)
std::string Unicode::doUCS4ToUTF8(const UInt8 *data, UInt32 n, bool *errors)
{
// make some space
String dst;
std::string dst;
dst.reserve(n);
// check if first character is 0xfffe or 0xfeff
@ -423,10 +424,10 @@ String Unicode::doUCS4ToUTF8(const UInt8 *data, UInt32 n, bool *errors)
return dst;
}
String Unicode::doUTF16ToUTF8(const UInt8 *data, UInt32 n, bool *errors)
std::string Unicode::doUTF16ToUTF8(const UInt8 *data, UInt32 n, bool *errors)
{
// make some space
String dst;
std::string dst;
dst.reserve(n);
// check if first character is 0xfffe or 0xfeff
@ -482,10 +483,10 @@ String Unicode::doUTF16ToUTF8(const UInt8 *data, UInt32 n, bool *errors)
return dst;
}
String Unicode::doUTF32ToUTF8(const UInt8 *data, UInt32 n, bool *errors)
std::string Unicode::doUTF32ToUTF8(const UInt8 *data, UInt32 n, bool *errors)
{
// make some space
String dst;
std::string dst;
dst.reserve(n);
// check if first character is 0xfffe or 0xfeff
@ -672,7 +673,7 @@ UInt32 Unicode::fromUTF8(const UInt8 *&data, UInt32 &n)
return c;
}
void Unicode::toUTF8(String &dst, UInt32 c, bool *errors)
void Unicode::toUTF8(std::string &dst, UInt32 c, bool *errors)
{
UInt8 data[6];

View File

@ -19,8 +19,8 @@
#pragma once
#include "arch/IArchString.h"
#include "base/String.h"
#include "common/basic_types.h"
#include <string>
//! Unicode utility functions
/*!
@ -38,7 +38,7 @@ public:
Returns true iff the string contains a valid sequence of UTF-8
encoded characters.
*/
static bool isUTF8(const String &);
static bool isUTF8(const std::string &);
//! Convert from UTF-8 to UCS-2 encoding
/*!
@ -46,7 +46,7 @@ public:
is set to true iff any character could not be encoded in UCS-2.
Decoding errors do not set *errors.
*/
static String UTF8ToUCS2(const String &, bool *errors = NULL);
static std::string UTF8ToUCS2(const std::string &, bool *errors = NULL);
//! Convert from UTF-8 to UCS-4 encoding
/*!
@ -54,7 +54,7 @@ public:
is set to true iff any character could not be encoded in UCS-4.
Decoding errors do not set *errors.
*/
static String UTF8ToUCS4(const String &, bool *errors = NULL);
static std::string UTF8ToUCS4(const std::string &, bool *errors = NULL);
//! Convert from UTF-8 to UTF-16 encoding
/*!
@ -62,7 +62,7 @@ public:
is set to true iff any character could not be encoded in UTF-16.
Decoding errors do not set *errors.
*/
static String UTF8ToUTF16(const String &, bool *errors = NULL);
static std::string UTF8ToUTF16(const std::string &, bool *errors = NULL);
//! Convert from UTF-8 to UTF-32 encoding
/*!
@ -70,7 +70,7 @@ public:
is set to true iff any character could not be encoded in UTF-32.
Decoding errors do not set *errors.
*/
static String UTF8ToUTF32(const String &, bool *errors = NULL);
static std::string UTF8ToUTF32(const std::string &, bool *errors = NULL);
//! Convert from UTF-8 to the current locale encoding
/*!
@ -78,43 +78,44 @@ public:
NULL then *errors is set to true iff any character could not be encoded.
Decoding errors do not set *errors.
*/
static String UTF8ToText(const String &, bool *errors = NULL);
static std::string UTF8ToText(const std::string &, bool *errors = NULL);
//! Convert from UCS-2 to UTF-8
/*!
Convert from UCS-2 to UTF-8. If errors is not NULL then *errors is
set to true iff any character could not be decoded.
*/
static String UCS2ToUTF8(const String &, bool *errors = NULL);
static std::string UCS2ToUTF8(const std::string &, bool *errors = NULL);
//! Convert from UCS-4 to UTF-8
/*!
Convert from UCS-4 to UTF-8. If errors is not NULL then *errors is
set to true iff any character could not be decoded.
*/
static String UCS4ToUTF8(const String &, bool *errors = NULL);
static std::string UCS4ToUTF8(const std::string &, bool *errors = NULL);
//! Convert from UTF-16 to UTF-8
/*!
Convert from UTF-16 to UTF-8. If errors is not NULL then *errors is
set to true iff any character could not be decoded.
*/
static String UTF16ToUTF8(const String &, bool *errors = NULL);
static std::string UTF16ToUTF8(const std::string &, bool *errors = NULL);
//! Convert from UTF-32 to UTF-8
/*!
Convert from UTF-32 to UTF-8. If errors is not NULL then *errors is
set to true iff any character could not be decoded.
*/
static String UTF32ToUTF8(const String &, bool *errors = NULL);
static std::string UTF32ToUTF8(const std::string &, bool *errors = NULL);
//! Convert from the current locale encoding to UTF-8
/*!
Convert from the current locale encoding to UTF-8. If errors is not
NULL then *errors is set to true iff any character could not be decoded.
*/
static String textToUTF8(
const String &, bool *errors = nullptr, IArchString::EWideCharEncoding encoding = IArchString::kPlatformDetermined
static std::string textToUTF8(
const std::string &, bool *errors = nullptr,
IArchString::EWideCharEncoding encoding = IArchString::kPlatformDetermined
);
//@}
@ -124,24 +125,24 @@ private:
// to the platform). caller must delete[] the returned string. the
// string is *not* nul terminated; the length (in characters) is
// returned in size.
static wchar_t *UTF8ToWideChar(const String &, UInt32 &size, bool *errors);
static wchar_t *UTF8ToWideChar(const std::string &, UInt32 &size, bool *errors);
// convert nul terminated wchar_t string (in platform's native
// encoding) to UTF8.
static String wideCharToUTF8(
static std::string wideCharToUTF8(
const wchar_t *, UInt32 size, bool *errors,
IArchString::EWideCharEncoding encoding = IArchString::kPlatformDetermined
);
// internal conversion to UTF8
static String doUCS2ToUTF8(const UInt8 *src, UInt32 n, bool *errors);
static String doUCS4ToUTF8(const UInt8 *src, UInt32 n, bool *errors);
static String doUTF16ToUTF8(const UInt8 *src, UInt32 n, bool *errors);
static String doUTF32ToUTF8(const UInt8 *src, UInt32 n, bool *errors);
static std::string doUCS2ToUTF8(const UInt8 *src, UInt32 n, bool *errors);
static std::string doUCS4ToUTF8(const UInt8 *src, UInt32 n, bool *errors);
static std::string doUTF16ToUTF8(const UInt8 *src, UInt32 n, bool *errors);
static std::string doUTF32ToUTF8(const UInt8 *src, UInt32 n, bool *errors);
// convert characters to/from UTF8
static UInt32 fromUTF8(const UInt8 *&src, UInt32 &size);
static void toUTF8(String &dst, UInt32 c, bool *errors);
static void toUTF8(std::string &dst, UInt32 c, bool *errors);
private:
static UInt32 s_invalid;

View File

@ -32,7 +32,7 @@ XBase::XBase() : std::runtime_error("")
// do nothing
}
XBase::XBase(const String &msg) : std::runtime_error(msg)
XBase::XBase(const std::string &msg) : std::runtime_error(msg)
{
// do nothing
}
@ -52,13 +52,13 @@ const char *XBase::what() const _NOEXCEPT
return m_what.c_str();
}
String XBase::format(const char * /*id*/, const char *fmt, ...) const throw()
std::string XBase::format(const char * /*id*/, const char *fmt, ...) const throw()
{
// FIXME -- lookup message string using id as an index. set
// fmt to that string if it exists.
// format
String result;
std::string result;
va_list args;
va_start(args, fmt);
try {

View File

@ -18,8 +18,8 @@
#pragma once
#include "base/String.h"
#include "common/stdexcept.h"
#include <string>
//! Exception base class
/*!
@ -31,7 +31,7 @@ public:
//! Use getWhat() as the result of what()
XBase();
//! Use \c msg as the result of what()
XBase(const String &msg);
XBase(const std::string &msg);
virtual ~XBase() _NOEXCEPT;
//! Reason for exception
@ -39,7 +39,7 @@ public:
protected:
//! Get a human readable string describing the exception
virtual String getWhat() const throw()
virtual std::string getWhat() const throw()
{
return "";
}
@ -50,16 +50,16 @@ protected:
no format can be found, then replaces positional parameters in
the format string and returns the result.
*/
virtual String format(const char *id, const char *defaultFormat, ...) const throw();
virtual std::string format(const char *id, const char *defaultFormat, ...) const throw();
private:
mutable String m_what;
mutable std::string m_what;
};
/*!
\def XBASE_SUBCLASS
Convenience macro to subclass from XBase (or a subclass of it),
providing the c'tor taking a const String&. getWhat() is not
providing the c'tor taking a const std::string&. getWhat() is not
declared.
*/
#define XBASE_SUBCLASS(name_, super_) \
@ -69,7 +69,7 @@ declared.
name_() : super_() \
{ \
} \
name_(const String &msg) : super_(msg) \
name_(const std::string &msg) : super_(msg) \
{ \
} \
virtual ~name_() _NOEXCEPT \
@ -80,7 +80,7 @@ declared.
/*!
\def XBASE_SUBCLASS
Convenience macro to subclass from XBase (or a subclass of it),
providing the c'tor taking a const String&. getWhat() must be
providing the c'tor taking a const std::string&. getWhat() must be
implemented.
*/
#define XBASE_SUBCLASS_WHAT(name_, super_) \
@ -90,7 +90,7 @@ implemented.
name_() : super_() \
{ \
} \
name_(const String &msg) : super_(msg) \
name_(const std::string &msg) : super_(msg) \
{ \
} \
virtual ~name_() _NOEXCEPT \
@ -98,13 +98,13 @@ implemented.
} \
\
protected: \
virtual String getWhat() const throw(); \
virtual std::string getWhat() const throw(); \
}
/*!
\def XBASE_SUBCLASS_FORMAT
Convenience macro to subclass from XBase (or a subclass of it),
providing the c'tor taking a const String&. what() is overridden
providing the c'tor taking a const std::string&. what() is overridden
to call getWhat() when first called; getWhat() can format the
error message and can call what() to get the message passed to the
c'tor.
@ -124,7 +124,7 @@ c'tor.
name_() : super_(), m_state(kDone) \
{ \
} \
name_(const String &msg) : super_(msg), m_state(kFirst) \
name_(const std::string &msg) : super_(msg), m_state(kFirst) \
{ \
} \
virtual ~name_() _NOEXCEPT \
@ -146,7 +146,7 @@ c'tor.
} \
\
protected: \
virtual String getWhat() const throw(); \
virtual std::string getWhat() const throw(); \
\
private: \
mutable EState m_state; \

View File

@ -19,6 +19,7 @@
#include "base/log_outputters.h"
#include "arch/Arch.h"
#include "base/Path.h"
#include "base/String.h"
#include "base/TMethodJob.h"
#include <fstream>
@ -205,7 +206,7 @@ bool BufferedLogOutputter::write(ELevel, const char *message)
while (m_buffer.size() >= m_maxBufferSize) {
m_buffer.pop_front();
}
m_buffer.push_back(String(message));
m_buffer.push_back(std::string(message));
return true;
}
@ -246,7 +247,7 @@ bool FileLogOutputter::write(ELevel level, const char *message)
m_handle.close();
if (moveFile) {
String oldLogFilename = deskflow::string::sprintf("%s.1", m_fileName.c_str());
std::string oldLogFilename = deskflow::string::sprintf("%s.1", m_fileName.c_str());
remove(oldLogFilename.c_str());
rename(m_fileName.c_str(), oldLogFilename.c_str());
}

View File

@ -19,13 +19,13 @@
#pragma once
#include "base/ILogOutputter.h"
#include "base/String.h"
#include "common/basic_types.h"
#include "common/stddeque.h"
#include "mt/Thread.h"
#include <fstream>
#include <list>
#include <string>
//! Stop traversing log chain outputter
/*!
@ -137,7 +137,7 @@ This outputter records the last N log messages.
class BufferedLogOutputter : public ILogOutputter
{
private:
using Buffer = std::deque<String>;
using Buffer = std::deque<std::string>;
public:
using const_iterator = Buffer::const_iterator;

View File

@ -57,7 +57,7 @@ using namespace deskflow::client;
//
Client::Client(
IEventQueue *events, const String &name, const NetworkAddress &address, ISocketFactory *socketFactory,
IEventQueue *events, const std::string &name, const NetworkAddress &address, ISocketFactory *socketFactory,
deskflow::Screen *screen, deskflow::ClientArgs const &args
)
: m_mock(false),
@ -299,12 +299,12 @@ void Client::setClipboardDirty(ClipboardID, bool)
assert(0 && "shouldn't be called");
}
void Client::keyDown(KeyID id, KeyModifierMask mask, KeyButton button, const String &lang)
void Client::keyDown(KeyID id, KeyModifierMask mask, KeyButton button, const std::string &lang)
{
m_screen->keyDown(id, mask, button, lang);
}
void Client::keyRepeat(KeyID id, KeyModifierMask mask, SInt32 count, KeyButton button, const String &lang)
void Client::keyRepeat(KeyID id, KeyModifierMask mask, SInt32 count, KeyButton button, const std::string &lang)
{
m_screen->keyRepeat(id, mask, count, button, lang);
}
@ -378,7 +378,7 @@ void Client::setOptions(const OptionsList &options)
m_screen->setOptions(options);
}
String Client::getName() const
std::string Client::getName() const
{
return m_name;
}
@ -402,7 +402,7 @@ void Client::sendClipboard(ClipboardID id)
// check time
if (m_timeClipboard[id] == 0 || clipboard.getTime() != m_timeClipboard[id]) {
// marshall the data
String data = clipboard.marshall();
std::string data = clipboard.marshall();
if (data.size() >= m_maximumClipboardSize * 1024) {
LOG(
(CLOG_NOTE "skipping clipboard transfer because the clipboard"
@ -757,7 +757,7 @@ void Client::writeToDropDirThread(void *)
DropHelper::writeToDir(m_screen->getDropTarget(), m_dragFileList, m_receivedFileData);
}
void Client::dragInfoReceived(UInt32 fileNum, String data)
void Client::dragInfoReceived(UInt32 fileNum, std::string data)
{
// TODO: fix duplicate function from CServer
if (!m_args.m_enableDragDrop) {
@ -798,7 +798,7 @@ void Client::sendFileThread(void *filename)
m_sendFileThread.reset(nullptr);
}
void Client::sendDragInfo(UInt32 fileCount, String &info, size_t size)
void Client::sendDragInfo(UInt32 fileCount, std::string &info, size_t size)
{
m_server->sendDragInfo(fileCount, info.c_str(), size);
}

View File

@ -59,7 +59,7 @@ public:
{
}
bool m_retry;
String m_what;
std::string m_what;
};
public:
@ -69,7 +69,7 @@ public:
to create the socket. \p screen is the local screen.
*/
Client(
IEventQueue *events, const String &name, const NetworkAddress &address, ISocketFactory *socketFactory,
IEventQueue *events, const std::string &name, const NetworkAddress &address, ISocketFactory *socketFactory,
deskflow::Screen *screen, deskflow::ClientArgs const &args
);
Client(Client const &) = delete;
@ -109,13 +109,13 @@ public:
virtual void handshakeComplete();
//! Received drag information
void dragInfoReceived(UInt32 fileNum, String data);
void dragInfoReceived(UInt32 fileNum, std::string data);
//! Create a new thread and use it to send file to Server
void sendFileToServer(const char *filename);
//! Send dragging file information back to server
void sendDragInfo(UInt32 fileCount, String &info, size_t size);
void sendDragInfo(UInt32 fileCount, std::string &info, size_t size);
//@}
//! @name accessors
@ -151,7 +151,7 @@ public:
}
//! Return received file data
String &getReceivedFileData()
std::string &getReceivedFileData()
{
return m_receivedFileData;
}
@ -182,8 +182,8 @@ public:
virtual void setClipboard(ClipboardID, const IClipboard *);
virtual void grabClipboard(ClipboardID);
virtual void setClipboardDirty(ClipboardID, bool);
virtual void keyDown(KeyID, KeyModifierMask, KeyButton, const String &);
virtual void keyRepeat(KeyID, KeyModifierMask, SInt32 count, KeyButton, const String &lang);
virtual void keyDown(KeyID, KeyModifierMask, KeyButton, const std::string &);
virtual void keyRepeat(KeyID, KeyModifierMask, SInt32 count, KeyButton, const std::string &lang);
virtual void keyUp(KeyID, KeyModifierMask, KeyButton);
virtual void mouseDown(ButtonID);
virtual void mouseUp(ButtonID);
@ -193,7 +193,7 @@ public:
virtual void screensaver(bool activate);
virtual void resetOptions();
virtual void setOptions(const OptionsList &options);
virtual String getName() const;
virtual std::string getName() const;
private:
void sendClipboard(ClipboardID);
@ -233,7 +233,7 @@ public:
bool m_mock;
private:
String m_name;
std::string m_name;
NetworkAddress m_serverAddress;
ISocketFactory *m_socketFactory;
deskflow::Screen *m_screen;
@ -247,12 +247,12 @@ private:
bool m_ownClipboard[kClipboardEnd];
bool m_sentClipboard[kClipboardEnd];
IClipboard::Time m_timeClipboard[kClipboardEnd];
String m_dataClipboard[kClipboardEnd];
std::string m_dataClipboard[kClipboardEnd];
IEventQueue *m_events;
std::size_t m_expectedFileSize;
String m_receivedFileData;
std::string m_receivedFileData;
DragFileList m_dragFileList;
String m_dragFileExt;
std::string m_dragFileExt;
using AutoThread = std::unique_ptr<Thread>;
AutoThread m_sendFileThread;
AutoThread m_writeToDropDirThread;

View File

@ -250,7 +250,7 @@ ServerProxy::EResult ServerProxy::parseMessage(const UInt8 *code)
}
else if (memcmp(code, kMsgDKeyDownLang, 4) == 0) {
String lang;
std::string lang;
UInt16 id = 0;
UInt16 mask = 0;
UInt16 button = 0;
@ -382,7 +382,7 @@ bool ServerProxy::onGrabClipboard(ClipboardID id)
void ServerProxy::onClipboardChanged(ClipboardID id, const IClipboard *clipboard)
{
String data = IClipboard::marshall(clipboard);
std::string data = IClipboard::marshall(clipboard);
LOG((CLOG_DEBUG "sending clipboard %d seqnum=%d", id, m_seqNum));
StreamChunker::sendClipboard(data, data.size(), id, m_seqNum, m_events, this);
@ -547,7 +547,7 @@ void ServerProxy::leave()
void ServerProxy::setClipboard()
{
// parse
static String dataCached;
static std::string dataCached;
ClipboardID id;
UInt32 seq;
@ -585,7 +585,7 @@ void ServerProxy::grabClipboard()
m_client->grabClipboard(id);
}
void ServerProxy::keyDown(UInt16 id, UInt16 mask, UInt16 button, const String &lang)
void ServerProxy::keyDown(UInt16 id, UInt16 mask, UInt16 button, const std::string &lang)
{
// get mouse up to date
flushCompressedMouse();
@ -608,7 +608,7 @@ void ServerProxy::keyRepeat()
// parse
UInt16 id, mask, count, button;
String lang;
std::string lang;
ProtocolUtil::readf(m_stream, kMsgDKeyRepeat + 4, &id, &mask, &count, &button, &lang);
LOG(
(CLOG_DEBUG1 "recv key repeat id=0x%08x, mask=0x%04x, count=%d, "
@ -836,7 +836,7 @@ void ServerProxy::fileChunkReceived()
m_events->addEvent(Event(m_events->forFile().fileRecieveCompleted(), m_client));
} else if (result == kStart) {
if (m_client->getDragFileList().size() > 0) {
String filename = m_client->getDragFileList().at(0).getFilename();
std::string filename = m_client->getDragFileList().at(0).getFilename();
LOG((CLOG_DEBUG "start receiving %s", filename.c_str()));
}
}
@ -846,7 +846,7 @@ void ServerProxy::dragInfoReceived()
{
// parse
UInt32 fileNum = 0;
String content;
std::string content;
ProtocolUtil::readf(m_stream, kMsgDDragInfo + 4, &fileNum, &content);
m_client->dragInfoReceived(fileNum, content);
@ -864,13 +864,13 @@ void ServerProxy::fileChunkSending(UInt8 mark, char *data, size_t dataSize)
void ServerProxy::sendDragInfo(UInt32 fileCount, const char *info, size_t size)
{
String data(info, size);
std::string data(info, size);
ProtocolUtil::writef(m_stream, kMsgDDragInfo, fileCount, &data);
}
void ServerProxy::secureInputNotification()
{
String app;
std::string app;
ProtocolUtil::readf(m_stream, kMsgDSecureInputNotification + 4, &app);
// display this notification on the client
@ -891,12 +891,12 @@ void ServerProxy::secureInputNotification()
void ServerProxy::setServerLanguages()
{
String serverLanguages;
std::string serverLanguages;
ProtocolUtil::readf(m_stream, kMsgDLanguageSynchronisation + 4, &serverLanguages);
m_languageManager.setRemoteLanguages(serverLanguages);
}
void ServerProxy::setActiveServerLanguage(const String &language)
void ServerProxy::setActiveServerLanguage(const std::string &language)
{
if (!language.empty() && std::strlen(language.c_str()) > 0) {
if (m_serverLanguage != language) {

View File

@ -20,7 +20,6 @@
#include "base/Event.h"
#include "base/Stopwatch.h"
#include "base/String.h"
#include "deskflow/clipboard_types.h"
#include "deskflow/key_types.h"
#include "deskflow/languages/LanguageManager.h"
@ -108,7 +107,7 @@ private:
void leave();
void setClipboard();
void grabClipboard();
void keyDown(UInt16 id, UInt16 mask, UInt16 button, const String &lang);
void keyDown(UInt16 id, UInt16 mask, UInt16 button, const std::string &lang);
void keyRepeat();
void keyUp();
void mouseDown();
@ -126,7 +125,7 @@ private:
void handleClipboardSendingEvent(const Event &, void *);
void secureInputNotification();
void setServerLanguages();
void setActiveServerLanguage(const String &language);
void setActiveServerLanguage(const std::string &language);
void checkMissedLanguages() const;
private:
@ -151,7 +150,7 @@ private:
MessageParser m_parser;
IEventQueue *m_events;
String m_serverLanguage = "";
std::string m_serverLanguage = "";
bool m_isUserNotifiedAboutLanguageSyncError = false;
deskflow::languages::LanguageManager m_languageManager;
};

View File

@ -319,7 +319,7 @@ void MinimalApp::loadConfig()
{
}
bool MinimalApp::loadConfig(const String &pathname)
bool MinimalApp::loadConfig(const std::string &pathname)
{
return false;
}

View File

@ -20,7 +20,6 @@
#include "base/EventQueue.h"
#include "base/Log.h"
#include "base/String.h"
#include "common/common.h"
#include "deskflow/IApp.h"
#include "ipc/IpcClient.h"
@ -67,7 +66,7 @@ public:
virtual void help() = 0;
virtual void parseArgs(int argc, const char *const *argv) = 0;
virtual void loadConfig() = 0;
virtual bool loadConfig(const String &pathname) = 0;
virtual bool loadConfig(const std::string &pathname) = 0;
virtual const char *daemonInfo() const = 0;
virtual std::string configSection() const = 0;
@ -165,7 +164,7 @@ public:
virtual int foregroundStartup(int argc, char **argv) override;
virtual deskflow::Screen *createScreen() override;
virtual void loadConfig() override;
virtual bool loadConfig(const String &pathname) override;
virtual bool loadConfig(const std::string &pathname) override;
virtual const char *daemonInfo() const override;
virtual const char *daemonName() const override;
virtual void parseArgs(int argc, const char *const *argv) override;

View File

@ -18,7 +18,6 @@
#include "deskflow/ArgParser.h"
#include "base/Log.h"
#include "base/String.h"
#include "deskflow/App.h"
#include "deskflow/ArgsBase.h"
#include "deskflow/ClientArgs.h"
@ -284,7 +283,7 @@ bool ArgParser::isArg(
return false;
}
void ArgParser::splitCommandString(String &command, std::vector<String> &argv)
void ArgParser::splitCommandString(std::string &command, std::vector<std::string> &argv)
{
if (command.empty()) {
return;
@ -297,7 +296,7 @@ void ArgParser::splitCommandString(String &command, std::vector<String> &argv)
size_t startPos = 0;
size_t space = command.find(" ", startPos);
while (space != String::npos) {
while (space != std::string::npos) {
bool ignoreThisSpace = false;
// check if the space is between two double quotes
@ -308,7 +307,7 @@ void ArgParser::splitCommandString(String &command, std::vector<String> &argv)
}
if (!ignoreThisSpace) {
String subString = command.substr(startPos, space - startPos);
std::string subString = command.substr(startPos, space - startPos);
removeDoubleQuotes(subString);
argv.push_back(subString);
@ -323,21 +322,21 @@ void ArgParser::splitCommandString(String &command, std::vector<String> &argv)
}
}
String subString = command.substr(startPos, command.size());
std::string subString = command.substr(startPos, command.size());
removeDoubleQuotes(subString);
argv.push_back(subString);
}
bool ArgParser::searchDoubleQuotes(String &command, size_t &left, size_t &right, size_t startPos)
bool ArgParser::searchDoubleQuotes(std::string &command, size_t &left, size_t &right, size_t startPos)
{
bool result = false;
left = String::npos;
right = String::npos;
left = std::string::npos;
right = std::string::npos;
left = command.find("\"", startPos);
if (left != String::npos) {
if (left != std::string::npos) {
right = command.find("\"", left + 1);
if (right != String::npos) {
if (right != std::string::npos) {
result = true;
}
}
@ -350,7 +349,7 @@ bool ArgParser::searchDoubleQuotes(String &command, size_t &left, size_t &right,
return result;
}
void ArgParser::removeDoubleQuotes(String &arg)
void ArgParser::removeDoubleQuotes(std::string &arg)
{
// if string is surrounded by double quotes, remove them
if (arg[0] == '\"' && arg[arg.size() - 1] == '\"') {
@ -358,7 +357,7 @@ void ArgParser::removeDoubleQuotes(String &arg)
}
}
const char **ArgParser::getArgv(std::vector<String> &argsArray)
const char **ArgParser::getArgv(std::vector<std::string> &argsArray)
{
size_t argc = argsArray.size();
@ -375,18 +374,19 @@ const char **ArgParser::getArgv(std::vector<String> &argsArray)
return argv;
}
String ArgParser::assembleCommand(std::vector<String> &argsArray, String ignoreArg, int parametersRequired)
std::string
ArgParser::assembleCommand(std::vector<std::string> &argsArray, std::string ignoreArg, int parametersRequired)
{
String result;
std::string result;
for (std::vector<String>::iterator it = argsArray.begin(); it != argsArray.end(); ++it) {
for (std::vector<std::string>::iterator it = argsArray.begin(); it != argsArray.end(); ++it) {
if (it->compare(ignoreArg) == 0) {
it = it + parametersRequired;
continue;
}
// if there is a space in this arg, use double quotes surround it
if ((*it).find(" ") != String::npos) {
if ((*it).find(" ") != std::string::npos) {
(*it).insert(0, "\"");
(*it).push_back('\"');
}

View File

@ -17,9 +17,10 @@
#pragma once
#include "base/String.h"
#include "common/stdvector.h"
#include <string>
namespace deskflow {
class ArgsBase;
class ServerArgs;
@ -47,11 +48,12 @@ public:
static bool isArg(
int argi, int argc, const char *const *argv, const char *name1, const char *name2, int minRequiredParameters = 0
);
static void splitCommandString(String &command, std::vector<String> &argv);
static bool searchDoubleQuotes(String &command, size_t &left, size_t &right, size_t startPos = 0);
static void removeDoubleQuotes(String &arg);
static const char **getArgv(std::vector<String> &argsArray);
static String assembleCommand(std::vector<String> &argsArray, String ignoreArg = "", int parametersRequired = 0);
static void splitCommandString(std::string &command, std::vector<std::string> &argv);
static bool searchDoubleQuotes(std::string &command, size_t &left, size_t &right, size_t startPos = 0);
static void removeDoubleQuotes(std::string &arg);
static const char **getArgv(std::vector<std::string> &argsArray);
static std::string
assembleCommand(std::vector<std::string> &argsArray, std::string ignoreArg = "", int parametersRequired = 0);
static deskflow::ArgsBase &argsBase()
{

View File

@ -17,7 +17,7 @@
#pragma once
#include "base/String.h"
#include <string>
namespace deskflow {
@ -65,7 +65,7 @@ public:
const char *m_display = nullptr;
/// @brief The name of the current computer
String m_name;
std::string m_name;
/// @brief Should the app add a tray icon
bool m_disableTray = false;
@ -83,19 +83,19 @@ public:
bool m_shouldExitFail = false;
/// @brief Bind to this address
String m_deskflowAddress;
std::string m_deskflowAddress;
/// @brief Should the connections be TLS encrypted
bool m_enableCrypto = false;
/// @brief The dir to load settings from
String m_profileDirectory;
std::string m_profileDirectory;
/// @brief The dir to load plugins from
String m_pluginDirectory;
std::string m_pluginDirectory;
/// @brief Contains the location of the TLS certificate file
String m_tlsCertFile;
std::string m_tlsCertFile;
/// @brief Stop this computer from sleeping
bool m_preventSleep = false;

View File

@ -23,7 +23,6 @@
#include "base/Event.h"
#include "base/IEventQueue.h"
#include "base/Log.h"
#include "base/String.h"
#include "base/TMethodEventJob.h"
#include "client/Client.h"
#include "common/constants.h"
@ -229,7 +228,7 @@ void ClientApp::updateStatus()
updateStatus("");
}
void ClientApp::updateStatus(const String &msg)
void ClientApp::updateStatus(const std::string &msg)
{
if (m_taskBarReceiver) {
m_taskBarReceiver->updateStatus(m_client, msg);
@ -321,7 +320,7 @@ void ClientApp::handleClientFailed(const Event &e, void *)
if ((++m_lastServerAddressIndex) < m_client->getLastResolvedAddressesCount()) {
std::unique_ptr<Client::FailInfo> info(static_cast<Client::FailInfo *>(e.getData()));
updateStatus(String("Failed to connect to server: ") + info->m_what + " Trying next address...");
updateStatus(std::string("Failed to connect to server: ") + info->m_what + " Trying next address...");
LOG((CLOG_NOTE "failed to connect to server=%s, trying next address", info->m_what.c_str()));
if (!m_suspended) {
scheduleClientRestart(nextRestartTimeout());
@ -336,7 +335,7 @@ void ClientApp::handleClientRefused(const Event &e, void *)
{
std::unique_ptr<Client::FailInfo> info(static_cast<Client::FailInfo *>(e.getData()));
updateStatus(String("Failed to connect to server: ") + info->m_what);
updateStatus(std::string("Failed to connect to server: ") + info->m_what);
if (!args().m_restartable || !info->m_retry) {
LOG((CLOG_ERR "failed to connect to server: %s", info->m_what.c_str()));
m_events->addEvent(Event(Event::kQuit));
@ -359,7 +358,7 @@ void ClientApp::handleClientDisconnected(const Event &, void *)
updateStatus();
}
Client *ClientApp::openClient(const String &name, const NetworkAddress &address, deskflow::Screen *screen)
Client *ClientApp::openClient(const std::string &name, const NetworkAddress &address, deskflow::Screen *screen)
{
Client *client = new Client(m_events, name, address, getSocketFactory(), screen, args());
@ -432,7 +431,7 @@ bool ClientApp::startClient()
} catch (XScreenUnavailable &e) {
LOG((CLOG_WARN "secondary screen unavailable: %s", e.what()));
closeClientScreen(clientScreen);
updateStatus(String("secondary screen unavailable: ") + e.what());
updateStatus(std::string("secondary screen unavailable: ") + e.what());
retryTime = e.getRetryTime();
} catch (XScreenOpenFailure &e) {
LOG((CLOG_CRIT "failed to start client: %s", e.what()));

View File

@ -50,7 +50,7 @@ public:
void loadConfig() override
{
}
bool loadConfig(const String &pathname) override
bool loadConfig(const std::string &pathname) override
{
return false;
}
@ -75,7 +75,7 @@ public:
//
void updateStatus();
void updateStatus(const String &msg);
void updateStatus(const std::string &msg);
void resetRestartTimeout();
double nextRestartTimeout();
void handleScreenError(const Event &, void *);
@ -87,7 +87,7 @@ public:
void handleClientFailed(const Event &e, void *);
void handleClientRefused(const Event &e, void *);
void handleClientDisconnected(const Event &, void *);
Client *openClient(const String &name, const NetworkAddress &address, deskflow::Screen *screen);
Client *openClient(const std::string &name, const NetworkAddress &address, deskflow::Screen *screen);
void closeClient(Client *client);
bool startClient();
void stopClient();

View File

@ -38,7 +38,7 @@ ClientTaskBarReceiver::~ClientTaskBarReceiver()
// do nothing
}
void ClientTaskBarReceiver::updateStatus(Client *client, const String &errorMsg)
void ClientTaskBarReceiver::updateStatus(Client *client, const std::string &errorMsg)
{
{
// update our status
@ -74,7 +74,7 @@ ClientTaskBarReceiver::EState ClientTaskBarReceiver::getStatus() const
return m_state;
}
const String &ClientTaskBarReceiver::getErrorMessage() const
const std::string &ClientTaskBarReceiver::getErrorMessage() const
{
return m_errorMessage;
}

View File

@ -19,7 +19,6 @@
#pragma once
#include "arch/IArchTaskBarReceiver.h"
#include "base/String.h"
#include "base/log_outputters.h"
#include "client/Client.h"
@ -39,9 +38,9 @@ public:
/*!
Determine the status and query required information from the client.
*/
void updateStatus(Client *, const String &errorMsg);
void updateStatus(Client *, const std::string &errorMsg);
void updateStatus(INode *n, const String &errorMsg)
void updateStatus(INode *n, const std::string &errorMsg)
{
updateStatus((Client *)n, errorMsg);
}
@ -75,7 +74,7 @@ protected:
EState getStatus() const;
//! Get error message
const String &getErrorMessage() const;
const std::string &getErrorMessage() const;
//! Quit app
/*!
@ -91,8 +90,8 @@ protected:
private:
EState m_state;
String m_errorMessage;
String m_server;
std::string m_errorMessage;
std::string m_server;
IEventQueue *m_events;
};

View File

@ -53,7 +53,7 @@ bool Clipboard::empty()
return true;
}
void Clipboard::add(EFormat format, const String &data)
void Clipboard::add(EFormat format, const std::string &data)
{
assert(m_open);
assert(m_owner);
@ -90,18 +90,18 @@ bool Clipboard::has(EFormat format) const
return m_added[format];
}
String Clipboard::get(EFormat format) const
std::string Clipboard::get(EFormat format) const
{
assert(m_open);
return m_data[format];
}
void Clipboard::unmarshall(const String &data, Time time)
void Clipboard::unmarshall(const std::string &data, Time time)
{
IClipboard::unmarshall(this, data, time);
}
String Clipboard::marshall() const
std::string Clipboard::marshall() const
{
return IClipboard::marshall(this);
}

View File

@ -38,7 +38,7 @@ public:
Extract marshalled clipboard data and store it in this clipboard.
Sets the clipboard time to \c time.
*/
void unmarshall(const String &data, Time time);
void unmarshall(const std::string &data, Time time);
//@}
//! @name accessors
@ -49,18 +49,18 @@ public:
Merge this clipboard's data into a single buffer that can be later
unmarshalled to restore the clipboard and return the buffer.
*/
String marshall() const;
std::string marshall() const;
//@}
// IClipboard overrides
virtual bool empty();
virtual void add(EFormat, const String &data);
virtual void add(EFormat, const std::string &data);
virtual bool open(Time) const;
virtual void close() const;
virtual Time getTime() const;
virtual bool has(EFormat) const;
virtual String get(EFormat) const;
virtual std::string get(EFormat) const;
private:
mutable bool m_open;
@ -68,5 +68,5 @@ private:
bool m_owner;
Time m_timeOwned;
bool m_added[kNumFormats];
String m_data[kNumFormats];
std::string m_data[kNumFormats];
};

View File

@ -18,6 +18,7 @@
#include "deskflow/ClipboardChunk.h"
#include "base/Log.h"
#include "base/String.h"
#include "deskflow/ProtocolUtil.h"
#include "deskflow/protocol_types.h"
#include "io/IStream.h"
@ -30,7 +31,7 @@ ClipboardChunk::ClipboardChunk(size_t size) : Chunk(size)
m_dataSize = size - CLIPBOARD_CHUNK_META_SIZE;
}
ClipboardChunk *ClipboardChunk::start(ClipboardID id, UInt32 sequence, const String &size)
ClipboardChunk *ClipboardChunk::start(ClipboardID id, UInt32 sequence, const std::string &size)
{
size_t sizeLength = size.size();
ClipboardChunk *start = new ClipboardChunk(sizeLength + CLIPBOARD_CHUNK_META_SIZE);
@ -45,7 +46,7 @@ ClipboardChunk *ClipboardChunk::start(ClipboardID id, UInt32 sequence, const Str
return start;
}
ClipboardChunk *ClipboardChunk::data(ClipboardID id, UInt32 sequence, const String &data)
ClipboardChunk *ClipboardChunk::data(ClipboardID id, UInt32 sequence, const std::string &data)
{
size_t dataSize = data.size();
ClipboardChunk *chunk = new ClipboardChunk(dataSize + CLIPBOARD_CHUNK_META_SIZE);
@ -73,10 +74,10 @@ ClipboardChunk *ClipboardChunk::end(ClipboardID id, UInt32 sequence)
return end;
}
int ClipboardChunk::assemble(deskflow::IStream *stream, String &dataCached, ClipboardID &id, UInt32 &sequence)
int ClipboardChunk::assemble(deskflow::IStream *stream, std::string &dataCached, ClipboardID &id, UInt32 &sequence)
{
UInt8 mark;
String data;
std::string data;
if (!ProtocolUtil::readf(stream, kMsgDClipboard + 4, &id, &sequence, &mark, &data)) {
return kError;
@ -116,7 +117,7 @@ void ClipboardChunk::send(deskflow::IStream *stream, void *data)
UInt32 sequence;
std::memcpy(&sequence, &chunk[1], 4);
UInt8 mark = chunk[5];
String dataChunk(&chunk[6], clipboardData->m_dataSize);
std::string dataChunk(&chunk[6], clipboardData->m_dataSize);
switch (mark) {
case kDataStart:

View File

@ -17,11 +17,12 @@
#pragma once
#include "base/String.h"
#include "common/basic_types.h"
#include "deskflow/Chunk.h"
#include "deskflow/clipboard_types.h"
#include <string>
#define CLIPBOARD_CHUNK_META_SIZE 7
namespace deskflow {
@ -33,11 +34,11 @@ class ClipboardChunk : public Chunk
public:
ClipboardChunk(size_t size);
static ClipboardChunk *start(ClipboardID id, UInt32 sequence, const String &size);
static ClipboardChunk *data(ClipboardID id, UInt32 sequence, const String &data);
static ClipboardChunk *start(ClipboardID id, UInt32 sequence, const std::string &size);
static ClipboardChunk *data(ClipboardID id, UInt32 sequence, const std::string &data);
static ClipboardChunk *end(ClipboardID id, UInt32 sequence);
static int assemble(deskflow::IStream *stream, String &dataCached, ClipboardID &id, UInt32 &sequence);
static int assemble(deskflow::IStream *stream, std::string &dataCached, ClipboardID &id, UInt32 &sequence);
static void send(deskflow::IStream *stream, void *data);

View File

@ -73,13 +73,13 @@ void updateSetting(const IpcMessage &message)
}
}
bool isServerCommandLine(const std::vector<String> &cmd)
bool isServerCommandLine(const std::vector<std::string> &cmd)
{
auto isServer = false;
if (cmd.size() > 1) {
isServer = (cmd[0].find("deskflow-server") != String::npos) ||
(cmd[0].find("deskflow-core") != String::npos && cmd[1] == "server");
isServer = (cmd[0].find("deskflow-server") != std::string::npos) ||
(cmd[0].find("deskflow-core") != std::string::npos && cmd[1] == "server");
}
return isServer;
@ -188,8 +188,8 @@ int DaemonApp::run(int argc, char **argv)
return kExitSuccess;
} catch (XArch &e) {
String message = e.what();
if (uninstall && (message.find("The service has not been started") != String::npos)) {
std::string message = e.what();
if (uninstall && (message.find("The service has not been started") != std::string::npos)) {
// TODO: if we're keeping this use error code instead (what is it?!).
// HACK: this message happens intermittently, not sure where from but
// it's quite misleading for the user. they thing something has gone
@ -246,7 +246,7 @@ void DaemonApp::mainLoop(bool logToFile, bool foreground)
// install the platform event queue to handle service stop events.
m_events->adoptBuffer(new MSWindowsEventQueueBuffer(m_events.get()));
String command = ARCH->setting("Command");
std::string command = ARCH->setting("Command");
bool elevate = ARCH->setting("Elevate") == "1";
if (command != "") {
LOG((CLOG_INFO "using last known command: %s", command.c_str()));
@ -301,7 +301,7 @@ void DaemonApp::handleIpcMessage(const Event &e, void *)
switch (m->type()) {
case IpcMessageType::Command: {
IpcCommandMessage *cm = static_cast<IpcCommandMessage *>(m);
String command = cm->command();
std::string command = cm->command();
// if empty quotes, clear.
if (command == "\"\"") {
@ -312,7 +312,7 @@ void DaemonApp::handleIpcMessage(const Event &e, void *)
LOG((CLOG_DEBUG "daemon got new core command"));
LOG((CLOG_DEBUG2 "new command, elevate=%d command=%s", cm->elevate(), command.c_str()));
std::vector<String> argsArray;
std::vector<std::string> argsArray;
ArgParser::splitCommandString(command, argsArray);
ArgParser argParser(NULL);
const char **argv = argParser.getArgv(argsArray);
@ -327,7 +327,7 @@ void DaemonApp::handleIpcMessage(const Event &e, void *)
}
delete[] argv;
String logLevel(ArgParser::argsBase().m_logFilter);
std::string logLevel(ArgParser::argsBase().m_logFilter);
if (!logLevel.empty()) {
try {
// change log level based on that in the command string
@ -348,7 +348,7 @@ void DaemonApp::handleIpcMessage(const Event &e, void *)
ARCH->setting("Command", command);
// TODO: it would be nice to store bools/ints...
ARCH->setting("Elevate", String(cm->elevate() ? "1" : "0"));
ARCH->setting("Elevate", std::string(cm->elevate() ? "1" : "0"));
} catch (XArch &e) {
LOG((CLOG_ERR "failed to save settings, %s", e.what()));
}
@ -364,7 +364,7 @@ void DaemonApp::handleIpcMessage(const Event &e, void *)
case IpcMessageType::Hello: {
IpcHelloMessage *hm = static_cast<IpcHelloMessage *>(m);
String type;
std::string type;
switch (hm->clientType()) {
case IpcClientType::GUI:
type = "gui";
@ -387,7 +387,7 @@ void DaemonApp::handleIpcMessage(const Event &e, void *)
}
#if SYSAPI_WIN32
String watchdogStatus = m_watchdog->isProcessActive() ? "active" : "idle";
std::string watchdogStatus = m_watchdog->isProcessActive() ? "active" : "idle";
LOG((CLOG_INFO "service status: %s", watchdogStatus.c_str()));
#endif

View File

@ -28,14 +28,14 @@ DragInformation::DragInformation() : m_filename(), m_filesize(0)
{
}
void DragInformation::parseDragInfo(DragFileList &dragFileList, UInt32 fileNum, String data)
void DragInformation::parseDragInfo(DragFileList &dragFileList, UInt32 fileNum, std::string data)
{
size_t startPos = 0;
size_t findResult1 = 0;
size_t findResult2 = 0;
dragFileList.clear();
String slash("\\");
if (data.find("/", startPos) != string::npos) {
std::string slash("\\");
if (data.find("/", startPos) != std::string::npos) {
slash = "/";
}
@ -51,7 +51,7 @@ void DragInformation::parseDragInfo(DragFileList &dragFileList, UInt32 fileNum,
// set filename
if (findResult1 - findResult2 > 1) {
String filename = data.substr(findResult2 + 1, findResult1 - findResult2 - 1);
std::string filename = data.substr(findResult2 + 1, findResult1 - findResult2 - 1);
DragInformation di;
di.setFilename(filename);
dragFileList.push_back(di);
@ -61,7 +61,7 @@ void DragInformation::parseDragInfo(DragFileList &dragFileList, UInt32 fileNum,
// set filesize
findResult2 = data.find(',', startPos);
if (findResult2 - findResult1 > 1) {
String filesize = data.substr(findResult1 + 1, findResult2 - findResult1 - 1);
std::string filesize = data.substr(findResult1 + 1, findResult2 - findResult1 - 1);
size_t size = stringToNum(filesize);
dragFileList.at(index).setFilesize(size);
}
@ -77,31 +77,31 @@ void DragInformation::parseDragInfo(DragFileList &dragFileList, UInt32 fileNum,
}
}
String DragInformation::getDragFileExtension(String filename)
std::string DragInformation::getDragFileExtension(std::string filename)
{
size_t findResult = string::npos;
size_t findResult = std::string::npos;
findResult = filename.find_last_of(".", filename.size());
if (findResult != string::npos) {
if (findResult != std::string::npos) {
return filename.substr(findResult + 1, filename.size() - findResult - 1);
} else {
return "";
}
}
int DragInformation::setupDragInfo(DragFileList &fileList, String &output)
int DragInformation::setupDragInfo(DragFileList &fileList, std::string &output)
{
int size = static_cast<int>(fileList.size());
for (int i = 0; i < size; ++i) {
output.append(fileList.at(i).getFilename());
output.append(",");
String filesize = getFileSize(fileList.at(i).getFilename());
std::string filesize = getFileSize(fileList.at(i).getFilename());
output.append(filesize);
output.append(",");
}
return size;
}
bool DragInformation::isFileValid(String filename)
bool DragInformation::isFileValid(std::string filename)
{
bool result = false;
std::fstream file(filename.c_str(), ios::in | ios::binary);
@ -115,7 +115,7 @@ bool DragInformation::isFileValid(String filename)
return result;
}
size_t DragInformation::stringToNum(String &str)
size_t DragInformation::stringToNum(std::string &str)
{
istringstream iss(str.c_str());
size_t size;
@ -123,7 +123,7 @@ size_t DragInformation::stringToNum(String &str)
return size;
}
String DragInformation::getFileSize(String &filename)
std::string DragInformation::getFileSize(std::string &filename)
{
std::fstream file(filename.c_str(), ios::in | ios::binary);

View File

@ -18,9 +18,10 @@
#pragma once
#include "base/EventTypes.h"
#include "base/String.h"
#include "common/stdvector.h"
#include <string>
class DragInformation;
using DragFileList = std::vector<DragInformation>;
@ -32,11 +33,11 @@ public:
{
}
String &getFilename()
std::string &getFilename()
{
return m_filename;
}
void setFilename(String &name)
void setFilename(std::string &name)
{
m_filename = name;
}
@ -49,20 +50,20 @@ public:
m_filesize = size;
}
static void parseDragInfo(DragFileList &dragFileList, UInt32 fileNum, String data);
static String getDragFileExtension(String filename);
static void parseDragInfo(DragFileList &dragFileList, UInt32 fileNum, std::string data);
static std::string getDragFileExtension(std::string filename);
// helper function to setup drag info
// example: filename1,filesize1,filename2,filesize2,
// return file count
static int setupDragInfo(DragFileList &fileList, String &output);
static int setupDragInfo(DragFileList &fileList, std::string &output);
static bool isFileValid(String filename);
static bool isFileValid(std::string filename);
private:
static size_t stringToNum(String &str);
static String getFileSize(String &filename);
static size_t stringToNum(std::string &str);
static std::string getFileSize(std::string &filename);
private:
String m_filename;
std::string m_filename;
size_t m_filesize;
};

View File

@ -21,13 +21,13 @@
#include <fstream>
void DropHelper::writeToDir(const String &destination, DragFileList &fileList, String &data)
void DropHelper::writeToDir(const std::string &destination, DragFileList &fileList, std::string &data)
{
LOG((CLOG_DEBUG "dropping file, files=%i target=%s", fileList.size(), destination.c_str()));
if (!destination.empty() && fileList.size() > 0) {
std::fstream file;
String dropTarget = destination;
std::string dropTarget = destination;
#ifdef SYSAPI_WIN32
dropTarget.append("\\");
#else

View File

@ -17,11 +17,10 @@
#pragma once
#include "base/String.h"
#include "deskflow/DragInformation.h"
class DropHelper
{
public:
static void writeToDir(const String &destination, DragFileList &fileList, String &data);
static void writeToDir(const std::string &destination, DragFileList &fileList, std::string &data);
};

View File

@ -19,6 +19,7 @@
#include "base/Log.h"
#include "base/Stopwatch.h"
#include "base/String.h"
#include "deskflow/ProtocolUtil.h"
#include "deskflow/protocol_types.h"
#include "io/IStream.h"
@ -30,7 +31,7 @@ FileChunk::FileChunk(size_t size) : Chunk(size)
m_dataSize = size - FILE_CHUNK_META_SIZE;
}
FileChunk *FileChunk::start(const String &size)
FileChunk *FileChunk::start(const std::string &size)
{
size_t sizeLength = size.size();
FileChunk *start = new FileChunk(sizeLength + FILE_CHUNK_META_SIZE);
@ -63,11 +64,11 @@ FileChunk *FileChunk::end()
return end;
}
int FileChunk::assemble(deskflow::IStream *stream, String &dataReceived, size_t &expectedSize)
int FileChunk::assemble(deskflow::IStream *stream, std::string &dataReceived, size_t &expectedSize)
{
// parse
UInt8 mark = 0;
String content;
std::string content;
static size_t receivedDataSize;
static double elapsedTime;
static Stopwatch stopwatch;
@ -130,7 +131,7 @@ int FileChunk::assemble(deskflow::IStream *stream, String &dataReceived, size_t
void FileChunk::send(deskflow::IStream *stream, UInt8 mark, char *data, size_t dataSize)
{
String chunk(data, dataSize);
std::string chunk(data, dataSize);
switch (mark) {
case kDataStart:

View File

@ -17,10 +17,11 @@
#pragma once
#include "base/String.h"
#include "common/basic_types.h"
#include "deskflow/Chunk.h"
#include <string>
#define FILE_CHUNK_META_SIZE 2
namespace deskflow {
@ -32,9 +33,9 @@ class FileChunk : public Chunk
public:
FileChunk(size_t size);
static FileChunk *start(const String &size);
static FileChunk *start(const std::string &size);
static FileChunk *data(UInt8 *data, size_t dataSize);
static FileChunk *end();
static int assemble(deskflow::IStream *stream, String &dataCached, size_t &expectedSize);
static int assemble(deskflow::IStream *stream, std::string &dataCached, size_t &expectedSize);
static void send(deskflow::IStream *stream, UInt8 mark, char *data, size_t dataSize);
};

View File

@ -18,10 +18,12 @@
#pragma once
#include "base/String.h"
#include "common/IInterface.h"
#include "deskflow/IApp.h"
#include <string>
#include <vector>
class IAppUtil : public IInterface
{
public:
@ -30,7 +32,7 @@ public:
virtual int run(int argc, char **argv) = 0;
virtual void beforeAppExit() = 0;
virtual void startNode() = 0;
virtual std::vector<String> getKeyboardLayoutList() = 0;
virtual String getCurrentLanguageCode() = 0;
virtual void showNotification(const String &title, const String &text) const = 0;
virtual std::vector<std::string> getKeyboardLayoutList() = 0;
virtual std::string getCurrentLanguageCode() = 0;
virtual void showNotification(const std::string &title, const std::string &text) const = 0;
};

View File

@ -18,13 +18,14 @@
#pragma once
#include "base/String.h"
#include "deskflow/IScreen.h"
#include "deskflow/clipboard_types.h"
#include "deskflow/key_types.h"
#include "deskflow/mouse_types.h"
#include "deskflow/option_types.h"
#include <string>
//! Client interface
/*!
This interface defines the methods necessary for the server to
@ -86,14 +87,14 @@ public:
synthesize an up or repeat for the same client key synthesized by
keyDown().
*/
virtual void keyDown(KeyID id, KeyModifierMask, KeyButton, const String &) = 0;
virtual void keyDown(KeyID id, KeyModifierMask, KeyButton, const std::string &) = 0;
//! Notify of key repeat
/*!
Synthesize key events to generate a press and release of key \c id
\c count times. If possible match the given modifier mask.
*/
virtual void keyRepeat(KeyID id, KeyModifierMask, SInt32 count, KeyButton, const String &lang) = 0;
virtual void keyRepeat(KeyID id, KeyModifierMask, SInt32 count, KeyButton, const std::string &lang) = 0;
//! Notify of key release
/*!
@ -161,7 +162,7 @@ public:
/*!
Return the client's name.
*/
virtual String getName() const = 0;
virtual std::string getName() const = 0;
//@}

View File

@ -23,7 +23,7 @@
// IClipboard
//
void IClipboard::unmarshall(IClipboard *clipboard, const String &data, Time time)
void IClipboard::unmarshall(IClipboard *clipboard, const std::string &data, Time time)
{
assert(clipboard != NULL);
@ -51,7 +51,7 @@ void IClipboard::unmarshall(IClipboard *clipboard, const String &data, Time time
// or server supports more clipboard formats than the other
// then one of them will get a format >= kNumFormats here.
if (format < IClipboard::kNumFormats) {
clipboard->add(format, String(index, size));
clipboard->add(format, std::string(index, size));
}
index += size;
}
@ -61,7 +61,7 @@ void IClipboard::unmarshall(IClipboard *clipboard, const String &data, Time time
}
}
String IClipboard::marshall(const IClipboard *clipboard)
std::string IClipboard::marshall(const IClipboard *clipboard)
{
// return data format:
// 4 bytes => number of formats included
@ -72,9 +72,9 @@ String IClipboard::marshall(const IClipboard *clipboard)
assert(clipboard != NULL);
String data;
std::string data;
std::vector<String> formatData;
std::vector<std::string> formatData;
formatData.resize(IClipboard::kNumFormats);
// FIXME -- use current time
if (clipboard->open(0)) {
@ -148,7 +148,7 @@ UInt32 IClipboard::readUInt32(const char *buf)
(static_cast<UInt32>(ubuf[2]) << 8) | static_cast<UInt32>(ubuf[3]);
}
void IClipboard::writeUInt32(String *buf, UInt32 v)
void IClipboard::writeUInt32(std::string *buf, UInt32 v)
{
*buf += static_cast<UInt8>((v >> 24) & 0xff);
*buf += static_cast<UInt8>((v >> 16) & 0xff);

View File

@ -19,9 +19,10 @@
#pragma once
#include "base/EventTypes.h"
#include "base/String.h"
#include "common/IInterface.h"
#include <string>
//! Clipboard interface
/*!
This interface defines the methods common to all clipboards.
@ -81,7 +82,7 @@ public:
Add data in the given format to the clipboard. May only be
called after a successful empty().
*/
virtual void add(EFormat, const String &data) = 0;
virtual void add(EFormat, const std::string &data) = 0;
//@}
//! @name accessors
@ -127,21 +128,21 @@ public:
if there is no data in that format. Must be called between
a successful open() and close().
*/
virtual String get(EFormat) const = 0;
virtual std::string get(EFormat) const = 0;
//! Marshall clipboard data
/*!
Merge \p clipboard's data into a single buffer that can be later
unmarshalled to restore the clipboard and return the buffer.
*/
static String marshall(const IClipboard *clipboard);
static std::string marshall(const IClipboard *clipboard);
//! Unmarshall clipboard data
/*!
Extract marshalled clipboard data and store it in \p clipboard.
Sets the clipboard time to \c time.
*/
static void unmarshall(IClipboard *clipboard, const String &data, Time time);
static void unmarshall(IClipboard *clipboard, const std::string &data, Time time);
//! Copy clipboard
/*!
@ -166,5 +167,5 @@ public:
private:
static UInt32 readUInt32(const char *);
static void writeUInt32(String *, UInt32);
static void writeUInt32(std::string *, UInt32);
};

View File

@ -47,10 +47,10 @@ IKeyState::KeyInfo *IKeyState::KeyInfo::alloc(KeyID id, KeyModifierMask mask, Ke
}
IKeyState::KeyInfo *IKeyState::KeyInfo::alloc(
KeyID id, KeyModifierMask mask, KeyButton button, SInt32 count, const std::set<String> &destinations
KeyID id, KeyModifierMask mask, KeyButton button, SInt32 count, const std::set<std::string> &destinations
)
{
String screens = join(destinations);
std::string screens = join(destinations);
const char *buffer = screens.c_str();
// build structure
@ -82,7 +82,7 @@ bool IKeyState::KeyInfo::isDefault(const char *screens)
return (screens == NULL || screens[0] == '\0');
}
bool IKeyState::KeyInfo::contains(const char *screens, const String &name)
bool IKeyState::KeyInfo::contains(const char *screens, const std::string &name)
{
// special cases
if (isDefault(screens)) {
@ -93,7 +93,7 @@ bool IKeyState::KeyInfo::contains(const char *screens, const String &name)
}
// search
String match;
std::string match;
match.reserve(name.size() + 2);
match += ":";
match += name;
@ -109,12 +109,12 @@ bool IKeyState::KeyInfo::equal(const KeyInfo *a, const KeyInfo *b)
);
}
String IKeyState::KeyInfo::join(const std::set<String> &destinations)
std::string IKeyState::KeyInfo::join(const std::set<std::string> &destinations)
{
// collect destinations into a string. names are surrounded by ':'
// which makes searching easy. the string is empty if there are no
// destinations and "*" means all destinations.
String screens;
std::string screens;
for (auto i = destinations.begin(); i != destinations.end(); ++i) {
if (*i == "*") {
screens = "*";
@ -130,7 +130,7 @@ String IKeyState::KeyInfo::join(const std::set<String> &destinations)
return screens;
}
void IKeyState::KeyInfo::split(const char *screens, std::set<String> &dst)
void IKeyState::KeyInfo::split(const char *screens, std::set<std::string> &dst)
{
dst.clear();
if (isDefault(screens)) {
@ -144,7 +144,7 @@ void IKeyState::KeyInfo::split(const char *screens, std::set<String> &dst)
const char *i = screens + 1;
while (*i != '\0') {
const char *j = strchr(i, ':');
dst.insert(String(i, j - i));
dst.insert(std::string(i, j - i));
i = j + 1;
}
}

View File

@ -21,7 +21,6 @@
#include "base/Event.h"
#include "base/EventTypes.h"
#include "base/IEventQueue.h"
#include "base/String.h"
#include "common/IInterface.h"
#include "common/stdset.h"
#include "deskflow/key_types.h"
@ -46,14 +45,14 @@ public:
{
public:
static KeyInfo *alloc(KeyID, KeyModifierMask, KeyButton, SInt32 count);
static KeyInfo *alloc(KeyID, KeyModifierMask, KeyButton, SInt32 count, const std::set<String> &destinations);
static KeyInfo *alloc(KeyID, KeyModifierMask, KeyButton, SInt32 count, const std::set<std::string> &destinations);
static KeyInfo *alloc(const KeyInfo &);
static bool isDefault(const char *screens);
static bool contains(const char *screens, const String &name);
static bool contains(const char *screens, const std::string &name);
static bool equal(const KeyInfo *, const KeyInfo *);
static String join(const std::set<String> &destinations);
static void split(const char *screens, std::set<String> &);
static std::string join(const std::set<std::string> &destinations);
static void split(const char *screens, std::set<std::string> &);
public:
KeyID m_key;
@ -95,13 +94,14 @@ public:
/*!
Synthesizes a key press event and updates the key state.
*/
virtual void fakeKeyDown(KeyID id, KeyModifierMask mask, KeyButton button, const String &lang) = 0;
virtual void fakeKeyDown(KeyID id, KeyModifierMask mask, KeyButton button, const std::string &lang) = 0;
//! Fake a key repeat
/*!
Synthesizes a key repeat event and updates the key state.
*/
virtual bool fakeKeyRepeat(KeyID id, KeyModifierMask mask, SInt32 count, KeyButton button, const String &lang) = 0;
virtual bool
fakeKeyRepeat(KeyID id, KeyModifierMask mask, SInt32 count, KeyButton button, const std::string &lang) = 0;
//! Fake a key release
/*!

View File

@ -146,7 +146,7 @@ public:
On MacOS check which app causes a secure input state to be enabled. No
alternative on other platforms
*/
virtual String getSecureInputApp() const = 0;
virtual std::string getSecureInputApp() const = 0;
//@}
//! @name accessors
@ -187,8 +187,9 @@ public:
virtual void updateKeyMap() = 0;
virtual void updateKeyState() = 0;
virtual void setHalfDuplexMask(KeyModifierMask) = 0;
virtual void fakeKeyDown(KeyID id, KeyModifierMask mask, KeyButton button, const String &lang) = 0;
virtual bool fakeKeyRepeat(KeyID id, KeyModifierMask mask, SInt32 count, KeyButton button, const String &lang) = 0;
virtual void fakeKeyDown(KeyID id, KeyModifierMask mask, KeyButton button, const std::string &lang) = 0;
virtual bool
fakeKeyRepeat(KeyID id, KeyModifierMask mask, SInt32 count, KeyButton button, const std::string &lang) = 0;
virtual bool fakeKeyUp(KeyButton button) = 0;
virtual void fakeAllKeysUp() = 0;
virtual bool fakeCtrlAltDel() = 0;
@ -199,13 +200,13 @@ public:
virtual SInt32 pollActiveGroup() const = 0;
virtual void pollPressedKeys(KeyButtonSet &pressedKeys) const = 0;
virtual String &getDraggingFilename() = 0;
virtual std::string &getDraggingFilename() = 0;
virtual void clearDraggingFilename() = 0;
virtual bool isDraggingStarted() = 0;
virtual bool isFakeDraggingStarted() = 0;
virtual void fakeDraggingFiles(DragFileList fileList) = 0;
virtual const String &getDropTarget() const = 0;
virtual const std::string &getDropTarget() const = 0;
protected:
//! Handle system event

View File

@ -243,7 +243,7 @@ void KeyMap::foreachKey(ForeachKeyCallback cb, void *userData)
const KeyMap::KeyItem *KeyMap::mapKey(
Keystrokes &keys, KeyID id, SInt32 group, ModifierToKeys &activeModifiers, KeyModifierMask &currentState,
KeyModifierMask desiredMask, bool isAutoRepeat, const String &lang
KeyModifierMask desiredMask, bool isAutoRepeat, const std::string &lang
) const
{
LOG(
@ -310,12 +310,12 @@ const KeyMap::KeyItem *KeyMap::mapKey(
return item;
}
void KeyMap::setLanguageData(std::vector<String> layouts)
void KeyMap::setLanguageData(std::vector<std::string> layouts)
{
m_keyboardLayouts = std::move(layouts);
}
SInt32 KeyMap::getLanguageGroupID(SInt32 group, const String &lang) const
SInt32 KeyMap::getLanguageGroupID(SInt32 group, const std::string &lang) const
{
SInt32 id = group;
@ -488,7 +488,7 @@ void KeyMap::setModifierKeys()
const KeyMap::KeyItem *KeyMap::mapCommandKey(
Keystrokes &keys, KeyID id, SInt32 group, ModifierToKeys &activeModifiers, KeyModifierMask &currentState,
KeyModifierMask desiredMask, bool isAutoRepeat, const String &lang
KeyModifierMask desiredMask, bool isAutoRepeat, const std::string &lang
) const
{
static const KeyModifierMask s_overrideModifiers = 0xffffu;
@ -591,7 +591,7 @@ KeyMap::getKeyItemList(const KeyMap::KeyGroupTable &keyGroupTable, SInt32 group,
const KeyMap::KeyItem *KeyMap::mapCharacterKey(
Keystrokes &keys, KeyID id, SInt32 group, ModifierToKeys &activeModifiers, KeyModifierMask &currentState,
KeyModifierMask desiredMask, bool isAutoRepeat, const String &lang
KeyModifierMask desiredMask, bool isAutoRepeat, const std::string &lang
) const
{
// find KeySym in table
@ -641,7 +641,7 @@ const KeyMap::KeyItem *KeyMap::mapCharacterKey(
return &keyItem;
}
void KeyMap::addGroupToKeystroke(Keystrokes &keys, SInt32 &group, const String &lang) const
void KeyMap::addGroupToKeystroke(Keystrokes &keys, SInt32 &group, const std::string &lang) const
{
group = getLanguageGroupID(group, lang);
keys.push_back(Keystroke(group, true, false));
@ -649,7 +649,7 @@ void KeyMap::addGroupToKeystroke(Keystrokes &keys, SInt32 &group, const String &
const KeyMap::KeyItem *KeyMap::mapModifierKey(
Keystrokes &keys, KeyID id, SInt32 group, ModifierToKeys &activeModifiers, KeyModifierMask &currentState,
KeyModifierMask desiredMask, bool isAutoRepeat, const String &lang
KeyModifierMask desiredMask, bool isAutoRepeat, const std::string &lang
) const
{
return mapCharacterKey(keys, id, group, activeModifiers, currentState, desiredMask, isAutoRepeat, lang);
@ -708,7 +708,7 @@ const KeyMap::KeyItem *KeyMap::keyForModifier(KeyButton button, SInt32 group, SI
bool KeyMap::keysForKeyItem(
const KeyItem &keyItem, SInt32 &group, ModifierToKeys &activeModifiers, KeyModifierMask &currentState,
KeyModifierMask desiredState, KeyModifierMask overrideModifiers, bool isAutoRepeat, Keystrokes &keystrokes,
const String &lang
const std::string &lang
) const
{
static const KeyModifierMask s_notRequiredMask = KeyModifierAltGr | KeyModifierNumLock | KeyModifierScrollLock;
@ -1090,12 +1090,12 @@ KeyID KeyMap::getDeadKey(KeyID key)
}
}
String KeyMap::formatKey(KeyID key, KeyModifierMask mask)
std::string KeyMap::formatKey(KeyID key, KeyModifierMask mask)
{
// initialize tables
initKeyNameMaps();
String x;
std::string x;
for (SInt32 i = 0; i < kKeyModifierNumBits; ++i) {
KeyModifierMask mod = (1u << i);
if ((mask & mod) != 0 && s_modifierToNameMap->count(mod) > 0) {
@ -1120,7 +1120,7 @@ String KeyMap::formatKey(KeyID key, KeyModifierMask mask)
return x;
}
bool KeyMap::parseKey(const String &x, KeyID &key)
bool KeyMap::parseKey(const std::string &x, KeyID &key)
{
// initialize tables
initKeyNameMaps();
@ -1152,20 +1152,20 @@ bool KeyMap::parseKey(const String &x, KeyID &key)
return true;
}
bool KeyMap::parseModifiers(String &x, KeyModifierMask &mask)
bool KeyMap::parseModifiers(std::string &x, KeyModifierMask &mask)
{
// initialize tables
initKeyNameMaps();
mask = 0;
String::size_type tb = x.find_first_not_of(" \t", 0);
while (tb != String::npos) {
std::string::size_type tb = x.find_first_not_of(" \t", 0);
while (tb != std::string::npos) {
// get next component
String::size_type te = x.find_first_of(" \t+)", tb);
if (te == String::npos) {
std::string::size_type te = x.find_first_of(" \t+)", tb);
if (te == std::string::npos) {
te = x.size();
}
String c = x.substr(tb, te - tb);
std::string c = x.substr(tb, te - tb);
if (c.empty()) {
// missing component
return false;
@ -1181,9 +1181,9 @@ bool KeyMap::parseModifiers(String &x, KeyModifierMask &mask)
} else {
// unknown string
x.erase(0, tb);
String::size_type tb = x.find_first_not_of(" \t");
String::size_type te = x.find_last_not_of(" \t");
if (tb == String::npos) {
std::string::size_type tb = x.find_first_not_of(" \t");
std::string::size_type te = x.find_last_not_of(" \t");
if (tb == std::string::npos) {
x = "";
} else {
x = x.substr(tb, te - tb + 1);
@ -1193,7 +1193,7 @@ bool KeyMap::parseModifiers(String &x, KeyModifierMask &mask)
// check for '+' or end of string
tb = x.find_first_not_of(" \t", te);
if (tb != String::npos) {
if (tb != std::string::npos) {
if (x[tb] != '+') {
// expected '+'
return false;

View File

@ -225,10 +225,10 @@ public:
*/
virtual const KeyItem *mapKey(
Keystrokes &keys, KeyID id, SInt32 group, ModifierToKeys &activeModifiers, KeyModifierMask &currentState,
KeyModifierMask desiredMask, bool isAutoRepeat, const String &lang
KeyModifierMask desiredMask, bool isAutoRepeat, const std::string &lang
) const;
void setLanguageData(std::vector<String> layouts);
void setLanguageData(std::vector<std::string> layouts);
//! Get number of groups
/*!
@ -310,14 +310,14 @@ public:
Converts a key and modifier mask into a string representing the
combination.
*/
static String formatKey(KeyID key, KeyModifierMask);
static std::string formatKey(KeyID key, KeyModifierMask);
//! Parse a string into a key
/*!
Converts a string into a key. Returns \c true on success and \c false
if the string cannot be parsed.
*/
static bool parseKey(const String &, KeyID &);
static bool parseKey(const std::string &, KeyID &);
//! Parse a string into a modifier mask
/*!
@ -326,7 +326,7 @@ public:
remaining leading and trailing whitespace is stripped from the input
string.
*/
static bool parseModifiers(String &, KeyModifierMask &);
static bool parseModifiers(std::string &, KeyModifierMask &);
//@}
@ -369,7 +369,7 @@ private:
// entries since they don't make sense as hotkeys.
const KeyItem *mapCommandKey(
Keystrokes &keys, KeyID id, SInt32 group, ModifierToKeys &activeModifiers, KeyModifierMask &currentState,
KeyModifierMask desiredMask, bool isAutoRepeat, const String &lang
KeyModifierMask desiredMask, bool isAutoRepeat, const std::string &lang
) const;
// maps a character key. a character key is trying to synthesize a
@ -377,13 +377,13 @@ private:
// used to do it.
const KeyItem *mapCharacterKey(
Keystrokes &keys, KeyID id, SInt32 group, ModifierToKeys &activeModifiers, KeyModifierMask &currentState,
KeyModifierMask desiredMask, bool isAutoRepeat, const String &lang
KeyModifierMask desiredMask, bool isAutoRepeat, const std::string &lang
) const;
// maps a modifier key
const KeyItem *mapModifierKey(
Keystrokes &keys, KeyID id, SInt32 group, ModifierToKeys &activeModifiers, KeyModifierMask &currentState,
KeyModifierMask desiredMask, bool isAutoRepeat, const String &lang
KeyModifierMask desiredMask, bool isAutoRepeat, const std::string &lang
) const;
// returns the index into \p entryList of the KeyItemList requiring
@ -403,7 +403,7 @@ private:
bool keysForKeyItem(
const KeyItem &keyItem, SInt32 &group, ModifierToKeys &activeModifiers, KeyModifierMask &currentState,
KeyModifierMask desiredState, KeyModifierMask overrideModifiers, bool isAutoRepeat, Keystrokes &keystrokes,
const String &lang
const std::string &lang
) const;
// fills \p keystrokes with the keys to synthesize the modifiers
@ -442,9 +442,9 @@ private:
// Ways to synthesize a KeyID over multiple keyboard groups
using KeyGroupTable = std::vector<KeyEntryList>;
void addGroupToKeystroke(Keystrokes &keys, SInt32 &group, const String &lang) const;
void addGroupToKeystroke(Keystrokes &keys, SInt32 &group, const std::string &lang) const;
SInt32 getLanguageGroupID(SInt32 group, const String &lang) const;
SInt32 getLanguageGroupID(SInt32 group, const std::string &lang) const;
const KeyItemList *
getKeyItemList(const KeyGroupTable &keyGroupTable, SInt32 group, KeyModifierMask desiredMask) const;
@ -469,10 +469,10 @@ private:
using KeyButtonSet = std::set<KeyButton>;
// Key maps for parsing/formatting
using NameToKeyMap = std::map<String, KeyID, deskflow::string::CaselessCmp>;
using NameToModifierMap = std::map<String, KeyModifierMask, deskflow::string::CaselessCmp>;
using KeyToNameMap = std::map<KeyID, String>;
using ModifierToNameMap = std::map<KeyModifierMask, String>;
using NameToKeyMap = std::map<std::string, KeyID, deskflow::string::CaselessCmp>;
using NameToModifierMap = std::map<std::string, KeyModifierMask, deskflow::string::CaselessCmp>;
using KeyToNameMap = std::map<KeyID, std::string>;
using ModifierToNameMap = std::map<KeyModifierMask, std::string>;
// KeyID info
KeyIDMap m_keyIDMap;
@ -490,7 +490,7 @@ private:
KeyItem m_modifierKeyItem;
// Language sync data
std::vector<String> m_keyboardLayouts;
std::vector<std::string> m_keyboardLayouts;
// parsing/formatting tables
static NameToKeyMap *s_nameToKeyMap;

View File

@ -653,7 +653,7 @@ static const KeyID s_numpadTable[] = {
// KeyState
//
KeyState::KeyState(IEventQueue *events, std::vector<String> layouts, bool isLangSyncEnabled)
KeyState::KeyState(IEventQueue *events, std::vector<std::string> layouts, bool isLangSyncEnabled)
: IKeyState(events),
m_keyMapPtr(new deskflow::KeyMap()),
m_keyMap(*m_keyMapPtr),
@ -665,7 +665,9 @@ KeyState::KeyState(IEventQueue *events, std::vector<String> layouts, bool isLang
init();
}
KeyState::KeyState(IEventQueue *events, deskflow::KeyMap &keyMap, std::vector<String> layouts, bool isLangSyncEnabled)
KeyState::KeyState(
IEventQueue *events, deskflow::KeyMap &keyMap, std::vector<std::string> layouts, bool isLangSyncEnabled
)
: IKeyState(events),
m_keyMapPtr(0),
m_keyMap(keyMap),
@ -801,7 +803,7 @@ void KeyState::setHalfDuplexMask(KeyModifierMask mask)
}
}
void KeyState::fakeKeyDown(KeyID id, KeyModifierMask mask, KeyButton serverID, const String &lang)
void KeyState::fakeKeyDown(KeyID id, KeyModifierMask mask, KeyButton serverID, const std::string &lang)
{
// if this server key is already down then this is probably a
// mis-reported autorepeat.
@ -848,7 +850,7 @@ void KeyState::fakeKeyDown(KeyID id, KeyModifierMask mask, KeyButton serverID, c
fakeKeys(keys, 1);
}
bool KeyState::fakeKeyRepeat(KeyID id, KeyModifierMask mask, SInt32 count, KeyButton serverID, const String &lang)
bool KeyState::fakeKeyRepeat(KeyID id, KeyModifierMask mask, SInt32 count, KeyButton serverID, const std::string &lang)
{
LOG((CLOG_DEBUG2 "fakeKeyRepeat"));
serverID &= kButtonMask;

View File

@ -29,8 +29,8 @@ platform specific methods.
class KeyState : public IKeyState
{
public:
KeyState(IEventQueue *events, std::vector<String> layouts, bool isLangSyncEnabled);
KeyState(IEventQueue *events, deskflow::KeyMap &keyMap, std::vector<String> layouts, bool isLangSyncEnabled);
KeyState(IEventQueue *events, std::vector<std::string> layouts, bool isLangSyncEnabled);
KeyState(IEventQueue *events, deskflow::KeyMap &keyMap, std::vector<std::string> layouts, bool isLangSyncEnabled);
virtual ~KeyState();
//! @name manipulators
@ -69,8 +69,8 @@ public:
}
void updateKeyState() override;
void setHalfDuplexMask(KeyModifierMask) override;
void fakeKeyDown(KeyID id, KeyModifierMask mask, KeyButton button, const String &lang) override;
bool fakeKeyRepeat(KeyID id, KeyModifierMask mask, SInt32 count, KeyButton button, const String &lang) override;
void fakeKeyDown(KeyID id, KeyModifierMask mask, KeyButton button, const std::string &lang) override;
bool fakeKeyRepeat(KeyID id, KeyModifierMask mask, SInt32 count, KeyButton button, const std::string &lang) override;
bool fakeKeyUp(KeyButton button) override;
void fakeAllKeysUp() override;
bool fakeMediaKey(KeyID id) override;

View File

@ -49,12 +49,14 @@ void PlatformScreen::setHalfDuplexMask(KeyModifierMask mask)
getKeyState()->setHalfDuplexMask(mask);
}
void PlatformScreen::fakeKeyDown(KeyID id, KeyModifierMask mask, KeyButton button, const String &lang)
void PlatformScreen::fakeKeyDown(KeyID id, KeyModifierMask mask, KeyButton button, const std::string &lang)
{
getKeyState()->fakeKeyDown(id, mask, button, lang);
}
bool PlatformScreen::fakeKeyRepeat(KeyID id, KeyModifierMask mask, SInt32 count, KeyButton button, const String &lang)
bool PlatformScreen::fakeKeyRepeat(
KeyID id, KeyModifierMask mask, SInt32 count, KeyButton button, const std::string &lang
)
{
return getKeyState()->fakeKeyRepeat(id, mask, count, button, lang);
}

View File

@ -64,8 +64,8 @@ public:
virtual void updateKeyMap();
virtual void updateKeyState();
virtual void setHalfDuplexMask(KeyModifierMask);
virtual void fakeKeyDown(KeyID id, KeyModifierMask mask, KeyButton button, const String &);
virtual bool fakeKeyRepeat(KeyID id, KeyModifierMask mask, SInt32 count, KeyButton button, const String &lang);
virtual void fakeKeyDown(KeyID id, KeyModifierMask mask, KeyButton button, const std::string &);
virtual bool fakeKeyRepeat(KeyID id, KeyModifierMask mask, SInt32 count, KeyButton button, const std::string &lang);
virtual bool fakeKeyUp(KeyButton button);
virtual void fakeAllKeysUp();
virtual bool fakeCtrlAltDel();
@ -84,7 +84,7 @@ public:
{
return m_fakeDraggingStarted;
}
virtual String &getDraggingFilename()
virtual std::string &getDraggingFilename()
{
return m_draggingFilename;
}
@ -112,7 +112,7 @@ public:
{
throw std::runtime_error("fakeDraggingFiles not implemented");
}
virtual const String &getDropTarget() const
virtual const std::string &getDropTarget() const
{
throw std::runtime_error("getDropTarget not implemented");
}
@ -143,7 +143,7 @@ protected:
virtual SInt32 mapClientScrollDirection(SInt32) const;
protected:
String m_draggingFilename;
std::string m_draggingFilename;
bool m_draggingStarted;
bool m_fakeDraggingStarted;

View File

@ -67,7 +67,7 @@ template <typename T> void writeVectorInt(const std::vector<T> *VectorData, std:
}
}
void writeString(const String *StringData, std::vector<UInt8> &Buffer)
void writeString(const std::string *StringData, std::vector<UInt8> &Buffer)
{
const UInt32 len = (StringData != NULL) ? (UInt32)StringData->size() : 0;
writeInt(len, sizeof(len), Buffer);
@ -200,7 +200,7 @@ void ProtocolUtil::vreadf(deskflow::IStream *stream, const char *fmt, va_list ar
}
case 's': {
String *destination = va_arg(args, String *);
std::string *destination = va_arg(args, std::string *);
if (len > PROTOCOL_MAX_STRING_LENGTH) {
LOG((CLOG_ERR "read: string length exceeds maximum allowed size: %u", len));
@ -271,7 +271,7 @@ UInt32 ProtocolUtil::getLength(const char *fmt, va_list args)
case 's':
assert(len == 0);
len = (UInt32)(va_arg(args, String *))->size() + 4;
len = (UInt32)(va_arg(args, std::string *))->size() + 4;
break;
case 'S':
@ -346,7 +346,7 @@ void ProtocolUtil::writef(std::vector<UInt8> &buffer, const char *fmt, va_list a
case 's': {
assert(len == 0);
const String *src = va_arg(args, String *);
const std::string *src = va_arg(args, std::string *);
writeString(src, buffer);
break;
}
@ -520,7 +520,7 @@ UInt32 ProtocolUtil::readVectorSize(deskflow::IStream *stream)
return size;
}
void ProtocolUtil::readBytes(deskflow::IStream *stream, UInt32 len, String *destination)
void ProtocolUtil::readBytes(deskflow::IStream *stream, UInt32 len, std::string *destination)
{
// read the string length
UInt8 buffer[128];
@ -575,7 +575,7 @@ void ProtocolUtil::readBytes(deskflow::IStream *stream, UInt32 len, String *dest
// XIOReadMismatch
//
String XIOReadMismatch::getWhat() const throw()
std::string XIOReadMismatch::getWhat() const throw()
{
return format("XIOReadMismatch", "ProtocolUtil::readf() mismatch");
}

View File

@ -22,6 +22,7 @@
#include "io/XIO.h"
#include <stdarg.h>
#include <vector>
namespace deskflow {
class IStream;
@ -50,7 +51,7 @@ public:
- \%1I -- converts std::vector<UInt8>* to 1 byte integers
- \%2I -- converts std::vector<UInt16>* to 2 byte integers in NBO
- \%4I -- converts std::vector<UInt32>* to 4 byte integers in NBO
- \%s -- converts String* to stream of bytes
- \%s -- converts std::string* to stream of bytes
- \%S -- converts integer N and const UInt8* to stream of N bytes
*/
static void writef(deskflow::IStream *, const char *fmt, ...);
@ -69,7 +70,7 @@ public:
- \%1I -- reads 1 byte integers; arg is std::vector<UInt8>*
- \%2I -- reads NBO 2 byte integers; arg is std::vector<UInt16>*
- \%4I -- reads NBO 4 byte integers; arg is std::vector<UInt32>*
- \%s -- reads bytes; argument must be a String*, \b not a char*
- \%s -- reads bytes; argument must be a std::string*, \b not a char*
*/
static bool readf(deskflow::IStream *, const char *fmt, ...);
@ -100,7 +101,7 @@ private:
/**
* @brief Handles an array of bytes
*/
static void readBytes(deskflow::IStream *, UInt32, String *);
static void readBytes(deskflow::IStream *, UInt32, std::string *);
};
//! Mismatched read exception
@ -112,5 +113,5 @@ class XIOReadMismatch : public XIO
{
public:
// XBase overrides
virtual String getWhat() const throw();
virtual std::string getWhat() const throw();
};

View File

@ -198,7 +198,7 @@ void Screen::screensaver(bool) const
// do nothing
}
void Screen::keyDown(KeyID id, KeyModifierMask mask, KeyButton button, const String &lang)
void Screen::keyDown(KeyID id, KeyModifierMask mask, KeyButton button, const std::string &lang)
{
// check for ctrl+alt+del emulation
if (id == kKeyDelete && (mask & (KeyModifierControl | KeyModifierAlt)) == (KeyModifierControl | KeyModifierAlt)) {
@ -210,7 +210,7 @@ void Screen::keyDown(KeyID id, KeyModifierMask mask, KeyButton button, const Str
m_screen->fakeKeyDown(id, mask, button, lang);
}
void Screen::keyRepeat(KeyID id, KeyModifierMask mask, SInt32 count, KeyButton button, const String &lang)
void Screen::keyRepeat(KeyID id, KeyModifierMask mask, SInt32 count, KeyButton button, const std::string &lang)
{
assert(!m_isPrimary);
m_screen->fakeKeyRepeat(id, mask, count, button, lang);
@ -400,7 +400,7 @@ void Screen::setEnableDragDrop(bool enabled)
m_enableDragDrop = enabled;
}
String &Screen::getDraggingFilename() const
std::string &Screen::getDraggingFilename() const
{
return m_screen->getDraggingFilename();
}
@ -410,7 +410,7 @@ void Screen::clearDraggingFilename()
m_screen->clearDraggingFilename();
}
const String &Screen::getDropTarget() const
const std::string &Screen::getDropTarget() const
{
return m_screen->getDropTarget();
}
@ -488,7 +488,7 @@ void Screen::leaveSecondary()
m_screen->fakeAllKeysUp();
}
String Screen::getSecureInputApp() const
std::string Screen::getSecureInputApp() const
{
return m_screen->getSecureInputApp();
}

View File

@ -18,7 +18,6 @@
#pragma once
#include "base/String.h"
#include "deskflow/DragInformation.h"
#include "deskflow/IScreen.h"
#include "deskflow/clipboard_types.h"
@ -130,14 +129,14 @@ public:
synthesize an up or repeat for the same client key synthesized by
keyDown().
*/
void keyDown(KeyID id, KeyModifierMask, KeyButton, const String &);
void keyDown(KeyID id, KeyModifierMask, KeyButton, const std::string &);
//! Notify of key repeat
/*!
Synthesize key events to generate a press and release of key \c id
\c count times. If possible match the given modifier mask.
*/
void keyRepeat(KeyID id, KeyModifierMask, SInt32 count, KeyButton, const String &lang);
void keyRepeat(KeyID id, KeyModifierMask, SInt32 count, KeyButton, const std::string &lang);
//! Notify of key release
/*!
@ -241,7 +240,7 @@ public:
On MacOS check which app causes a secure input state to be enabled. No
alternative on other platforms
*/
String getSecureInputApp() const;
std::string getSecureInputApp() const;
//@}
//! @name accessors
@ -298,13 +297,13 @@ public:
bool isFakeDraggingStarted() const;
//! Get the filename of the file being dragged
String &getDraggingFilename() const;
std::string &getDraggingFilename() const;
//! Clear the filename of the file that was dragged
void clearDraggingFilename();
//! Get the drop target directory
const String &getDropTarget() const;
const std::string &getDropTarget() const;
//@}

View File

@ -236,7 +236,7 @@ void ServerApp::loadConfig()
}
}
bool ServerApp::loadConfig(const String &pathname)
bool ServerApp::loadConfig(const std::string &pathname)
{
try {
// load configuration
@ -325,7 +325,7 @@ void ServerApp::updateStatus()
updateStatus("");
}
void ServerApp::updateStatus(const String &msg)
void ServerApp::updateStatus(const std::string &msg)
{
if (m_taskBarReceiver) {
m_taskBarReceiver->updateStatus(m_server, msg);
@ -445,7 +445,7 @@ bool ServerApp::initServer()
deskflow::Screen *serverScreen = NULL;
PrimaryClient *primaryClient = NULL;
try {
String name = args().m_config->getCanonicalName(args().m_name);
std::string name = args().m_config->getCanonicalName(args().m_name);
serverScreen = openServerScreen();
primaryClient = openPrimaryClient(name, serverScreen);
m_serverScreen = serverScreen;
@ -457,7 +457,7 @@ bool ServerApp::initServer()
LOG((CLOG_WARN "primary screen unavailable: %s", e.what()));
closePrimaryClient(primaryClient);
closeServerScreen(serverScreen);
updateStatus(String("primary screen unavailable: ") + e.what());
updateStatus(std::string("primary screen unavailable: ") + e.what());
retryTime = e.getRetryTime();
} catch (XScreenOpenFailure &e) {
LOG((CLOG_CRIT "failed to start server: %s", e.what()));
@ -543,7 +543,7 @@ bool ServerApp::startServer()
LOG((CLOG_CRIT "cannot listen for clients: %s", e.what()));
}
closeClientListener(listener);
updateStatus(String("cannot listen for clients: ") + e.what());
updateStatus(std::string("cannot listen for clients: ") + e.what());
} catch (XBase &e) {
LOG((CLOG_CRIT "failed to start server: %s", e.what()));
closeClientListener(listener);
@ -594,7 +594,7 @@ deskflow::Screen *ServerApp::createScreen()
#endif
}
PrimaryClient *ServerApp::openPrimaryClient(const String &name, deskflow::Screen *screen)
PrimaryClient *ServerApp::openPrimaryClient(const std::string &name, deskflow::Screen *screen)
{
LOG((CLOG_DEBUG1 "creating primary screen"));
return new PrimaryClient(name, screen);
@ -714,7 +714,7 @@ int ServerApp::mainLoop()
}
// canonicalize the primary screen name
String primaryName = args().m_config->getCanonicalName(args().m_name);
std::string primaryName = args().m_config->getCanonicalName(args().m_name);
if (primaryName.empty()) {
LOG((CLOG_CRIT "unknown screen name `%s'", args().m_name.c_str()));
return kExitFailed;

View File

@ -68,7 +68,7 @@ public:
const char *daemonName() const override;
const char *daemonInfo() const override;
void loadConfig() override;
bool loadConfig(const String &pathname) override;
bool loadConfig(const std::string &pathname) override;
deskflow::Screen *createScreen() override;
int mainLoop() override;
int runInner(int argc, char **argv, ILogOutputter *outputter, StartupFunc startup) override;
@ -97,7 +97,7 @@ public:
void closeServer(Server *server);
void stopRetryTimer();
void updateStatus();
void updateStatus(const String &msg);
void updateStatus(const std::string &msg);
void closeClientListener(ClientListener *listen);
void stopServer();
void closePrimaryClient(PrimaryClient *primaryClient);
@ -106,7 +106,7 @@ public:
bool initServer();
void retryHandler(const Event &, void *);
deskflow::Screen *openServerScreen();
PrimaryClient *openPrimaryClient(const String &name, deskflow::Screen *screen);
PrimaryClient *openPrimaryClient(const std::string &name, deskflow::Screen *screen);
void handleScreenError(const Event &, void *);
void handleSuspend(const Event &, void *);
void handleResume(const Event &, void *);

View File

@ -38,7 +38,7 @@ public:
ServerArgs &operator=(ServerArgs &&) = default;
public:
String m_configFile = "";
std::string m_configFile = "";
std::shared_ptr<Config> m_config;
};

View File

@ -38,7 +38,7 @@ ServerTaskBarReceiver::~ServerTaskBarReceiver()
// do nothing
}
void ServerTaskBarReceiver::updateStatus(Server *server, const String &errorMsg)
void ServerTaskBarReceiver::updateStatus(Server *server, const std::string &errorMsg)
{
{
// update our status
@ -72,7 +72,7 @@ ServerTaskBarReceiver::EState ServerTaskBarReceiver::getStatus() const
return m_state;
}
const String &ServerTaskBarReceiver::getErrorMessage() const
const std::string &ServerTaskBarReceiver::getErrorMessage() const
{
return m_errorMessage;
}

View File

@ -21,7 +21,6 @@
#include "arch/IArchTaskBarReceiver.h"
#include "base/Event.h"
#include "base/EventTypes.h"
#include "base/String.h"
#include "common/stdvector.h"
#include "deskflow/ServerApp.h"
#include "server/Server.h"
@ -42,9 +41,9 @@ public:
/*!
Determine the status and query required information from the server.
*/
void updateStatus(Server *, const String &errorMsg);
void updateStatus(Server *, const std::string &errorMsg);
void updateStatus(INode *n, const String &errorMsg)
void updateStatus(INode *n, const std::string &errorMsg)
{
updateStatus((Server *)n, errorMsg);
}
@ -61,7 +60,7 @@ public:
virtual std::string getToolTip() const;
protected:
using Clients = std::vector<String>;
using Clients = std::vector<std::string>;
enum EState
{
kNotRunning,
@ -75,7 +74,7 @@ protected:
EState getStatus() const;
//! Get error message
const String &getErrorMessage() const;
const std::string &getErrorMessage() const;
//! Get connected clients
const Clients &getClients() const;
@ -95,7 +94,7 @@ protected:
private:
EState m_state;
String m_errorMessage;
std::string m_errorMessage;
Clients m_clients;
IEventQueue *m_events;
};

View File

@ -55,7 +55,7 @@ void StreamChunker::sendFile(char *filename, IEventQueue *events, void *eventTar
size_t size = (size_t)file.tellg();
// send first message (file size)
String fileSize = deskflow::string::sizeTypeToString(size);
std::string fileSize = deskflow::string::sizeTypeToString(size);
FileChunk *sizeMessage = FileChunk::start(fileSize);
events->addEvent(Event(events->forFile().fileChunkSending(), eventTarget, sizeMessage));
@ -106,11 +106,11 @@ void StreamChunker::sendFile(char *filename, IEventQueue *events, void *eventTar
}
void StreamChunker::sendClipboard(
String &data, size_t size, ClipboardID id, UInt32 sequence, IEventQueue *events, void *eventTarget
std::string &data, size_t size, ClipboardID id, UInt32 sequence, IEventQueue *events, void *eventTarget
)
{
// send first message (data size)
String dataSize = deskflow::string::sizeTypeToString(size);
std::string dataSize = deskflow::string::sizeTypeToString(size);
ClipboardChunk *sizeMessage = ClipboardChunk::start(id, sequence, dataSize);
events->addEvent(Event(events->forClipboard().clipboardSending(), eventTarget, sizeMessage));
@ -127,7 +127,7 @@ void StreamChunker::sendClipboard(
chunkSize = size - sentLength;
}
String chunk(data.substr(sentLength, chunkSize).c_str(), chunkSize);
std::string chunk(data.substr(sentLength, chunkSize).c_str(), chunkSize);
ClipboardChunk *dataChunk = ClipboardChunk::data(id, sequence, chunk);
events->addEvent(Event(events->forClipboard().clipboardSending(), eventTarget, dataChunk));

View File

@ -17,9 +17,10 @@
#pragma once
#include "base/String.h"
#include "deskflow/clipboard_types.h"
#include <string>
class IEventQueue;
class Mutex;
@ -27,8 +28,9 @@ class StreamChunker
{
public:
static void sendFile(char *filename, IEventQueue *events, void *eventTarget);
static void
sendClipboard(String &data, size_t size, ClipboardID id, UInt32 sequence, IEventQueue *events, void *eventTarget);
static void sendClipboard(
std::string &data, size_t size, ClipboardID id, UInt32 sequence, IEventQueue *events, void *eventTarget
);
static void interruptFile();
private:

View File

@ -23,7 +23,7 @@
// XBadClient
//
String XBadClient::getWhat() const throw()
std::string XBadClient::getWhat() const throw()
{
return "XBadClient";
}
@ -32,7 +32,7 @@ String XBadClient::getWhat() const throw()
// XInvalidProtocol
//
String XInvalidProtocol::getWhat() const throw()
std::string XInvalidProtocol::getWhat() const throw()
{
return "XInvalidProtocol";
}
@ -56,7 +56,7 @@ int XIncompatibleClient::getMinor() const throw()
return m_minor;
}
String XIncompatibleClient::getWhat() const throw()
std::string XIncompatibleClient::getWhat() const throw()
{
return format(
"XIncompatibleClient", "incompatible client %{1}.%{2}", deskflow::string::sprintf("%d", m_major).c_str(),
@ -68,17 +68,17 @@ String XIncompatibleClient::getWhat() const throw()
// XDuplicateClient
//
XDuplicateClient::XDuplicateClient(const String &name) : m_name(name)
XDuplicateClient::XDuplicateClient(const std::string &name) : m_name(name)
{
// do nothing
}
const String &XDuplicateClient::getName() const throw()
const std::string &XDuplicateClient::getName() const throw()
{
return m_name;
}
String XDuplicateClient::getWhat() const throw()
std::string XDuplicateClient::getWhat() const throw()
{
return format("XDuplicateClient", "duplicate client %{1}", m_name.c_str());
}
@ -87,17 +87,17 @@ String XDuplicateClient::getWhat() const throw()
// XUnknownClient
//
XUnknownClient::XUnknownClient(const String &name) : m_name(name)
XUnknownClient::XUnknownClient(const std::string &name) : m_name(name)
{
// do nothing
}
const String &XUnknownClient::getName() const throw()
const std::string &XUnknownClient::getName() const throw()
{
return m_name;
}
String XUnknownClient::getWhat() const throw()
std::string XUnknownClient::getWhat() const throw()
{
return format("XUnknownClient", "unknown client %{1}", m_name.c_str());
}
@ -116,7 +116,7 @@ int XExitApp::getCode() const throw()
return m_code;
}
String XExitApp::getWhat() const throw()
std::string XExitApp::getWhat() const throw()
{
return format("XExitApp", "exiting with code %{1}", deskflow::string::sprintf("%d", m_code).c_str());
}

View File

@ -61,7 +61,7 @@ public:
//@}
protected:
virtual String getWhat() const throw();
virtual std::string getWhat() const throw();
private:
int m_major;
@ -76,7 +76,7 @@ a client that is already connected.
class XDuplicateClient : public XDeskflow
{
public:
XDuplicateClient(const String &name);
XDuplicateClient(const std::string &name);
virtual ~XDuplicateClient() _NOEXCEPT
{
}
@ -85,15 +85,15 @@ public:
//@{
//! Get client's name
virtual const String &getName() const throw();
virtual const std::string &getName() const throw();
//@}
protected:
virtual String getWhat() const throw();
virtual std::string getWhat() const throw();
private:
String m_name;
std::string m_name;
};
//! Client not in map exception
@ -104,7 +104,7 @@ unknown to the server.
class XUnknownClient : public XDeskflow
{
public:
XUnknownClient(const String &name);
XUnknownClient(const std::string &name);
virtual ~XUnknownClient() _NOEXCEPT
{
}
@ -113,15 +113,15 @@ public:
//@{
//! Get the client's name
virtual const String &getName() const throw();
virtual const std::string &getName() const throw();
//@}
protected:
virtual String getWhat() const throw();
virtual std::string getWhat() const throw();
private:
String m_name;
std::string m_name;
};
//! Generic exit eception
@ -142,7 +142,7 @@ public:
int getCode() const throw();
protected:
virtual String getWhat() const throw();
virtual std::string getWhat() const throw();
private:
int m_code;

View File

@ -22,7 +22,7 @@
// XScreenOpenFailure
//
String XScreenOpenFailure::getWhat() const throw()
std::string XScreenOpenFailure::getWhat() const throw()
{
return format("XScreenOpenFailure", "unable to open screen");
}
@ -31,7 +31,7 @@ String XScreenOpenFailure::getWhat() const throw()
// XScreenXInputFailure
//
String XScreenXInputFailure::getWhat() const throw()
std::string XScreenXInputFailure::getWhat() const throw()
{
return "";
}
@ -55,7 +55,7 @@ double XScreenUnavailable::getRetryTime() const
return m_timeUntilRetry;
}
String XScreenUnavailable::getWhat() const throw()
std::string XScreenUnavailable::getWhat() const throw()
{
return format("XScreenUnavailable", "unable to open screen");
}

View File

@ -62,7 +62,7 @@ public:
//@}
protected:
virtual String getWhat() const throw();
virtual std::string getWhat() const throw();
private:
double m_timeUntilRetry;

View File

@ -21,9 +21,9 @@
namespace {
String vectorToString(const std::vector<String> &vector, const String &delimiter = "")
std::string vectorToString(const std::vector<std::string> &vector, const std::string &delimiter = "")
{
String string;
std::string string;
for (const auto &item : vector) {
if (&item != &vector[0]) {
string += delimiter;
@ -39,12 +39,12 @@ namespace deskflow {
namespace languages {
LanguageManager::LanguageManager(const std::vector<String> &localLanguages) : m_localLanguages(localLanguages)
LanguageManager::LanguageManager(const std::vector<std::string> &localLanguages) : m_localLanguages(localLanguages)
{
LOG((CLOG_INFO "local languages: %s", vectorToString(m_localLanguages, ", ").c_str()));
}
void LanguageManager::setRemoteLanguages(const String &remoteLanguages)
void LanguageManager::setRemoteLanguages(const std::string &remoteLanguages)
{
m_remoteLanguages.clear();
if (!remoteLanguages.empty()) {
@ -55,19 +55,19 @@ void LanguageManager::setRemoteLanguages(const String &remoteLanguages)
LOG((CLOG_INFO "remote languages: %s", vectorToString(m_remoteLanguages, ", ").c_str()));
}
const std::vector<String> &LanguageManager::getRemoteLanguages() const
const std::vector<std::string> &LanguageManager::getRemoteLanguages() const
{
return m_remoteLanguages;
}
const std::vector<String> &LanguageManager::getLocalLanguages() const
const std::vector<std::string> &LanguageManager::getLocalLanguages() const
{
return m_localLanguages;
}
String LanguageManager::getMissedLanguages() const
std::string LanguageManager::getMissedLanguages() const
{
String missedLanguages;
std::string missedLanguages;
for (const auto &language : m_remoteLanguages) {
if (!isLanguageInstalled(language)) {
@ -81,12 +81,12 @@ String LanguageManager::getMissedLanguages() const
return missedLanguages;
}
String LanguageManager::getSerializedLocalLanguages() const
std::string LanguageManager::getSerializedLocalLanguages() const
{
return vectorToString(m_localLanguages);
}
bool LanguageManager::isLanguageInstalled(const String &language) const
bool LanguageManager::isLanguageInstalled(const std::string &language) const
{
bool isInstalled = true;

View File

@ -16,7 +16,6 @@
*/
#pragma once
#include "base/String.h"
#include "deskflow/AppUtil.h"
#include <vector>
@ -26,49 +25,51 @@ namespace languages {
class LanguageManager
{
std::vector<String> m_remoteLanguages;
std::vector<String> m_localLanguages;
std::vector<std::string> m_remoteLanguages;
std::vector<std::string> m_localLanguages;
public:
explicit LanguageManager(const std::vector<String> &localLanguages = AppUtil::instance().getKeyboardLayoutList());
explicit LanguageManager(
const std::vector<std::string> &localLanguages = AppUtil::instance().getKeyboardLayoutList()
);
/**
* @brief setRemoteLanguages sets remote languages
* @param remoteLanguages is a string with sericalized languages
*/
void setRemoteLanguages(const String &remoteLanguages);
void setRemoteLanguages(const std::string &remoteLanguages);
/**
* @brief getRemoteLanguages getter for remote languages
* @return vector of remote languages
*/
const std::vector<String> &getRemoteLanguages() const;
const std::vector<std::string> &getRemoteLanguages() const;
/**
* @brief getLocalLanguages getter for local languages
* @return vector of local languages
*/
const std::vector<String> &getLocalLanguages() const;
const std::vector<std::string> &getLocalLanguages() const;
/**
* @brief getMissedLanguages getter for missed languages on local machine
* @return difference between remote and local languages as a coma separated
* string
*/
String getMissedLanguages() const;
std::string getMissedLanguages() const;
/**
* @brief getSerializedLocalLanguages getter for local serialized languages
* @return serialized local languages as a string
*/
String getSerializedLocalLanguages() const;
std::string getSerializedLocalLanguages() const;
/**
* @brief isLanguageInstalled checks if language is installed
* @param language which should be checked
* @return true if the specified language is installed
*/
bool isLanguageInstalled(const String &language) const;
bool isLanguageInstalled(const std::string &language) const;
};
} // namespace languages

View File

@ -60,9 +60,9 @@ void AppUtilUnix::startNode()
app().startNode();
}
std::vector<String> AppUtilUnix::getKeyboardLayoutList()
std::vector<std::string> AppUtilUnix::getKeyboardLayoutList()
{
std::vector<String> layoutLangCodes;
std::vector<std::string> layoutLangCodes;
#if WINAPI_XWINDOWS
layoutLangCodes = X11LayoutsParser::getX11LanguageList("/usr/share/X11/xkb/rules/evdev.xml");
@ -97,9 +97,9 @@ std::vector<String> AppUtilUnix::getKeyboardLayoutList()
return layoutLangCodes;
}
String AppUtilUnix::getCurrentLanguageCode()
std::string AppUtilUnix::getCurrentLanguageCode()
{
String result = "";
std::string result = "";
#if WINAPI_XWINDOWS
auto display = XOpenDisplay(nullptr);
@ -165,7 +165,7 @@ String AppUtilUnix::getCurrentLanguageCode()
return result;
}
void AppUtilUnix::showNotification(const String &title, const String &text) const
void AppUtilUnix::showNotification(const std::string &title, const std::string &text) const
{
#if HAVE_LIBNOTIFY
LOG((CLOG_INFO "showing notification, title=\"%s\", text=\"%s\"", title.c_str(), text.c_str()));

View File

@ -32,7 +32,7 @@ public:
int run(int argc, char **argv) override;
void startNode() override;
std::vector<String> getKeyboardLayoutList() override;
String getCurrentLanguageCode() override;
void showNotification(const String &title, const String &text) const override;
std::vector<std::string> getKeyboardLayoutList() override;
std::string getCurrentLanguageCode() override;
void showNotification(const std::string &title, const std::string &text) const override;
};

View File

@ -18,13 +18,13 @@
#pragma once
#include "base/String.h"
#include <string>
#include <vector>
// copy from
// https://www.loc.gov/standards/iso639-2/php/code_list.php
// 10.06.2021
// first param - ISO 639-2, second param - 639-1
const std::vector<std::pair<String, String>> ISO_Table = {
const std::vector<std::pair<std::string, std::string>> ISO_Table = {
std::make_pair("aar", "aa"), std::make_pair("abk", "ab"), std::make_pair("afr", "af"), std::make_pair("aka", "ak"),
std::make_pair("sqi", "sq"), std::make_pair("amh", "am"), std::make_pair("ara", "ar"), std::make_pair("arg", "an"),
std::make_pair("hye", "hy"), std::make_pair("asm", "as"), std::make_pair("ava", "av"), std::make_pair("ave", "ae"),

View File

@ -28,11 +28,11 @@
namespace {
void splitLine(std::vector<String> &parts, const String &line, char delimiter)
void splitLine(std::vector<std::string> &parts, const std::string &line, char delimiter)
{
std::stringstream stream(line);
while (stream.good()) {
String part;
std::string part;
getline(stream, part, delimiter);
parts.push_back(part);
}
@ -64,7 +64,7 @@ bool X11LayoutsParser::readXMLConfigItemElem(const pugi::xml_node *root, std::ve
return true;
}
std::vector<X11LayoutsParser::Lang> X11LayoutsParser::getAllLanguageData(const String &pathToEvdevFile)
std::vector<X11LayoutsParser::Lang> X11LayoutsParser::getAllLanguageData(const std::string &pathToEvdevFile)
{
std::vector<Lang> allCodes;
pugi::xml_document doc;
@ -101,18 +101,18 @@ std::vector<X11LayoutsParser::Lang> X11LayoutsParser::getAllLanguageData(const S
return allCodes;
}
void X11LayoutsParser::appendVectorUniq(const std::vector<String> &source, std::vector<String> &dst)
void X11LayoutsParser::appendVectorUniq(const std::vector<std::string> &source, std::vector<std::string> &dst)
{
for (const auto &elem : source) {
if (std::find_if(dst.begin(), dst.end(), [elem](const String &s) { return s == elem; }) == dst.end()) {
if (std::find_if(dst.begin(), dst.end(), [elem](const std::string &s) { return s == elem; }) == dst.end()) {
dst.push_back(elem);
}
}
};
void X11LayoutsParser::convertLayoutToISO639_2(
const String &pathToEvdevFile, bool needToReloadEvdev, const std::vector<String> &layoutNames,
const std::vector<String> &layoutVariantNames, std::vector<String> &iso639_2Codes
const std::string &pathToEvdevFile, bool needToReloadEvdev, const std::vector<std::string> &layoutNames,
const std::vector<std::string> &layoutVariantNames, std::vector<std::string> &iso639_2Codes
)
{
if (layoutNames.size() != layoutVariantNames.size()) {
@ -133,7 +133,7 @@ void X11LayoutsParser::convertLayoutToISO639_2(
continue;
}
const std::vector<String> *toCopy = nullptr;
const std::vector<std::string> *toCopy = nullptr;
if (layoutVariantNames[i].empty()) {
toCopy = &langIter->layoutBaseISO639_2;
} else {
@ -163,25 +163,26 @@ void X11LayoutsParser::convertLayoutToISO639_2(
}
}
std::vector<String> X11LayoutsParser::getX11LanguageList(const String &pathToEvdevFile)
std::vector<std::string> X11LayoutsParser::getX11LanguageList(const std::string &pathToEvdevFile)
{
std::vector<String> layoutNames;
std::vector<String> layoutVariantNames;
std::vector<std::string> layoutNames;
std::vector<std::string> layoutVariantNames;
deskflow::linux::DeskflowXkbKeyboard keyboard;
splitLine(layoutNames, keyboard.getLayout(), ',');
splitLine(layoutVariantNames, keyboard.getVariant(), ',');
std::vector<String> iso639_2Codes;
std::vector<std::string> iso639_2Codes;
iso639_2Codes.reserve(layoutNames.size());
convertLayoutToISO639_2(pathToEvdevFile, true, layoutNames, layoutVariantNames, iso639_2Codes);
return convertISO639_2ToISO639_1(iso639_2Codes);
}
String
X11LayoutsParser::convertLayotToISO(const String &pathToEvdevFile, const String &layoutLangCode, bool needToReloadFiles)
std::string X11LayoutsParser::convertLayotToISO(
const std::string &pathToEvdevFile, const std::string &layoutLangCode, bool needToReloadFiles
)
{
std::vector<String> iso639_2Codes;
std::vector<std::string> iso639_2Codes;
convertLayoutToISO639_2(pathToEvdevFile, needToReloadFiles, {layoutLangCode}, {""}, iso639_2Codes);
if (iso639_2Codes.empty()) {
LOG((CLOG_WARN "failed to convert layout lang code: \"%s\"", layoutLangCode.c_str()));
@ -197,12 +198,12 @@ X11LayoutsParser::convertLayotToISO(const String &pathToEvdevFile, const String
return *iso639_1Codes.begin();
}
std::vector<String> X11LayoutsParser::convertISO639_2ToISO639_1(const std::vector<String> &iso639_2Codes)
std::vector<std::string> X11LayoutsParser::convertISO639_2ToISO639_1(const std::vector<std::string> &iso639_2Codes)
{
std::vector<String> result;
std::vector<std::string> result;
for (const auto &isoCode : iso639_2Codes) {
const auto &tableIter =
std::find_if(ISO_Table.begin(), ISO_Table.end(), [&isoCode](const std::pair<String, String> &c) {
std::find_if(ISO_Table.begin(), ISO_Table.end(), [&isoCode](const std::pair<std::string, std::string> &c) {
return c.first == isoCode;
});
if (tableIter == ISO_Table.end()) {

View File

@ -18,7 +18,9 @@
#if WINAPI_XWINDOWS
#pragma once
#include "base/String.h"
#include <string>
#include <vector>
namespace pugi {
class xml_node;
@ -27,30 +29,31 @@ class xml_node;
class X11LayoutsParser
{
public:
static std::vector<String> getX11LanguageList(const String &pathToEvdevFile);
static String
convertLayotToISO(const String &pathToEvdevFile, const String &layoutLangCode, bool needToReloadFiles = false);
static std::vector<std::string> getX11LanguageList(const std::string &pathToEvdevFile);
static std::string convertLayotToISO(
const std::string &pathToEvdevFile, const std::string &layoutLangCode, bool needToReloadFiles = false
);
private:
struct Lang
{
String name = "";
std::vector<String> layoutBaseISO639_2;
std::string name = "";
std::vector<std::string> layoutBaseISO639_2;
std::vector<Lang> variants;
};
static bool readXMLConfigItemElem(const pugi::xml_node *root, std::vector<Lang> &langList);
static std::vector<Lang> getAllLanguageData(const String &pathToEvdevFile);
static std::vector<Lang> getAllLanguageData(const std::string &pathToEvdevFile);
static void appendVectorUniq(const std::vector<String> &source, std::vector<String> &dst);
static void appendVectorUniq(const std::vector<std::string> &source, std::vector<std::string> &dst);
static void convertLayoutToISO639_2(
const String &pathToEvdevFile, bool needToReloadEvdev, const std::vector<String> &layoutNames,
const std::vector<String> &layoutVariantNames, std::vector<String> &iso639_2Codes
const std::string &pathToEvdevFile, bool needToReloadEvdev, const std::vector<std::string> &layoutNames,
const std::vector<std::string> &layoutVariantNames, std::vector<std::string> &iso639_2Codes
);
static std::vector<String> convertISO639_2ToISO639_1(const std::vector<String> &iso639_2Codes);
static std::vector<std::string> convertISO639_2ToISO639_1(const std::vector<std::string> &iso639_2Codes);
};
#endif // WINAPI_XWINDOWS

View File

@ -169,16 +169,16 @@ void AppUtilWindows::startNode()
app().startNode();
}
std::vector<String> AppUtilWindows::getKeyboardLayoutList()
std::vector<std::string> AppUtilWindows::getKeyboardLayoutList()
{
std::vector<String> layoutLangCodes;
std::vector<std::string> layoutLangCodes;
{
auto uLayouts = GetKeyboardLayoutList(0, NULL);
auto lpList = (HKL *)LocalAlloc(LPTR, (uLayouts * sizeof(HKL)));
uLayouts = GetKeyboardLayoutList(uLayouts, lpList);
for (int i = 0; i < uLayouts; ++i) {
String code("", 2);
std::string code("", 2);
GetLocaleInfoA(
MAKELCID(((ULONG_PTR)lpList[i] & 0xffffffff), SORT_DEFAULT), LOCALE_SISO639LANGNAME, &code[0],
static_cast<int>(code.size())
@ -193,9 +193,9 @@ std::vector<String> AppUtilWindows::getKeyboardLayoutList()
return layoutLangCodes;
}
String AppUtilWindows::getCurrentLanguageCode()
std::string AppUtilWindows::getCurrentLanguageCode()
{
String code("", 2);
std::string code("", 2);
auto hklLayout = getCurrentKeyboardLayout();
if (hklLayout) {
@ -243,7 +243,7 @@ public:
};
#endif
void AppUtilWindows::showNotification(const String &title, const String &text) const
void AppUtilWindows::showNotification(const std::string &title, const std::string &text) const
{
#if HAVE_WINTOAST
LOG((CLOG_INFO "showing notification, title=\"%s\", text=\"%s\"", title.c_str(), text.c_str()));

View File

@ -48,10 +48,10 @@ public:
void exitApp(int code) override;
void beforeAppExit() override;
void startNode() override;
std::vector<String> getKeyboardLayoutList() override;
String getCurrentLanguageCode() override;
std::vector<std::string> getKeyboardLayoutList() override;
std::string getCurrentLanguageCode() override;
HKL getCurrentKeyboardLayout() const;
void showNotification(const String &title, const String &text) const override;
void showNotification(const std::string &title, const std::string &text) const override;
private:
AppExitMode m_exitMode;

View File

@ -22,7 +22,7 @@
// XIOClosed
//
String XIOClosed::getWhat() const throw()
std::string XIOClosed::getWhat() const throw()
{
return format("XIOClosed", "already closed");
}
@ -31,7 +31,7 @@ String XIOClosed::getWhat() const throw()
// XIOEndOfStream
//
String XIOEndOfStream::getWhat() const throw()
std::string XIOEndOfStream::getWhat() const throw()
{
return format("XIOEndOfStream", "reached end of stream");
}
@ -40,7 +40,7 @@ String XIOEndOfStream::getWhat() const throw()
// XIOWouldBlock
//
String XIOWouldBlock::getWhat() const throw()
std::string XIOWouldBlock::getWhat() const throw()
{
return format("XIOWouldBlock", "stream operation would block");
}

View File

@ -130,7 +130,7 @@ void IpcClientProxy::send(const IpcMessage &message)
switch (message.type()) {
case IpcMessageType::LogLine: {
const IpcLogLineMessage &llm = static_cast<const IpcLogLineMessage &>(message);
const String logLine = llm.logLine();
const std::string logLine = llm.logLine();
ProtocolUtil::writef(&m_stream, kIpcMsgLogLine, &logLine);
break;
}
@ -162,7 +162,7 @@ IpcHelloMessage *IpcClientProxy::parseHello()
IpcCommandMessage *IpcClientProxy::parseCommand()
{
String command;
std::string command;
UInt8 elevate;
ProtocolUtil::readf(&m_stream, kIpcMsgCommand + 4, &command, &elevate);
@ -172,8 +172,8 @@ IpcCommandMessage *IpcClientProxy::parseCommand()
IpcSettingMessage *IpcClientProxy::parseSetting() const
{
String name;
String value;
std::string name;
std::string value;
ProtocolUtil::readf(&m_stream, kIpcMsgSetting + 4, &name, &value);

View File

@ -108,7 +108,7 @@ bool IpcLogOutputter::write(ELevel, const char *text)
return true;
}
void IpcLogOutputter::appendBuffer(const String &text)
void IpcLogOutputter::appendBuffer(const std::string &text)
{
ArchMutexLock lock(m_bufferMutex);
@ -166,7 +166,7 @@ void IpcLogOutputter::notifyBuffer()
ARCH->broadcastCondVar(m_notifyCond);
}
String IpcLogOutputter::getChunk(size_t count)
std::string IpcLogOutputter::getChunk(size_t count)
{
ArchMutexLock lock(m_bufferMutex);
@ -174,7 +174,7 @@ String IpcLogOutputter::getChunk(size_t count)
count = m_buffer.size();
}
String chunk;
std::string chunk;
for (size_t i = 0; i < count; i++) {
chunk.append(m_buffer.front());
chunk.append("\n");

View File

@ -93,12 +93,12 @@ public:
private:
void init();
void bufferThread(void *);
String getChunk(size_t count);
void appendBuffer(const String &text);
std::string getChunk(size_t count);
void appendBuffer(const std::string &text);
bool isRunning();
private:
using Buffer = std::deque<String>;
using Buffer = std::deque<std::string>;
IpcServer &m_ipcServer;
Buffer m_buffer;

View File

@ -35,11 +35,13 @@ IpcShutdownMessage::IpcShutdownMessage() : IpcMessage(IpcMessageType::Shutdown)
{
}
IpcLogLineMessage::IpcLogLineMessage(const String &logLine) : IpcMessage(IpcMessageType::LogLine), m_logLine(logLine)
IpcLogLineMessage::IpcLogLineMessage(const std::string &logLine)
: IpcMessage(IpcMessageType::LogLine),
m_logLine(logLine)
{
}
IpcCommandMessage::IpcCommandMessage(const String &command, bool elevate)
IpcCommandMessage::IpcCommandMessage(const std::string &command, bool elevate)
: IpcMessage(IpcMessageType::Command),
m_command(command),
m_elevate(elevate)

View File

@ -18,9 +18,10 @@
#pragma once
#include "base/Event.h"
#include "base/String.h"
#include "common/ipc.h"
#include <string>
class IpcMessage : public EventData
{
public:
@ -72,27 +73,27 @@ public:
class IpcLogLineMessage : public IpcMessage
{
public:
explicit IpcLogLineMessage(const String &logLine);
explicit IpcLogLineMessage(const std::string &logLine);
~IpcLogLineMessage() override = default;
//! Gets the log line.
String logLine() const
std::string logLine() const
{
return m_logLine;
}
private:
String m_logLine;
std::string m_logLine;
};
class IpcCommandMessage : public IpcMessage
{
public:
explicit IpcCommandMessage(const String &command, bool elevate);
explicit IpcCommandMessage(const std::string &command, bool elevate);
~IpcCommandMessage() override = default;
//! Gets the command.
String command() const
std::string command() const
{
return m_command;
}
@ -104,6 +105,6 @@ public:
}
private:
String m_command;
std::string m_command;
bool m_elevate;
};

View File

@ -86,7 +86,7 @@ void IpcServerProxy::send(const IpcMessage &message)
case IpcMessageType::Command: {
const IpcCommandMessage &cm = static_cast<const IpcCommandMessage &>(message);
const String command = cm.command();
const std::string command = cm.command();
ProtocolUtil::writef(&m_stream, kIpcMsgCommand, &command);
break;
}
@ -99,7 +99,7 @@ void IpcServerProxy::send(const IpcMessage &message)
IpcLogLineMessage *IpcServerProxy::parseLogLine()
{
String logLine;
std::string logLine;
ProtocolUtil::readf(&m_stream, kIpcMsgLogLine + 4, &logLine);
// must be deleted by event handler.

View File

@ -22,7 +22,7 @@
// XMTThreadUnavailable
//
String XMTThreadUnavailable::getWhat() const throw()
std::string XMTThreadUnavailable::getWhat() const throw()
{
return format("XMTThreadUnavailable", "cannot create thread");
}

View File

@ -19,7 +19,6 @@
#pragma once
#include "base/EventTypes.h"
#include "base/String.h"
#include "io/IStream.h"
#include "net/ISocket.h"
@ -37,7 +36,7 @@ public:
ConnectionFailedInfo(const char *what) : m_what(what)
{
}
String m_what;
std::string m_what;
};
IDataSocket(IEventQueue *events)

View File

@ -18,6 +18,7 @@
#include "SecureServerSocket.h"
#include <arch/XArch.h>
#include <base/String.h>
#include <common/constants.h>
#include <deskflow/ArgParser.h>
#include <deskflow/ArgsBase.h>

View File

@ -6,6 +6,7 @@
#include <base/Log.h>
#include <base/Path.h>
#include <base/String.h>
#include <openssl/err.h>
namespace deskflow {

View File

@ -43,7 +43,7 @@ NetworkAddress::NetworkAddress(const NetworkAddress &addr) : m_hostname(addr.m_h
*this = addr;
}
NetworkAddress::NetworkAddress(const String &hostname, int port) : m_hostname(hostname), m_port(port)
NetworkAddress::NetworkAddress(const std::string &hostname, int port) : m_hostname(hostname), m_port(port)
{
// detect internet protocol version with colom count
auto isColomPredicate = [](char c) { return c == ':'; };
@ -64,11 +64,11 @@ NetworkAddress::NetworkAddress(const String &hostname, int port) : m_hostname(ho
// ipv6 part
if (m_hostname[0] == '[') {
// ipv6 with port part
String portDelimeter = "]:";
std::string portDelimeter = "]:";
auto hostIt = m_hostname.find(portDelimeter);
// bad syntax of ipv6 with port
if (hostIt == String::npos) {
if (hostIt == std::string::npos) {
throw XSocketAddress(XSocketAddress::kUnknown, m_hostname, m_port);
}
@ -89,7 +89,7 @@ NetworkAddress::NetworkAddress(const String &hostname, int port) : m_hostname(ho
}
// ensure that ipv6 link-local adress ended with scope id
if (m_hostname.rfind("fe80:", 0) == 0 && m_hostname.find('%') == String::npos) {
if (m_hostname.rfind("fe80:", 0) == 0 && m_hostname.find('%') == std::string::npos) {
throw XSocketAddress(XSocketAddress::kUnknown, m_hostname, m_port);
}
}
@ -208,7 +208,7 @@ int NetworkAddress::getPort() const
return m_port;
}
String NetworkAddress::getHostname() const
std::string NetworkAddress::getHostname() const
{
return m_hostname;
}

View File

@ -20,7 +20,6 @@
#include "arch/IArchNetwork.h"
#include "base/EventTypes.h"
#include "base/String.h"
//! Network address type
/*!
@ -50,7 +49,7 @@ public:
is thrown with an error of \c XSocketAddress::kBadPort. The hostname
is not resolved by the c'tor; use \c resolve to do that.
*/
NetworkAddress(const String &hostname, int port = 0);
NetworkAddress(const std::string &hostname, int port = 0);
NetworkAddress(const NetworkAddress &);
@ -112,7 +111,7 @@ public:
/*!
Returns the hostname passed to the c'tor sans any port suffix.
*/
String getHostname() const;
std::string getHostname() const;
//@}
@ -121,6 +120,6 @@ private:
private:
ArchNetAddress m_address = nullptr;
String m_hostname;
std::string m_hostname;
int m_port = 0;
};

View File

@ -19,6 +19,7 @@
#include "SecureSocket.h"
#include "arch/XArch.h"
#include "base/String.h"
#include "common/constants.h"
#include "deskflow/ArgParser.h"
#include "deskflow/ArgsBase.h"
@ -53,7 +54,7 @@ IDataSocket *SecureListenSocket::accept()
}
// default location of the TLS cert file in users dir
String certificateFilename = deskflow::string::sprintf(
std::string certificateFilename = deskflow::string::sprintf(
"%s/%s/%s.%s", ARCH->getProfileDirectory().c_str(), s_certificateDir, kAppId, s_certificateFileExt
);

View File

@ -20,6 +20,7 @@
#include "arch/XArch.h"
#include "base/Log.h"
#include "base/Path.h"
#include "base/String.h"
#include "base/TMethodEventJob.h"
#include "mt/Lock.h"
#include "net/TCPSocket.h"
@ -303,7 +304,7 @@ void SecureSocket::initSsl(bool server)
initContext(server);
}
bool SecureSocket::loadCertificates(String &filename)
bool SecureSocket::loadCertificates(std::string &filename)
{
std::lock_guard<std::mutex> ssl_lock{ssl_mutex_};
@ -316,7 +317,7 @@ bool SecureSocket::loadCertificates(String &filename)
file.close();
if (!exist) {
String errorMsg("tls certificate doesn't exist: ");
std::string errorMsg("tls certificate doesn't exist: ");
errorMsg.append(filename);
SslLogger::logError(errorMsg.c_str());
return false;
@ -620,7 +621,7 @@ void SecureSocket::disconnect()
sendEvent(getEvents()->forIStream().inputShutdown());
}
void SecureSocket::formatFingerprint(String &fingerprint, bool hex, bool separator)
void SecureSocket::formatFingerprint(std::string &fingerprint, bool hex, bool separator)
{
if (hex) {
// to hexidecimal
@ -655,17 +656,17 @@ bool SecureSocket::verifyCertFingerprint()
}
// format fingerprint into hexdecimal format with colon separator
String fingerprint(static_cast<char *>(static_cast<void *>(tempFingerprint)), tempFingerprintLen);
std::string fingerprint(static_cast<char *>(static_cast<void *>(tempFingerprint)), tempFingerprintLen);
formatFingerprint(fingerprint);
LOG((CLOG_NOTE "server fingerprint: %s", fingerprint.c_str()));
String trustedServersFilename;
std::string trustedServersFilename;
trustedServersFilename = deskflow::string::sprintf(
"%s/%s/%s", ARCH->getProfileDirectory().c_str(), kFingerprintDirName, kFingerprintTrustedServersFilename
);
// check if this fingerprint exist
String fileLine;
std::string fileLine;
std::ifstream file;
file.open(deskflow::filesystem::path(trustedServersFilename));

Some files were not shown because too many files have changed in this diff Show More