refactor: use std::string in place of String
basedon: https://github.com/debauchee/barrier/pull/709
This commit is contained in:
parent
42a17726d9
commit
3991e0c1a1
223 changed files with 1415 additions and 1385 deletions
|
|
@ -211,7 +211,7 @@ void MSWindowsClientTaskBarReceiver::copyLog() const
|
||||||
{
|
{
|
||||||
if (m_logBuffer != NULL) {
|
if (m_logBuffer != NULL) {
|
||||||
// collect log buffer
|
// collect log buffer
|
||||||
String data;
|
std::string data;
|
||||||
for (BufferedLogOutputter::const_iterator index = m_logBuffer->begin(); index != m_logBuffer->end(); ++index) {
|
for (BufferedLogOutputter::const_iterator index = m_logBuffer->begin(); index != m_logBuffer->end(); ++index) {
|
||||||
data += *index;
|
data += *index;
|
||||||
data += "\n";
|
data += "\n";
|
||||||
|
|
|
||||||
|
|
@ -238,7 +238,7 @@ void MSWindowsServerTaskBarReceiver::copyLog() const
|
||||||
{
|
{
|
||||||
if (m_logBuffer != NULL) {
|
if (m_logBuffer != NULL) {
|
||||||
// collect log buffer
|
// collect log buffer
|
||||||
String data;
|
std::string data;
|
||||||
for (BufferedLogOutputter::const_iterator index = m_logBuffer->begin(); index != m_logBuffer->end(); ++index) {
|
for (BufferedLogOutputter::const_iterator index = m_logBuffer->begin(); index != m_logBuffer->end(); ++index) {
|
||||||
data += *index;
|
data += *index;
|
||||||
data += "\n";
|
data += "\n";
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "base/String.h"
|
|
||||||
#include "common/IInterface.h"
|
#include "common/IInterface.h"
|
||||||
|
#include <string>
|
||||||
|
|
||||||
//! Interface for architecture dependent daemonizing
|
//! Interface for architecture dependent daemonizing
|
||||||
/*!
|
/*!
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "base/String.h"
|
|
||||||
#include "common/IInterface.h"
|
#include "common/IInterface.h"
|
||||||
#include "common/stdstring.h"
|
#include "common/stdstring.h"
|
||||||
|
|
||||||
|
|
@ -93,12 +92,12 @@ public:
|
||||||
/*
|
/*
|
||||||
Returns the user's profile directory.
|
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
|
//! Set the user's plugin directory
|
||||||
/*
|
/*
|
||||||
Returns 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;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -18,9 +18,10 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "base/String.h"
|
|
||||||
#include "common/IInterface.h"
|
#include "common/IInterface.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
class IScreen;
|
class IScreen;
|
||||||
class INode;
|
class INode;
|
||||||
|
|
||||||
|
|
@ -91,7 +92,7 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual std::string getToolTip() const = 0;
|
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()
|
virtual void cleanup()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -146,12 +146,12 @@ std::string ArchFileUnix::concatPath(const std::string &prefix, const std::strin
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArchFileUnix::setProfileDirectory(const String &s)
|
void ArchFileUnix::setProfileDirectory(const std::string &s)
|
||||||
{
|
{
|
||||||
m_profileDirectory = s;
|
m_profileDirectory = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArchFileUnix::setPluginDirectory(const String &s)
|
void ArchFileUnix::setPluginDirectory(const std::string &s)
|
||||||
{
|
{
|
||||||
m_pluginDirectory = s;
|
m_pluginDirectory = s;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,10 +38,10 @@ public:
|
||||||
virtual std::string getPluginDirectory();
|
virtual std::string getPluginDirectory();
|
||||||
virtual std::string getProfileDirectory();
|
virtual std::string getProfileDirectory();
|
||||||
virtual std::string concatPath(const std::string &prefix, const std::string &suffix);
|
virtual std::string concatPath(const std::string &prefix, const std::string &suffix);
|
||||||
virtual void setProfileDirectory(const String &s);
|
virtual void setProfileDirectory(const std::string &s);
|
||||||
virtual void setPluginDirectory(const String &s);
|
virtual void setPluginDirectory(const std::string &s);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
String m_profileDirectory;
|
std::string m_profileDirectory;
|
||||||
String m_pluginDirectory;
|
std::string m_pluginDirectory;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -143,7 +143,7 @@ std::string ArchFileWindows::getPluginDirectory()
|
||||||
|
|
||||||
std::string ArchFileWindows::getProfileDirectory()
|
std::string ArchFileWindows::getProfileDirectory()
|
||||||
{
|
{
|
||||||
String dir;
|
std::string dir;
|
||||||
if (!m_profileDirectory.empty()) {
|
if (!m_profileDirectory.empty()) {
|
||||||
dir = m_profileDirectory;
|
dir = m_profileDirectory;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -173,12 +173,12 @@ std::string ArchFileWindows::concatPath(const std::string &prefix, const std::st
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArchFileWindows::setProfileDirectory(const String &s)
|
void ArchFileWindows::setProfileDirectory(const std::string &s)
|
||||||
{
|
{
|
||||||
m_profileDirectory = s;
|
m_profileDirectory = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArchFileWindows::setPluginDirectory(const String &s)
|
void ArchFileWindows::setPluginDirectory(const std::string &s)
|
||||||
{
|
{
|
||||||
m_pluginDirectory = s;
|
m_pluginDirectory = s;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,10 +38,10 @@ public:
|
||||||
virtual std::string getPluginDirectory();
|
virtual std::string getPluginDirectory();
|
||||||
virtual std::string getProfileDirectory();
|
virtual std::string getProfileDirectory();
|
||||||
virtual std::string concatPath(const std::string &prefix, const std::string &suffix);
|
virtual std::string concatPath(const std::string &prefix, const std::string &suffix);
|
||||||
virtual void setProfileDirectory(const String &s);
|
virtual void setProfileDirectory(const std::string &s);
|
||||||
virtual void setPluginDirectory(const String &s);
|
virtual void setPluginDirectory(const std::string &s);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
String m_profileDirectory;
|
std::string m_profileDirectory;
|
||||||
String m_pluginDirectory;
|
std::string m_pluginDirectory;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -384,7 +384,7 @@ void ArchMiscWindows::wakeupDisplay()
|
||||||
|
|
||||||
bool ArchMiscWindows::wasLaunchedAsService()
|
bool ArchMiscWindows::wasLaunchedAsService()
|
||||||
{
|
{
|
||||||
String name;
|
std::string name;
|
||||||
if (!getParentProcessName(name)) {
|
if (!getParentProcessName(name)) {
|
||||||
LOG((CLOG_ERR "cannot determine if process was launched as service"));
|
LOG((CLOG_ERR "cannot determine if process was launched as service"));
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -393,7 +393,7 @@ bool ArchMiscWindows::wasLaunchedAsService()
|
||||||
return (name == SERVICE_LAUNCHER);
|
return (name == SERVICE_LAUNCHER);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ArchMiscWindows::getParentProcessName(String &name)
|
bool ArchMiscWindows::getParentProcessName(std::string &name)
|
||||||
{
|
{
|
||||||
PROCESSENTRY32 parentEntry;
|
PROCESSENTRY32 parentEntry;
|
||||||
if (!getParentProcessEntry(parentEntry)) {
|
if (!getParentProcessEntry(parentEntry)) {
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "base/String.h"
|
|
||||||
#include "common/stdset.h"
|
#include "common/stdset.h"
|
||||||
#include "common/stdstring.h"
|
#include "common/stdstring.h"
|
||||||
|
|
||||||
|
|
@ -164,7 +163,7 @@ public:
|
||||||
static bool wasLaunchedAsService();
|
static bool wasLaunchedAsService();
|
||||||
|
|
||||||
//! Returns true if we got the parent process name.
|
//! Returns true if we got the parent process name.
|
||||||
static bool getParentProcessName(String &name);
|
static bool getParentProcessName(std::string &name);
|
||||||
|
|
||||||
static HINSTANCE instanceWin32();
|
static HINSTANCE instanceWin32();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -510,7 +510,7 @@ double EventQueue::getNextTimerTimeout() const
|
||||||
return m_timerQueue.top();
|
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);
|
NameMap::const_iterator found = m_nameMap.find(name);
|
||||||
if (found != m_nameMap.end())
|
if (found != m_nameMap.end())
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ public:
|
||||||
virtual bool isEmpty() const;
|
virtual bool isEmpty() const;
|
||||||
virtual IEventJob *getHandler(Event::Type type, void *target) const;
|
virtual IEventJob *getHandler(Event::Type type, void *target) const;
|
||||||
virtual const char *getTypeName(Event::Type type);
|
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();
|
void *getSystemTarget();
|
||||||
virtual void waitForReady() const;
|
virtual void waitForReady() const;
|
||||||
|
|
||||||
|
|
@ -107,7 +107,7 @@ private:
|
||||||
using EventTable = std::map<UInt32, Event>;
|
using EventTable = std::map<UInt32, Event>;
|
||||||
using EventIDList = std::vector<UInt32>;
|
using EventIDList = std::vector<UInt32>;
|
||||||
using TypeMap = std::map<Event::Type, const char *>;
|
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 TypeHandlerTable = std::map<Event::Type, IEventJob *>;
|
||||||
using HandlerTable = std::map<void *, TypeHandlerTable>;
|
using HandlerTable = std::map<void *, TypeHandlerTable>;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "base/Event.h"
|
#include "base/Event.h"
|
||||||
#include "base/String.h"
|
|
||||||
#include "common/IInterface.h"
|
#include "common/IInterface.h"
|
||||||
|
#include <string>
|
||||||
|
|
||||||
class IEventJob;
|
class IEventJob;
|
||||||
class IEventQueueBuffer;
|
class IEventQueueBuffer;
|
||||||
|
|
@ -211,7 +211,7 @@ public:
|
||||||
/*!
|
/*!
|
||||||
Returns the registered type for an event for a given name.
|
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
|
//! Get the system event type target
|
||||||
/*!
|
/*!
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ namespace filesystem {
|
||||||
|
|
||||||
#ifdef SYSAPI_WIN32
|
#ifdef SYSAPI_WIN32
|
||||||
|
|
||||||
std::wstring path(const String &filePath)
|
std::wstring path(const std::string &filePath)
|
||||||
{
|
{
|
||||||
std::wstring result;
|
std::wstring result;
|
||||||
|
|
||||||
|
|
@ -40,7 +40,7 @@ std::wstring path(const String &filePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
std::string path(const String &filePath)
|
std::string path(const std::string &filePath)
|
||||||
{
|
{
|
||||||
return filePath;
|
return filePath;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,16 +16,17 @@
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "String.h"
|
#include <common/common.h>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace deskflow {
|
namespace deskflow {
|
||||||
|
|
||||||
namespace filesystem {
|
namespace filesystem {
|
||||||
|
|
||||||
#ifdef SYSAPI_WIN32
|
#ifdef SYSAPI_WIN32
|
||||||
std::wstring path(const String &filePath);
|
std::wstring path(const std::string &filePath);
|
||||||
#else
|
#else
|
||||||
std::string path(const String &filePath);
|
std::string path(const std::string &filePath);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
} // namespace filesystem
|
} // namespace filesystem
|
||||||
|
|
|
||||||
|
|
@ -30,20 +30,21 @@
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace deskflow {
|
namespace deskflow {
|
||||||
namespace string {
|
namespace string {
|
||||||
|
|
||||||
String format(const char *fmt, ...)
|
std::string format(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
String result = vformat(fmt, args);
|
std::string result = vformat(fmt, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
return result;
|
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
|
// find highest indexed substitution and the locations of substitutions
|
||||||
std::vector<size_t> pos;
|
std::vector<size_t> pos;
|
||||||
|
|
@ -108,7 +109,7 @@ String vformat(const char *fmt, va_list args)
|
||||||
}
|
}
|
||||||
|
|
||||||
// substitute
|
// substitute
|
||||||
String result;
|
std::string result;
|
||||||
result.reserve(resultLength);
|
result.reserve(resultLength);
|
||||||
size_t src = 0;
|
size_t src = 0;
|
||||||
for (int i = 0; i < n; ++i) {
|
for (int i = 0; i < n; ++i) {
|
||||||
|
|
@ -121,12 +122,12 @@ String vformat(const char *fmt, va_list args)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
String sprintf(const char *fmt, ...)
|
std::string sprintf(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
char tmp[1024];
|
char tmp[1024];
|
||||||
char *buffer = tmp;
|
char *buffer = tmp;
|
||||||
int len = (int)(sizeof(tmp) / sizeof(tmp[0]));
|
int len = (int)(sizeof(tmp) / sizeof(tmp[0]));
|
||||||
String result;
|
std::string result;
|
||||||
while (buffer != NULL) {
|
while (buffer != NULL) {
|
||||||
// try printing into the buffer
|
// try printing into the buffer
|
||||||
va_list args;
|
va_list args;
|
||||||
|
|
@ -156,27 +157,27 @@ String sprintf(const char *fmt, ...)
|
||||||
return result;
|
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;
|
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);
|
subject.replace(pos, find.length(), replace);
|
||||||
pos += replace.length();
|
pos += replace.length();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String removeFileExt(String filename)
|
std::string removeFileExt(std::string filename)
|
||||||
{
|
{
|
||||||
size_t dot = filename.find_last_of('.');
|
size_t dot = filename.find_last_of('.');
|
||||||
|
|
||||||
if (dot == String::npos) {
|
if (dot == std::string::npos) {
|
||||||
return filename;
|
return filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
return filename.substr(0, dot);
|
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;
|
std::stringstream ss;
|
||||||
ss << std::hex;
|
ss << std::hex;
|
||||||
|
|
@ -187,24 +188,24 @@ void toHex(String &subject, int width, const char fill)
|
||||||
subject = ss.str();
|
subject = ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
void uppercase(String &subject)
|
void uppercase(std::string &subject)
|
||||||
{
|
{
|
||||||
std::transform(subject.begin(), subject.end(), subject.begin(), ::toupper);
|
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());
|
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;
|
std::stringstream ss;
|
||||||
ss << n;
|
ss << n;
|
||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t stringToSizeType(String string)
|
size_t stringToSizeType(std::string string)
|
||||||
{
|
{
|
||||||
std::istringstream iss(string);
|
std::istringstream iss(string);
|
||||||
size_t value;
|
size_t value;
|
||||||
|
|
@ -212,13 +213,13 @@ size_t stringToSizeType(String string)
|
||||||
return value;
|
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 head = 0;
|
||||||
size_t separator = string.find(c);
|
size_t separator = string.find(c);
|
||||||
while (separator != String::npos) {
|
while (separator != std::string::npos) {
|
||||||
if (head != separator) {
|
if (head != separator) {
|
||||||
results.push_back(string.substr(head, separator - head));
|
results.push_back(string.substr(head, separator - head));
|
||||||
}
|
}
|
||||||
|
|
@ -237,31 +238,31 @@ std::vector<String> splitString(String string, const char c)
|
||||||
// CaselessCmp
|
// 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 less(a, b);
|
||||||
return tolower(a) == tolower(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
|
// should use std::tolower but not in all versions of libstdc++ have it
|
||||||
return tolower(a) < tolower(b);
|
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);
|
// should use std::tolower but not in all versions of libstdc++ have it
|
||||||
}
|
return tolower(a) == tolower(b);
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace string
|
} // namespace string
|
||||||
|
|
|
||||||
|
|
@ -24,12 +24,9 @@
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
// use standard C++ string class for our string class
|
|
||||||
using String = std::string;
|
|
||||||
|
|
||||||
namespace deskflow {
|
namespace deskflow {
|
||||||
|
|
||||||
//! String utilities
|
//! std::string utilities
|
||||||
/*!
|
/*!
|
||||||
Provides functions for string manipulation.
|
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
|
All arguments in the variable list are const char*. Positional
|
||||||
elements are indexed from 1.
|
elements are indexed from 1.
|
||||||
*/
|
*/
|
||||||
String format(const char *fmt, ...);
|
std::string format(const char *fmt, ...);
|
||||||
|
|
||||||
//! Format positional arguments
|
//! Format positional arguments
|
||||||
/*!
|
/*!
|
||||||
Same as format() except takes va_list.
|
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
|
//! Print a string using sprintf-style formatting
|
||||||
/*!
|
/*!
|
||||||
Equivalent to sprintf() except the result is returned as a String.
|
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
|
//! Find and replace all
|
||||||
/*!
|
/*!
|
||||||
Finds \c find inside \c subject and replaces it with \c replace
|
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
|
//! Remove file extension
|
||||||
/*!
|
/*!
|
||||||
Finds the last dot and remove all characters from the dot to the end
|
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 into hexdecimal
|
||||||
/*!
|
/*!
|
||||||
Convert each character in \c subject into hexdecimal form with \c width
|
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 to all uppercase
|
||||||
/*!
|
/*!
|
||||||
Convert each character in \c subject to 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 char in suject
|
||||||
/*!
|
/*!
|
||||||
Remove all specific \c c in \c 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 a size type to a string
|
||||||
/*!
|
/*!
|
||||||
Convert an 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 a string to a size type
|
||||||
/*!
|
/*!
|
||||||
Convert an a \c string to an 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 string into substrings
|
||||||
/*!
|
/*!
|
||||||
Split a \c string that separated by a \c c 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
|
//! Case-insensitive comparisons
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -115,19 +112,19 @@ class CaselessCmp
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//! Same as less()
|
//! 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
|
//! 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
|
//! 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
|
//! 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
|
//! 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
|
} // namespace string
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@ inline static void setError(bool *errors)
|
||||||
UInt32 Unicode::s_invalid = 0x0000ffff;
|
UInt32 Unicode::s_invalid = 0x0000ffff;
|
||||||
UInt32 Unicode::s_replacement = 0x0000fffd;
|
UInt32 Unicode::s_replacement = 0x0000fffd;
|
||||||
|
|
||||||
bool Unicode::isUTF8(const String &src)
|
bool Unicode::isUTF8(const std::string &src)
|
||||||
{
|
{
|
||||||
// convert and test each character
|
// convert and test each character
|
||||||
const UInt8 *data = reinterpret_cast<const UInt8 *>(src.c_str());
|
const UInt8 *data = reinterpret_cast<const UInt8 *>(src.c_str());
|
||||||
|
|
@ -96,14 +96,14 @@ bool Unicode::isUTF8(const String &src)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
String Unicode::UTF8ToUCS2(const String &src, bool *errors)
|
std::string Unicode::UTF8ToUCS2(const std::string &src, bool *errors)
|
||||||
{
|
{
|
||||||
// default to success
|
// default to success
|
||||||
resetError(errors);
|
resetError(errors);
|
||||||
|
|
||||||
// get size of input string and reserve some space in output
|
// get size of input string and reserve some space in output
|
||||||
UInt32 n = (UInt32)src.size();
|
UInt32 n = (UInt32)src.size();
|
||||||
String dst;
|
std::string dst;
|
||||||
dst.reserve(2 * n);
|
dst.reserve(2 * n);
|
||||||
|
|
||||||
// convert each character
|
// convert each character
|
||||||
|
|
@ -123,14 +123,14 @@ String Unicode::UTF8ToUCS2(const String &src, bool *errors)
|
||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
String Unicode::UTF8ToUCS4(const String &src, bool *errors)
|
std::string Unicode::UTF8ToUCS4(const std::string &src, bool *errors)
|
||||||
{
|
{
|
||||||
// default to success
|
// default to success
|
||||||
resetError(errors);
|
resetError(errors);
|
||||||
|
|
||||||
// get size of input string and reserve some space in output
|
// get size of input string and reserve some space in output
|
||||||
UInt32 n = (UInt32)src.size();
|
UInt32 n = (UInt32)src.size();
|
||||||
String dst;
|
std::string dst;
|
||||||
dst.reserve(4 * n);
|
dst.reserve(4 * n);
|
||||||
|
|
||||||
// convert each character
|
// convert each character
|
||||||
|
|
@ -146,14 +146,14 @@ String Unicode::UTF8ToUCS4(const String &src, bool *errors)
|
||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
String Unicode::UTF8ToUTF16(const String &src, bool *errors)
|
std::string Unicode::UTF8ToUTF16(const std::string &src, bool *errors)
|
||||||
{
|
{
|
||||||
// default to success
|
// default to success
|
||||||
resetError(errors);
|
resetError(errors);
|
||||||
|
|
||||||
// get size of input string and reserve some space in output
|
// get size of input string and reserve some space in output
|
||||||
UInt32 n = (UInt32)src.size();
|
UInt32 n = (UInt32)src.size();
|
||||||
String dst;
|
std::string dst;
|
||||||
dst.reserve(2 * n);
|
dst.reserve(2 * n);
|
||||||
|
|
||||||
// convert each character
|
// convert each character
|
||||||
|
|
@ -181,14 +181,14 @@ String Unicode::UTF8ToUTF16(const String &src, bool *errors)
|
||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
String Unicode::UTF8ToUTF32(const String &src, bool *errors)
|
std::string Unicode::UTF8ToUTF32(const std::string &src, bool *errors)
|
||||||
{
|
{
|
||||||
// default to success
|
// default to success
|
||||||
resetError(errors);
|
resetError(errors);
|
||||||
|
|
||||||
// get size of input string and reserve some space in output
|
// get size of input string and reserve some space in output
|
||||||
UInt32 n = (UInt32)src.size();
|
UInt32 n = (UInt32)src.size();
|
||||||
String dst;
|
std::string dst;
|
||||||
dst.reserve(4 * n);
|
dst.reserve(4 * n);
|
||||||
|
|
||||||
// convert each character
|
// convert each character
|
||||||
|
|
@ -207,7 +207,7 @@ String Unicode::UTF8ToUTF32(const String &src, bool *errors)
|
||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
String Unicode::UTF8ToText(const String &src, bool *errors)
|
std::string Unicode::UTF8ToText(const std::string &src, bool *errors)
|
||||||
{
|
{
|
||||||
// default to success
|
// default to success
|
||||||
resetError(errors);
|
resetError(errors);
|
||||||
|
|
@ -220,7 +220,7 @@ String Unicode::UTF8ToText(const String &src, bool *errors)
|
||||||
int len = ARCH->convStringWCToMB(NULL, tmp, size, errors);
|
int len = ARCH->convStringWCToMB(NULL, tmp, size, errors);
|
||||||
char *mbs = new char[len + 1];
|
char *mbs = new char[len + 1];
|
||||||
ARCH->convStringWCToMB(mbs, tmp, size, errors);
|
ARCH->convStringWCToMB(mbs, tmp, size, errors);
|
||||||
String text(mbs, len);
|
std::string text(mbs, len);
|
||||||
|
|
||||||
// clean up
|
// clean up
|
||||||
delete[] mbs;
|
delete[] mbs;
|
||||||
|
|
@ -229,7 +229,7 @@ String Unicode::UTF8ToText(const String &src, bool *errors)
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
String Unicode::UCS2ToUTF8(const String &src, bool *errors)
|
std::string Unicode::UCS2ToUTF8(const std::string &src, bool *errors)
|
||||||
{
|
{
|
||||||
// default to success
|
// default to success
|
||||||
resetError(errors);
|
resetError(errors);
|
||||||
|
|
@ -239,7 +239,7 @@ String Unicode::UCS2ToUTF8(const String &src, bool *errors)
|
||||||
return doUCS2ToUTF8(reinterpret_cast<const UInt8 *>(src.data()), n, 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
|
// default to success
|
||||||
resetError(errors);
|
resetError(errors);
|
||||||
|
|
@ -249,7 +249,7 @@ String Unicode::UCS4ToUTF8(const String &src, bool *errors)
|
||||||
return doUCS4ToUTF8(reinterpret_cast<const UInt8 *>(src.data()), n, 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
|
// default to success
|
||||||
resetError(errors);
|
resetError(errors);
|
||||||
|
|
@ -259,7 +259,7 @@ String Unicode::UTF16ToUTF8(const String &src, bool *errors)
|
||||||
return doUTF16ToUTF8(reinterpret_cast<const UInt8 *>(src.data()), n, 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
|
// default to success
|
||||||
resetError(errors);
|
resetError(errors);
|
||||||
|
|
@ -269,7 +269,7 @@ String Unicode::UTF32ToUTF8(const String &src, bool *errors)
|
||||||
return doUTF32ToUTF8(reinterpret_cast<const UInt8 *>(src.data()), n, 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
|
// default to success
|
||||||
resetError(errors);
|
resetError(errors);
|
||||||
|
|
@ -281,7 +281,7 @@ String Unicode::textToUTF8(const String &src, bool *errors, IArchString::EWideCh
|
||||||
ARCH->convStringMBToWC(wcs, src.c_str(), n, errors);
|
ARCH->convStringMBToWC(wcs, src.c_str(), n, errors);
|
||||||
|
|
||||||
// convert to UTF8
|
// convert to UTF8
|
||||||
String utf8 = wideCharToUTF8(wcs, len, errors, encoding);
|
std::string utf8 = wideCharToUTF8(wcs, len, errors, encoding);
|
||||||
|
|
||||||
// clean up
|
// clean up
|
||||||
delete[] wcs;
|
delete[] wcs;
|
||||||
|
|
@ -289,10 +289,10 @@ String Unicode::textToUTF8(const String &src, bool *errors, IArchString::EWideCh
|
||||||
return utf8;
|
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
|
// convert to platform's wide character encoding
|
||||||
String tmp;
|
std::string tmp;
|
||||||
switch (ARCH->getWideCharEncoding()) {
|
switch (ARCH->getWideCharEncoding()) {
|
||||||
case IArchString::kUCS2:
|
case IArchString::kUCS2:
|
||||||
tmp = UTF8ToUCS2(src, errors);
|
tmp = UTF8ToUCS2(src, errors);
|
||||||
|
|
@ -324,7 +324,8 @@ wchar_t *Unicode::UTF8ToWideChar(const String &src, UInt32 &size, bool *errors)
|
||||||
return dst;
|
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) {
|
if (encoding == IArchString::kPlatformDetermined) {
|
||||||
encoding = ARCH->getWideCharEncoding();
|
encoding = ARCH->getWideCharEncoding();
|
||||||
|
|
@ -347,14 +348,14 @@ String Unicode::wideCharToUTF8(const wchar_t *src, UInt32 size, bool *errors, IA
|
||||||
|
|
||||||
default:
|
default:
|
||||||
assert(0 && "unknown wide character encoding");
|
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
|
// make some space
|
||||||
String dst;
|
std::string dst;
|
||||||
dst.reserve(n);
|
dst.reserve(n);
|
||||||
|
|
||||||
// check if first character is 0xfffe or 0xfeff
|
// check if first character is 0xfffe or 0xfeff
|
||||||
|
|
@ -387,10 +388,10 @@ String Unicode::doUCS2ToUTF8(const UInt8 *data, UInt32 n, bool *errors)
|
||||||
return dst;
|
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
|
// make some space
|
||||||
String dst;
|
std::string dst;
|
||||||
dst.reserve(n);
|
dst.reserve(n);
|
||||||
|
|
||||||
// check if first character is 0xfffe or 0xfeff
|
// check if first character is 0xfffe or 0xfeff
|
||||||
|
|
@ -423,10 +424,10 @@ String Unicode::doUCS4ToUTF8(const UInt8 *data, UInt32 n, bool *errors)
|
||||||
return dst;
|
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
|
// make some space
|
||||||
String dst;
|
std::string dst;
|
||||||
dst.reserve(n);
|
dst.reserve(n);
|
||||||
|
|
||||||
// check if first character is 0xfffe or 0xfeff
|
// check if first character is 0xfffe or 0xfeff
|
||||||
|
|
@ -482,10 +483,10 @@ String Unicode::doUTF16ToUTF8(const UInt8 *data, UInt32 n, bool *errors)
|
||||||
return dst;
|
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
|
// make some space
|
||||||
String dst;
|
std::string dst;
|
||||||
dst.reserve(n);
|
dst.reserve(n);
|
||||||
|
|
||||||
// check if first character is 0xfffe or 0xfeff
|
// check if first character is 0xfffe or 0xfeff
|
||||||
|
|
@ -672,7 +673,7 @@ UInt32 Unicode::fromUTF8(const UInt8 *&data, UInt32 &n)
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Unicode::toUTF8(String &dst, UInt32 c, bool *errors)
|
void Unicode::toUTF8(std::string &dst, UInt32 c, bool *errors)
|
||||||
{
|
{
|
||||||
UInt8 data[6];
|
UInt8 data[6];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "arch/IArchString.h"
|
#include "arch/IArchString.h"
|
||||||
#include "base/String.h"
|
|
||||||
#include "common/basic_types.h"
|
#include "common/basic_types.h"
|
||||||
|
#include <string>
|
||||||
|
|
||||||
//! Unicode utility functions
|
//! Unicode utility functions
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -38,7 +38,7 @@ public:
|
||||||
Returns true iff the string contains a valid sequence of UTF-8
|
Returns true iff the string contains a valid sequence of UTF-8
|
||||||
encoded characters.
|
encoded characters.
|
||||||
*/
|
*/
|
||||||
static bool isUTF8(const String &);
|
static bool isUTF8(const std::string &);
|
||||||
|
|
||||||
//! Convert from UTF-8 to UCS-2 encoding
|
//! 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.
|
is set to true iff any character could not be encoded in UCS-2.
|
||||||
Decoding errors do not set *errors.
|
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
|
//! 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.
|
is set to true iff any character could not be encoded in UCS-4.
|
||||||
Decoding errors do not set *errors.
|
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
|
//! 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.
|
is set to true iff any character could not be encoded in UTF-16.
|
||||||
Decoding errors do not set *errors.
|
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
|
//! 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.
|
is set to true iff any character could not be encoded in UTF-32.
|
||||||
Decoding errors do not set *errors.
|
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
|
//! 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.
|
NULL then *errors is set to true iff any character could not be encoded.
|
||||||
Decoding errors do not set *errors.
|
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
|
||||||
/*!
|
/*!
|
||||||
Convert from UCS-2 to UTF-8. If errors is not NULL then *errors is
|
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.
|
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
|
||||||
/*!
|
/*!
|
||||||
Convert from UCS-4 to UTF-8. If errors is not NULL then *errors is
|
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.
|
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
|
||||||
/*!
|
/*!
|
||||||
Convert from UTF-16 to UTF-8. If errors is not NULL then *errors is
|
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.
|
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
|
||||||
/*!
|
/*!
|
||||||
Convert from UTF-32 to UTF-8. If errors is not NULL then *errors is
|
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.
|
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
|
||||||
/*!
|
/*!
|
||||||
Convert from the current locale encoding to UTF-8. If errors is not
|
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.
|
NULL then *errors is set to true iff any character could not be decoded.
|
||||||
*/
|
*/
|
||||||
static String textToUTF8(
|
static std::string textToUTF8(
|
||||||
const String &, bool *errors = nullptr, IArchString::EWideCharEncoding encoding = IArchString::kPlatformDetermined
|
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
|
// to the platform). caller must delete[] the returned string. the
|
||||||
// string is *not* nul terminated; the length (in characters) is
|
// string is *not* nul terminated; the length (in characters) is
|
||||||
// returned in size.
|
// 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
|
// convert nul terminated wchar_t string (in platform's native
|
||||||
// encoding) to UTF8.
|
// encoding) to UTF8.
|
||||||
static String wideCharToUTF8(
|
static std::string wideCharToUTF8(
|
||||||
const wchar_t *, UInt32 size, bool *errors,
|
const wchar_t *, UInt32 size, bool *errors,
|
||||||
IArchString::EWideCharEncoding encoding = IArchString::kPlatformDetermined
|
IArchString::EWideCharEncoding encoding = IArchString::kPlatformDetermined
|
||||||
);
|
);
|
||||||
|
|
||||||
// internal conversion to UTF8
|
// internal conversion to UTF8
|
||||||
static String doUCS2ToUTF8(const UInt8 *src, UInt32 n, bool *errors);
|
static std::string doUCS2ToUTF8(const UInt8 *src, UInt32 n, bool *errors);
|
||||||
static String doUCS4ToUTF8(const UInt8 *src, UInt32 n, bool *errors);
|
static std::string doUCS4ToUTF8(const UInt8 *src, UInt32 n, bool *errors);
|
||||||
static String doUTF16ToUTF8(const UInt8 *src, UInt32 n, bool *errors);
|
static std::string doUTF16ToUTF8(const UInt8 *src, UInt32 n, bool *errors);
|
||||||
static String doUTF32ToUTF8(const UInt8 *src, UInt32 n, bool *errors);
|
static std::string doUTF32ToUTF8(const UInt8 *src, UInt32 n, bool *errors);
|
||||||
|
|
||||||
// convert characters to/from UTF8
|
// convert characters to/from UTF8
|
||||||
static UInt32 fromUTF8(const UInt8 *&src, UInt32 &size);
|
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:
|
private:
|
||||||
static UInt32 s_invalid;
|
static UInt32 s_invalid;
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ XBase::XBase() : std::runtime_error("")
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
XBase::XBase(const String &msg) : std::runtime_error(msg)
|
XBase::XBase(const std::string &msg) : std::runtime_error(msg)
|
||||||
{
|
{
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
@ -52,13 +52,13 @@ const char *XBase::what() const _NOEXCEPT
|
||||||
return m_what.c_str();
|
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
|
// FIXME -- lookup message string using id as an index. set
|
||||||
// fmt to that string if it exists.
|
// fmt to that string if it exists.
|
||||||
|
|
||||||
// format
|
// format
|
||||||
String result;
|
std::string result;
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "base/String.h"
|
|
||||||
#include "common/stdexcept.h"
|
#include "common/stdexcept.h"
|
||||||
|
#include <string>
|
||||||
|
|
||||||
//! Exception base class
|
//! Exception base class
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -31,7 +31,7 @@ public:
|
||||||
//! Use getWhat() as the result of what()
|
//! Use getWhat() as the result of what()
|
||||||
XBase();
|
XBase();
|
||||||
//! Use \c msg as the result of what()
|
//! Use \c msg as the result of what()
|
||||||
XBase(const String &msg);
|
XBase(const std::string &msg);
|
||||||
virtual ~XBase() _NOEXCEPT;
|
virtual ~XBase() _NOEXCEPT;
|
||||||
|
|
||||||
//! Reason for exception
|
//! Reason for exception
|
||||||
|
|
@ -39,7 +39,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//! Get a human readable string describing the exception
|
//! Get a human readable string describing the exception
|
||||||
virtual String getWhat() const throw()
|
virtual std::string getWhat() const throw()
|
||||||
{
|
{
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
@ -50,16 +50,16 @@ protected:
|
||||||
no format can be found, then replaces positional parameters in
|
no format can be found, then replaces positional parameters in
|
||||||
the format string and returns the result.
|
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:
|
private:
|
||||||
mutable String m_what;
|
mutable std::string m_what;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\def XBASE_SUBCLASS
|
\def XBASE_SUBCLASS
|
||||||
Convenience macro to subclass from XBase (or a subclass of it),
|
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.
|
declared.
|
||||||
*/
|
*/
|
||||||
#define XBASE_SUBCLASS(name_, super_) \
|
#define XBASE_SUBCLASS(name_, super_) \
|
||||||
|
|
@ -69,7 +69,7 @@ declared.
|
||||||
name_() : super_() \
|
name_() : super_() \
|
||||||
{ \
|
{ \
|
||||||
} \
|
} \
|
||||||
name_(const String &msg) : super_(msg) \
|
name_(const std::string &msg) : super_(msg) \
|
||||||
{ \
|
{ \
|
||||||
} \
|
} \
|
||||||
virtual ~name_() _NOEXCEPT \
|
virtual ~name_() _NOEXCEPT \
|
||||||
|
|
@ -80,7 +80,7 @@ declared.
|
||||||
/*!
|
/*!
|
||||||
\def XBASE_SUBCLASS
|
\def XBASE_SUBCLASS
|
||||||
Convenience macro to subclass from XBase (or a subclass of it),
|
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.
|
implemented.
|
||||||
*/
|
*/
|
||||||
#define XBASE_SUBCLASS_WHAT(name_, super_) \
|
#define XBASE_SUBCLASS_WHAT(name_, super_) \
|
||||||
|
|
@ -90,7 +90,7 @@ implemented.
|
||||||
name_() : super_() \
|
name_() : super_() \
|
||||||
{ \
|
{ \
|
||||||
} \
|
} \
|
||||||
name_(const String &msg) : super_(msg) \
|
name_(const std::string &msg) : super_(msg) \
|
||||||
{ \
|
{ \
|
||||||
} \
|
} \
|
||||||
virtual ~name_() _NOEXCEPT \
|
virtual ~name_() _NOEXCEPT \
|
||||||
|
|
@ -98,13 +98,13 @@ implemented.
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
protected: \
|
protected: \
|
||||||
virtual String getWhat() const throw(); \
|
virtual std::string getWhat() const throw(); \
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\def XBASE_SUBCLASS_FORMAT
|
\def XBASE_SUBCLASS_FORMAT
|
||||||
Convenience macro to subclass from XBase (or a subclass of it),
|
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
|
to call getWhat() when first called; getWhat() can format the
|
||||||
error message and can call what() to get the message passed to the
|
error message and can call what() to get the message passed to the
|
||||||
c'tor.
|
c'tor.
|
||||||
|
|
@ -124,7 +124,7 @@ c'tor.
|
||||||
name_() : super_(), m_state(kDone) \
|
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 \
|
virtual ~name_() _NOEXCEPT \
|
||||||
|
|
@ -146,7 +146,7 @@ c'tor.
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
protected: \
|
protected: \
|
||||||
virtual String getWhat() const throw(); \
|
virtual std::string getWhat() const throw(); \
|
||||||
\
|
\
|
||||||
private: \
|
private: \
|
||||||
mutable EState m_state; \
|
mutable EState m_state; \
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@
|
||||||
#include "base/log_outputters.h"
|
#include "base/log_outputters.h"
|
||||||
#include "arch/Arch.h"
|
#include "arch/Arch.h"
|
||||||
#include "base/Path.h"
|
#include "base/Path.h"
|
||||||
|
#include "base/String.h"
|
||||||
#include "base/TMethodJob.h"
|
#include "base/TMethodJob.h"
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
@ -205,7 +206,7 @@ bool BufferedLogOutputter::write(ELevel, const char *message)
|
||||||
while (m_buffer.size() >= m_maxBufferSize) {
|
while (m_buffer.size() >= m_maxBufferSize) {
|
||||||
m_buffer.pop_front();
|
m_buffer.pop_front();
|
||||||
}
|
}
|
||||||
m_buffer.push_back(String(message));
|
m_buffer.push_back(std::string(message));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -246,7 +247,7 @@ bool FileLogOutputter::write(ELevel level, const char *message)
|
||||||
m_handle.close();
|
m_handle.close();
|
||||||
|
|
||||||
if (moveFile) {
|
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());
|
remove(oldLogFilename.c_str());
|
||||||
rename(m_fileName.c_str(), oldLogFilename.c_str());
|
rename(m_fileName.c_str(), oldLogFilename.c_str());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,13 +19,13 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "base/ILogOutputter.h"
|
#include "base/ILogOutputter.h"
|
||||||
#include "base/String.h"
|
|
||||||
#include "common/basic_types.h"
|
#include "common/basic_types.h"
|
||||||
#include "common/stddeque.h"
|
#include "common/stddeque.h"
|
||||||
#include "mt/Thread.h"
|
#include "mt/Thread.h"
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
//! Stop traversing log chain outputter
|
//! Stop traversing log chain outputter
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -137,7 +137,7 @@ This outputter records the last N log messages.
|
||||||
class BufferedLogOutputter : public ILogOutputter
|
class BufferedLogOutputter : public ILogOutputter
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
using Buffer = std::deque<String>;
|
using Buffer = std::deque<std::string>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using const_iterator = Buffer::const_iterator;
|
using const_iterator = Buffer::const_iterator;
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ using namespace deskflow::client;
|
||||||
//
|
//
|
||||||
|
|
||||||
Client::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
|
deskflow::Screen *screen, deskflow::ClientArgs const &args
|
||||||
)
|
)
|
||||||
: m_mock(false),
|
: m_mock(false),
|
||||||
|
|
@ -299,12 +299,12 @@ void Client::setClipboardDirty(ClipboardID, bool)
|
||||||
assert(0 && "shouldn't be called");
|
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);
|
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);
|
m_screen->keyRepeat(id, mask, count, button, lang);
|
||||||
}
|
}
|
||||||
|
|
@ -378,7 +378,7 @@ void Client::setOptions(const OptionsList &options)
|
||||||
m_screen->setOptions(options);
|
m_screen->setOptions(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
String Client::getName() const
|
std::string Client::getName() const
|
||||||
{
|
{
|
||||||
return m_name;
|
return m_name;
|
||||||
}
|
}
|
||||||
|
|
@ -402,7 +402,7 @@ void Client::sendClipboard(ClipboardID id)
|
||||||
// check time
|
// check time
|
||||||
if (m_timeClipboard[id] == 0 || clipboard.getTime() != m_timeClipboard[id]) {
|
if (m_timeClipboard[id] == 0 || clipboard.getTime() != m_timeClipboard[id]) {
|
||||||
// marshall the data
|
// marshall the data
|
||||||
String data = clipboard.marshall();
|
std::string data = clipboard.marshall();
|
||||||
if (data.size() >= m_maximumClipboardSize * 1024) {
|
if (data.size() >= m_maximumClipboardSize * 1024) {
|
||||||
LOG(
|
LOG(
|
||||||
(CLOG_NOTE "skipping clipboard transfer because the clipboard"
|
(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);
|
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
|
// TODO: fix duplicate function from CServer
|
||||||
if (!m_args.m_enableDragDrop) {
|
if (!m_args.m_enableDragDrop) {
|
||||||
|
|
@ -798,7 +798,7 @@ void Client::sendFileThread(void *filename)
|
||||||
m_sendFileThread.reset(nullptr);
|
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);
|
m_server->sendDragInfo(fileCount, info.c_str(), size);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
bool m_retry;
|
bool m_retry;
|
||||||
String m_what;
|
std::string m_what;
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -69,7 +69,7 @@ public:
|
||||||
to create the socket. \p screen is the local screen.
|
to create the socket. \p screen is the local screen.
|
||||||
*/
|
*/
|
||||||
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
|
deskflow::Screen *screen, deskflow::ClientArgs const &args
|
||||||
);
|
);
|
||||||
Client(Client const &) = delete;
|
Client(Client const &) = delete;
|
||||||
|
|
@ -109,13 +109,13 @@ public:
|
||||||
virtual void handshakeComplete();
|
virtual void handshakeComplete();
|
||||||
|
|
||||||
//! Received drag information
|
//! 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
|
//! Create a new thread and use it to send file to Server
|
||||||
void sendFileToServer(const char *filename);
|
void sendFileToServer(const char *filename);
|
||||||
|
|
||||||
//! Send dragging file information back to server
|
//! 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
|
//! @name accessors
|
||||||
|
|
@ -151,7 +151,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Return received file data
|
//! Return received file data
|
||||||
String &getReceivedFileData()
|
std::string &getReceivedFileData()
|
||||||
{
|
{
|
||||||
return m_receivedFileData;
|
return m_receivedFileData;
|
||||||
}
|
}
|
||||||
|
|
@ -182,8 +182,8 @@ public:
|
||||||
virtual void setClipboard(ClipboardID, const IClipboard *);
|
virtual void setClipboard(ClipboardID, const IClipboard *);
|
||||||
virtual void grabClipboard(ClipboardID);
|
virtual void grabClipboard(ClipboardID);
|
||||||
virtual void setClipboardDirty(ClipboardID, bool);
|
virtual void setClipboardDirty(ClipboardID, bool);
|
||||||
virtual void keyDown(KeyID, KeyModifierMask, KeyButton, const String &);
|
virtual void keyDown(KeyID, KeyModifierMask, KeyButton, const std::string &);
|
||||||
virtual void keyRepeat(KeyID, KeyModifierMask, SInt32 count, KeyButton, const String &lang);
|
virtual void keyRepeat(KeyID, KeyModifierMask, SInt32 count, KeyButton, const std::string &lang);
|
||||||
virtual void keyUp(KeyID, KeyModifierMask, KeyButton);
|
virtual void keyUp(KeyID, KeyModifierMask, KeyButton);
|
||||||
virtual void mouseDown(ButtonID);
|
virtual void mouseDown(ButtonID);
|
||||||
virtual void mouseUp(ButtonID);
|
virtual void mouseUp(ButtonID);
|
||||||
|
|
@ -193,7 +193,7 @@ public:
|
||||||
virtual void screensaver(bool activate);
|
virtual void screensaver(bool activate);
|
||||||
virtual void resetOptions();
|
virtual void resetOptions();
|
||||||
virtual void setOptions(const OptionsList &options);
|
virtual void setOptions(const OptionsList &options);
|
||||||
virtual String getName() const;
|
virtual std::string getName() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void sendClipboard(ClipboardID);
|
void sendClipboard(ClipboardID);
|
||||||
|
|
@ -233,7 +233,7 @@ public:
|
||||||
bool m_mock;
|
bool m_mock;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
String m_name;
|
std::string m_name;
|
||||||
NetworkAddress m_serverAddress;
|
NetworkAddress m_serverAddress;
|
||||||
ISocketFactory *m_socketFactory;
|
ISocketFactory *m_socketFactory;
|
||||||
deskflow::Screen *m_screen;
|
deskflow::Screen *m_screen;
|
||||||
|
|
@ -247,12 +247,12 @@ private:
|
||||||
bool m_ownClipboard[kClipboardEnd];
|
bool m_ownClipboard[kClipboardEnd];
|
||||||
bool m_sentClipboard[kClipboardEnd];
|
bool m_sentClipboard[kClipboardEnd];
|
||||||
IClipboard::Time m_timeClipboard[kClipboardEnd];
|
IClipboard::Time m_timeClipboard[kClipboardEnd];
|
||||||
String m_dataClipboard[kClipboardEnd];
|
std::string m_dataClipboard[kClipboardEnd];
|
||||||
IEventQueue *m_events;
|
IEventQueue *m_events;
|
||||||
std::size_t m_expectedFileSize;
|
std::size_t m_expectedFileSize;
|
||||||
String m_receivedFileData;
|
std::string m_receivedFileData;
|
||||||
DragFileList m_dragFileList;
|
DragFileList m_dragFileList;
|
||||||
String m_dragFileExt;
|
std::string m_dragFileExt;
|
||||||
using AutoThread = std::unique_ptr<Thread>;
|
using AutoThread = std::unique_ptr<Thread>;
|
||||||
AutoThread m_sendFileThread;
|
AutoThread m_sendFileThread;
|
||||||
AutoThread m_writeToDropDirThread;
|
AutoThread m_writeToDropDirThread;
|
||||||
|
|
|
||||||
|
|
@ -250,7 +250,7 @@ ServerProxy::EResult ServerProxy::parseMessage(const UInt8 *code)
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (memcmp(code, kMsgDKeyDownLang, 4) == 0) {
|
else if (memcmp(code, kMsgDKeyDownLang, 4) == 0) {
|
||||||
String lang;
|
std::string lang;
|
||||||
UInt16 id = 0;
|
UInt16 id = 0;
|
||||||
UInt16 mask = 0;
|
UInt16 mask = 0;
|
||||||
UInt16 button = 0;
|
UInt16 button = 0;
|
||||||
|
|
@ -382,7 +382,7 @@ bool ServerProxy::onGrabClipboard(ClipboardID id)
|
||||||
|
|
||||||
void ServerProxy::onClipboardChanged(ClipboardID id, const IClipboard *clipboard)
|
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));
|
LOG((CLOG_DEBUG "sending clipboard %d seqnum=%d", id, m_seqNum));
|
||||||
|
|
||||||
StreamChunker::sendClipboard(data, data.size(), id, m_seqNum, m_events, this);
|
StreamChunker::sendClipboard(data, data.size(), id, m_seqNum, m_events, this);
|
||||||
|
|
@ -547,7 +547,7 @@ void ServerProxy::leave()
|
||||||
void ServerProxy::setClipboard()
|
void ServerProxy::setClipboard()
|
||||||
{
|
{
|
||||||
// parse
|
// parse
|
||||||
static String dataCached;
|
static std::string dataCached;
|
||||||
ClipboardID id;
|
ClipboardID id;
|
||||||
UInt32 seq;
|
UInt32 seq;
|
||||||
|
|
||||||
|
|
@ -585,7 +585,7 @@ void ServerProxy::grabClipboard()
|
||||||
m_client->grabClipboard(id);
|
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
|
// get mouse up to date
|
||||||
flushCompressedMouse();
|
flushCompressedMouse();
|
||||||
|
|
@ -608,7 +608,7 @@ void ServerProxy::keyRepeat()
|
||||||
|
|
||||||
// parse
|
// parse
|
||||||
UInt16 id, mask, count, button;
|
UInt16 id, mask, count, button;
|
||||||
String lang;
|
std::string lang;
|
||||||
ProtocolUtil::readf(m_stream, kMsgDKeyRepeat + 4, &id, &mask, &count, &button, &lang);
|
ProtocolUtil::readf(m_stream, kMsgDKeyRepeat + 4, &id, &mask, &count, &button, &lang);
|
||||||
LOG(
|
LOG(
|
||||||
(CLOG_DEBUG1 "recv key repeat id=0x%08x, mask=0x%04x, count=%d, "
|
(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));
|
m_events->addEvent(Event(m_events->forFile().fileRecieveCompleted(), m_client));
|
||||||
} else if (result == kStart) {
|
} else if (result == kStart) {
|
||||||
if (m_client->getDragFileList().size() > 0) {
|
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()));
|
LOG((CLOG_DEBUG "start receiving %s", filename.c_str()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -846,7 +846,7 @@ void ServerProxy::dragInfoReceived()
|
||||||
{
|
{
|
||||||
// parse
|
// parse
|
||||||
UInt32 fileNum = 0;
|
UInt32 fileNum = 0;
|
||||||
String content;
|
std::string content;
|
||||||
ProtocolUtil::readf(m_stream, kMsgDDragInfo + 4, &fileNum, &content);
|
ProtocolUtil::readf(m_stream, kMsgDDragInfo + 4, &fileNum, &content);
|
||||||
|
|
||||||
m_client->dragInfoReceived(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)
|
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);
|
ProtocolUtil::writef(m_stream, kMsgDDragInfo, fileCount, &data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerProxy::secureInputNotification()
|
void ServerProxy::secureInputNotification()
|
||||||
{
|
{
|
||||||
String app;
|
std::string app;
|
||||||
ProtocolUtil::readf(m_stream, kMsgDSecureInputNotification + 4, &app);
|
ProtocolUtil::readf(m_stream, kMsgDSecureInputNotification + 4, &app);
|
||||||
|
|
||||||
// display this notification on the client
|
// display this notification on the client
|
||||||
|
|
@ -891,12 +891,12 @@ void ServerProxy::secureInputNotification()
|
||||||
|
|
||||||
void ServerProxy::setServerLanguages()
|
void ServerProxy::setServerLanguages()
|
||||||
{
|
{
|
||||||
String serverLanguages;
|
std::string serverLanguages;
|
||||||
ProtocolUtil::readf(m_stream, kMsgDLanguageSynchronisation + 4, &serverLanguages);
|
ProtocolUtil::readf(m_stream, kMsgDLanguageSynchronisation + 4, &serverLanguages);
|
||||||
m_languageManager.setRemoteLanguages(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 (!language.empty() && std::strlen(language.c_str()) > 0) {
|
||||||
if (m_serverLanguage != language) {
|
if (m_serverLanguage != language) {
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@
|
||||||
|
|
||||||
#include "base/Event.h"
|
#include "base/Event.h"
|
||||||
#include "base/Stopwatch.h"
|
#include "base/Stopwatch.h"
|
||||||
#include "base/String.h"
|
|
||||||
#include "deskflow/clipboard_types.h"
|
#include "deskflow/clipboard_types.h"
|
||||||
#include "deskflow/key_types.h"
|
#include "deskflow/key_types.h"
|
||||||
#include "deskflow/languages/LanguageManager.h"
|
#include "deskflow/languages/LanguageManager.h"
|
||||||
|
|
@ -108,7 +107,7 @@ private:
|
||||||
void leave();
|
void leave();
|
||||||
void setClipboard();
|
void setClipboard();
|
||||||
void grabClipboard();
|
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 keyRepeat();
|
||||||
void keyUp();
|
void keyUp();
|
||||||
void mouseDown();
|
void mouseDown();
|
||||||
|
|
@ -126,7 +125,7 @@ private:
|
||||||
void handleClipboardSendingEvent(const Event &, void *);
|
void handleClipboardSendingEvent(const Event &, void *);
|
||||||
void secureInputNotification();
|
void secureInputNotification();
|
||||||
void setServerLanguages();
|
void setServerLanguages();
|
||||||
void setActiveServerLanguage(const String &language);
|
void setActiveServerLanguage(const std::string &language);
|
||||||
void checkMissedLanguages() const;
|
void checkMissedLanguages() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -151,7 +150,7 @@ private:
|
||||||
|
|
||||||
MessageParser m_parser;
|
MessageParser m_parser;
|
||||||
IEventQueue *m_events;
|
IEventQueue *m_events;
|
||||||
String m_serverLanguage = "";
|
std::string m_serverLanguage = "";
|
||||||
bool m_isUserNotifiedAboutLanguageSyncError = false;
|
bool m_isUserNotifiedAboutLanguageSyncError = false;
|
||||||
deskflow::languages::LanguageManager m_languageManager;
|
deskflow::languages::LanguageManager m_languageManager;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -319,7 +319,7 @@ void MinimalApp::loadConfig()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MinimalApp::loadConfig(const String &pathname)
|
bool MinimalApp::loadConfig(const std::string &pathname)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@
|
||||||
|
|
||||||
#include "base/EventQueue.h"
|
#include "base/EventQueue.h"
|
||||||
#include "base/Log.h"
|
#include "base/Log.h"
|
||||||
#include "base/String.h"
|
|
||||||
#include "common/common.h"
|
#include "common/common.h"
|
||||||
#include "deskflow/IApp.h"
|
#include "deskflow/IApp.h"
|
||||||
#include "ipc/IpcClient.h"
|
#include "ipc/IpcClient.h"
|
||||||
|
|
@ -67,7 +66,7 @@ public:
|
||||||
virtual void help() = 0;
|
virtual void help() = 0;
|
||||||
virtual void parseArgs(int argc, const char *const *argv) = 0;
|
virtual void parseArgs(int argc, const char *const *argv) = 0;
|
||||||
virtual void loadConfig() = 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 const char *daemonInfo() const = 0;
|
||||||
virtual std::string configSection() const = 0;
|
virtual std::string configSection() const = 0;
|
||||||
|
|
||||||
|
|
@ -165,7 +164,7 @@ public:
|
||||||
virtual int foregroundStartup(int argc, char **argv) override;
|
virtual int foregroundStartup(int argc, char **argv) override;
|
||||||
virtual deskflow::Screen *createScreen() override;
|
virtual deskflow::Screen *createScreen() override;
|
||||||
virtual void loadConfig() 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 *daemonInfo() const override;
|
||||||
virtual const char *daemonName() const override;
|
virtual const char *daemonName() const override;
|
||||||
virtual void parseArgs(int argc, const char *const *argv) override;
|
virtual void parseArgs(int argc, const char *const *argv) override;
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@
|
||||||
#include "deskflow/ArgParser.h"
|
#include "deskflow/ArgParser.h"
|
||||||
|
|
||||||
#include "base/Log.h"
|
#include "base/Log.h"
|
||||||
#include "base/String.h"
|
|
||||||
#include "deskflow/App.h"
|
#include "deskflow/App.h"
|
||||||
#include "deskflow/ArgsBase.h"
|
#include "deskflow/ArgsBase.h"
|
||||||
#include "deskflow/ClientArgs.h"
|
#include "deskflow/ClientArgs.h"
|
||||||
|
|
@ -284,7 +283,7 @@ bool ArgParser::isArg(
|
||||||
return false;
|
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()) {
|
if (command.empty()) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -297,7 +296,7 @@ void ArgParser::splitCommandString(String &command, std::vector<String> &argv)
|
||||||
size_t startPos = 0;
|
size_t startPos = 0;
|
||||||
size_t space = command.find(" ", startPos);
|
size_t space = command.find(" ", startPos);
|
||||||
|
|
||||||
while (space != String::npos) {
|
while (space != std::string::npos) {
|
||||||
bool ignoreThisSpace = false;
|
bool ignoreThisSpace = false;
|
||||||
|
|
||||||
// check if the space is between two double quotes
|
// check if the space is between two double quotes
|
||||||
|
|
@ -308,7 +307,7 @@ void ArgParser::splitCommandString(String &command, std::vector<String> &argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ignoreThisSpace) {
|
if (!ignoreThisSpace) {
|
||||||
String subString = command.substr(startPos, space - startPos);
|
std::string subString = command.substr(startPos, space - startPos);
|
||||||
|
|
||||||
removeDoubleQuotes(subString);
|
removeDoubleQuotes(subString);
|
||||||
argv.push_back(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);
|
removeDoubleQuotes(subString);
|
||||||
argv.push_back(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;
|
bool result = false;
|
||||||
left = String::npos;
|
left = std::string::npos;
|
||||||
right = String::npos;
|
right = std::string::npos;
|
||||||
|
|
||||||
left = command.find("\"", startPos);
|
left = command.find("\"", startPos);
|
||||||
if (left != String::npos) {
|
if (left != std::string::npos) {
|
||||||
right = command.find("\"", left + 1);
|
right = command.find("\"", left + 1);
|
||||||
if (right != String::npos) {
|
if (right != std::string::npos) {
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -350,7 +349,7 @@ bool ArgParser::searchDoubleQuotes(String &command, size_t &left, size_t &right,
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArgParser::removeDoubleQuotes(String &arg)
|
void ArgParser::removeDoubleQuotes(std::string &arg)
|
||||||
{
|
{
|
||||||
// if string is surrounded by double quotes, remove them
|
// if string is surrounded by double quotes, remove them
|
||||||
if (arg[0] == '\"' && arg[arg.size() - 1] == '\"') {
|
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();
|
size_t argc = argsArray.size();
|
||||||
|
|
||||||
|
|
@ -375,18 +374,19 @@ const char **ArgParser::getArgv(std::vector<String> &argsArray)
|
||||||
return argv;
|
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) {
|
if (it->compare(ignoreArg) == 0) {
|
||||||
it = it + parametersRequired;
|
it = it + parametersRequired;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if there is a space in this arg, use double quotes surround it
|
// 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).insert(0, "\"");
|
||||||
(*it).push_back('\"');
|
(*it).push_back('\"');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,10 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "base/String.h"
|
|
||||||
#include "common/stdvector.h"
|
#include "common/stdvector.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace deskflow {
|
namespace deskflow {
|
||||||
class ArgsBase;
|
class ArgsBase;
|
||||||
class ServerArgs;
|
class ServerArgs;
|
||||||
|
|
@ -47,11 +48,12 @@ public:
|
||||||
static bool isArg(
|
static bool isArg(
|
||||||
int argi, int argc, const char *const *argv, const char *name1, const char *name2, int minRequiredParameters = 0
|
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 void splitCommandString(std::string &command, std::vector<std::string> &argv);
|
||||||
static bool searchDoubleQuotes(String &command, size_t &left, size_t &right, size_t startPos = 0);
|
static bool searchDoubleQuotes(std::string &command, size_t &left, size_t &right, size_t startPos = 0);
|
||||||
static void removeDoubleQuotes(String &arg);
|
static void removeDoubleQuotes(std::string &arg);
|
||||||
static const char **getArgv(std::vector<String> &argsArray);
|
static const char **getArgv(std::vector<std::string> &argsArray);
|
||||||
static String assembleCommand(std::vector<String> &argsArray, String ignoreArg = "", int parametersRequired = 0);
|
static std::string
|
||||||
|
assembleCommand(std::vector<std::string> &argsArray, std::string ignoreArg = "", int parametersRequired = 0);
|
||||||
|
|
||||||
static deskflow::ArgsBase &argsBase()
|
static deskflow::ArgsBase &argsBase()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "base/String.h"
|
#include <string>
|
||||||
|
|
||||||
namespace deskflow {
|
namespace deskflow {
|
||||||
|
|
||||||
|
|
@ -65,7 +65,7 @@ public:
|
||||||
const char *m_display = nullptr;
|
const char *m_display = nullptr;
|
||||||
|
|
||||||
/// @brief The name of the current computer
|
/// @brief The name of the current computer
|
||||||
String m_name;
|
std::string m_name;
|
||||||
|
|
||||||
/// @brief Should the app add a tray icon
|
/// @brief Should the app add a tray icon
|
||||||
bool m_disableTray = false;
|
bool m_disableTray = false;
|
||||||
|
|
@ -83,19 +83,19 @@ public:
|
||||||
bool m_shouldExitFail = false;
|
bool m_shouldExitFail = false;
|
||||||
|
|
||||||
/// @brief Bind to this address
|
/// @brief Bind to this address
|
||||||
String m_deskflowAddress;
|
std::string m_deskflowAddress;
|
||||||
|
|
||||||
/// @brief Should the connections be TLS encrypted
|
/// @brief Should the connections be TLS encrypted
|
||||||
bool m_enableCrypto = false;
|
bool m_enableCrypto = false;
|
||||||
|
|
||||||
/// @brief The dir to load settings from
|
/// @brief The dir to load settings from
|
||||||
String m_profileDirectory;
|
std::string m_profileDirectory;
|
||||||
|
|
||||||
/// @brief The dir to load plugins from
|
/// @brief The dir to load plugins from
|
||||||
String m_pluginDirectory;
|
std::string m_pluginDirectory;
|
||||||
|
|
||||||
/// @brief Contains the location of the TLS certificate file
|
/// @brief Contains the location of the TLS certificate file
|
||||||
String m_tlsCertFile;
|
std::string m_tlsCertFile;
|
||||||
|
|
||||||
/// @brief Stop this computer from sleeping
|
/// @brief Stop this computer from sleeping
|
||||||
bool m_preventSleep = false;
|
bool m_preventSleep = false;
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@
|
||||||
#include "base/Event.h"
|
#include "base/Event.h"
|
||||||
#include "base/IEventQueue.h"
|
#include "base/IEventQueue.h"
|
||||||
#include "base/Log.h"
|
#include "base/Log.h"
|
||||||
#include "base/String.h"
|
|
||||||
#include "base/TMethodEventJob.h"
|
#include "base/TMethodEventJob.h"
|
||||||
#include "client/Client.h"
|
#include "client/Client.h"
|
||||||
#include "common/constants.h"
|
#include "common/constants.h"
|
||||||
|
|
@ -229,7 +228,7 @@ void ClientApp::updateStatus()
|
||||||
updateStatus("");
|
updateStatus("");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientApp::updateStatus(const String &msg)
|
void ClientApp::updateStatus(const std::string &msg)
|
||||||
{
|
{
|
||||||
if (m_taskBarReceiver) {
|
if (m_taskBarReceiver) {
|
||||||
m_taskBarReceiver->updateStatus(m_client, msg);
|
m_taskBarReceiver->updateStatus(m_client, msg);
|
||||||
|
|
@ -321,7 +320,7 @@ void ClientApp::handleClientFailed(const Event &e, void *)
|
||||||
if ((++m_lastServerAddressIndex) < m_client->getLastResolvedAddressesCount()) {
|
if ((++m_lastServerAddressIndex) < m_client->getLastResolvedAddressesCount()) {
|
||||||
std::unique_ptr<Client::FailInfo> info(static_cast<Client::FailInfo *>(e.getData()));
|
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()));
|
LOG((CLOG_NOTE "failed to connect to server=%s, trying next address", info->m_what.c_str()));
|
||||||
if (!m_suspended) {
|
if (!m_suspended) {
|
||||||
scheduleClientRestart(nextRestartTimeout());
|
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()));
|
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) {
|
if (!args().m_restartable || !info->m_retry) {
|
||||||
LOG((CLOG_ERR "failed to connect to server: %s", info->m_what.c_str()));
|
LOG((CLOG_ERR "failed to connect to server: %s", info->m_what.c_str()));
|
||||||
m_events->addEvent(Event(Event::kQuit));
|
m_events->addEvent(Event(Event::kQuit));
|
||||||
|
|
@ -359,7 +358,7 @@ void ClientApp::handleClientDisconnected(const Event &, void *)
|
||||||
updateStatus();
|
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());
|
Client *client = new Client(m_events, name, address, getSocketFactory(), screen, args());
|
||||||
|
|
||||||
|
|
@ -432,7 +431,7 @@ bool ClientApp::startClient()
|
||||||
} catch (XScreenUnavailable &e) {
|
} catch (XScreenUnavailable &e) {
|
||||||
LOG((CLOG_WARN "secondary screen unavailable: %s", e.what()));
|
LOG((CLOG_WARN "secondary screen unavailable: %s", e.what()));
|
||||||
closeClientScreen(clientScreen);
|
closeClientScreen(clientScreen);
|
||||||
updateStatus(String("secondary screen unavailable: ") + e.what());
|
updateStatus(std::string("secondary screen unavailable: ") + e.what());
|
||||||
retryTime = e.getRetryTime();
|
retryTime = e.getRetryTime();
|
||||||
} catch (XScreenOpenFailure &e) {
|
} catch (XScreenOpenFailure &e) {
|
||||||
LOG((CLOG_CRIT "failed to start client: %s", e.what()));
|
LOG((CLOG_CRIT "failed to start client: %s", e.what()));
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ public:
|
||||||
void loadConfig() override
|
void loadConfig() override
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
bool loadConfig(const String &pathname) override
|
bool loadConfig(const std::string &pathname) override
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -75,7 +75,7 @@ public:
|
||||||
//
|
//
|
||||||
|
|
||||||
void updateStatus();
|
void updateStatus();
|
||||||
void updateStatus(const String &msg);
|
void updateStatus(const std::string &msg);
|
||||||
void resetRestartTimeout();
|
void resetRestartTimeout();
|
||||||
double nextRestartTimeout();
|
double nextRestartTimeout();
|
||||||
void handleScreenError(const Event &, void *);
|
void handleScreenError(const Event &, void *);
|
||||||
|
|
@ -87,7 +87,7 @@ public:
|
||||||
void handleClientFailed(const Event &e, void *);
|
void handleClientFailed(const Event &e, void *);
|
||||||
void handleClientRefused(const Event &e, void *);
|
void handleClientRefused(const Event &e, void *);
|
||||||
void handleClientDisconnected(const Event &, 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);
|
void closeClient(Client *client);
|
||||||
bool startClient();
|
bool startClient();
|
||||||
void stopClient();
|
void stopClient();
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ ClientTaskBarReceiver::~ClientTaskBarReceiver()
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientTaskBarReceiver::updateStatus(Client *client, const String &errorMsg)
|
void ClientTaskBarReceiver::updateStatus(Client *client, const std::string &errorMsg)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
// update our status
|
// update our status
|
||||||
|
|
@ -74,7 +74,7 @@ ClientTaskBarReceiver::EState ClientTaskBarReceiver::getStatus() const
|
||||||
return m_state;
|
return m_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
const String &ClientTaskBarReceiver::getErrorMessage() const
|
const std::string &ClientTaskBarReceiver::getErrorMessage() const
|
||||||
{
|
{
|
||||||
return m_errorMessage;
|
return m_errorMessage;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "arch/IArchTaskBarReceiver.h"
|
#include "arch/IArchTaskBarReceiver.h"
|
||||||
#include "base/String.h"
|
|
||||||
#include "base/log_outputters.h"
|
#include "base/log_outputters.h"
|
||||||
#include "client/Client.h"
|
#include "client/Client.h"
|
||||||
|
|
||||||
|
|
@ -39,9 +38,9 @@ public:
|
||||||
/*!
|
/*!
|
||||||
Determine the status and query required information from the client.
|
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);
|
updateStatus((Client *)n, errorMsg);
|
||||||
}
|
}
|
||||||
|
|
@ -75,7 +74,7 @@ protected:
|
||||||
EState getStatus() const;
|
EState getStatus() const;
|
||||||
|
|
||||||
//! Get error message
|
//! Get error message
|
||||||
const String &getErrorMessage() const;
|
const std::string &getErrorMessage() const;
|
||||||
|
|
||||||
//! Quit app
|
//! Quit app
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -91,8 +90,8 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
EState m_state;
|
EState m_state;
|
||||||
String m_errorMessage;
|
std::string m_errorMessage;
|
||||||
String m_server;
|
std::string m_server;
|
||||||
IEventQueue *m_events;
|
IEventQueue *m_events;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ bool Clipboard::empty()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Clipboard::add(EFormat format, const String &data)
|
void Clipboard::add(EFormat format, const std::string &data)
|
||||||
{
|
{
|
||||||
assert(m_open);
|
assert(m_open);
|
||||||
assert(m_owner);
|
assert(m_owner);
|
||||||
|
|
@ -90,18 +90,18 @@ bool Clipboard::has(EFormat format) const
|
||||||
return m_added[format];
|
return m_added[format];
|
||||||
}
|
}
|
||||||
|
|
||||||
String Clipboard::get(EFormat format) const
|
std::string Clipboard::get(EFormat format) const
|
||||||
{
|
{
|
||||||
assert(m_open);
|
assert(m_open);
|
||||||
return m_data[format];
|
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);
|
IClipboard::unmarshall(this, data, time);
|
||||||
}
|
}
|
||||||
|
|
||||||
String Clipboard::marshall() const
|
std::string Clipboard::marshall() const
|
||||||
{
|
{
|
||||||
return IClipboard::marshall(this);
|
return IClipboard::marshall(this);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ public:
|
||||||
Extract marshalled clipboard data and store it in this clipboard.
|
Extract marshalled clipboard data and store it in this clipboard.
|
||||||
Sets the clipboard time to \c time.
|
Sets the clipboard time to \c time.
|
||||||
*/
|
*/
|
||||||
void unmarshall(const String &data, Time time);
|
void unmarshall(const std::string &data, Time time);
|
||||||
|
|
||||||
//@}
|
//@}
|
||||||
//! @name accessors
|
//! @name accessors
|
||||||
|
|
@ -49,18 +49,18 @@ public:
|
||||||
Merge this clipboard's data into a single buffer that can be later
|
Merge this clipboard's data into a single buffer that can be later
|
||||||
unmarshalled to restore the clipboard and return the buffer.
|
unmarshalled to restore the clipboard and return the buffer.
|
||||||
*/
|
*/
|
||||||
String marshall() const;
|
std::string marshall() const;
|
||||||
|
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
// IClipboard overrides
|
// IClipboard overrides
|
||||||
virtual bool empty();
|
virtual bool empty();
|
||||||
virtual void add(EFormat, const String &data);
|
virtual void add(EFormat, const std::string &data);
|
||||||
virtual bool open(Time) const;
|
virtual bool open(Time) const;
|
||||||
virtual void close() const;
|
virtual void close() const;
|
||||||
virtual Time getTime() const;
|
virtual Time getTime() const;
|
||||||
virtual bool has(EFormat) const;
|
virtual bool has(EFormat) const;
|
||||||
virtual String get(EFormat) const;
|
virtual std::string get(EFormat) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
mutable bool m_open;
|
mutable bool m_open;
|
||||||
|
|
@ -68,5 +68,5 @@ private:
|
||||||
bool m_owner;
|
bool m_owner;
|
||||||
Time m_timeOwned;
|
Time m_timeOwned;
|
||||||
bool m_added[kNumFormats];
|
bool m_added[kNumFormats];
|
||||||
String m_data[kNumFormats];
|
std::string m_data[kNumFormats];
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
#include "deskflow/ClipboardChunk.h"
|
#include "deskflow/ClipboardChunk.h"
|
||||||
|
|
||||||
#include "base/Log.h"
|
#include "base/Log.h"
|
||||||
|
#include "base/String.h"
|
||||||
#include "deskflow/ProtocolUtil.h"
|
#include "deskflow/ProtocolUtil.h"
|
||||||
#include "deskflow/protocol_types.h"
|
#include "deskflow/protocol_types.h"
|
||||||
#include "io/IStream.h"
|
#include "io/IStream.h"
|
||||||
|
|
@ -30,7 +31,7 @@ ClipboardChunk::ClipboardChunk(size_t size) : Chunk(size)
|
||||||
m_dataSize = size - CLIPBOARD_CHUNK_META_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();
|
size_t sizeLength = size.size();
|
||||||
ClipboardChunk *start = new ClipboardChunk(sizeLength + CLIPBOARD_CHUNK_META_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;
|
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();
|
size_t dataSize = data.size();
|
||||||
ClipboardChunk *chunk = new ClipboardChunk(dataSize + CLIPBOARD_CHUNK_META_SIZE);
|
ClipboardChunk *chunk = new ClipboardChunk(dataSize + CLIPBOARD_CHUNK_META_SIZE);
|
||||||
|
|
@ -73,10 +74,10 @@ ClipboardChunk *ClipboardChunk::end(ClipboardID id, UInt32 sequence)
|
||||||
return end;
|
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;
|
UInt8 mark;
|
||||||
String data;
|
std::string data;
|
||||||
|
|
||||||
if (!ProtocolUtil::readf(stream, kMsgDClipboard + 4, &id, &sequence, &mark, &data)) {
|
if (!ProtocolUtil::readf(stream, kMsgDClipboard + 4, &id, &sequence, &mark, &data)) {
|
||||||
return kError;
|
return kError;
|
||||||
|
|
@ -116,7 +117,7 @@ void ClipboardChunk::send(deskflow::IStream *stream, void *data)
|
||||||
UInt32 sequence;
|
UInt32 sequence;
|
||||||
std::memcpy(&sequence, &chunk[1], 4);
|
std::memcpy(&sequence, &chunk[1], 4);
|
||||||
UInt8 mark = chunk[5];
|
UInt8 mark = chunk[5];
|
||||||
String dataChunk(&chunk[6], clipboardData->m_dataSize);
|
std::string dataChunk(&chunk[6], clipboardData->m_dataSize);
|
||||||
|
|
||||||
switch (mark) {
|
switch (mark) {
|
||||||
case kDataStart:
|
case kDataStart:
|
||||||
|
|
|
||||||
|
|
@ -17,11 +17,12 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "base/String.h"
|
|
||||||
#include "common/basic_types.h"
|
#include "common/basic_types.h"
|
||||||
#include "deskflow/Chunk.h"
|
#include "deskflow/Chunk.h"
|
||||||
#include "deskflow/clipboard_types.h"
|
#include "deskflow/clipboard_types.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#define CLIPBOARD_CHUNK_META_SIZE 7
|
#define CLIPBOARD_CHUNK_META_SIZE 7
|
||||||
|
|
||||||
namespace deskflow {
|
namespace deskflow {
|
||||||
|
|
@ -33,11 +34,11 @@ class ClipboardChunk : public Chunk
|
||||||
public:
|
public:
|
||||||
ClipboardChunk(size_t size);
|
ClipboardChunk(size_t size);
|
||||||
|
|
||||||
static ClipboardChunk *start(ClipboardID id, UInt32 sequence, const String &size);
|
static ClipboardChunk *start(ClipboardID id, UInt32 sequence, const std::string &size);
|
||||||
static ClipboardChunk *data(ClipboardID id, UInt32 sequence, const String &data);
|
static ClipboardChunk *data(ClipboardID id, UInt32 sequence, const std::string &data);
|
||||||
static ClipboardChunk *end(ClipboardID id, UInt32 sequence);
|
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);
|
static void send(deskflow::IStream *stream, void *data);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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;
|
auto isServer = false;
|
||||||
|
|
||||||
if (cmd.size() > 1) {
|
if (cmd.size() > 1) {
|
||||||
isServer = (cmd[0].find("deskflow-server") != String::npos) ||
|
isServer = (cmd[0].find("deskflow-server") != std::string::npos) ||
|
||||||
(cmd[0].find("deskflow-core") != String::npos && cmd[1] == "server");
|
(cmd[0].find("deskflow-core") != std::string::npos && cmd[1] == "server");
|
||||||
}
|
}
|
||||||
|
|
||||||
return isServer;
|
return isServer;
|
||||||
|
|
@ -188,8 +188,8 @@ int DaemonApp::run(int argc, char **argv)
|
||||||
|
|
||||||
return kExitSuccess;
|
return kExitSuccess;
|
||||||
} catch (XArch &e) {
|
} catch (XArch &e) {
|
||||||
String message = e.what();
|
std::string message = e.what();
|
||||||
if (uninstall && (message.find("The service has not been started") != String::npos)) {
|
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?!).
|
// TODO: if we're keeping this use error code instead (what is it?!).
|
||||||
// HACK: this message happens intermittently, not sure where from but
|
// HACK: this message happens intermittently, not sure where from but
|
||||||
// it's quite misleading for the user. they thing something has gone
|
// 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.
|
// install the platform event queue to handle service stop events.
|
||||||
m_events->adoptBuffer(new MSWindowsEventQueueBuffer(m_events.get()));
|
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";
|
bool elevate = ARCH->setting("Elevate") == "1";
|
||||||
if (command != "") {
|
if (command != "") {
|
||||||
LOG((CLOG_INFO "using last known command: %s", command.c_str()));
|
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()) {
|
switch (m->type()) {
|
||||||
case IpcMessageType::Command: {
|
case IpcMessageType::Command: {
|
||||||
IpcCommandMessage *cm = static_cast<IpcCommandMessage *>(m);
|
IpcCommandMessage *cm = static_cast<IpcCommandMessage *>(m);
|
||||||
String command = cm->command();
|
std::string command = cm->command();
|
||||||
|
|
||||||
// if empty quotes, clear.
|
// if empty quotes, clear.
|
||||||
if (command == "\"\"") {
|
if (command == "\"\"") {
|
||||||
|
|
@ -312,7 +312,7 @@ void DaemonApp::handleIpcMessage(const Event &e, void *)
|
||||||
LOG((CLOG_DEBUG "daemon got new core command"));
|
LOG((CLOG_DEBUG "daemon got new core command"));
|
||||||
LOG((CLOG_DEBUG2 "new command, elevate=%d command=%s", cm->elevate(), command.c_str()));
|
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::splitCommandString(command, argsArray);
|
||||||
ArgParser argParser(NULL);
|
ArgParser argParser(NULL);
|
||||||
const char **argv = argParser.getArgv(argsArray);
|
const char **argv = argParser.getArgv(argsArray);
|
||||||
|
|
@ -327,7 +327,7 @@ void DaemonApp::handleIpcMessage(const Event &e, void *)
|
||||||
}
|
}
|
||||||
|
|
||||||
delete[] argv;
|
delete[] argv;
|
||||||
String logLevel(ArgParser::argsBase().m_logFilter);
|
std::string logLevel(ArgParser::argsBase().m_logFilter);
|
||||||
if (!logLevel.empty()) {
|
if (!logLevel.empty()) {
|
||||||
try {
|
try {
|
||||||
// change log level based on that in the command string
|
// 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);
|
ARCH->setting("Command", command);
|
||||||
|
|
||||||
// TODO: it would be nice to store bools/ints...
|
// 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) {
|
} catch (XArch &e) {
|
||||||
LOG((CLOG_ERR "failed to save settings, %s", e.what()));
|
LOG((CLOG_ERR "failed to save settings, %s", e.what()));
|
||||||
}
|
}
|
||||||
|
|
@ -364,7 +364,7 @@ void DaemonApp::handleIpcMessage(const Event &e, void *)
|
||||||
|
|
||||||
case IpcMessageType::Hello: {
|
case IpcMessageType::Hello: {
|
||||||
IpcHelloMessage *hm = static_cast<IpcHelloMessage *>(m);
|
IpcHelloMessage *hm = static_cast<IpcHelloMessage *>(m);
|
||||||
String type;
|
std::string type;
|
||||||
switch (hm->clientType()) {
|
switch (hm->clientType()) {
|
||||||
case IpcClientType::GUI:
|
case IpcClientType::GUI:
|
||||||
type = "gui";
|
type = "gui";
|
||||||
|
|
@ -387,7 +387,7 @@ void DaemonApp::handleIpcMessage(const Event &e, void *)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SYSAPI_WIN32
|
#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()));
|
LOG((CLOG_INFO "service status: %s", watchdogStatus.c_str()));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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 startPos = 0;
|
||||||
size_t findResult1 = 0;
|
size_t findResult1 = 0;
|
||||||
size_t findResult2 = 0;
|
size_t findResult2 = 0;
|
||||||
dragFileList.clear();
|
dragFileList.clear();
|
||||||
String slash("\\");
|
std::string slash("\\");
|
||||||
if (data.find("/", startPos) != string::npos) {
|
if (data.find("/", startPos) != std::string::npos) {
|
||||||
slash = "/";
|
slash = "/";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -51,7 +51,7 @@ void DragInformation::parseDragInfo(DragFileList &dragFileList, UInt32 fileNum,
|
||||||
|
|
||||||
// set filename
|
// set filename
|
||||||
if (findResult1 - findResult2 > 1) {
|
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;
|
DragInformation di;
|
||||||
di.setFilename(filename);
|
di.setFilename(filename);
|
||||||
dragFileList.push_back(di);
|
dragFileList.push_back(di);
|
||||||
|
|
@ -61,7 +61,7 @@ void DragInformation::parseDragInfo(DragFileList &dragFileList, UInt32 fileNum,
|
||||||
// set filesize
|
// set filesize
|
||||||
findResult2 = data.find(',', startPos);
|
findResult2 = data.find(',', startPos);
|
||||||
if (findResult2 - findResult1 > 1) {
|
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);
|
size_t size = stringToNum(filesize);
|
||||||
dragFileList.at(index).setFilesize(size);
|
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());
|
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);
|
return filename.substr(findResult + 1, filename.size() - findResult - 1);
|
||||||
} else {
|
} else {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int DragInformation::setupDragInfo(DragFileList &fileList, String &output)
|
int DragInformation::setupDragInfo(DragFileList &fileList, std::string &output)
|
||||||
{
|
{
|
||||||
int size = static_cast<int>(fileList.size());
|
int size = static_cast<int>(fileList.size());
|
||||||
for (int i = 0; i < size; ++i) {
|
for (int i = 0; i < size; ++i) {
|
||||||
output.append(fileList.at(i).getFilename());
|
output.append(fileList.at(i).getFilename());
|
||||||
output.append(",");
|
output.append(",");
|
||||||
String filesize = getFileSize(fileList.at(i).getFilename());
|
std::string filesize = getFileSize(fileList.at(i).getFilename());
|
||||||
output.append(filesize);
|
output.append(filesize);
|
||||||
output.append(",");
|
output.append(",");
|
||||||
}
|
}
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DragInformation::isFileValid(String filename)
|
bool DragInformation::isFileValid(std::string filename)
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
std::fstream file(filename.c_str(), ios::in | ios::binary);
|
std::fstream file(filename.c_str(), ios::in | ios::binary);
|
||||||
|
|
@ -115,7 +115,7 @@ bool DragInformation::isFileValid(String filename)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t DragInformation::stringToNum(String &str)
|
size_t DragInformation::stringToNum(std::string &str)
|
||||||
{
|
{
|
||||||
istringstream iss(str.c_str());
|
istringstream iss(str.c_str());
|
||||||
size_t size;
|
size_t size;
|
||||||
|
|
@ -123,7 +123,7 @@ size_t DragInformation::stringToNum(String &str)
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
String DragInformation::getFileSize(String &filename)
|
std::string DragInformation::getFileSize(std::string &filename)
|
||||||
{
|
{
|
||||||
std::fstream file(filename.c_str(), ios::in | ios::binary);
|
std::fstream file(filename.c_str(), ios::in | ios::binary);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,9 +18,10 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "base/EventTypes.h"
|
#include "base/EventTypes.h"
|
||||||
#include "base/String.h"
|
|
||||||
#include "common/stdvector.h"
|
#include "common/stdvector.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
class DragInformation;
|
class DragInformation;
|
||||||
using DragFileList = std::vector<DragInformation>;
|
using DragFileList = std::vector<DragInformation>;
|
||||||
|
|
||||||
|
|
@ -32,11 +33,11 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
String &getFilename()
|
std::string &getFilename()
|
||||||
{
|
{
|
||||||
return m_filename;
|
return m_filename;
|
||||||
}
|
}
|
||||||
void setFilename(String &name)
|
void setFilename(std::string &name)
|
||||||
{
|
{
|
||||||
m_filename = name;
|
m_filename = name;
|
||||||
}
|
}
|
||||||
|
|
@ -49,20 +50,20 @@ public:
|
||||||
m_filesize = size;
|
m_filesize = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void parseDragInfo(DragFileList &dragFileList, UInt32 fileNum, String data);
|
static void parseDragInfo(DragFileList &dragFileList, UInt32 fileNum, std::string data);
|
||||||
static String getDragFileExtension(String filename);
|
static std::string getDragFileExtension(std::string filename);
|
||||||
// helper function to setup drag info
|
// helper function to setup drag info
|
||||||
// example: filename1,filesize1,filename2,filesize2,
|
// example: filename1,filesize1,filename2,filesize2,
|
||||||
// return file count
|
// 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:
|
private:
|
||||||
static size_t stringToNum(String &str);
|
static size_t stringToNum(std::string &str);
|
||||||
static String getFileSize(String &filename);
|
static std::string getFileSize(std::string &filename);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
String m_filename;
|
std::string m_filename;
|
||||||
size_t m_filesize;
|
size_t m_filesize;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -21,13 +21,13 @@
|
||||||
|
|
||||||
#include <fstream>
|
#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()));
|
LOG((CLOG_DEBUG "dropping file, files=%i target=%s", fileList.size(), destination.c_str()));
|
||||||
|
|
||||||
if (!destination.empty() && fileList.size() > 0) {
|
if (!destination.empty() && fileList.size() > 0) {
|
||||||
std::fstream file;
|
std::fstream file;
|
||||||
String dropTarget = destination;
|
std::string dropTarget = destination;
|
||||||
#ifdef SYSAPI_WIN32
|
#ifdef SYSAPI_WIN32
|
||||||
dropTarget.append("\\");
|
dropTarget.append("\\");
|
||||||
#else
|
#else
|
||||||
|
|
|
||||||
|
|
@ -17,11 +17,10 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "base/String.h"
|
|
||||||
#include "deskflow/DragInformation.h"
|
#include "deskflow/DragInformation.h"
|
||||||
|
|
||||||
class DropHelper
|
class DropHelper
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void writeToDir(const String &destination, DragFileList &fileList, String &data);
|
static void writeToDir(const std::string &destination, DragFileList &fileList, std::string &data);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
#include "base/Log.h"
|
#include "base/Log.h"
|
||||||
#include "base/Stopwatch.h"
|
#include "base/Stopwatch.h"
|
||||||
|
#include "base/String.h"
|
||||||
#include "deskflow/ProtocolUtil.h"
|
#include "deskflow/ProtocolUtil.h"
|
||||||
#include "deskflow/protocol_types.h"
|
#include "deskflow/protocol_types.h"
|
||||||
#include "io/IStream.h"
|
#include "io/IStream.h"
|
||||||
|
|
@ -30,7 +31,7 @@ FileChunk::FileChunk(size_t size) : Chunk(size)
|
||||||
m_dataSize = size - FILE_CHUNK_META_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();
|
size_t sizeLength = size.size();
|
||||||
FileChunk *start = new FileChunk(sizeLength + FILE_CHUNK_META_SIZE);
|
FileChunk *start = new FileChunk(sizeLength + FILE_CHUNK_META_SIZE);
|
||||||
|
|
@ -63,11 +64,11 @@ FileChunk *FileChunk::end()
|
||||||
return 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
|
// parse
|
||||||
UInt8 mark = 0;
|
UInt8 mark = 0;
|
||||||
String content;
|
std::string content;
|
||||||
static size_t receivedDataSize;
|
static size_t receivedDataSize;
|
||||||
static double elapsedTime;
|
static double elapsedTime;
|
||||||
static Stopwatch stopwatch;
|
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)
|
void FileChunk::send(deskflow::IStream *stream, UInt8 mark, char *data, size_t dataSize)
|
||||||
{
|
{
|
||||||
String chunk(data, dataSize);
|
std::string chunk(data, dataSize);
|
||||||
|
|
||||||
switch (mark) {
|
switch (mark) {
|
||||||
case kDataStart:
|
case kDataStart:
|
||||||
|
|
|
||||||
|
|
@ -17,10 +17,11 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "base/String.h"
|
|
||||||
#include "common/basic_types.h"
|
#include "common/basic_types.h"
|
||||||
#include "deskflow/Chunk.h"
|
#include "deskflow/Chunk.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#define FILE_CHUNK_META_SIZE 2
|
#define FILE_CHUNK_META_SIZE 2
|
||||||
|
|
||||||
namespace deskflow {
|
namespace deskflow {
|
||||||
|
|
@ -32,9 +33,9 @@ class FileChunk : public Chunk
|
||||||
public:
|
public:
|
||||||
FileChunk(size_t size);
|
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 *data(UInt8 *data, size_t dataSize);
|
||||||
static FileChunk *end();
|
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);
|
static void send(deskflow::IStream *stream, UInt8 mark, char *data, size_t dataSize);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -18,10 +18,12 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "base/String.h"
|
|
||||||
#include "common/IInterface.h"
|
#include "common/IInterface.h"
|
||||||
#include "deskflow/IApp.h"
|
#include "deskflow/IApp.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
class IAppUtil : public IInterface
|
class IAppUtil : public IInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -30,7 +32,7 @@ public:
|
||||||
virtual int run(int argc, char **argv) = 0;
|
virtual int run(int argc, char **argv) = 0;
|
||||||
virtual void beforeAppExit() = 0;
|
virtual void beforeAppExit() = 0;
|
||||||
virtual void startNode() = 0;
|
virtual void startNode() = 0;
|
||||||
virtual std::vector<String> getKeyboardLayoutList() = 0;
|
virtual std::vector<std::string> getKeyboardLayoutList() = 0;
|
||||||
virtual String getCurrentLanguageCode() = 0;
|
virtual std::string getCurrentLanguageCode() = 0;
|
||||||
virtual void showNotification(const String &title, const String &text) const = 0;
|
virtual void showNotification(const std::string &title, const std::string &text) const = 0;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -18,13 +18,14 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "base/String.h"
|
|
||||||
#include "deskflow/IScreen.h"
|
#include "deskflow/IScreen.h"
|
||||||
#include "deskflow/clipboard_types.h"
|
#include "deskflow/clipboard_types.h"
|
||||||
#include "deskflow/key_types.h"
|
#include "deskflow/key_types.h"
|
||||||
#include "deskflow/mouse_types.h"
|
#include "deskflow/mouse_types.h"
|
||||||
#include "deskflow/option_types.h"
|
#include "deskflow/option_types.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
//! Client interface
|
//! Client interface
|
||||||
/*!
|
/*!
|
||||||
This interface defines the methods necessary for the server to
|
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
|
synthesize an up or repeat for the same client key synthesized by
|
||||||
keyDown().
|
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
|
//! Notify of key repeat
|
||||||
/*!
|
/*!
|
||||||
Synthesize key events to generate a press and release of key \c id
|
Synthesize key events to generate a press and release of key \c id
|
||||||
\c count times. If possible match the given modifier mask.
|
\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
|
//! Notify of key release
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -161,7 +162,7 @@ public:
|
||||||
/*!
|
/*!
|
||||||
Return the client's name.
|
Return the client's name.
|
||||||
*/
|
*/
|
||||||
virtual String getName() const = 0;
|
virtual std::string getName() const = 0;
|
||||||
|
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
// IClipboard
|
// 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);
|
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
|
// or server supports more clipboard formats than the other
|
||||||
// then one of them will get a format >= kNumFormats here.
|
// then one of them will get a format >= kNumFormats here.
|
||||||
if (format < IClipboard::kNumFormats) {
|
if (format < IClipboard::kNumFormats) {
|
||||||
clipboard->add(format, String(index, size));
|
clipboard->add(format, std::string(index, size));
|
||||||
}
|
}
|
||||||
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:
|
// return data format:
|
||||||
// 4 bytes => number of formats included
|
// 4 bytes => number of formats included
|
||||||
|
|
@ -72,9 +72,9 @@ String IClipboard::marshall(const IClipboard *clipboard)
|
||||||
|
|
||||||
assert(clipboard != NULL);
|
assert(clipboard != NULL);
|
||||||
|
|
||||||
String data;
|
std::string data;
|
||||||
|
|
||||||
std::vector<String> formatData;
|
std::vector<std::string> formatData;
|
||||||
formatData.resize(IClipboard::kNumFormats);
|
formatData.resize(IClipboard::kNumFormats);
|
||||||
// FIXME -- use current time
|
// FIXME -- use current time
|
||||||
if (clipboard->open(0)) {
|
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]);
|
(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 >> 24) & 0xff);
|
||||||
*buf += static_cast<UInt8>((v >> 16) & 0xff);
|
*buf += static_cast<UInt8>((v >> 16) & 0xff);
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,10 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "base/EventTypes.h"
|
#include "base/EventTypes.h"
|
||||||
#include "base/String.h"
|
|
||||||
#include "common/IInterface.h"
|
#include "common/IInterface.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
//! Clipboard interface
|
//! Clipboard interface
|
||||||
/*!
|
/*!
|
||||||
This interface defines the methods common to all clipboards.
|
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
|
Add data in the given format to the clipboard. May only be
|
||||||
called after a successful empty().
|
called after a successful empty().
|
||||||
*/
|
*/
|
||||||
virtual void add(EFormat, const String &data) = 0;
|
virtual void add(EFormat, const std::string &data) = 0;
|
||||||
|
|
||||||
//@}
|
//@}
|
||||||
//! @name accessors
|
//! @name accessors
|
||||||
|
|
@ -127,21 +128,21 @@ public:
|
||||||
if there is no data in that format. Must be called between
|
if there is no data in that format. Must be called between
|
||||||
a successful open() and close().
|
a successful open() and close().
|
||||||
*/
|
*/
|
||||||
virtual String get(EFormat) const = 0;
|
virtual std::string get(EFormat) const = 0;
|
||||||
|
|
||||||
//! Marshall clipboard data
|
//! Marshall clipboard data
|
||||||
/*!
|
/*!
|
||||||
Merge \p clipboard's data into a single buffer that can be later
|
Merge \p clipboard's data into a single buffer that can be later
|
||||||
unmarshalled to restore the clipboard and return the buffer.
|
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
|
//! Unmarshall clipboard data
|
||||||
/*!
|
/*!
|
||||||
Extract marshalled clipboard data and store it in \p clipboard.
|
Extract marshalled clipboard data and store it in \p clipboard.
|
||||||
Sets the clipboard time to \c time.
|
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
|
//! Copy clipboard
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -166,5 +167,5 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static UInt32 readUInt32(const char *);
|
static UInt32 readUInt32(const char *);
|
||||||
static void writeUInt32(String *, UInt32);
|
static void writeUInt32(std::string *, UInt32);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -47,10 +47,10 @@ IKeyState::KeyInfo *IKeyState::KeyInfo::alloc(KeyID id, KeyModifierMask mask, Ke
|
||||||
}
|
}
|
||||||
|
|
||||||
IKeyState::KeyInfo *IKeyState::KeyInfo::alloc(
|
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();
|
const char *buffer = screens.c_str();
|
||||||
|
|
||||||
// build structure
|
// build structure
|
||||||
|
|
@ -82,7 +82,7 @@ bool IKeyState::KeyInfo::isDefault(const char *screens)
|
||||||
return (screens == NULL || screens[0] == '\0');
|
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
|
// special cases
|
||||||
if (isDefault(screens)) {
|
if (isDefault(screens)) {
|
||||||
|
|
@ -93,7 +93,7 @@ bool IKeyState::KeyInfo::contains(const char *screens, const String &name)
|
||||||
}
|
}
|
||||||
|
|
||||||
// search
|
// search
|
||||||
String match;
|
std::string match;
|
||||||
match.reserve(name.size() + 2);
|
match.reserve(name.size() + 2);
|
||||||
match += ":";
|
match += ":";
|
||||||
match += name;
|
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 ':'
|
// collect destinations into a string. names are surrounded by ':'
|
||||||
// which makes searching easy. the string is empty if there are no
|
// which makes searching easy. the string is empty if there are no
|
||||||
// destinations and "*" means all destinations.
|
// destinations and "*" means all destinations.
|
||||||
String screens;
|
std::string screens;
|
||||||
for (auto i = destinations.begin(); i != destinations.end(); ++i) {
|
for (auto i = destinations.begin(); i != destinations.end(); ++i) {
|
||||||
if (*i == "*") {
|
if (*i == "*") {
|
||||||
screens = "*";
|
screens = "*";
|
||||||
|
|
@ -130,7 +130,7 @@ String IKeyState::KeyInfo::join(const std::set<String> &destinations)
|
||||||
return screens;
|
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();
|
dst.clear();
|
||||||
if (isDefault(screens)) {
|
if (isDefault(screens)) {
|
||||||
|
|
@ -144,7 +144,7 @@ void IKeyState::KeyInfo::split(const char *screens, std::set<String> &dst)
|
||||||
const char *i = screens + 1;
|
const char *i = screens + 1;
|
||||||
while (*i != '\0') {
|
while (*i != '\0') {
|
||||||
const char *j = strchr(i, ':');
|
const char *j = strchr(i, ':');
|
||||||
dst.insert(String(i, j - i));
|
dst.insert(std::string(i, j - i));
|
||||||
i = j + 1;
|
i = j + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,6 @@
|
||||||
#include "base/Event.h"
|
#include "base/Event.h"
|
||||||
#include "base/EventTypes.h"
|
#include "base/EventTypes.h"
|
||||||
#include "base/IEventQueue.h"
|
#include "base/IEventQueue.h"
|
||||||
#include "base/String.h"
|
|
||||||
#include "common/IInterface.h"
|
#include "common/IInterface.h"
|
||||||
#include "common/stdset.h"
|
#include "common/stdset.h"
|
||||||
#include "deskflow/key_types.h"
|
#include "deskflow/key_types.h"
|
||||||
|
|
@ -46,14 +45,14 @@ public:
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static KeyInfo *alloc(KeyID, KeyModifierMask, KeyButton, SInt32 count);
|
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 KeyInfo *alloc(const KeyInfo &);
|
||||||
|
|
||||||
static bool isDefault(const char *screens);
|
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 bool equal(const KeyInfo *, const KeyInfo *);
|
||||||
static String join(const std::set<String> &destinations);
|
static std::string join(const std::set<std::string> &destinations);
|
||||||
static void split(const char *screens, std::set<String> &);
|
static void split(const char *screens, std::set<std::string> &);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
KeyID m_key;
|
KeyID m_key;
|
||||||
|
|
@ -95,13 +94,14 @@ public:
|
||||||
/*!
|
/*!
|
||||||
Synthesizes a key press event and updates the key state.
|
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
|
//! Fake a key repeat
|
||||||
/*!
|
/*!
|
||||||
Synthesizes a key repeat event and updates the key state.
|
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
|
//! Fake a key release
|
||||||
/*!
|
/*!
|
||||||
|
|
|
||||||
|
|
@ -146,7 +146,7 @@ public:
|
||||||
On MacOS check which app causes a secure input state to be enabled. No
|
On MacOS check which app causes a secure input state to be enabled. No
|
||||||
alternative on other platforms
|
alternative on other platforms
|
||||||
*/
|
*/
|
||||||
virtual String getSecureInputApp() const = 0;
|
virtual std::string getSecureInputApp() const = 0;
|
||||||
|
|
||||||
//@}
|
//@}
|
||||||
//! @name accessors
|
//! @name accessors
|
||||||
|
|
@ -187,8 +187,9 @@ public:
|
||||||
virtual void updateKeyMap() = 0;
|
virtual void updateKeyMap() = 0;
|
||||||
virtual void updateKeyState() = 0;
|
virtual void updateKeyState() = 0;
|
||||||
virtual void setHalfDuplexMask(KeyModifierMask) = 0;
|
virtual void setHalfDuplexMask(KeyModifierMask) = 0;
|
||||||
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;
|
||||||
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;
|
||||||
virtual bool fakeKeyUp(KeyButton button) = 0;
|
virtual bool fakeKeyUp(KeyButton button) = 0;
|
||||||
virtual void fakeAllKeysUp() = 0;
|
virtual void fakeAllKeysUp() = 0;
|
||||||
virtual bool fakeCtrlAltDel() = 0;
|
virtual bool fakeCtrlAltDel() = 0;
|
||||||
|
|
@ -199,13 +200,13 @@ public:
|
||||||
virtual SInt32 pollActiveGroup() const = 0;
|
virtual SInt32 pollActiveGroup() const = 0;
|
||||||
virtual void pollPressedKeys(KeyButtonSet &pressedKeys) const = 0;
|
virtual void pollPressedKeys(KeyButtonSet &pressedKeys) const = 0;
|
||||||
|
|
||||||
virtual String &getDraggingFilename() = 0;
|
virtual std::string &getDraggingFilename() = 0;
|
||||||
virtual void clearDraggingFilename() = 0;
|
virtual void clearDraggingFilename() = 0;
|
||||||
virtual bool isDraggingStarted() = 0;
|
virtual bool isDraggingStarted() = 0;
|
||||||
virtual bool isFakeDraggingStarted() = 0;
|
virtual bool isFakeDraggingStarted() = 0;
|
||||||
|
|
||||||
virtual void fakeDraggingFiles(DragFileList fileList) = 0;
|
virtual void fakeDraggingFiles(DragFileList fileList) = 0;
|
||||||
virtual const String &getDropTarget() const = 0;
|
virtual const std::string &getDropTarget() const = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//! Handle system event
|
//! Handle system event
|
||||||
|
|
|
||||||
|
|
@ -243,7 +243,7 @@ void KeyMap::foreachKey(ForeachKeyCallback cb, void *userData)
|
||||||
|
|
||||||
const KeyMap::KeyItem *KeyMap::mapKey(
|
const KeyMap::KeyItem *KeyMap::mapKey(
|
||||||
Keystrokes &keys, KeyID id, SInt32 group, ModifierToKeys &activeModifiers, KeyModifierMask ¤tState,
|
Keystrokes &keys, KeyID id, SInt32 group, ModifierToKeys &activeModifiers, KeyModifierMask ¤tState,
|
||||||
KeyModifierMask desiredMask, bool isAutoRepeat, const String &lang
|
KeyModifierMask desiredMask, bool isAutoRepeat, const std::string &lang
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
LOG(
|
LOG(
|
||||||
|
|
@ -310,12 +310,12 @@ const KeyMap::KeyItem *KeyMap::mapKey(
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeyMap::setLanguageData(std::vector<String> layouts)
|
void KeyMap::setLanguageData(std::vector<std::string> layouts)
|
||||||
{
|
{
|
||||||
m_keyboardLayouts = std::move(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;
|
SInt32 id = group;
|
||||||
|
|
||||||
|
|
@ -488,7 +488,7 @@ void KeyMap::setModifierKeys()
|
||||||
|
|
||||||
const KeyMap::KeyItem *KeyMap::mapCommandKey(
|
const KeyMap::KeyItem *KeyMap::mapCommandKey(
|
||||||
Keystrokes &keys, KeyID id, SInt32 group, ModifierToKeys &activeModifiers, KeyModifierMask ¤tState,
|
Keystrokes &keys, KeyID id, SInt32 group, ModifierToKeys &activeModifiers, KeyModifierMask ¤tState,
|
||||||
KeyModifierMask desiredMask, bool isAutoRepeat, const String &lang
|
KeyModifierMask desiredMask, bool isAutoRepeat, const std::string &lang
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
static const KeyModifierMask s_overrideModifiers = 0xffffu;
|
static const KeyModifierMask s_overrideModifiers = 0xffffu;
|
||||||
|
|
@ -591,7 +591,7 @@ KeyMap::getKeyItemList(const KeyMap::KeyGroupTable &keyGroupTable, SInt32 group,
|
||||||
|
|
||||||
const KeyMap::KeyItem *KeyMap::mapCharacterKey(
|
const KeyMap::KeyItem *KeyMap::mapCharacterKey(
|
||||||
Keystrokes &keys, KeyID id, SInt32 group, ModifierToKeys &activeModifiers, KeyModifierMask ¤tState,
|
Keystrokes &keys, KeyID id, SInt32 group, ModifierToKeys &activeModifiers, KeyModifierMask ¤tState,
|
||||||
KeyModifierMask desiredMask, bool isAutoRepeat, const String &lang
|
KeyModifierMask desiredMask, bool isAutoRepeat, const std::string &lang
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
// find KeySym in table
|
// find KeySym in table
|
||||||
|
|
@ -641,7 +641,7 @@ const KeyMap::KeyItem *KeyMap::mapCharacterKey(
|
||||||
return &keyItem;
|
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);
|
group = getLanguageGroupID(group, lang);
|
||||||
keys.push_back(Keystroke(group, true, false));
|
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(
|
const KeyMap::KeyItem *KeyMap::mapModifierKey(
|
||||||
Keystrokes &keys, KeyID id, SInt32 group, ModifierToKeys &activeModifiers, KeyModifierMask ¤tState,
|
Keystrokes &keys, KeyID id, SInt32 group, ModifierToKeys &activeModifiers, KeyModifierMask ¤tState,
|
||||||
KeyModifierMask desiredMask, bool isAutoRepeat, const String &lang
|
KeyModifierMask desiredMask, bool isAutoRepeat, const std::string &lang
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
return mapCharacterKey(keys, id, group, activeModifiers, currentState, desiredMask, isAutoRepeat, lang);
|
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(
|
bool KeyMap::keysForKeyItem(
|
||||||
const KeyItem &keyItem, SInt32 &group, ModifierToKeys &activeModifiers, KeyModifierMask ¤tState,
|
const KeyItem &keyItem, SInt32 &group, ModifierToKeys &activeModifiers, KeyModifierMask ¤tState,
|
||||||
KeyModifierMask desiredState, KeyModifierMask overrideModifiers, bool isAutoRepeat, Keystrokes &keystrokes,
|
KeyModifierMask desiredState, KeyModifierMask overrideModifiers, bool isAutoRepeat, Keystrokes &keystrokes,
|
||||||
const String &lang
|
const std::string &lang
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
static const KeyModifierMask s_notRequiredMask = KeyModifierAltGr | KeyModifierNumLock | KeyModifierScrollLock;
|
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
|
// initialize tables
|
||||||
initKeyNameMaps();
|
initKeyNameMaps();
|
||||||
|
|
||||||
String x;
|
std::string x;
|
||||||
for (SInt32 i = 0; i < kKeyModifierNumBits; ++i) {
|
for (SInt32 i = 0; i < kKeyModifierNumBits; ++i) {
|
||||||
KeyModifierMask mod = (1u << i);
|
KeyModifierMask mod = (1u << i);
|
||||||
if ((mask & mod) != 0 && s_modifierToNameMap->count(mod) > 0) {
|
if ((mask & mod) != 0 && s_modifierToNameMap->count(mod) > 0) {
|
||||||
|
|
@ -1120,7 +1120,7 @@ String KeyMap::formatKey(KeyID key, KeyModifierMask mask)
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KeyMap::parseKey(const String &x, KeyID &key)
|
bool KeyMap::parseKey(const std::string &x, KeyID &key)
|
||||||
{
|
{
|
||||||
// initialize tables
|
// initialize tables
|
||||||
initKeyNameMaps();
|
initKeyNameMaps();
|
||||||
|
|
@ -1152,20 +1152,20 @@ bool KeyMap::parseKey(const String &x, KeyID &key)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KeyMap::parseModifiers(String &x, KeyModifierMask &mask)
|
bool KeyMap::parseModifiers(std::string &x, KeyModifierMask &mask)
|
||||||
{
|
{
|
||||||
// initialize tables
|
// initialize tables
|
||||||
initKeyNameMaps();
|
initKeyNameMaps();
|
||||||
|
|
||||||
mask = 0;
|
mask = 0;
|
||||||
String::size_type tb = x.find_first_not_of(" \t", 0);
|
std::string::size_type tb = x.find_first_not_of(" \t", 0);
|
||||||
while (tb != String::npos) {
|
while (tb != std::string::npos) {
|
||||||
// get next component
|
// get next component
|
||||||
String::size_type te = x.find_first_of(" \t+)", tb);
|
std::string::size_type te = x.find_first_of(" \t+)", tb);
|
||||||
if (te == String::npos) {
|
if (te == std::string::npos) {
|
||||||
te = x.size();
|
te = x.size();
|
||||||
}
|
}
|
||||||
String c = x.substr(tb, te - tb);
|
std::string c = x.substr(tb, te - tb);
|
||||||
if (c.empty()) {
|
if (c.empty()) {
|
||||||
// missing component
|
// missing component
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -1181,9 +1181,9 @@ bool KeyMap::parseModifiers(String &x, KeyModifierMask &mask)
|
||||||
} else {
|
} else {
|
||||||
// unknown string
|
// unknown string
|
||||||
x.erase(0, tb);
|
x.erase(0, tb);
|
||||||
String::size_type tb = x.find_first_not_of(" \t");
|
std::string::size_type tb = x.find_first_not_of(" \t");
|
||||||
String::size_type te = x.find_last_not_of(" \t");
|
std::string::size_type te = x.find_last_not_of(" \t");
|
||||||
if (tb == String::npos) {
|
if (tb == std::string::npos) {
|
||||||
x = "";
|
x = "";
|
||||||
} else {
|
} else {
|
||||||
x = x.substr(tb, te - tb + 1);
|
x = x.substr(tb, te - tb + 1);
|
||||||
|
|
@ -1193,7 +1193,7 @@ bool KeyMap::parseModifiers(String &x, KeyModifierMask &mask)
|
||||||
|
|
||||||
// check for '+' or end of string
|
// check for '+' or end of string
|
||||||
tb = x.find_first_not_of(" \t", te);
|
tb = x.find_first_not_of(" \t", te);
|
||||||
if (tb != String::npos) {
|
if (tb != std::string::npos) {
|
||||||
if (x[tb] != '+') {
|
if (x[tb] != '+') {
|
||||||
// expected '+'
|
// expected '+'
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -225,10 +225,10 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual const KeyItem *mapKey(
|
virtual const KeyItem *mapKey(
|
||||||
Keystrokes &keys, KeyID id, SInt32 group, ModifierToKeys &activeModifiers, KeyModifierMask ¤tState,
|
Keystrokes &keys, KeyID id, SInt32 group, ModifierToKeys &activeModifiers, KeyModifierMask ¤tState,
|
||||||
KeyModifierMask desiredMask, bool isAutoRepeat, const String &lang
|
KeyModifierMask desiredMask, bool isAutoRepeat, const std::string &lang
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
void setLanguageData(std::vector<String> layouts);
|
void setLanguageData(std::vector<std::string> layouts);
|
||||||
|
|
||||||
//! Get number of groups
|
//! Get number of groups
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -310,14 +310,14 @@ public:
|
||||||
Converts a key and modifier mask into a string representing the
|
Converts a key and modifier mask into a string representing the
|
||||||
combination.
|
combination.
|
||||||
*/
|
*/
|
||||||
static String formatKey(KeyID key, KeyModifierMask);
|
static std::string formatKey(KeyID key, KeyModifierMask);
|
||||||
|
|
||||||
//! Parse a string into a key
|
//! Parse a string into a key
|
||||||
/*!
|
/*!
|
||||||
Converts a string into a key. Returns \c true on success and \c false
|
Converts a string into a key. Returns \c true on success and \c false
|
||||||
if the string cannot be parsed.
|
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
|
//! Parse a string into a modifier mask
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -326,7 +326,7 @@ public:
|
||||||
remaining leading and trailing whitespace is stripped from the input
|
remaining leading and trailing whitespace is stripped from the input
|
||||||
string.
|
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.
|
// entries since they don't make sense as hotkeys.
|
||||||
const KeyItem *mapCommandKey(
|
const KeyItem *mapCommandKey(
|
||||||
Keystrokes &keys, KeyID id, SInt32 group, ModifierToKeys &activeModifiers, KeyModifierMask ¤tState,
|
Keystrokes &keys, KeyID id, SInt32 group, ModifierToKeys &activeModifiers, KeyModifierMask ¤tState,
|
||||||
KeyModifierMask desiredMask, bool isAutoRepeat, const String &lang
|
KeyModifierMask desiredMask, bool isAutoRepeat, const std::string &lang
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
// maps a character key. a character key is trying to synthesize a
|
// maps a character key. a character key is trying to synthesize a
|
||||||
|
|
@ -377,13 +377,13 @@ private:
|
||||||
// used to do it.
|
// used to do it.
|
||||||
const KeyItem *mapCharacterKey(
|
const KeyItem *mapCharacterKey(
|
||||||
Keystrokes &keys, KeyID id, SInt32 group, ModifierToKeys &activeModifiers, KeyModifierMask ¤tState,
|
Keystrokes &keys, KeyID id, SInt32 group, ModifierToKeys &activeModifiers, KeyModifierMask ¤tState,
|
||||||
KeyModifierMask desiredMask, bool isAutoRepeat, const String &lang
|
KeyModifierMask desiredMask, bool isAutoRepeat, const std::string &lang
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
// maps a modifier key
|
// maps a modifier key
|
||||||
const KeyItem *mapModifierKey(
|
const KeyItem *mapModifierKey(
|
||||||
Keystrokes &keys, KeyID id, SInt32 group, ModifierToKeys &activeModifiers, KeyModifierMask ¤tState,
|
Keystrokes &keys, KeyID id, SInt32 group, ModifierToKeys &activeModifiers, KeyModifierMask ¤tState,
|
||||||
KeyModifierMask desiredMask, bool isAutoRepeat, const String &lang
|
KeyModifierMask desiredMask, bool isAutoRepeat, const std::string &lang
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
// returns the index into \p entryList of the KeyItemList requiring
|
// returns the index into \p entryList of the KeyItemList requiring
|
||||||
|
|
@ -403,7 +403,7 @@ private:
|
||||||
bool keysForKeyItem(
|
bool keysForKeyItem(
|
||||||
const KeyItem &keyItem, SInt32 &group, ModifierToKeys &activeModifiers, KeyModifierMask ¤tState,
|
const KeyItem &keyItem, SInt32 &group, ModifierToKeys &activeModifiers, KeyModifierMask ¤tState,
|
||||||
KeyModifierMask desiredState, KeyModifierMask overrideModifiers, bool isAutoRepeat, Keystrokes &keystrokes,
|
KeyModifierMask desiredState, KeyModifierMask overrideModifiers, bool isAutoRepeat, Keystrokes &keystrokes,
|
||||||
const String &lang
|
const std::string &lang
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
// fills \p keystrokes with the keys to synthesize the modifiers
|
// fills \p keystrokes with the keys to synthesize the modifiers
|
||||||
|
|
@ -442,9 +442,9 @@ private:
|
||||||
// Ways to synthesize a KeyID over multiple keyboard groups
|
// Ways to synthesize a KeyID over multiple keyboard groups
|
||||||
using KeyGroupTable = std::vector<KeyEntryList>;
|
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 *
|
const KeyItemList *
|
||||||
getKeyItemList(const KeyGroupTable &keyGroupTable, SInt32 group, KeyModifierMask desiredMask) const;
|
getKeyItemList(const KeyGroupTable &keyGroupTable, SInt32 group, KeyModifierMask desiredMask) const;
|
||||||
|
|
||||||
|
|
@ -469,10 +469,10 @@ private:
|
||||||
using KeyButtonSet = std::set<KeyButton>;
|
using KeyButtonSet = std::set<KeyButton>;
|
||||||
|
|
||||||
// Key maps for parsing/formatting
|
// Key maps for parsing/formatting
|
||||||
using NameToKeyMap = std::map<String, KeyID, deskflow::string::CaselessCmp>;
|
using NameToKeyMap = std::map<std::string, KeyID, deskflow::string::CaselessCmp>;
|
||||||
using NameToModifierMap = std::map<String, KeyModifierMask, deskflow::string::CaselessCmp>;
|
using NameToModifierMap = std::map<std::string, KeyModifierMask, deskflow::string::CaselessCmp>;
|
||||||
using KeyToNameMap = std::map<KeyID, String>;
|
using KeyToNameMap = std::map<KeyID, std::string>;
|
||||||
using ModifierToNameMap = std::map<KeyModifierMask, String>;
|
using ModifierToNameMap = std::map<KeyModifierMask, std::string>;
|
||||||
|
|
||||||
// KeyID info
|
// KeyID info
|
||||||
KeyIDMap m_keyIDMap;
|
KeyIDMap m_keyIDMap;
|
||||||
|
|
@ -490,7 +490,7 @@ private:
|
||||||
KeyItem m_modifierKeyItem;
|
KeyItem m_modifierKeyItem;
|
||||||
|
|
||||||
// Language sync data
|
// Language sync data
|
||||||
std::vector<String> m_keyboardLayouts;
|
std::vector<std::string> m_keyboardLayouts;
|
||||||
|
|
||||||
// parsing/formatting tables
|
// parsing/formatting tables
|
||||||
static NameToKeyMap *s_nameToKeyMap;
|
static NameToKeyMap *s_nameToKeyMap;
|
||||||
|
|
|
||||||
|
|
@ -653,7 +653,7 @@ static const KeyID s_numpadTable[] = {
|
||||||
// KeyState
|
// KeyState
|
||||||
//
|
//
|
||||||
|
|
||||||
KeyState::KeyState(IEventQueue *events, std::vector<String> layouts, bool isLangSyncEnabled)
|
KeyState::KeyState(IEventQueue *events, std::vector<std::string> layouts, bool isLangSyncEnabled)
|
||||||
: IKeyState(events),
|
: IKeyState(events),
|
||||||
m_keyMapPtr(new deskflow::KeyMap()),
|
m_keyMapPtr(new deskflow::KeyMap()),
|
||||||
m_keyMap(*m_keyMapPtr),
|
m_keyMap(*m_keyMapPtr),
|
||||||
|
|
@ -665,7 +665,9 @@ KeyState::KeyState(IEventQueue *events, std::vector<String> layouts, bool isLang
|
||||||
init();
|
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),
|
: IKeyState(events),
|
||||||
m_keyMapPtr(0),
|
m_keyMapPtr(0),
|
||||||
m_keyMap(keyMap),
|
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
|
// if this server key is already down then this is probably a
|
||||||
// mis-reported autorepeat.
|
// mis-reported autorepeat.
|
||||||
|
|
@ -848,7 +850,7 @@ void KeyState::fakeKeyDown(KeyID id, KeyModifierMask mask, KeyButton serverID, c
|
||||||
fakeKeys(keys, 1);
|
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"));
|
LOG((CLOG_DEBUG2 "fakeKeyRepeat"));
|
||||||
serverID &= kButtonMask;
|
serverID &= kButtonMask;
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,8 @@ platform specific methods.
|
||||||
class KeyState : public IKeyState
|
class KeyState : public IKeyState
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
KeyState(IEventQueue *events, std::vector<String> layouts, bool isLangSyncEnabled);
|
KeyState(IEventQueue *events, std::vector<std::string> layouts, bool isLangSyncEnabled);
|
||||||
KeyState(IEventQueue *events, deskflow::KeyMap &keyMap, std::vector<String> layouts, bool isLangSyncEnabled);
|
KeyState(IEventQueue *events, deskflow::KeyMap &keyMap, std::vector<std::string> layouts, bool isLangSyncEnabled);
|
||||||
virtual ~KeyState();
|
virtual ~KeyState();
|
||||||
|
|
||||||
//! @name manipulators
|
//! @name manipulators
|
||||||
|
|
@ -69,8 +69,8 @@ public:
|
||||||
}
|
}
|
||||||
void updateKeyState() override;
|
void updateKeyState() override;
|
||||||
void setHalfDuplexMask(KeyModifierMask) override;
|
void setHalfDuplexMask(KeyModifierMask) override;
|
||||||
void fakeKeyDown(KeyID id, KeyModifierMask mask, 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 String &lang) override;
|
bool fakeKeyRepeat(KeyID id, KeyModifierMask mask, SInt32 count, KeyButton button, const std::string &lang) override;
|
||||||
bool fakeKeyUp(KeyButton button) override;
|
bool fakeKeyUp(KeyButton button) override;
|
||||||
void fakeAllKeysUp() override;
|
void fakeAllKeysUp() override;
|
||||||
bool fakeMediaKey(KeyID id) override;
|
bool fakeMediaKey(KeyID id) override;
|
||||||
|
|
|
||||||
|
|
@ -49,12 +49,14 @@ void PlatformScreen::setHalfDuplexMask(KeyModifierMask mask)
|
||||||
getKeyState()->setHalfDuplexMask(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);
|
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);
|
return getKeyState()->fakeKeyRepeat(id, mask, count, button, lang);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -64,8 +64,8 @@ public:
|
||||||
virtual void updateKeyMap();
|
virtual void updateKeyMap();
|
||||||
virtual void updateKeyState();
|
virtual void updateKeyState();
|
||||||
virtual void setHalfDuplexMask(KeyModifierMask);
|
virtual void setHalfDuplexMask(KeyModifierMask);
|
||||||
virtual void fakeKeyDown(KeyID id, KeyModifierMask mask, KeyButton button, const String &);
|
virtual void fakeKeyDown(KeyID id, KeyModifierMask mask, KeyButton button, const std::string &);
|
||||||
virtual bool fakeKeyRepeat(KeyID id, KeyModifierMask mask, SInt32 count, KeyButton button, const String &lang);
|
virtual bool fakeKeyRepeat(KeyID id, KeyModifierMask mask, SInt32 count, KeyButton button, const std::string &lang);
|
||||||
virtual bool fakeKeyUp(KeyButton button);
|
virtual bool fakeKeyUp(KeyButton button);
|
||||||
virtual void fakeAllKeysUp();
|
virtual void fakeAllKeysUp();
|
||||||
virtual bool fakeCtrlAltDel();
|
virtual bool fakeCtrlAltDel();
|
||||||
|
|
@ -84,7 +84,7 @@ public:
|
||||||
{
|
{
|
||||||
return m_fakeDraggingStarted;
|
return m_fakeDraggingStarted;
|
||||||
}
|
}
|
||||||
virtual String &getDraggingFilename()
|
virtual std::string &getDraggingFilename()
|
||||||
{
|
{
|
||||||
return m_draggingFilename;
|
return m_draggingFilename;
|
||||||
}
|
}
|
||||||
|
|
@ -112,7 +112,7 @@ public:
|
||||||
{
|
{
|
||||||
throw std::runtime_error("fakeDraggingFiles not implemented");
|
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");
|
throw std::runtime_error("getDropTarget not implemented");
|
||||||
}
|
}
|
||||||
|
|
@ -143,7 +143,7 @@ protected:
|
||||||
virtual SInt32 mapClientScrollDirection(SInt32) const;
|
virtual SInt32 mapClientScrollDirection(SInt32) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
String m_draggingFilename;
|
std::string m_draggingFilename;
|
||||||
bool m_draggingStarted;
|
bool m_draggingStarted;
|
||||||
bool m_fakeDraggingStarted;
|
bool m_fakeDraggingStarted;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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;
|
const UInt32 len = (StringData != NULL) ? (UInt32)StringData->size() : 0;
|
||||||
writeInt(len, sizeof(len), Buffer);
|
writeInt(len, sizeof(len), Buffer);
|
||||||
|
|
@ -200,7 +200,7 @@ void ProtocolUtil::vreadf(deskflow::IStream *stream, const char *fmt, va_list ar
|
||||||
}
|
}
|
||||||
|
|
||||||
case 's': {
|
case 's': {
|
||||||
String *destination = va_arg(args, String *);
|
std::string *destination = va_arg(args, std::string *);
|
||||||
|
|
||||||
if (len > PROTOCOL_MAX_STRING_LENGTH) {
|
if (len > PROTOCOL_MAX_STRING_LENGTH) {
|
||||||
LOG((CLOG_ERR "read: string length exceeds maximum allowed size: %u", len));
|
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':
|
case 's':
|
||||||
assert(len == 0);
|
assert(len == 0);
|
||||||
len = (UInt32)(va_arg(args, String *))->size() + 4;
|
len = (UInt32)(va_arg(args, std::string *))->size() + 4;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'S':
|
case 'S':
|
||||||
|
|
@ -346,7 +346,7 @@ void ProtocolUtil::writef(std::vector<UInt8> &buffer, const char *fmt, va_list a
|
||||||
|
|
||||||
case 's': {
|
case 's': {
|
||||||
assert(len == 0);
|
assert(len == 0);
|
||||||
const String *src = va_arg(args, String *);
|
const std::string *src = va_arg(args, std::string *);
|
||||||
writeString(src, buffer);
|
writeString(src, buffer);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -520,7 +520,7 @@ UInt32 ProtocolUtil::readVectorSize(deskflow::IStream *stream)
|
||||||
return size;
|
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
|
// read the string length
|
||||||
UInt8 buffer[128];
|
UInt8 buffer[128];
|
||||||
|
|
@ -575,7 +575,7 @@ void ProtocolUtil::readBytes(deskflow::IStream *stream, UInt32 len, String *dest
|
||||||
// XIOReadMismatch
|
// XIOReadMismatch
|
||||||
//
|
//
|
||||||
|
|
||||||
String XIOReadMismatch::getWhat() const throw()
|
std::string XIOReadMismatch::getWhat() const throw()
|
||||||
{
|
{
|
||||||
return format("XIOReadMismatch", "ProtocolUtil::readf() mismatch");
|
return format("XIOReadMismatch", "ProtocolUtil::readf() mismatch");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@
|
||||||
#include "io/XIO.h"
|
#include "io/XIO.h"
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
namespace deskflow {
|
namespace deskflow {
|
||||||
class IStream;
|
class IStream;
|
||||||
|
|
@ -50,7 +51,7 @@ public:
|
||||||
- \%1I -- converts std::vector<UInt8>* to 1 byte integers
|
- \%1I -- converts std::vector<UInt8>* to 1 byte integers
|
||||||
- \%2I -- converts std::vector<UInt16>* to 2 byte integers in NBO
|
- \%2I -- converts std::vector<UInt16>* to 2 byte integers in NBO
|
||||||
- \%4I -- converts std::vector<UInt32>* to 4 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
|
- \%S -- converts integer N and const UInt8* to stream of N bytes
|
||||||
*/
|
*/
|
||||||
static void writef(deskflow::IStream *, const char *fmt, ...);
|
static void writef(deskflow::IStream *, const char *fmt, ...);
|
||||||
|
|
@ -69,7 +70,7 @@ public:
|
||||||
- \%1I -- reads 1 byte integers; arg is std::vector<UInt8>*
|
- \%1I -- reads 1 byte integers; arg is std::vector<UInt8>*
|
||||||
- \%2I -- reads NBO 2 byte integers; arg is std::vector<UInt16>*
|
- \%2I -- reads NBO 2 byte integers; arg is std::vector<UInt16>*
|
||||||
- \%4I -- reads NBO 4 byte integers; arg is std::vector<UInt32>*
|
- \%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, ...);
|
static bool readf(deskflow::IStream *, const char *fmt, ...);
|
||||||
|
|
||||||
|
|
@ -100,7 +101,7 @@ private:
|
||||||
/**
|
/**
|
||||||
* @brief Handles an array of bytes
|
* @brief Handles an array of bytes
|
||||||
*/
|
*/
|
||||||
static void readBytes(deskflow::IStream *, UInt32, String *);
|
static void readBytes(deskflow::IStream *, UInt32, std::string *);
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Mismatched read exception
|
//! Mismatched read exception
|
||||||
|
|
@ -112,5 +113,5 @@ class XIOReadMismatch : public XIO
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// XBase overrides
|
// XBase overrides
|
||||||
virtual String getWhat() const throw();
|
virtual std::string getWhat() const throw();
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -198,7 +198,7 @@ void Screen::screensaver(bool) const
|
||||||
// do nothing
|
// 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
|
// check for ctrl+alt+del emulation
|
||||||
if (id == kKeyDelete && (mask & (KeyModifierControl | KeyModifierAlt)) == (KeyModifierControl | KeyModifierAlt)) {
|
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);
|
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);
|
assert(!m_isPrimary);
|
||||||
m_screen->fakeKeyRepeat(id, mask, count, button, lang);
|
m_screen->fakeKeyRepeat(id, mask, count, button, lang);
|
||||||
|
|
@ -400,7 +400,7 @@ void Screen::setEnableDragDrop(bool enabled)
|
||||||
m_enableDragDrop = enabled;
|
m_enableDragDrop = enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
String &Screen::getDraggingFilename() const
|
std::string &Screen::getDraggingFilename() const
|
||||||
{
|
{
|
||||||
return m_screen->getDraggingFilename();
|
return m_screen->getDraggingFilename();
|
||||||
}
|
}
|
||||||
|
|
@ -410,7 +410,7 @@ void Screen::clearDraggingFilename()
|
||||||
m_screen->clearDraggingFilename();
|
m_screen->clearDraggingFilename();
|
||||||
}
|
}
|
||||||
|
|
||||||
const String &Screen::getDropTarget() const
|
const std::string &Screen::getDropTarget() const
|
||||||
{
|
{
|
||||||
return m_screen->getDropTarget();
|
return m_screen->getDropTarget();
|
||||||
}
|
}
|
||||||
|
|
@ -488,7 +488,7 @@ void Screen::leaveSecondary()
|
||||||
m_screen->fakeAllKeysUp();
|
m_screen->fakeAllKeysUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
String Screen::getSecureInputApp() const
|
std::string Screen::getSecureInputApp() const
|
||||||
{
|
{
|
||||||
return m_screen->getSecureInputApp();
|
return m_screen->getSecureInputApp();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "base/String.h"
|
|
||||||
#include "deskflow/DragInformation.h"
|
#include "deskflow/DragInformation.h"
|
||||||
#include "deskflow/IScreen.h"
|
#include "deskflow/IScreen.h"
|
||||||
#include "deskflow/clipboard_types.h"
|
#include "deskflow/clipboard_types.h"
|
||||||
|
|
@ -130,14 +129,14 @@ public:
|
||||||
synthesize an up or repeat for the same client key synthesized by
|
synthesize an up or repeat for the same client key synthesized by
|
||||||
keyDown().
|
keyDown().
|
||||||
*/
|
*/
|
||||||
void keyDown(KeyID id, KeyModifierMask, KeyButton, const String &);
|
void keyDown(KeyID id, KeyModifierMask, KeyButton, const std::string &);
|
||||||
|
|
||||||
//! Notify of key repeat
|
//! Notify of key repeat
|
||||||
/*!
|
/*!
|
||||||
Synthesize key events to generate a press and release of key \c id
|
Synthesize key events to generate a press and release of key \c id
|
||||||
\c count times. If possible match the given modifier mask.
|
\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
|
//! Notify of key release
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -241,7 +240,7 @@ public:
|
||||||
On MacOS check which app causes a secure input state to be enabled. No
|
On MacOS check which app causes a secure input state to be enabled. No
|
||||||
alternative on other platforms
|
alternative on other platforms
|
||||||
*/
|
*/
|
||||||
String getSecureInputApp() const;
|
std::string getSecureInputApp() const;
|
||||||
|
|
||||||
//@}
|
//@}
|
||||||
//! @name accessors
|
//! @name accessors
|
||||||
|
|
@ -298,13 +297,13 @@ public:
|
||||||
bool isFakeDraggingStarted() const;
|
bool isFakeDraggingStarted() const;
|
||||||
|
|
||||||
//! Get the filename of the file being dragged
|
//! Get the filename of the file being dragged
|
||||||
String &getDraggingFilename() const;
|
std::string &getDraggingFilename() const;
|
||||||
|
|
||||||
//! Clear the filename of the file that was dragged
|
//! Clear the filename of the file that was dragged
|
||||||
void clearDraggingFilename();
|
void clearDraggingFilename();
|
||||||
|
|
||||||
//! Get the drop target directory
|
//! Get the drop target directory
|
||||||
const String &getDropTarget() const;
|
const std::string &getDropTarget() const;
|
||||||
|
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -236,7 +236,7 @@ void ServerApp::loadConfig()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ServerApp::loadConfig(const String &pathname)
|
bool ServerApp::loadConfig(const std::string &pathname)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
// load configuration
|
// load configuration
|
||||||
|
|
@ -325,7 +325,7 @@ void ServerApp::updateStatus()
|
||||||
updateStatus("");
|
updateStatus("");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerApp::updateStatus(const String &msg)
|
void ServerApp::updateStatus(const std::string &msg)
|
||||||
{
|
{
|
||||||
if (m_taskBarReceiver) {
|
if (m_taskBarReceiver) {
|
||||||
m_taskBarReceiver->updateStatus(m_server, msg);
|
m_taskBarReceiver->updateStatus(m_server, msg);
|
||||||
|
|
@ -445,7 +445,7 @@ bool ServerApp::initServer()
|
||||||
deskflow::Screen *serverScreen = NULL;
|
deskflow::Screen *serverScreen = NULL;
|
||||||
PrimaryClient *primaryClient = NULL;
|
PrimaryClient *primaryClient = NULL;
|
||||||
try {
|
try {
|
||||||
String name = args().m_config->getCanonicalName(args().m_name);
|
std::string name = args().m_config->getCanonicalName(args().m_name);
|
||||||
serverScreen = openServerScreen();
|
serverScreen = openServerScreen();
|
||||||
primaryClient = openPrimaryClient(name, serverScreen);
|
primaryClient = openPrimaryClient(name, serverScreen);
|
||||||
m_serverScreen = serverScreen;
|
m_serverScreen = serverScreen;
|
||||||
|
|
@ -457,7 +457,7 @@ bool ServerApp::initServer()
|
||||||
LOG((CLOG_WARN "primary screen unavailable: %s", e.what()));
|
LOG((CLOG_WARN "primary screen unavailable: %s", e.what()));
|
||||||
closePrimaryClient(primaryClient);
|
closePrimaryClient(primaryClient);
|
||||||
closeServerScreen(serverScreen);
|
closeServerScreen(serverScreen);
|
||||||
updateStatus(String("primary screen unavailable: ") + e.what());
|
updateStatus(std::string("primary screen unavailable: ") + e.what());
|
||||||
retryTime = e.getRetryTime();
|
retryTime = e.getRetryTime();
|
||||||
} catch (XScreenOpenFailure &e) {
|
} catch (XScreenOpenFailure &e) {
|
||||||
LOG((CLOG_CRIT "failed to start server: %s", e.what()));
|
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()));
|
LOG((CLOG_CRIT "cannot listen for clients: %s", e.what()));
|
||||||
}
|
}
|
||||||
closeClientListener(listener);
|
closeClientListener(listener);
|
||||||
updateStatus(String("cannot listen for clients: ") + e.what());
|
updateStatus(std::string("cannot listen for clients: ") + e.what());
|
||||||
} catch (XBase &e) {
|
} catch (XBase &e) {
|
||||||
LOG((CLOG_CRIT "failed to start server: %s", e.what()));
|
LOG((CLOG_CRIT "failed to start server: %s", e.what()));
|
||||||
closeClientListener(listener);
|
closeClientListener(listener);
|
||||||
|
|
@ -594,7 +594,7 @@ deskflow::Screen *ServerApp::createScreen()
|
||||||
#endif
|
#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"));
|
LOG((CLOG_DEBUG1 "creating primary screen"));
|
||||||
return new PrimaryClient(name, screen);
|
return new PrimaryClient(name, screen);
|
||||||
|
|
@ -714,7 +714,7 @@ int ServerApp::mainLoop()
|
||||||
}
|
}
|
||||||
|
|
||||||
// canonicalize the primary screen name
|
// 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()) {
|
if (primaryName.empty()) {
|
||||||
LOG((CLOG_CRIT "unknown screen name `%s'", args().m_name.c_str()));
|
LOG((CLOG_CRIT "unknown screen name `%s'", args().m_name.c_str()));
|
||||||
return kExitFailed;
|
return kExitFailed;
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ public:
|
||||||
const char *daemonName() const override;
|
const char *daemonName() const override;
|
||||||
const char *daemonInfo() const override;
|
const char *daemonInfo() const override;
|
||||||
void loadConfig() override;
|
void loadConfig() override;
|
||||||
bool loadConfig(const String &pathname) override;
|
bool loadConfig(const std::string &pathname) override;
|
||||||
deskflow::Screen *createScreen() override;
|
deskflow::Screen *createScreen() override;
|
||||||
int mainLoop() override;
|
int mainLoop() override;
|
||||||
int runInner(int argc, char **argv, ILogOutputter *outputter, StartupFunc startup) override;
|
int runInner(int argc, char **argv, ILogOutputter *outputter, StartupFunc startup) override;
|
||||||
|
|
@ -97,7 +97,7 @@ public:
|
||||||
void closeServer(Server *server);
|
void closeServer(Server *server);
|
||||||
void stopRetryTimer();
|
void stopRetryTimer();
|
||||||
void updateStatus();
|
void updateStatus();
|
||||||
void updateStatus(const String &msg);
|
void updateStatus(const std::string &msg);
|
||||||
void closeClientListener(ClientListener *listen);
|
void closeClientListener(ClientListener *listen);
|
||||||
void stopServer();
|
void stopServer();
|
||||||
void closePrimaryClient(PrimaryClient *primaryClient);
|
void closePrimaryClient(PrimaryClient *primaryClient);
|
||||||
|
|
@ -106,7 +106,7 @@ public:
|
||||||
bool initServer();
|
bool initServer();
|
||||||
void retryHandler(const Event &, void *);
|
void retryHandler(const Event &, void *);
|
||||||
deskflow::Screen *openServerScreen();
|
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 handleScreenError(const Event &, void *);
|
||||||
void handleSuspend(const Event &, void *);
|
void handleSuspend(const Event &, void *);
|
||||||
void handleResume(const Event &, void *);
|
void handleResume(const Event &, void *);
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ public:
|
||||||
ServerArgs &operator=(ServerArgs &&) = default;
|
ServerArgs &operator=(ServerArgs &&) = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
String m_configFile = "";
|
std::string m_configFile = "";
|
||||||
std::shared_ptr<Config> m_config;
|
std::shared_ptr<Config> m_config;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ ServerTaskBarReceiver::~ServerTaskBarReceiver()
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerTaskBarReceiver::updateStatus(Server *server, const String &errorMsg)
|
void ServerTaskBarReceiver::updateStatus(Server *server, const std::string &errorMsg)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
// update our status
|
// update our status
|
||||||
|
|
@ -72,7 +72,7 @@ ServerTaskBarReceiver::EState ServerTaskBarReceiver::getStatus() const
|
||||||
return m_state;
|
return m_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
const String &ServerTaskBarReceiver::getErrorMessage() const
|
const std::string &ServerTaskBarReceiver::getErrorMessage() const
|
||||||
{
|
{
|
||||||
return m_errorMessage;
|
return m_errorMessage;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,6 @@
|
||||||
#include "arch/IArchTaskBarReceiver.h"
|
#include "arch/IArchTaskBarReceiver.h"
|
||||||
#include "base/Event.h"
|
#include "base/Event.h"
|
||||||
#include "base/EventTypes.h"
|
#include "base/EventTypes.h"
|
||||||
#include "base/String.h"
|
|
||||||
#include "common/stdvector.h"
|
#include "common/stdvector.h"
|
||||||
#include "deskflow/ServerApp.h"
|
#include "deskflow/ServerApp.h"
|
||||||
#include "server/Server.h"
|
#include "server/Server.h"
|
||||||
|
|
@ -42,9 +41,9 @@ public:
|
||||||
/*!
|
/*!
|
||||||
Determine the status and query required information from the server.
|
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);
|
updateStatus((Server *)n, errorMsg);
|
||||||
}
|
}
|
||||||
|
|
@ -61,7 +60,7 @@ public:
|
||||||
virtual std::string getToolTip() const;
|
virtual std::string getToolTip() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
using Clients = std::vector<String>;
|
using Clients = std::vector<std::string>;
|
||||||
enum EState
|
enum EState
|
||||||
{
|
{
|
||||||
kNotRunning,
|
kNotRunning,
|
||||||
|
|
@ -75,7 +74,7 @@ protected:
|
||||||
EState getStatus() const;
|
EState getStatus() const;
|
||||||
|
|
||||||
//! Get error message
|
//! Get error message
|
||||||
const String &getErrorMessage() const;
|
const std::string &getErrorMessage() const;
|
||||||
|
|
||||||
//! Get connected clients
|
//! Get connected clients
|
||||||
const Clients &getClients() const;
|
const Clients &getClients() const;
|
||||||
|
|
@ -95,7 +94,7 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
EState m_state;
|
EState m_state;
|
||||||
String m_errorMessage;
|
std::string m_errorMessage;
|
||||||
Clients m_clients;
|
Clients m_clients;
|
||||||
IEventQueue *m_events;
|
IEventQueue *m_events;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ void StreamChunker::sendFile(char *filename, IEventQueue *events, void *eventTar
|
||||||
size_t size = (size_t)file.tellg();
|
size_t size = (size_t)file.tellg();
|
||||||
|
|
||||||
// send first message (file size)
|
// send first message (file size)
|
||||||
String fileSize = deskflow::string::sizeTypeToString(size);
|
std::string fileSize = deskflow::string::sizeTypeToString(size);
|
||||||
FileChunk *sizeMessage = FileChunk::start(fileSize);
|
FileChunk *sizeMessage = FileChunk::start(fileSize);
|
||||||
|
|
||||||
events->addEvent(Event(events->forFile().fileChunkSending(), eventTarget, sizeMessage));
|
events->addEvent(Event(events->forFile().fileChunkSending(), eventTarget, sizeMessage));
|
||||||
|
|
@ -106,11 +106,11 @@ void StreamChunker::sendFile(char *filename, IEventQueue *events, void *eventTar
|
||||||
}
|
}
|
||||||
|
|
||||||
void StreamChunker::sendClipboard(
|
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)
|
// 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);
|
ClipboardChunk *sizeMessage = ClipboardChunk::start(id, sequence, dataSize);
|
||||||
|
|
||||||
events->addEvent(Event(events->forClipboard().clipboardSending(), eventTarget, sizeMessage));
|
events->addEvent(Event(events->forClipboard().clipboardSending(), eventTarget, sizeMessage));
|
||||||
|
|
@ -127,7 +127,7 @@ void StreamChunker::sendClipboard(
|
||||||
chunkSize = size - sentLength;
|
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);
|
ClipboardChunk *dataChunk = ClipboardChunk::data(id, sequence, chunk);
|
||||||
|
|
||||||
events->addEvent(Event(events->forClipboard().clipboardSending(), eventTarget, dataChunk));
|
events->addEvent(Event(events->forClipboard().clipboardSending(), eventTarget, dataChunk));
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,10 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "base/String.h"
|
|
||||||
#include "deskflow/clipboard_types.h"
|
#include "deskflow/clipboard_types.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
class IEventQueue;
|
class IEventQueue;
|
||||||
class Mutex;
|
class Mutex;
|
||||||
|
|
||||||
|
|
@ -27,8 +28,9 @@ class StreamChunker
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void sendFile(char *filename, IEventQueue *events, void *eventTarget);
|
static void sendFile(char *filename, IEventQueue *events, void *eventTarget);
|
||||||
static void
|
static void sendClipboard(
|
||||||
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
|
||||||
|
);
|
||||||
static void interruptFile();
|
static void interruptFile();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
// XBadClient
|
// XBadClient
|
||||||
//
|
//
|
||||||
|
|
||||||
String XBadClient::getWhat() const throw()
|
std::string XBadClient::getWhat() const throw()
|
||||||
{
|
{
|
||||||
return "XBadClient";
|
return "XBadClient";
|
||||||
}
|
}
|
||||||
|
|
@ -32,7 +32,7 @@ String XBadClient::getWhat() const throw()
|
||||||
// XInvalidProtocol
|
// XInvalidProtocol
|
||||||
//
|
//
|
||||||
|
|
||||||
String XInvalidProtocol::getWhat() const throw()
|
std::string XInvalidProtocol::getWhat() const throw()
|
||||||
{
|
{
|
||||||
return "XInvalidProtocol";
|
return "XInvalidProtocol";
|
||||||
}
|
}
|
||||||
|
|
@ -56,7 +56,7 @@ int XIncompatibleClient::getMinor() const throw()
|
||||||
return m_minor;
|
return m_minor;
|
||||||
}
|
}
|
||||||
|
|
||||||
String XIncompatibleClient::getWhat() const throw()
|
std::string XIncompatibleClient::getWhat() const throw()
|
||||||
{
|
{
|
||||||
return format(
|
return format(
|
||||||
"XIncompatibleClient", "incompatible client %{1}.%{2}", deskflow::string::sprintf("%d", m_major).c_str(),
|
"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::XDuplicateClient(const String &name) : m_name(name)
|
XDuplicateClient::XDuplicateClient(const std::string &name) : m_name(name)
|
||||||
{
|
{
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
const String &XDuplicateClient::getName() const throw()
|
const std::string &XDuplicateClient::getName() const throw()
|
||||||
{
|
{
|
||||||
return m_name;
|
return m_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
String XDuplicateClient::getWhat() const throw()
|
std::string XDuplicateClient::getWhat() const throw()
|
||||||
{
|
{
|
||||||
return format("XDuplicateClient", "duplicate client %{1}", m_name.c_str());
|
return format("XDuplicateClient", "duplicate client %{1}", m_name.c_str());
|
||||||
}
|
}
|
||||||
|
|
@ -87,17 +87,17 @@ String XDuplicateClient::getWhat() const throw()
|
||||||
// XUnknownClient
|
// XUnknownClient
|
||||||
//
|
//
|
||||||
|
|
||||||
XUnknownClient::XUnknownClient(const String &name) : m_name(name)
|
XUnknownClient::XUnknownClient(const std::string &name) : m_name(name)
|
||||||
{
|
{
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
const String &XUnknownClient::getName() const throw()
|
const std::string &XUnknownClient::getName() const throw()
|
||||||
{
|
{
|
||||||
return m_name;
|
return m_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
String XUnknownClient::getWhat() const throw()
|
std::string XUnknownClient::getWhat() const throw()
|
||||||
{
|
{
|
||||||
return format("XUnknownClient", "unknown client %{1}", m_name.c_str());
|
return format("XUnknownClient", "unknown client %{1}", m_name.c_str());
|
||||||
}
|
}
|
||||||
|
|
@ -116,7 +116,7 @@ int XExitApp::getCode() const throw()
|
||||||
return m_code;
|
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());
|
return format("XExitApp", "exiting with code %{1}", deskflow::string::sprintf("%d", m_code).c_str());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ public:
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual String getWhat() const throw();
|
virtual std::string getWhat() const throw();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_major;
|
int m_major;
|
||||||
|
|
@ -76,7 +76,7 @@ a client that is already connected.
|
||||||
class XDuplicateClient : public XDeskflow
|
class XDuplicateClient : public XDeskflow
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
XDuplicateClient(const String &name);
|
XDuplicateClient(const std::string &name);
|
||||||
virtual ~XDuplicateClient() _NOEXCEPT
|
virtual ~XDuplicateClient() _NOEXCEPT
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
@ -85,15 +85,15 @@ public:
|
||||||
//@{
|
//@{
|
||||||
|
|
||||||
//! Get client's name
|
//! Get client's name
|
||||||
virtual const String &getName() const throw();
|
virtual const std::string &getName() const throw();
|
||||||
|
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual String getWhat() const throw();
|
virtual std::string getWhat() const throw();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
String m_name;
|
std::string m_name;
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Client not in map exception
|
//! Client not in map exception
|
||||||
|
|
@ -104,7 +104,7 @@ unknown to the server.
|
||||||
class XUnknownClient : public XDeskflow
|
class XUnknownClient : public XDeskflow
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
XUnknownClient(const String &name);
|
XUnknownClient(const std::string &name);
|
||||||
virtual ~XUnknownClient() _NOEXCEPT
|
virtual ~XUnknownClient() _NOEXCEPT
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
@ -113,15 +113,15 @@ public:
|
||||||
//@{
|
//@{
|
||||||
|
|
||||||
//! Get the client's name
|
//! Get the client's name
|
||||||
virtual const String &getName() const throw();
|
virtual const std::string &getName() const throw();
|
||||||
|
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual String getWhat() const throw();
|
virtual std::string getWhat() const throw();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
String m_name;
|
std::string m_name;
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Generic exit eception
|
//! Generic exit eception
|
||||||
|
|
@ -142,7 +142,7 @@ public:
|
||||||
int getCode() const throw();
|
int getCode() const throw();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual String getWhat() const throw();
|
virtual std::string getWhat() const throw();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_code;
|
int m_code;
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
// XScreenOpenFailure
|
// XScreenOpenFailure
|
||||||
//
|
//
|
||||||
|
|
||||||
String XScreenOpenFailure::getWhat() const throw()
|
std::string XScreenOpenFailure::getWhat() const throw()
|
||||||
{
|
{
|
||||||
return format("XScreenOpenFailure", "unable to open screen");
|
return format("XScreenOpenFailure", "unable to open screen");
|
||||||
}
|
}
|
||||||
|
|
@ -31,7 +31,7 @@ String XScreenOpenFailure::getWhat() const throw()
|
||||||
// XScreenXInputFailure
|
// XScreenXInputFailure
|
||||||
//
|
//
|
||||||
|
|
||||||
String XScreenXInputFailure::getWhat() const throw()
|
std::string XScreenXInputFailure::getWhat() const throw()
|
||||||
{
|
{
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
@ -55,7 +55,7 @@ double XScreenUnavailable::getRetryTime() const
|
||||||
return m_timeUntilRetry;
|
return m_timeUntilRetry;
|
||||||
}
|
}
|
||||||
|
|
||||||
String XScreenUnavailable::getWhat() const throw()
|
std::string XScreenUnavailable::getWhat() const throw()
|
||||||
{
|
{
|
||||||
return format("XScreenUnavailable", "unable to open screen");
|
return format("XScreenUnavailable", "unable to open screen");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ public:
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual String getWhat() const throw();
|
virtual std::string getWhat() const throw();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double m_timeUntilRetry;
|
double m_timeUntilRetry;
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,9 @@
|
||||||
|
|
||||||
namespace {
|
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) {
|
for (const auto &item : vector) {
|
||||||
if (&item != &vector[0]) {
|
if (&item != &vector[0]) {
|
||||||
string += delimiter;
|
string += delimiter;
|
||||||
|
|
@ -39,12 +39,12 @@ namespace deskflow {
|
||||||
|
|
||||||
namespace languages {
|
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()));
|
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();
|
m_remoteLanguages.clear();
|
||||||
if (!remoteLanguages.empty()) {
|
if (!remoteLanguages.empty()) {
|
||||||
|
|
@ -55,19 +55,19 @@ void LanguageManager::setRemoteLanguages(const String &remoteLanguages)
|
||||||
LOG((CLOG_INFO "remote languages: %s", vectorToString(m_remoteLanguages, ", ").c_str()));
|
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;
|
return m_remoteLanguages;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<String> &LanguageManager::getLocalLanguages() const
|
const std::vector<std::string> &LanguageManager::getLocalLanguages() const
|
||||||
{
|
{
|
||||||
return m_localLanguages;
|
return m_localLanguages;
|
||||||
}
|
}
|
||||||
|
|
||||||
String LanguageManager::getMissedLanguages() const
|
std::string LanguageManager::getMissedLanguages() const
|
||||||
{
|
{
|
||||||
String missedLanguages;
|
std::string missedLanguages;
|
||||||
|
|
||||||
for (const auto &language : m_remoteLanguages) {
|
for (const auto &language : m_remoteLanguages) {
|
||||||
if (!isLanguageInstalled(language)) {
|
if (!isLanguageInstalled(language)) {
|
||||||
|
|
@ -81,12 +81,12 @@ String LanguageManager::getMissedLanguages() const
|
||||||
return missedLanguages;
|
return missedLanguages;
|
||||||
}
|
}
|
||||||
|
|
||||||
String LanguageManager::getSerializedLocalLanguages() const
|
std::string LanguageManager::getSerializedLocalLanguages() const
|
||||||
{
|
{
|
||||||
return vectorToString(m_localLanguages);
|
return vectorToString(m_localLanguages);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LanguageManager::isLanguageInstalled(const String &language) const
|
bool LanguageManager::isLanguageInstalled(const std::string &language) const
|
||||||
{
|
{
|
||||||
bool isInstalled = true;
|
bool isInstalled = true;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,6 @@
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "base/String.h"
|
|
||||||
#include "deskflow/AppUtil.h"
|
#include "deskflow/AppUtil.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
@ -26,49 +25,51 @@ namespace languages {
|
||||||
|
|
||||||
class LanguageManager
|
class LanguageManager
|
||||||
{
|
{
|
||||||
std::vector<String> m_remoteLanguages;
|
std::vector<std::string> m_remoteLanguages;
|
||||||
std::vector<String> m_localLanguages;
|
std::vector<std::string> m_localLanguages;
|
||||||
|
|
||||||
public:
|
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
|
* @brief setRemoteLanguages sets remote languages
|
||||||
* @param remoteLanguages is a string with sericalized 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
|
* @brief getRemoteLanguages getter for remote languages
|
||||||
* @return vector of 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
|
* @brief getLocalLanguages getter for local languages
|
||||||
* @return vector of 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
|
* @brief getMissedLanguages getter for missed languages on local machine
|
||||||
* @return difference between remote and local languages as a coma separated
|
* @return difference between remote and local languages as a coma separated
|
||||||
* string
|
* string
|
||||||
*/
|
*/
|
||||||
String getMissedLanguages() const;
|
std::string getMissedLanguages() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief getSerializedLocalLanguages getter for local serialized languages
|
* @brief getSerializedLocalLanguages getter for local serialized languages
|
||||||
* @return serialized local languages as a string
|
* @return serialized local languages as a string
|
||||||
*/
|
*/
|
||||||
String getSerializedLocalLanguages() const;
|
std::string getSerializedLocalLanguages() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief isLanguageInstalled checks if language is installed
|
* @brief isLanguageInstalled checks if language is installed
|
||||||
* @param language which should be checked
|
* @param language which should be checked
|
||||||
* @return true if the specified language is installed
|
* @return true if the specified language is installed
|
||||||
*/
|
*/
|
||||||
bool isLanguageInstalled(const String &language) const;
|
bool isLanguageInstalled(const std::string &language) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace languages
|
} // namespace languages
|
||||||
|
|
|
||||||
|
|
@ -60,9 +60,9 @@ void AppUtilUnix::startNode()
|
||||||
app().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
|
#if WINAPI_XWINDOWS
|
||||||
layoutLangCodes = X11LayoutsParser::getX11LanguageList("/usr/share/X11/xkb/rules/evdev.xml");
|
layoutLangCodes = X11LayoutsParser::getX11LanguageList("/usr/share/X11/xkb/rules/evdev.xml");
|
||||||
|
|
@ -97,9 +97,9 @@ std::vector<String> AppUtilUnix::getKeyboardLayoutList()
|
||||||
return layoutLangCodes;
|
return layoutLangCodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
String AppUtilUnix::getCurrentLanguageCode()
|
std::string AppUtilUnix::getCurrentLanguageCode()
|
||||||
{
|
{
|
||||||
String result = "";
|
std::string result = "";
|
||||||
#if WINAPI_XWINDOWS
|
#if WINAPI_XWINDOWS
|
||||||
|
|
||||||
auto display = XOpenDisplay(nullptr);
|
auto display = XOpenDisplay(nullptr);
|
||||||
|
|
@ -165,7 +165,7 @@ String AppUtilUnix::getCurrentLanguageCode()
|
||||||
return result;
|
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
|
#if HAVE_LIBNOTIFY
|
||||||
LOG((CLOG_INFO "showing notification, title=\"%s\", text=\"%s\"", title.c_str(), text.c_str()));
|
LOG((CLOG_INFO "showing notification, title=\"%s\", text=\"%s\"", title.c_str(), text.c_str()));
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ public:
|
||||||
|
|
||||||
int run(int argc, char **argv) override;
|
int run(int argc, char **argv) override;
|
||||||
void startNode() override;
|
void startNode() override;
|
||||||
std::vector<String> getKeyboardLayoutList() override;
|
std::vector<std::string> getKeyboardLayoutList() override;
|
||||||
String getCurrentLanguageCode() override;
|
std::string getCurrentLanguageCode() override;
|
||||||
void showNotification(const String &title, const String &text) const override;
|
void showNotification(const std::string &title, const std::string &text) const override;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -18,13 +18,13 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "base/String.h"
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
// copy from
|
// copy from
|
||||||
// https://www.loc.gov/standards/iso639-2/php/code_list.php
|
// https://www.loc.gov/standards/iso639-2/php/code_list.php
|
||||||
// 10.06.2021
|
// 10.06.2021
|
||||||
// first param - ISO 639-2, second param - 639-1
|
// 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("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("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"),
|
std::make_pair("hye", "hy"), std::make_pair("asm", "as"), std::make_pair("ava", "av"), std::make_pair("ave", "ae"),
|
||||||
|
|
|
||||||
|
|
@ -28,11 +28,11 @@
|
||||||
|
|
||||||
namespace {
|
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);
|
std::stringstream stream(line);
|
||||||
while (stream.good()) {
|
while (stream.good()) {
|
||||||
String part;
|
std::string part;
|
||||||
getline(stream, part, delimiter);
|
getline(stream, part, delimiter);
|
||||||
parts.push_back(part);
|
parts.push_back(part);
|
||||||
}
|
}
|
||||||
|
|
@ -64,7 +64,7 @@ bool X11LayoutsParser::readXMLConfigItemElem(const pugi::xml_node *root, std::ve
|
||||||
return true;
|
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;
|
std::vector<Lang> allCodes;
|
||||||
pugi::xml_document doc;
|
pugi::xml_document doc;
|
||||||
|
|
@ -101,18 +101,18 @@ std::vector<X11LayoutsParser::Lang> X11LayoutsParser::getAllLanguageData(const S
|
||||||
return allCodes;
|
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) {
|
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);
|
dst.push_back(elem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void X11LayoutsParser::convertLayoutToISO639_2(
|
void X11LayoutsParser::convertLayoutToISO639_2(
|
||||||
const String &pathToEvdevFile, bool needToReloadEvdev, const std::vector<String> &layoutNames,
|
const std::string &pathToEvdevFile, bool needToReloadEvdev, const std::vector<std::string> &layoutNames,
|
||||||
const std::vector<String> &layoutVariantNames, std::vector<String> &iso639_2Codes
|
const std::vector<std::string> &layoutVariantNames, std::vector<std::string> &iso639_2Codes
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (layoutNames.size() != layoutVariantNames.size()) {
|
if (layoutNames.size() != layoutVariantNames.size()) {
|
||||||
|
|
@ -133,7 +133,7 @@ void X11LayoutsParser::convertLayoutToISO639_2(
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<String> *toCopy = nullptr;
|
const std::vector<std::string> *toCopy = nullptr;
|
||||||
if (layoutVariantNames[i].empty()) {
|
if (layoutVariantNames[i].empty()) {
|
||||||
toCopy = &langIter->layoutBaseISO639_2;
|
toCopy = &langIter->layoutBaseISO639_2;
|
||||||
} else {
|
} 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<std::string> layoutNames;
|
||||||
std::vector<String> layoutVariantNames;
|
std::vector<std::string> layoutVariantNames;
|
||||||
|
|
||||||
deskflow::linux::DeskflowXkbKeyboard keyboard;
|
deskflow::linux::DeskflowXkbKeyboard keyboard;
|
||||||
splitLine(layoutNames, keyboard.getLayout(), ',');
|
splitLine(layoutNames, keyboard.getLayout(), ',');
|
||||||
splitLine(layoutVariantNames, keyboard.getVariant(), ',');
|
splitLine(layoutVariantNames, keyboard.getVariant(), ',');
|
||||||
|
|
||||||
std::vector<String> iso639_2Codes;
|
std::vector<std::string> iso639_2Codes;
|
||||||
iso639_2Codes.reserve(layoutNames.size());
|
iso639_2Codes.reserve(layoutNames.size());
|
||||||
convertLayoutToISO639_2(pathToEvdevFile, true, layoutNames, layoutVariantNames, iso639_2Codes);
|
convertLayoutToISO639_2(pathToEvdevFile, true, layoutNames, layoutVariantNames, iso639_2Codes);
|
||||||
return convertISO639_2ToISO639_1(iso639_2Codes);
|
return convertISO639_2ToISO639_1(iso639_2Codes);
|
||||||
}
|
}
|
||||||
|
|
||||||
String
|
std::string X11LayoutsParser::convertLayotToISO(
|
||||||
X11LayoutsParser::convertLayotToISO(const String &pathToEvdevFile, const String &layoutLangCode, bool needToReloadFiles)
|
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);
|
convertLayoutToISO639_2(pathToEvdevFile, needToReloadFiles, {layoutLangCode}, {""}, iso639_2Codes);
|
||||||
if (iso639_2Codes.empty()) {
|
if (iso639_2Codes.empty()) {
|
||||||
LOG((CLOG_WARN "failed to convert layout lang code: \"%s\"", layoutLangCode.c_str()));
|
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();
|
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) {
|
for (const auto &isoCode : iso639_2Codes) {
|
||||||
const auto &tableIter =
|
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;
|
return c.first == isoCode;
|
||||||
});
|
});
|
||||||
if (tableIter == ISO_Table.end()) {
|
if (tableIter == ISO_Table.end()) {
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,9 @@
|
||||||
|
|
||||||
#if WINAPI_XWINDOWS
|
#if WINAPI_XWINDOWS
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "base/String.h"
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
namespace pugi {
|
namespace pugi {
|
||||||
class xml_node;
|
class xml_node;
|
||||||
|
|
@ -27,30 +29,31 @@ class xml_node;
|
||||||
class X11LayoutsParser
|
class X11LayoutsParser
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static std::vector<String> getX11LanguageList(const String &pathToEvdevFile);
|
static std::vector<std::string> getX11LanguageList(const std::string &pathToEvdevFile);
|
||||||
static String
|
static std::string convertLayotToISO(
|
||||||
convertLayotToISO(const String &pathToEvdevFile, const String &layoutLangCode, bool needToReloadFiles = false);
|
const std::string &pathToEvdevFile, const std::string &layoutLangCode, bool needToReloadFiles = false
|
||||||
|
);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct Lang
|
struct Lang
|
||||||
{
|
{
|
||||||
String name = "";
|
std::string name = "";
|
||||||
std::vector<String> layoutBaseISO639_2;
|
std::vector<std::string> layoutBaseISO639_2;
|
||||||
std::vector<Lang> variants;
|
std::vector<Lang> variants;
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool readXMLConfigItemElem(const pugi::xml_node *root, std::vector<Lang> &langList);
|
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(
|
static void convertLayoutToISO639_2(
|
||||||
const String &pathToEvdevFile, bool needToReloadEvdev, const std::vector<String> &layoutNames,
|
const std::string &pathToEvdevFile, bool needToReloadEvdev, const std::vector<std::string> &layoutNames,
|
||||||
const std::vector<String> &layoutVariantNames, std::vector<String> &iso639_2Codes
|
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
|
#endif // WINAPI_XWINDOWS
|
||||||
|
|
|
||||||
|
|
@ -169,16 +169,16 @@ void AppUtilWindows::startNode()
|
||||||
app().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 uLayouts = GetKeyboardLayoutList(0, NULL);
|
||||||
auto lpList = (HKL *)LocalAlloc(LPTR, (uLayouts * sizeof(HKL)));
|
auto lpList = (HKL *)LocalAlloc(LPTR, (uLayouts * sizeof(HKL)));
|
||||||
uLayouts = GetKeyboardLayoutList(uLayouts, lpList);
|
uLayouts = GetKeyboardLayoutList(uLayouts, lpList);
|
||||||
|
|
||||||
for (int i = 0; i < uLayouts; ++i) {
|
for (int i = 0; i < uLayouts; ++i) {
|
||||||
String code("", 2);
|
std::string code("", 2);
|
||||||
GetLocaleInfoA(
|
GetLocaleInfoA(
|
||||||
MAKELCID(((ULONG_PTR)lpList[i] & 0xffffffff), SORT_DEFAULT), LOCALE_SISO639LANGNAME, &code[0],
|
MAKELCID(((ULONG_PTR)lpList[i] & 0xffffffff), SORT_DEFAULT), LOCALE_SISO639LANGNAME, &code[0],
|
||||||
static_cast<int>(code.size())
|
static_cast<int>(code.size())
|
||||||
|
|
@ -193,9 +193,9 @@ std::vector<String> AppUtilWindows::getKeyboardLayoutList()
|
||||||
return layoutLangCodes;
|
return layoutLangCodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
String AppUtilWindows::getCurrentLanguageCode()
|
std::string AppUtilWindows::getCurrentLanguageCode()
|
||||||
{
|
{
|
||||||
String code("", 2);
|
std::string code("", 2);
|
||||||
|
|
||||||
auto hklLayout = getCurrentKeyboardLayout();
|
auto hklLayout = getCurrentKeyboardLayout();
|
||||||
if (hklLayout) {
|
if (hklLayout) {
|
||||||
|
|
@ -243,7 +243,7 @@ public:
|
||||||
};
|
};
|
||||||
#endif
|
#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
|
#if HAVE_WINTOAST
|
||||||
LOG((CLOG_INFO "showing notification, title=\"%s\", text=\"%s\"", title.c_str(), text.c_str()));
|
LOG((CLOG_INFO "showing notification, title=\"%s\", text=\"%s\"", title.c_str(), text.c_str()));
|
||||||
|
|
|
||||||
|
|
@ -48,10 +48,10 @@ public:
|
||||||
void exitApp(int code) override;
|
void exitApp(int code) override;
|
||||||
void beforeAppExit() override;
|
void beforeAppExit() override;
|
||||||
void startNode() override;
|
void startNode() override;
|
||||||
std::vector<String> getKeyboardLayoutList() override;
|
std::vector<std::string> getKeyboardLayoutList() override;
|
||||||
String getCurrentLanguageCode() override;
|
std::string getCurrentLanguageCode() override;
|
||||||
HKL getCurrentKeyboardLayout() const;
|
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:
|
private:
|
||||||
AppExitMode m_exitMode;
|
AppExitMode m_exitMode;
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
// XIOClosed
|
// XIOClosed
|
||||||
//
|
//
|
||||||
|
|
||||||
String XIOClosed::getWhat() const throw()
|
std::string XIOClosed::getWhat() const throw()
|
||||||
{
|
{
|
||||||
return format("XIOClosed", "already closed");
|
return format("XIOClosed", "already closed");
|
||||||
}
|
}
|
||||||
|
|
@ -31,7 +31,7 @@ String XIOClosed::getWhat() const throw()
|
||||||
// XIOEndOfStream
|
// XIOEndOfStream
|
||||||
//
|
//
|
||||||
|
|
||||||
String XIOEndOfStream::getWhat() const throw()
|
std::string XIOEndOfStream::getWhat() const throw()
|
||||||
{
|
{
|
||||||
return format("XIOEndOfStream", "reached end of stream");
|
return format("XIOEndOfStream", "reached end of stream");
|
||||||
}
|
}
|
||||||
|
|
@ -40,7 +40,7 @@ String XIOEndOfStream::getWhat() const throw()
|
||||||
// XIOWouldBlock
|
// XIOWouldBlock
|
||||||
//
|
//
|
||||||
|
|
||||||
String XIOWouldBlock::getWhat() const throw()
|
std::string XIOWouldBlock::getWhat() const throw()
|
||||||
{
|
{
|
||||||
return format("XIOWouldBlock", "stream operation would block");
|
return format("XIOWouldBlock", "stream operation would block");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -130,7 +130,7 @@ void IpcClientProxy::send(const IpcMessage &message)
|
||||||
switch (message.type()) {
|
switch (message.type()) {
|
||||||
case IpcMessageType::LogLine: {
|
case IpcMessageType::LogLine: {
|
||||||
const IpcLogLineMessage &llm = static_cast<const IpcLogLineMessage &>(message);
|
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);
|
ProtocolUtil::writef(&m_stream, kIpcMsgLogLine, &logLine);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -162,7 +162,7 @@ IpcHelloMessage *IpcClientProxy::parseHello()
|
||||||
|
|
||||||
IpcCommandMessage *IpcClientProxy::parseCommand()
|
IpcCommandMessage *IpcClientProxy::parseCommand()
|
||||||
{
|
{
|
||||||
String command;
|
std::string command;
|
||||||
UInt8 elevate;
|
UInt8 elevate;
|
||||||
ProtocolUtil::readf(&m_stream, kIpcMsgCommand + 4, &command, &elevate);
|
ProtocolUtil::readf(&m_stream, kIpcMsgCommand + 4, &command, &elevate);
|
||||||
|
|
||||||
|
|
@ -172,8 +172,8 @@ IpcCommandMessage *IpcClientProxy::parseCommand()
|
||||||
|
|
||||||
IpcSettingMessage *IpcClientProxy::parseSetting() const
|
IpcSettingMessage *IpcClientProxy::parseSetting() const
|
||||||
{
|
{
|
||||||
String name;
|
std::string name;
|
||||||
String value;
|
std::string value;
|
||||||
|
|
||||||
ProtocolUtil::readf(&m_stream, kIpcMsgSetting + 4, &name, &value);
|
ProtocolUtil::readf(&m_stream, kIpcMsgSetting + 4, &name, &value);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -108,7 +108,7 @@ bool IpcLogOutputter::write(ELevel, const char *text)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IpcLogOutputter::appendBuffer(const String &text)
|
void IpcLogOutputter::appendBuffer(const std::string &text)
|
||||||
{
|
{
|
||||||
ArchMutexLock lock(m_bufferMutex);
|
ArchMutexLock lock(m_bufferMutex);
|
||||||
|
|
||||||
|
|
@ -166,7 +166,7 @@ void IpcLogOutputter::notifyBuffer()
|
||||||
ARCH->broadcastCondVar(m_notifyCond);
|
ARCH->broadcastCondVar(m_notifyCond);
|
||||||
}
|
}
|
||||||
|
|
||||||
String IpcLogOutputter::getChunk(size_t count)
|
std::string IpcLogOutputter::getChunk(size_t count)
|
||||||
{
|
{
|
||||||
ArchMutexLock lock(m_bufferMutex);
|
ArchMutexLock lock(m_bufferMutex);
|
||||||
|
|
||||||
|
|
@ -174,7 +174,7 @@ String IpcLogOutputter::getChunk(size_t count)
|
||||||
count = m_buffer.size();
|
count = m_buffer.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
String chunk;
|
std::string chunk;
|
||||||
for (size_t i = 0; i < count; i++) {
|
for (size_t i = 0; i < count; i++) {
|
||||||
chunk.append(m_buffer.front());
|
chunk.append(m_buffer.front());
|
||||||
chunk.append("\n");
|
chunk.append("\n");
|
||||||
|
|
|
||||||
|
|
@ -93,12 +93,12 @@ public:
|
||||||
private:
|
private:
|
||||||
void init();
|
void init();
|
||||||
void bufferThread(void *);
|
void bufferThread(void *);
|
||||||
String getChunk(size_t count);
|
std::string getChunk(size_t count);
|
||||||
void appendBuffer(const String &text);
|
void appendBuffer(const std::string &text);
|
||||||
bool isRunning();
|
bool isRunning();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
using Buffer = std::deque<String>;
|
using Buffer = std::deque<std::string>;
|
||||||
|
|
||||||
IpcServer &m_ipcServer;
|
IpcServer &m_ipcServer;
|
||||||
Buffer m_buffer;
|
Buffer m_buffer;
|
||||||
|
|
|
||||||
|
|
@ -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),
|
: IpcMessage(IpcMessageType::Command),
|
||||||
m_command(command),
|
m_command(command),
|
||||||
m_elevate(elevate)
|
m_elevate(elevate)
|
||||||
|
|
|
||||||
|
|
@ -18,9 +18,10 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "base/Event.h"
|
#include "base/Event.h"
|
||||||
#include "base/String.h"
|
|
||||||
#include "common/ipc.h"
|
#include "common/ipc.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
class IpcMessage : public EventData
|
class IpcMessage : public EventData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -72,27 +73,27 @@ public:
|
||||||
class IpcLogLineMessage : public IpcMessage
|
class IpcLogLineMessage : public IpcMessage
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit IpcLogLineMessage(const String &logLine);
|
explicit IpcLogLineMessage(const std::string &logLine);
|
||||||
~IpcLogLineMessage() override = default;
|
~IpcLogLineMessage() override = default;
|
||||||
|
|
||||||
//! Gets the log line.
|
//! Gets the log line.
|
||||||
String logLine() const
|
std::string logLine() const
|
||||||
{
|
{
|
||||||
return m_logLine;
|
return m_logLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
String m_logLine;
|
std::string m_logLine;
|
||||||
};
|
};
|
||||||
|
|
||||||
class IpcCommandMessage : public IpcMessage
|
class IpcCommandMessage : public IpcMessage
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit IpcCommandMessage(const String &command, bool elevate);
|
explicit IpcCommandMessage(const std::string &command, bool elevate);
|
||||||
~IpcCommandMessage() override = default;
|
~IpcCommandMessage() override = default;
|
||||||
|
|
||||||
//! Gets the command.
|
//! Gets the command.
|
||||||
String command() const
|
std::string command() const
|
||||||
{
|
{
|
||||||
return m_command;
|
return m_command;
|
||||||
}
|
}
|
||||||
|
|
@ -104,6 +105,6 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
String m_command;
|
std::string m_command;
|
||||||
bool m_elevate;
|
bool m_elevate;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ void IpcServerProxy::send(const IpcMessage &message)
|
||||||
|
|
||||||
case IpcMessageType::Command: {
|
case IpcMessageType::Command: {
|
||||||
const IpcCommandMessage &cm = static_cast<const IpcCommandMessage &>(message);
|
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);
|
ProtocolUtil::writef(&m_stream, kIpcMsgCommand, &command);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -99,7 +99,7 @@ void IpcServerProxy::send(const IpcMessage &message)
|
||||||
|
|
||||||
IpcLogLineMessage *IpcServerProxy::parseLogLine()
|
IpcLogLineMessage *IpcServerProxy::parseLogLine()
|
||||||
{
|
{
|
||||||
String logLine;
|
std::string logLine;
|
||||||
ProtocolUtil::readf(&m_stream, kIpcMsgLogLine + 4, &logLine);
|
ProtocolUtil::readf(&m_stream, kIpcMsgLogLine + 4, &logLine);
|
||||||
|
|
||||||
// must be deleted by event handler.
|
// must be deleted by event handler.
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
// XMTThreadUnavailable
|
// XMTThreadUnavailable
|
||||||
//
|
//
|
||||||
|
|
||||||
String XMTThreadUnavailable::getWhat() const throw()
|
std::string XMTThreadUnavailable::getWhat() const throw()
|
||||||
{
|
{
|
||||||
return format("XMTThreadUnavailable", "cannot create thread");
|
return format("XMTThreadUnavailable", "cannot create thread");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "base/EventTypes.h"
|
#include "base/EventTypes.h"
|
||||||
#include "base/String.h"
|
|
||||||
#include "io/IStream.h"
|
#include "io/IStream.h"
|
||||||
#include "net/ISocket.h"
|
#include "net/ISocket.h"
|
||||||
|
|
||||||
|
|
@ -37,7 +36,7 @@ public:
|
||||||
ConnectionFailedInfo(const char *what) : m_what(what)
|
ConnectionFailedInfo(const char *what) : m_what(what)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
String m_what;
|
std::string m_what;
|
||||||
};
|
};
|
||||||
|
|
||||||
IDataSocket(IEventQueue *events)
|
IDataSocket(IEventQueue *events)
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
#include "SecureServerSocket.h"
|
#include "SecureServerSocket.h"
|
||||||
|
|
||||||
#include <arch/XArch.h>
|
#include <arch/XArch.h>
|
||||||
|
#include <base/String.h>
|
||||||
#include <common/constants.h>
|
#include <common/constants.h>
|
||||||
#include <deskflow/ArgParser.h>
|
#include <deskflow/ArgParser.h>
|
||||||
#include <deskflow/ArgsBase.h>
|
#include <deskflow/ArgsBase.h>
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include <base/Log.h>
|
#include <base/Log.h>
|
||||||
#include <base/Path.h>
|
#include <base/Path.h>
|
||||||
|
#include <base/String.h>
|
||||||
#include <openssl/err.h>
|
#include <openssl/err.h>
|
||||||
|
|
||||||
namespace deskflow {
|
namespace deskflow {
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ NetworkAddress::NetworkAddress(const NetworkAddress &addr) : m_hostname(addr.m_h
|
||||||
*this = addr;
|
*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
|
// detect internet protocol version with colom count
|
||||||
auto isColomPredicate = [](char c) { return c == ':'; };
|
auto isColomPredicate = [](char c) { return c == ':'; };
|
||||||
|
|
@ -64,11 +64,11 @@ NetworkAddress::NetworkAddress(const String &hostname, int port) : m_hostname(ho
|
||||||
// ipv6 part
|
// ipv6 part
|
||||||
if (m_hostname[0] == '[') {
|
if (m_hostname[0] == '[') {
|
||||||
// ipv6 with port part
|
// ipv6 with port part
|
||||||
String portDelimeter = "]:";
|
std::string portDelimeter = "]:";
|
||||||
auto hostIt = m_hostname.find(portDelimeter);
|
auto hostIt = m_hostname.find(portDelimeter);
|
||||||
|
|
||||||
// bad syntax of ipv6 with port
|
// bad syntax of ipv6 with port
|
||||||
if (hostIt == String::npos) {
|
if (hostIt == std::string::npos) {
|
||||||
throw XSocketAddress(XSocketAddress::kUnknown, m_hostname, m_port);
|
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
|
// 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);
|
throw XSocketAddress(XSocketAddress::kUnknown, m_hostname, m_port);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -208,7 +208,7 @@ int NetworkAddress::getPort() const
|
||||||
return m_port;
|
return m_port;
|
||||||
}
|
}
|
||||||
|
|
||||||
String NetworkAddress::getHostname() const
|
std::string NetworkAddress::getHostname() const
|
||||||
{
|
{
|
||||||
return m_hostname;
|
return m_hostname;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@
|
||||||
|
|
||||||
#include "arch/IArchNetwork.h"
|
#include "arch/IArchNetwork.h"
|
||||||
#include "base/EventTypes.h"
|
#include "base/EventTypes.h"
|
||||||
#include "base/String.h"
|
|
||||||
|
|
||||||
//! Network address type
|
//! Network address type
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -50,7 +49,7 @@ public:
|
||||||
is thrown with an error of \c XSocketAddress::kBadPort. The hostname
|
is thrown with an error of \c XSocketAddress::kBadPort. The hostname
|
||||||
is not resolved by the c'tor; use \c resolve to do that.
|
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 &);
|
NetworkAddress(const NetworkAddress &);
|
||||||
|
|
||||||
|
|
@ -112,7 +111,7 @@ public:
|
||||||
/*!
|
/*!
|
||||||
Returns the hostname passed to the c'tor sans any port suffix.
|
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:
|
private:
|
||||||
ArchNetAddress m_address = nullptr;
|
ArchNetAddress m_address = nullptr;
|
||||||
String m_hostname;
|
std::string m_hostname;
|
||||||
int m_port = 0;
|
int m_port = 0;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
#include "SecureSocket.h"
|
#include "SecureSocket.h"
|
||||||
#include "arch/XArch.h"
|
#include "arch/XArch.h"
|
||||||
|
#include "base/String.h"
|
||||||
#include "common/constants.h"
|
#include "common/constants.h"
|
||||||
#include "deskflow/ArgParser.h"
|
#include "deskflow/ArgParser.h"
|
||||||
#include "deskflow/ArgsBase.h"
|
#include "deskflow/ArgsBase.h"
|
||||||
|
|
@ -53,7 +54,7 @@ IDataSocket *SecureListenSocket::accept()
|
||||||
}
|
}
|
||||||
|
|
||||||
// default location of the TLS cert file in users dir
|
// 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
|
"%s/%s/%s.%s", ARCH->getProfileDirectory().c_str(), s_certificateDir, kAppId, s_certificateFileExt
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@
|
||||||
#include "arch/XArch.h"
|
#include "arch/XArch.h"
|
||||||
#include "base/Log.h"
|
#include "base/Log.h"
|
||||||
#include "base/Path.h"
|
#include "base/Path.h"
|
||||||
|
#include "base/String.h"
|
||||||
#include "base/TMethodEventJob.h"
|
#include "base/TMethodEventJob.h"
|
||||||
#include "mt/Lock.h"
|
#include "mt/Lock.h"
|
||||||
#include "net/TCPSocket.h"
|
#include "net/TCPSocket.h"
|
||||||
|
|
@ -303,7 +304,7 @@ void SecureSocket::initSsl(bool server)
|
||||||
initContext(server);
|
initContext(server);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SecureSocket::loadCertificates(String &filename)
|
bool SecureSocket::loadCertificates(std::string &filename)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> ssl_lock{ssl_mutex_};
|
std::lock_guard<std::mutex> ssl_lock{ssl_mutex_};
|
||||||
|
|
||||||
|
|
@ -316,7 +317,7 @@ bool SecureSocket::loadCertificates(String &filename)
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
if (!exist) {
|
if (!exist) {
|
||||||
String errorMsg("tls certificate doesn't exist: ");
|
std::string errorMsg("tls certificate doesn't exist: ");
|
||||||
errorMsg.append(filename);
|
errorMsg.append(filename);
|
||||||
SslLogger::logError(errorMsg.c_str());
|
SslLogger::logError(errorMsg.c_str());
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -620,7 +621,7 @@ void SecureSocket::disconnect()
|
||||||
sendEvent(getEvents()->forIStream().inputShutdown());
|
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) {
|
if (hex) {
|
||||||
// to hexidecimal
|
// to hexidecimal
|
||||||
|
|
@ -655,17 +656,17 @@ bool SecureSocket::verifyCertFingerprint()
|
||||||
}
|
}
|
||||||
|
|
||||||
// format fingerprint into hexdecimal format with colon separator
|
// 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);
|
formatFingerprint(fingerprint);
|
||||||
LOG((CLOG_NOTE "server fingerprint: %s", fingerprint.c_str()));
|
LOG((CLOG_NOTE "server fingerprint: %s", fingerprint.c_str()));
|
||||||
|
|
||||||
String trustedServersFilename;
|
std::string trustedServersFilename;
|
||||||
trustedServersFilename = deskflow::string::sprintf(
|
trustedServersFilename = deskflow::string::sprintf(
|
||||||
"%s/%s/%s", ARCH->getProfileDirectory().c_str(), kFingerprintDirName, kFingerprintTrustedServersFilename
|
"%s/%s/%s", ARCH->getProfileDirectory().c_str(), kFingerprintDirName, kFingerprintTrustedServersFilename
|
||||||
);
|
);
|
||||||
|
|
||||||
// check if this fingerprint exist
|
// check if this fingerprint exist
|
||||||
String fileLine;
|
std::string fileLine;
|
||||||
std::ifstream file;
|
std::ifstream file;
|
||||||
file.open(deskflow::filesystem::path(trustedServersFilename));
|
file.open(deskflow::filesystem::path(trustedServersFilename));
|
||||||
|
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue