summaryrefslogtreecommitdiffstats
path: root/src/lib/barrier
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/barrier')
-rw-r--r--src/lib/barrier/App.cpp47
-rw-r--r--src/lib/barrier/App.h24
-rw-r--r--src/lib/barrier/AppUtil.cpp8
-rw-r--r--src/lib/barrier/AppUtil.h8
-rw-r--r--src/lib/barrier/ArgParser.cpp67
-rw-r--r--src/lib/barrier/ArgParser.h20
-rw-r--r--src/lib/barrier/ArgsBase.cpp9
-rw-r--r--src/lib/barrier/ArgsBase.h10
-rw-r--r--src/lib/barrier/BarrierType.h26
-rw-r--r--src/lib/barrier/CMakeLists.txt4
-rw-r--r--src/lib/barrier/Chunk.cpp4
-rw-r--r--src/lib/barrier/Chunk.h6
-rw-r--r--src/lib/barrier/ClientApp.cpp58
-rw-r--r--src/lib/barrier/ClientApp.h7
-rw-r--r--src/lib/barrier/ClientArgs.cpp4
-rw-r--r--src/lib/barrier/ClientArgs.h4
-rw-r--r--src/lib/barrier/ClientTaskBarReceiver.cpp4
-rw-r--r--src/lib/barrier/ClientTaskBarReceiver.h4
-rw-r--r--src/lib/barrier/Clipboard.cpp4
-rw-r--r--src/lib/barrier/Clipboard.h4
-rw-r--r--src/lib/barrier/ClipboardChunk.cpp8
-rw-r--r--src/lib/barrier/ClipboardChunk.h4
-rw-r--r--src/lib/barrier/DragInformation.cpp16
-rw-r--r--src/lib/barrier/DragInformation.h8
-rw-r--r--src/lib/barrier/DropHelper.cpp11
-rw-r--r--src/lib/barrier/DropHelper.h4
-rw-r--r--src/lib/barrier/FileChunk.cpp4
-rw-r--r--src/lib/barrier/FileChunk.h4
-rw-r--r--src/lib/barrier/IApp.h4
-rw-r--r--src/lib/barrier/IAppUtil.h6
-rw-r--r--src/lib/barrier/IClient.h4
-rw-r--r--src/lib/barrier/IClipboard.cpp8
-rw-r--r--src/lib/barrier/IClipboard.h4
-rw-r--r--src/lib/barrier/IKeyState.cpp4
-rw-r--r--src/lib/barrier/IKeyState.h8
-rw-r--r--src/lib/barrier/INode.h6
-rw-r--r--src/lib/barrier/IPlatformScreen.cpp4
-rw-r--r--src/lib/barrier/IPlatformScreen.h7
-rw-r--r--src/lib/barrier/IPrimaryScreen.cpp4
-rw-r--r--src/lib/barrier/IPrimaryScreen.h4
-rw-r--r--src/lib/barrier/IScreen.h6
-rw-r--r--src/lib/barrier/IScreenSaver.h6
-rw-r--r--src/lib/barrier/ISecondaryScreen.h4
-rw-r--r--src/lib/barrier/KeyMap.cpp14
-rw-r--r--src/lib/barrier/KeyMap.h12
-rw-r--r--src/lib/barrier/KeyState.cpp10
-rw-r--r--src/lib/barrier/KeyState.h8
-rw-r--r--src/lib/barrier/PacketStreamFilter.cpp26
-rw-r--r--src/lib/barrier/PacketStreamFilter.h10
-rw-r--r--src/lib/barrier/PlatformScreen.cpp4
-rw-r--r--src/lib/barrier/PlatformScreen.h1
-rw-r--r--src/lib/barrier/PortableTaskBarReceiver.cpp6
-rw-r--r--src/lib/barrier/PortableTaskBarReceiver.h4
-rw-r--r--src/lib/barrier/ProtocolUtil.cpp18
-rw-r--r--src/lib/barrier/ProtocolUtil.h10
-rw-r--r--src/lib/barrier/Screen.cpp12
-rw-r--r--src/lib/barrier/Screen.h14
-rw-r--r--src/lib/barrier/ServerApp.cpp92
-rw-r--r--src/lib/barrier/ServerApp.h8
-rw-r--r--src/lib/barrier/ServerArgs.h1
-rw-r--r--src/lib/barrier/ServerTaskBarReceiver.cpp6
-rw-r--r--src/lib/barrier/ServerTaskBarReceiver.h4
-rw-r--r--src/lib/barrier/StreamChunker.cpp27
-rw-r--r--src/lib/barrier/StreamChunker.h11
-rw-r--r--src/lib/barrier/XBarrier.cpp6
-rw-r--r--src/lib/barrier/XBarrier.h10
-rw-r--r--src/lib/barrier/XScreen.cpp4
-rw-r--r--src/lib/barrier/XScreen.h4
-rw-r--r--src/lib/barrier/clipboard_types.h4
-rw-r--r--src/lib/barrier/key_types.cpp14
-rw-r--r--src/lib/barrier/key_types.h17
-rw-r--r--src/lib/barrier/mouse_types.h4
-rw-r--r--src/lib/barrier/option_types.h4
-rw-r--r--src/lib/barrier/protocol_types.cpp4
-rw-r--r--src/lib/barrier/protocol_types.h16
-rw-r--r--src/lib/barrier/unix/AppUtilUnix.cpp4
-rw-r--r--src/lib/barrier/unix/AppUtilUnix.h6
-rw-r--r--src/lib/barrier/win32/AppUtilWindows.cpp28
-rw-r--r--src/lib/barrier/win32/AppUtilWindows.h6
-rw-r--r--src/lib/barrier/win32/DaemonApp.cpp25
-rw-r--r--src/lib/barrier/win32/DaemonApp.h6
81 files changed, 535 insertions, 385 deletions
diff --git a/src/lib/barrier/App.cpp b/src/lib/barrier/App.cpp
index 8a79aa2..2b3eccc 100644
--- a/src/lib/barrier/App.cpp
+++ b/src/lib/barrier/App.cpp
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -34,7 +34,6 @@
#if SYSAPI_WIN32
#include "base/IEventQueue.h"
-#include "base/TMethodJob.h"
#endif
#include <iostream>
@@ -79,18 +78,18 @@ App::~App()
void
App::version()
{
- std::cout << argsBase().m_exename << " " << kVersion << std::endl;
- std::cout <<"Protocol version " << kProtocolMajorVersion << "." << kProtocolMinorVersion << std::endl;
- std::cout << kCopyright << std::endl;
+ std::cout << argsBase().m_exename << " " << kVersion << "\n";
+ std::cout <<"Protocol version " << kProtocolMajorVersion << "." << kProtocolMinorVersion << "\n";
+ std::cout << kCopyright << "\n";
}
int
App::run(int argc, char** argv)
-{
+{
#if MAC_OS_X_VERSION_10_7
// dock hide only supported on lion :(
ProcessSerialNumber psn = { 0, kCurrentProcess };
-
+
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
GetCurrentProcess(&psn);
@@ -101,7 +100,7 @@ App::run(int argc, char** argv)
// install application in to arch
appUtil().adoptApp(this);
-
+
// HACK: fail by default (saves us setting result in each catch)
int result = kExitFailed;
@@ -110,7 +109,7 @@ App::run(int argc, char** argv)
}
catch (XExitApp& e) {
// instead of showing a nasty error, just exit with the error code.
- // not sure if i like this behaviour, but it's probably better than
+ // not sure if i like this behaviour, but it's probably better than
// using the exit(int) function!
result = e.getCode();
}
@@ -122,7 +121,7 @@ App::run(int argc, char** argv)
}
appUtil().beforeAppExit();
-
+
return result;
}
@@ -137,7 +136,7 @@ App::daemonMainLoop(int, const char**)
return mainLoop();
}
-void
+void
App::setupFileLogging()
{
if (argsBase().m_logFile != NULL) {
@@ -147,24 +146,24 @@ App::setupFileLogging()
}
}
-void
+void
App::loggingFilterWarning()
{
if (CLOG->getFilter() > CLOG->getConsoleMaxLevel()) {
if (argsBase().m_logFile == NULL) {
- LOG((CLOG_WARN "log messages above %s are NOT sent to console (use file logging)",
+ LOG((CLOG_WARN "log messages above %s are NOT sent to console (use file logging)",
CLOG->getFilterName(CLOG->getConsoleMaxLevel())));
}
}
}
-void
+void
App::initApp(int argc, const char** argv)
{
// parse command line
parseArgs(argc, argv);
-
- DataDirectories::profile(argsBase().m_profileDirectory);
+
+ barrier::DataDirectories::profile(argsBase().m_profileDirectory);
// set log filter
if (!CLOG->setFilter(argsBase().m_logFilter)) {
@@ -173,9 +172,12 @@ App::initApp(int argc, const char** argv)
m_bye(kExitArgs);
}
loggingFilterWarning();
-
+
if (argsBase().m_enableDragDrop) {
LOG((CLOG_INFO "drag and drop enabled"));
+ if (!argsBase().m_dropTarget.empty()) {
+ LOG((CLOG_INFO "drop target: %s", argsBase().m_dropTarget.c_str()));
+ }
}
// setup file logging after parsing args
@@ -226,15 +228,14 @@ App::handleIpcMessage(const Event& e, void*)
}
}
-void
-App::runEventsLoop(void*)
+void App::run_events_loop()
{
m_events->loop();
-
+
#if defined(MAC_OS_X_VERSION_10_7)
-
+
stopCocoaLoop();
-
+
#endif
}
diff --git a/src/lib/barrier/App.h b/src/lib/barrier/App.h
index 8040da8..8e17a71 100644
--- a/src/lib/barrier/App.h
+++ b/src/lib/barrier/App.h
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -59,7 +59,7 @@ public:
// Parse command line arguments.
virtual void parseArgs(int argc, const char* const* argv) = 0;
-
+
int run(int argc, char** argv);
int daemonMainLoop(int, const char**);
@@ -90,11 +90,11 @@ public:
ARCH_APP_UTIL& appUtil() { return m_appUtil; }
- virtual IArchTaskBarReceiver* taskBarReceiver() const { return m_taskBarReceiver; }
+ virtual IArchTaskBarReceiver* taskBarReceiver() const { return m_taskBarReceiver; }
virtual void setByeFunc(void(*bye)(int)) { m_bye = bye; }
virtual void bye(int error) { m_bye(error); }
-
+
virtual IEventQueue* getEvents() const { return m_events; }
void setSocketMultiplexer(std::unique_ptr<SocketMultiplexer>&& sm) { m_socketMultiplexer = std::move(sm); }
@@ -108,7 +108,7 @@ private:
protected:
void initIpcClient();
void cleanupIpcClient();
- void runEventsLoop(void*);
+ void run_events_loop();
IArchTaskBarReceiver* m_taskBarReceiver;
bool m_suspended;
@@ -135,7 +135,7 @@ public:
virtual void startNode();
virtual int mainLoop();
virtual int foregroundStartup(int argc, char** argv);
- virtual barrier::Screen*
+ virtual barrier::Screen*
createScreen();
virtual void loadConfig();
virtual bool loadConfig(const String& pathname);
@@ -166,7 +166,10 @@ private:
" -l --log <file> write log messages to file.\n" \
" --no-tray disable the system tray icon.\n" \
" --enable-drag-drop enable file drag & drop.\n" \
- " --enable-crypto enable the crypto (ssl) plugin.\n"
+ " --enable-crypto enable the crypto (ssl) plugin (default, deprecated).\n" \
+ " --disable-crypto disable the crypto (ssl) plugin.\n" \
+ " --profile-dir <path> use named profile directory instead.\n" \
+ " --drop-dir <path> use named drop target directory instead.\n"
#define HELP_COMMON_INFO_2 \
" -h, --help display this help and exit.\n" \
@@ -191,12 +194,11 @@ private:
// windows args
# define HELP_SYS_ARGS \
- " [--service <action>] [--relaunch] [--exit-pause]"
+ " [--exit-pause]"
# define HELP_SYS_INFO \
" --service <action> manage the windows service, valid options are:\n" \
" install/uninstall/start/stop\n" \
- " --relaunch persistently relaunches process in current user \n" \
- " session (useful for vista and upward).\n" \
+ " (obsolete, use barrierd instead)\n" \
" --exit-pause wait for key press on exit, can be useful for\n" \
" reading error messages that occur on exit.\n"
#endif
diff --git a/src/lib/barrier/AppUtil.cpp b/src/lib/barrier/AppUtil.cpp
index 3298d7b..d615648 100644
--- a/src/lib/barrier/AppUtil.cpp
+++ b/src/lib/barrier/AppUtil.cpp
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -15,11 +15,11 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
+
#include "barrier/AppUtil.h"
AppUtil* AppUtil::s_instance = nullptr;
-
+
AppUtil::AppUtil() :
m_app(nullptr)
{
diff --git a/src/lib/barrier/AppUtil.h b/src/lib/barrier/AppUtil.h
index 6f5f073..097c7f2 100644
--- a/src/lib/barrier/AppUtil.h
+++ b/src/lib/barrier/AppUtil.h
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
+
#pragma once
#include "barrier/IAppUtil.h"
@@ -33,7 +33,7 @@ public:
static AppUtil& instance();
static void exitAppStatic(int code) { instance().exitApp(code); }
virtual void beforeAppExit() {}
-
+
private:
IApp* m_app;
static AppUtil* s_instance;
diff --git a/src/lib/barrier/ArgParser.cpp b/src/lib/barrier/ArgParser.cpp
index ec3991c..99cd803 100644
--- a/src/lib/barrier/ArgParser.cpp
+++ b/src/lib/barrier/ArgParser.cpp
@@ -24,7 +24,7 @@
#include "barrier/ArgsBase.h"
#include "base/Log.h"
#include "base/String.h"
-#include "common/PathUtilities.h"
+#include "io/filesystem.h"
#ifdef WINAPI_MSWINDOWS
#include <VersionHelpers.h>
@@ -65,7 +65,9 @@ ArgParser::parseServerArgs(ServerArgs& args, int argc, const char* const* argv)
// save screen change script path
args.m_screenChangeScript = argv[++i];
}
- else {
+ else if (isArg(i, argc, argv, nullptr, "--disable-client-cert-checking")) {
+ args.check_client_certificates = false;
+ } else {
LOG((CLOG_PRINT "%s: unrecognized option `%s'" BYE, args.m_exename.c_str(), argv[i], args.m_exename.c_str()));
return false;
}
@@ -133,10 +135,10 @@ ArgParser::parseClientArgs(ClientArgs& args, int argc, const char* const* argv)
return true;
}
+#if WINAPI_MSWINDOWS
bool
-ArgParser::parsePlatformArg(ArgsBase& argsBase, const int& argc, const char* const* argv, int& i)
+ArgParser::parseMSWindowsArg(ArgsBase& argsBase, const int& argc, const char* const* argv, int& i)
{
-#if WINAPI_MSWINDOWS
if (isArg(i, argc, argv, NULL, "--service")) {
LOG((CLOG_WARN "obsolete argument --service, use barrierd instead."));
argsBase.m_shouldExit = true;
@@ -153,25 +155,46 @@ ArgParser::parsePlatformArg(ArgsBase& argsBase, const int& argc, const char* con
}
return true;
-#elif WINAPI_XWINDOWS
+}
+#endif
+
+#if WINAPI_CARBON
+bool
+ArgParser::parseCarbonArg(ArgsBase& argsBase, const int& argc, const char* const* argv, int& i)
+{
+ // no options for carbon
+ return false;
+}
+#endif
+
+#if WINAPI_XWINDOWS
+bool
+ArgParser::parseXWindowsArg(ArgsBase& argsBase, const int& argc, const char* const* argv, int& i)
+{
if (isArg(i, argc, argv, "-display", "--display", 1)) {
// use alternative display
argsBase.m_display = argv[++i];
}
-
else if (isArg(i, argc, argv, NULL, "--no-xinitthreads")) {
argsBase.m_disableXInitThreads = true;
- }
-
- else {
+ } else {
// option not supported here
return false;
}
return true;
+}
+#endif
+
+bool
+ArgParser::parsePlatformArg(ArgsBase& argsBase, const int& argc, const char* const* argv, int& i)
+{
+#if WINAPI_MSWINDOWS
+ return parseMSWindowsArg(argsBase, argc, argv, i);
#elif WINAPI_CARBON
- // no options for carbon
- return false;
+ return parseCarbonArg(argsBase, argc, argv, i);
+#elif WINAPI_XWINDOWS
+ return parseXWindowsArg(argsBase, argc, argv, i);
#endif
}
@@ -257,14 +280,20 @@ ArgParser::parseGenericArgs(int argc, const char* const* argv, int& i)
argsBase().m_enableDragDrop = true;
}
}
+ else if (isArg(i, argc, argv, NULL, "--drop-dir")) {
+ argsBase().m_dropTarget = argv[++i];
+ }
else if (isArg(i, argc, argv, NULL, "--enable-crypto")) {
- argsBase().m_enableCrypto = true;
+ LOG((CLOG_INFO "--enable-crypto is used by default. The option is deprecated."));
+ }
+ else if (isArg(i, argc, argv, NULL, "--disable-crypto")) {
+ argsBase().m_enableCrypto = false;
}
else if (isArg(i, argc, argv, NULL, "--profile-dir", 1)) {
- argsBase().m_profileDirectory = argv[++i];
+ argsBase().m_profileDirectory = barrier::fs::u8path(argv[++i]);
}
else if (isArg(i, argc, argv, NULL, "--plugin-dir", 1)) {
- argsBase().m_pluginDirectory = argv[++i];
+ argsBase().m_pluginDirectory = barrier::fs::u8path(argv[++i]);
}
else {
// option not supported here
@@ -349,7 +378,7 @@ ArgParser::splitCommandString(String& command, std::vector<String>& argv)
if (space > leftDoubleQuote && space < rightDoubleQuote) {
ignoreThisSpace = true;
}
- else if (space > rightDoubleQuote){
+ else if (space > rightDoubleQuote) {
searchDoubleQuotes(command, leftDoubleQuote, rightDoubleQuote, rightDoubleQuote + 1);
}
@@ -460,7 +489,13 @@ void
ArgParser::updateCommonArgs(const char* const* argv)
{
argsBase().m_name = ARCH->getHostName();
- argsBase().m_exename = PathUtilities::basename(argv[0]);
+ argsBase().m_exename = parse_exename(argv[0]);
+}
+
+std::string ArgParser::parse_exename(const char* arg)
+{
+ // FIXME: we assume UTF-8 encoding, but on Windows this is not correct
+ return barrier::fs::u8path(arg).filename().u8string();
}
bool
diff --git a/src/lib/barrier/ArgParser.h b/src/lib/barrier/ArgParser.h
index 32300c6..472d93a 100644
--- a/src/lib/barrier/ArgParser.h
+++ b/src/lib/barrier/ArgParser.h
@@ -1,11 +1,11 @@
/*
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2014-2016 Symless Ltd.
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
+
#pragma once
#include "base/String.h"
@@ -41,21 +41,27 @@ public:
const char* name1, const char* name2,
int minRequiredParameters = 0);
static void splitCommandString(String& command, std::vector<String>& argv);
- static bool searchDoubleQuotes(String& command, size_t& left,
+ static bool searchDoubleQuotes(String& command, size_t& left,
size_t& right, size_t startPos = 0);
static void removeDoubleQuotes(String& arg);
static const char** getArgv(std::vector<String>& argsArray);
- static String assembleCommand(std::vector<String>& argsArray,
+ static String assembleCommand(std::vector<String>& argsArray,
String ignoreArg = "", int parametersRequired = 0);
+ static std::string parse_exename(const char* arg);
+
private:
void updateCommonArgs(const char* const* argv);
bool checkUnexpectedArgs();
-
+
static ArgsBase& argsBase() { return *m_argsBase; }
+ bool parseMSWindowsArg(ArgsBase& argsBase, const int& argc, const char* const* argv, int& i);
+ bool parseCarbonArg(ArgsBase& argsBase, const int& argc, const char* const* argv, int& i);
+ bool parseXWindowsArg(ArgsBase& argsBase, const int& argc, const char* const* argv, int& i);
+
private:
App* m_app;
-
+
static ArgsBase* m_argsBase;
};
diff --git a/src/lib/barrier/ArgsBase.cpp b/src/lib/barrier/ArgsBase.cpp
index eb63150..e3e3803 100644
--- a/src/lib/barrier/ArgsBase.cpp
+++ b/src/lib/barrier/ArgsBase.cpp
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2012 Nick Bolton
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -39,10 +39,11 @@ m_display(NULL),
m_disableTray(false),
m_enableIpc(false),
m_enableDragDrop(false),
+m_dropTarget(""),
m_shouldExit(false),
m_barrierAddress(),
-m_enableCrypto(false),
-m_profileDirectory(""),
+ m_enableCrypto(true),
+m_profileDirectory(),
m_pluginDirectory("")
{
}
diff --git a/src/lib/barrier/ArgsBase.h b/src/lib/barrier/ArgsBase.h
index 99929b3..cdb5092 100644
--- a/src/lib/barrier/ArgsBase.h
+++ b/src/lib/barrier/ArgsBase.h
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2012 Nick Bolton
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -19,6 +19,7 @@
#pragma once
#include "base/String.h"
+#include "io/filesystem.h"
class ArgsBase {
public:
@@ -38,6 +39,7 @@ public:
bool m_disableTray;
bool m_enableIpc;
bool m_enableDragDrop;
+ String m_dropTarget;
#if SYSAPI_WIN32
bool m_debugServiceWait;
bool m_pauseOnExit;
@@ -49,6 +51,6 @@ public:
bool m_shouldExit;
String m_barrierAddress;
bool m_enableCrypto;
- String m_profileDirectory;
- String m_pluginDirectory;
+ barrier::fs::path m_profileDirectory;
+ barrier::fs::path m_pluginDirectory;
};
diff --git a/src/lib/barrier/BarrierType.h b/src/lib/barrier/BarrierType.h
new file mode 100644
index 0000000..0a18477
--- /dev/null
+++ b/src/lib/barrier/BarrierType.h
@@ -0,0 +1,26 @@
+/*
+ barrier -- mouse and keyboard sharing utility
+ Copyright (C) Barrier contributors
+
+ This package is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ found in the file LICENSE that should have accompanied this file.
+
+ This package is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef BARRIER_LIB_BARRIER_BARRIER_TYPE_H
+#define BARRIER_LIB_BARRIER_BARRIER_TYPE_H
+
+enum class BarrierType {
+ Server,
+ Client
+};
+
+#endif // BARRIER_LIB_BARRIER_BARRIER_TYPE_H
diff --git a/src/lib/barrier/CMakeLists.txt b/src/lib/barrier/CMakeLists.txt
index 6978aef..b60936d 100644
--- a/src/lib/barrier/CMakeLists.txt
+++ b/src/lib/barrier/CMakeLists.txt
@@ -1,11 +1,11 @@
# barrier -- mouse and keyboard sharing utility
# Copyright (C) 2012-2016 Symless Ltd.
# Copyright (C) 2009 Nick Bolton
-#
+#
# This package is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# found in the file LICENSE that should have accompanied this file.
-#
+#
# This package is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
diff --git a/src/lib/barrier/Chunk.cpp b/src/lib/barrier/Chunk.cpp
index f11bff5..fd69cdb 100644
--- a/src/lib/barrier/Chunk.cpp
+++ b/src/lib/barrier/Chunk.cpp
@@ -1,11 +1,11 @@
/*
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2015-2016 Symless Ltd.
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
diff --git a/src/lib/barrier/Chunk.h b/src/lib/barrier/Chunk.h
index 42b85bf..26a343d 100644
--- a/src/lib/barrier/Chunk.h
+++ b/src/lib/barrier/Chunk.h
@@ -1,11 +1,11 @@
/*
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2015-2016 Symless Ltd.
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -17,7 +17,7 @@
#pragma once
-#include "common/basic_types.h"
+#include <cstddef>
class Chunk {
public:
diff --git a/src/lib/barrier/ClientApp.cpp b/src/lib/barrier/ClientApp.cpp
index b1a7661..4b0ef61 100644
--- a/src/lib/barrier/ClientApp.cpp
+++ b/src/lib/barrier/ClientApp.cpp
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -37,10 +37,8 @@
#include "base/TMethodEventJob.h"
#include "base/log_outputters.h"
#include "base/EventQueue.h"
-#include "base/TMethodJob.h"
#include "base/Log.h"
#include "common/Version.h"
-#include "common/PathUtilities.h"
#if WINAPI_MSWINDOWS
#include "platform/MSWindowsScreen.h"
@@ -118,23 +116,23 @@ ClientApp::help()
#endif
std::ostringstream buffer;
- buffer << "Start the barrier client and connect to a remote server component." << std::endl
- << std::endl
+ buffer << "Start the barrier client and connect to a remote server component.\n"
+ << "\n"
<< "Usage: " << args().m_exename << " [--yscroll <delta>]" << WINAPI_ARG << HELP_SYS_ARGS
- << HELP_COMMON_ARGS << " <server-address>" << std::endl
- << std::endl
- << "Options:" << std::endl
+ << HELP_COMMON_ARGS << " <server-address>\n"
+ << "\n"
+ << "Options:\n"
<< HELP_COMMON_INFO_1 << WINAPI_INFO << HELP_SYS_INFO
- << " --yscroll <delta> defines the vertical scrolling delta, which is" << std::endl
- << " 120 by default." << std::endl
+ << " --yscroll <delta> defines the vertical scrolling delta, which is\n"
+ << " 120 by default.\n"
<< HELP_COMMON_INFO_2
- << std::endl
- << "Default options are marked with a *" << std::endl
- << std::endl
- << "The server address is of the form: [<hostname>][:<port>]. The hostname" << std::endl
- << "must be the address or hostname of the server. Placing brackets around" << std::endl
- << "an IPv6 address is required when also specifying a port number and " << std::endl
- << "optional otherwise. The default port number is " << kDefaultPort << "." << std::endl;
+ << "\n"
+ << "Default options are marked with a *\n"
+ << "\n"
+ << "The server address is of the form: [<hostname>][:<port>]. The hostname\n"
+ << "must be the address or hostname of the server. Placing brackets around\n"
+ << "an IPv6 address is required when also specifying a port number and \n"
+ << "optional otherwise. The default port number is " << kDefaultPort << ".\n";
LOG((CLOG_PRINT "%s", buffer.str().c_str()));
}
@@ -235,6 +233,9 @@ barrier::Screen*
ClientApp::openClientScreen()
{
barrier::Screen* screen = createScreen();
+ if (!argsBase().m_dropTarget.empty()) {
+ screen->setDropTarget(argsBase().m_dropTarget);
+ }
screen->setEnableDragDrop(argsBase().m_enableDragDrop);
m_events->adoptHandler(m_events->forIScreen().error(),
screen->getEventTarget(),
@@ -449,7 +450,7 @@ ClientApp::mainLoop()
// start client, etc
appUtil().startNode();
-
+
// init ipc client after node start, since create a new screen wipes out
// the event queue (the screen ctors call adoptBuffer).
if (argsBase().m_enableIpc) {
@@ -460,24 +461,21 @@ ClientApp::mainLoop()
// later. the timer installed by startClient() will take care of
// that.
DAEMON_RUNNING(true);
-
+
#if defined(MAC_OS_X_VERSION_10_7)
-
- Thread thread(
- new TMethodJob<ClientApp>(
- this, &ClientApp::runEventsLoop,
- NULL));
-
+
+ Thread thread([this](){ run_events_loop(); });
+
// wait until carbon loop is ready
OSXScreen* screen = dynamic_cast<OSXScreen*>(
m_clientScreen->getPlatformScreen());
screen->waitForCarbonLoop();
-
+
runCocoaApp();
#else
m_events->loop();
#endif
-
+
DAEMON_RUNNING(false);
// close down
@@ -519,7 +517,7 @@ ClientApp::runInner(int argc, char** argv, ILogOutputter* outputter, StartupFunc
{
// general initialization
m_serverAddress = new NetworkAddress;
- args().m_exename = PathUtilities::basename(argv[0]);
+ argsBase().m_exename = ArgParser::parse_exename(argv[0]);
// install caller's output filter
if (outputter != NULL) {
@@ -548,7 +546,7 @@ ClientApp::runInner(int argc, char** argv, ILogOutputter* outputter, StartupFunc
return result;
}
-void
+void
ClientApp::startNode()
{
// start the client. if this return false then we've failed and
diff --git a/src/lib/barrier/ClientApp.h b/src/lib/barrier/ClientApp.h
index 777f3d3..d1db8d0 100644
--- a/src/lib/barrier/ClientApp.h
+++ b/src/lib/barrier/ClientApp.h
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -24,7 +24,6 @@ namespace barrier { class Screen; }
class Event;
class Client;
class NetworkAddress;
-class Thread;
class ClientArgs;
class ClientApp : public App {
@@ -64,7 +63,7 @@ public:
void handleClientConnected(const Event&, void*);
void handleClientFailed(const Event& e, void*);
void handleClientDisconnected(const Event&, void*);
- Client* openClient(const String& name, const NetworkAddress& address,
+ Client* openClient(const String& name, const NetworkAddress& address,
barrier::Screen* screen);
void closeClient(Client* client);
bool startClient();
diff --git a/src/lib/barrier/ClientArgs.cpp b/src/lib/barrier/ClientArgs.cpp
index 5c9ed88..9d1d37a 100644
--- a/src/lib/barrier/ClientArgs.cpp
+++ b/src/lib/barrier/ClientArgs.cpp
@@ -1,11 +1,11 @@
/*
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2014-2016 Symless Ltd.
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
diff --git a/src/lib/barrier/ClientArgs.h b/src/lib/barrier/ClientArgs.h
index 70285fa..c11fa28 100644
--- a/src/lib/barrier/ClientArgs.h
+++ b/src/lib/barrier/ClientArgs.h
@@ -1,11 +1,11 @@
/*
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2014-2016 Symless Ltd.
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
diff --git a/src/lib/barrier/ClientTaskBarReceiver.cpp b/src/lib/barrier/ClientTaskBarReceiver.cpp
index 2ea6566..ea29f3d 100644
--- a/src/lib/barrier/ClientTaskBarReceiver.cpp
+++ b/src/lib/barrier/ClientTaskBarReceiver.cpp
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2003 Chris Schoeneman
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
diff --git a/src/lib/barrier/ClientTaskBarReceiver.h b/src/lib/barrier/ClientTaskBarReceiver.h
index da15154..b79b958 100644
--- a/src/lib/barrier/ClientTaskBarReceiver.h
+++ b/src/lib/barrier/ClientTaskBarReceiver.h
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2003 Chris Schoeneman
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
diff --git a/src/lib/barrier/Clipboard.cpp b/src/lib/barrier/Clipboard.cpp
index a6a166d..d7ad0b8 100644
--- a/src/lib/barrier/Clipboard.cpp
+++ b/src/lib/barrier/Clipboard.cpp
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
diff --git a/src/lib/barrier/Clipboard.h b/src/lib/barrier/Clipboard.h
index 23bea75..5365a8c 100644
--- a/src/lib/barrier/Clipboard.h
+++ b/src/lib/barrier/Clipboard.h
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
diff --git a/src/lib/barrier/ClipboardChunk.cpp b/src/lib/barrier/ClipboardChunk.cpp
index bc71471..c2ffab0 100644
--- a/src/lib/barrier/ClipboardChunk.cpp
+++ b/src/lib/barrier/ClipboardChunk.cpp
@@ -1,11 +1,11 @@
/*
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2015-2016 Symless Ltd.
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -74,7 +74,7 @@ ClipboardChunk::end(ClipboardID id, UInt32 sequence)
{
ClipboardChunk* end = new ClipboardChunk(CLIPBOARD_CHUNK_META_SIZE);
char* chunk = end->m_chunk;
-
+
chunk[0] = id;
std::memcpy (&chunk[1], &sequence, 4);
chunk[5] = kDataEnd;
@@ -95,7 +95,7 @@ ClipboardChunk::assemble(barrier::IStream* stream,
if (!ProtocolUtil::readf(stream, kMsgDClipboard + 4, &id, &sequence, &mark, &data)) {
return kError;
}
-
+
if (mark == kDataStart) {
s_expectedSize = barrier::string::stringToSizeType(data);
LOG((CLOG_DEBUG "start receiving clipboard data"));
diff --git a/src/lib/barrier/ClipboardChunk.h b/src/lib/barrier/ClipboardChunk.h
index 6402aca..a96877f 100644
--- a/src/lib/barrier/ClipboardChunk.h
+++ b/src/lib/barrier/ClipboardChunk.h
@@ -1,11 +1,11 @@
/*
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2015-2016 Symless Ltd.
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
diff --git a/src/lib/barrier/DragInformation.cpp b/src/lib/barrier/DragInformation.cpp
index db28f3d..5a46678 100644
--- a/src/lib/barrier/DragInformation.cpp
+++ b/src/lib/barrier/DragInformation.cpp
@@ -1,11 +1,11 @@
/*
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2013-2016 Symless Ltd.
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -41,7 +41,7 @@ DragInformation::parseDragInfo(DragFileList& dragFileList, UInt32 fileNum, Strin
if (data.find("/", startPos) != string::npos) {
slash = "/";
}
-
+
UInt32 index = 0;
while (index < fileNum) {
findResult1 = data.find(',', startPos);
@@ -51,7 +51,7 @@ DragInformation::parseDragInfo(DragFileList& dragFileList, UInt32 fileNum, Strin
//TODO: file number does not match, something goes wrong
break;
}
-
+
// set filename
if (findResult1 - findResult2 > 1) {
String filename = data.substr(findResult2 + 1,
@@ -61,7 +61,7 @@ DragInformation::parseDragInfo(DragFileList& dragFileList, UInt32 fileNum, Strin
dragFileList.push_back(di);
}
startPos = findResult1 + 1;
-
+
//set filesize
findResult2 = data.find(',', startPos);
if (findResult2 - findResult1 > 1) {
@@ -71,7 +71,7 @@ DragInformation::parseDragInfo(DragFileList& dragFileList, UInt32 fileNum, Strin
dragFileList.at(index).setFilesize(size);
}
startPos = findResult1 + 1;
-
+
++index;
}
@@ -151,8 +151,8 @@ DragInformation::getFileSize(String& filename)
stringstream ss;
ss << size;
-
+
file. close();
-
+
return ss.str();
}
diff --git a/src/lib/barrier/DragInformation.h b/src/lib/barrier/DragInformation.h
index b985bd1..a5d76b0 100644
--- a/src/lib/barrier/DragInformation.h
+++ b/src/lib/barrier/DragInformation.h
@@ -1,11 +1,11 @@
/*
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2013-2016 Symless Ltd.
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -28,12 +28,12 @@ class DragInformation {
public:
DragInformation();
~DragInformation() { }
-
+
String& getFilename() { return m_filename; }
void setFilename(String& name) { m_filename = name; }
size_t getFilesize() { return m_filesize; }
void setFilesize(size_t size) { m_filesize = size; }
-
+
static void parseDragInfo(DragFileList& dragFileList, UInt32 fileNum, String data);
static String getDragFileExtension(String filename);
// helper function to setup drag info
diff --git a/src/lib/barrier/DropHelper.cpp b/src/lib/barrier/DropHelper.cpp
index ee5e5ee..af22b52 100644
--- a/src/lib/barrier/DropHelper.cpp
+++ b/src/lib/barrier/DropHelper.cpp
@@ -1,11 +1,11 @@
/*
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2014-2016 Symless Ltd.
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -18,6 +18,7 @@
#include "barrier/DropHelper.h"
#include "base/Log.h"
+#include "io/filesystem.h"
#include <fstream>
@@ -35,15 +36,15 @@ DropHelper::writeToDir(const String& destination, DragFileList& fileList, String
dropTarget.append("/");
#endif
dropTarget.append(fileList.at(0).getFilename());
- file.open(dropTarget.c_str(), std::ios::out | std::ios::binary);
+ barrier::open_utf8_path(file, dropTarget, std::ios::out | std::ios::binary);
if (!file.is_open()) {
LOG((CLOG_ERR "drop file failed: can not open %s", dropTarget.c_str()));
}
-
+
file.write(data.c_str(), data.size());
file.close();
- LOG((CLOG_DEBUG "%s is saved to %s", fileList.at(0).getFilename().c_str(), destination.c_str()));
+ LOG((CLOG_INFO "dropped file \"%s\" in \"%s\"", fileList.at(0).getFilename().c_str(), destination.c_str()));
fileList.clear();
}
diff --git a/src/lib/barrier/DropHelper.h b/src/lib/barrier/DropHelper.h
index 67facbb..801779c 100644
--- a/src/lib/barrier/DropHelper.h
+++ b/src/lib/barrier/DropHelper.h
@@ -1,11 +1,11 @@
/*
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2014-2016 Symless Ltd.
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
diff --git a/src/lib/barrier/FileChunk.cpp b/src/lib/barrier/FileChunk.cpp
index 3a98568..08c489b 100644
--- a/src/lib/barrier/FileChunk.cpp
+++ b/src/lib/barrier/FileChunk.cpp
@@ -1,11 +1,11 @@
/*
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2015-2016 Symless Ltd.
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
diff --git a/src/lib/barrier/FileChunk.h b/src/lib/barrier/FileChunk.h
index bdc2f64..bdb5006 100644
--- a/src/lib/barrier/FileChunk.h
+++ b/src/lib/barrier/FileChunk.h
@@ -1,11 +1,11 @@
/*
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2015-2016 Symless Ltd.
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
diff --git a/src/lib/barrier/IApp.h b/src/lib/barrier/IApp.h
index 3a8cd56..0c516b9 100644
--- a/src/lib/barrier/IApp.h
+++ b/src/lib/barrier/IApp.h
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2012 Nick Bolton
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
diff --git a/src/lib/barrier/IAppUtil.h b/src/lib/barrier/IAppUtil.h
index 39df65d..521bfce 100644
--- a/src/lib/barrier/IAppUtil.h
+++ b/src/lib/barrier/IAppUtil.h
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
+
#pragma once
#include "common/IInterface.h"
diff --git a/src/lib/barrier/IClient.h b/src/lib/barrier/IClient.h
index d9b2194..e1382b7 100644
--- a/src/lib/barrier/IClient.h
+++ b/src/lib/barrier/IClient.h
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
diff --git a/src/lib/barrier/IClipboard.cpp b/src/lib/barrier/IClipboard.cpp
index 19b4b56..d484121 100644
--- a/src/lib/barrier/IClipboard.cpp
+++ b/src/lib/barrier/IClipboard.cpp
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2004 Chris Schoeneman
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -66,13 +66,13 @@ IClipboard::unmarshall(IClipboard* clipboard, const String& data, Time time)
String
IClipboard::marshall(const IClipboard* clipboard)
{
- // return data format:
+ // return data format:
// 4 bytes => number of formats included
// 4 bytes => format enum
// 4 bytes => clipboard data size n
// n bytes => clipboard data
// back to the second 4 bytes if there is another format
-
+
assert(clipboard != NULL);
String data;
diff --git a/src/lib/barrier/IClipboard.h b/src/lib/barrier/IClipboard.h
index e11b264..436b21b 100644
--- a/src/lib/barrier/IClipboard.h
+++ b/src/lib/barrier/IClipboard.h
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
diff --git a/src/lib/barrier/IKeyState.cpp b/src/lib/barrier/IKeyState.cpp
index 5d1114c..e89c0e9 100644
--- a/src/lib/barrier/IKeyState.cpp
+++ b/src/lib/barrier/IKeyState.cpp
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2004 Chris Schoeneman
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
diff --git a/src/lib/barrier/IKeyState.h b/src/lib/barrier/IKeyState.h
index b9d4706..e7f88fa 100644
--- a/src/lib/barrier/IKeyState.h
+++ b/src/lib/barrier/IKeyState.h
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2003 Chris Schoeneman
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -122,14 +122,14 @@ public:
complete and false if normal key processing should continue.
*/
virtual bool fakeCtrlAltDel() = 0;
-
+
//! Fake a media key
/*!
Synthesizes a media key down and up. Only Mac would implement this by
use cocoa appkit framework.
*/
virtual bool fakeMediaKey(KeyID id) = 0;
-
+
//@}
//! @name accessors
//@{
diff --git a/src/lib/barrier/INode.h b/src/lib/barrier/INode.h
index 2e78f7c..02fd9de 100644
--- a/src/lib/barrier/INode.h
+++ b/src/lib/barrier/INode.h
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -21,5 +21,5 @@
#include "common/IInterface.h"
class INode : IInterface {
-
+
};
diff --git a/src/lib/barrier/IPlatformScreen.cpp b/src/lib/barrier/IPlatformScreen.cpp
index d1d9f78..a037f75 100644
--- a/src/lib/barrier/IPlatformScreen.cpp
+++ b/src/lib/barrier/IPlatformScreen.cpp
@@ -1,11 +1,11 @@
/*
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2016 Symless.
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file COPYING that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
diff --git a/src/lib/barrier/IPlatformScreen.h b/src/lib/barrier/IPlatformScreen.h
index 440e218..995ff73 100644
--- a/src/lib/barrier/IPlatformScreen.h
+++ b/src/lib/barrier/IPlatformScreen.h
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -197,7 +197,8 @@ public:
virtual void fakeDraggingFiles(DragFileList fileList) = 0;
virtual const String&
getDropTarget() const = 0;
-
+ virtual void setDropTarget(const String&) = 0;
+
protected:
//! Handle system event
/*!
diff --git a/src/lib/barrier/IPrimaryScreen.cpp b/src/lib/barrier/IPrimaryScreen.cpp
index 4954e4f..2220212 100644
--- a/src/lib/barrier/IPrimaryScreen.cpp
+++ b/src/lib/barrier/IPrimaryScreen.cpp
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2004 Chris Schoeneman
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
diff --git a/src/lib/barrier/IPrimaryScreen.h b/src/lib/barrier/IPrimaryScreen.h
index 7f3fa9c..0cf3688 100644
--- a/src/lib/barrier/IPrimaryScreen.h
+++ b/src/lib/barrier/IPrimaryScreen.h
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2003 Chris Schoeneman
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
diff --git a/src/lib/barrier/IScreen.h b/src/lib/barrier/IScreen.h
index 47d6578..a1e7c47 100644
--- a/src/lib/barrier/IScreen.h
+++ b/src/lib/barrier/IScreen.h
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2003 Chris Schoeneman
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -66,6 +66,6 @@ public:
Return the current position of the cursor in \c x and \c y.
*/
virtual void getCursorPos(SInt32& x, SInt32& y) const = 0;
-
+
//@}
};
diff --git a/src/lib/barrier/IScreenSaver.h b/src/lib/barrier/IScreenSaver.h
index fc21ac5..2099f6d 100644
--- a/src/lib/barrier/IScreenSaver.h
+++ b/src/lib/barrier/IScreenSaver.h
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -56,7 +56,7 @@ public:
//! Deactivate screen saver
/*!
- Deactivate (i.e. hide) the screen saver, reseting the screen saver
+ Deactivate (i.e. hide) the screen saver, resetting the screen saver
timer.
*/
virtual void deactivate() = 0;
diff --git a/src/lib/barrier/ISecondaryScreen.h b/src/lib/barrier/ISecondaryScreen.h
index 527ca2e..85da511 100644
--- a/src/lib/barrier/ISecondaryScreen.h
+++ b/src/lib/barrier/ISecondaryScreen.h
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2003 Chris Schoeneman
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
diff --git a/src/lib/barrier/KeyMap.cpp b/src/lib/barrier/KeyMap.cpp
index 621e747..7d53deb 100644
--- a/src/lib/barrier/KeyMap.cpp
+++ b/src/lib/barrier/KeyMap.cpp
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2005 Chris Schoeneman
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -733,7 +733,7 @@ KeyMap::keyForModifier(KeyButton button, SInt32 group,
assert(modifierBit >= 0 && modifierBit < kKeyModifierNumBits);
assert(group >= 0 && group < getNumGroups());
- // find a key that generates the given modifier in the given group
+ // find a key that generates the given modifier in the given group
// but doesn't use the given button, presumably because we're trying
// to generate a KeyID that's only bound the the given button.
// this is important when a shift button is modified by shift; we
@@ -989,7 +989,7 @@ KeyMap::addKeystrokes(EKeystroke type, const KeyItem& keyItem,
}
}
break;
-
+
case kKeystrokeRelease:
keystrokes.push_back(Keystroke(button, false, false, data));
if (keyItem.m_generates != 0 && !keyItem.m_lock) {
@@ -1011,19 +1011,19 @@ KeyMap::addKeystrokes(EKeystroke type, const KeyItem& keyItem,
}
}
break;
-
+
case kKeystrokeRepeat:
keystrokes.push_back(Keystroke(button, false, true, data));
keystrokes.push_back(Keystroke(button, true, true, data));
// no modifier changes on key repeat
break;
-
+
case kKeystrokeClick:
keystrokes.push_back(Keystroke(button, true, false, data));
keystrokes.push_back(Keystroke(button, false, false, data));
// no modifier changes on key click
break;
-
+
case kKeystrokeModify:
case kKeystrokeUnmodify:
if (keyItem.m_lock) {
diff --git a/src/lib/barrier/KeyMap.h b/src/lib/barrier/KeyMap.h
index b6eb865..bc72020 100644
--- a/src/lib/barrier/KeyMap.h
+++ b/src/lib/barrier/KeyMap.h
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2005 Chris Schoeneman
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -24,7 +24,9 @@
#include "common/stdset.h"
#include "common/stdvector.h"
+#ifdef BARRIER_TEST_ENV
#include <gtest/gtest_prod.h>
+#endif
namespace barrier {
@@ -320,13 +322,14 @@ public:
Converts a string into a modifier mask. Returns \c true on success
and \c false if the string cannot be parsed. The modifiers plus any
remaining leading and trailing whitespace is stripped from the input
- string.
+ string.
*/
static bool parseModifiers(String&, KeyModifierMask&);
//@}
private:
+#ifdef BARRIER_TEST_ENV
FRIEND_TEST(KeyMapTests,
findBestKey_requiredDown_matchExactFirstItem);
FRIEND_TEST(KeyMapTests,
@@ -340,6 +343,7 @@ private:
FRIEND_TEST(KeyMapTests,
findBestKey_onlyOneRequiredDown_matchTwoRequiredChangesItem);
FRIEND_TEST(KeyMapTests, findBestKey_noRequiredDown_cannotMatch);
+#endif
private:
//! Ways to synthesize a key
@@ -351,7 +355,7 @@ private:
kKeystrokeModify, //!< Synthesize pressing a modifier
kKeystrokeUnmodify //!< Synthesize releasing a modifier
};
-
+
// A list of ways to synthesize a KeyID
typedef std::vector<KeyItemList> KeyEntryList;
diff --git a/src/lib/barrier/KeyState.cpp b/src/lib/barrier/KeyState.cpp
index fc5579d..4c04277 100644
--- a/src/lib/barrier/KeyState.cpp
+++ b/src/lib/barrier/KeyState.cpp
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2004 Chris Schoeneman
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -529,7 +529,7 @@ KeyState::addActiveModifierCB(KeyID, SInt32 group,
(keyItem.m_generates & context->m_mask) != 0) {
context->m_activeModifiers.insert(std::make_pair(
keyItem.m_generates, keyItem));
- }
+ }
}
void
@@ -581,10 +581,10 @@ KeyState::fakeKeyDown(KeyID id, KeyModifierMask mask, KeyButton serverID)
LOG((CLOG_DEBUG1 "emulating media key"));
fakeMediaKey(id);
}
-
+
return;
}
-
+
KeyButton localID = (KeyButton)(keyItem->m_button & kButtonMask);
updateModifierKeyState(localID, oldActiveModifiers, m_activeModifiers);
if (localID != 0) {
diff --git a/src/lib/barrier/KeyState.h b/src/lib/barrier/KeyState.h
index 737d515..6f32b5d 100644
--- a/src/lib/barrier/KeyState.h
+++ b/src/lib/barrier/KeyState.h
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2004 Chris Schoeneman
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -74,7 +74,7 @@ public:
virtual void fakeAllKeysUp();
virtual bool fakeCtrlAltDel() = 0;
virtual bool fakeMediaKey(KeyID id);
-
+
virtual bool isKeyDown(KeyButton) const;
virtual KeyModifierMask
getActiveModifiers() const;
@@ -157,7 +157,7 @@ public:
AddActiveModifierContext& operator=(const AddActiveModifierContext&);
};
private:
-
+
class ButtonToKeyLess {
public:
bool operator()(const barrier::KeyMap::ButtonToKeyMap::value_type& a,
diff --git a/src/lib/barrier/PacketStreamFilter.cpp b/src/lib/barrier/PacketStreamFilter.cpp
index 16f0fe7..5955b6c 100644
--- a/src/lib/barrier/PacketStreamFilter.cpp
+++ b/src/lib/barrier/PacketStreamFilter.cpp
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2004 Chris Schoeneman
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -17,6 +17,7 @@
*/
#include "barrier/PacketStreamFilter.h"
+#include "barrier/protocol_types.h"
#include "base/IEventQueue.h"
#include "mt/Lock.h"
#include "base/TMethodEventJob.h"
@@ -133,8 +134,7 @@ PacketStreamFilter::isReadyNoLock() const
return (m_size != 0 && m_buffer.getSize() >= m_size);
}
-void
-PacketStreamFilter::readPacketSize()
+bool PacketStreamFilter::readPacketSize()
{
// note -- m_mutex must be locked on entry
@@ -146,7 +146,13 @@ PacketStreamFilter::readPacketSize()
((UInt32)buffer[1] << 16) |
((UInt32)buffer[2] << 8) |
(UInt32)buffer[3];
+
+ if (m_size > PROTOCOL_MAX_MESSAGE_LENGTH) {
+ m_events->addEvent(Event(m_events->forIStream().inputFormatError(), getEventTarget()));
+ return false;
+ }
}
+ return true;
}
bool
@@ -160,13 +166,17 @@ PacketStreamFilter::readMore()
UInt32 n = getStream()->read(buffer, sizeof(buffer));
while (n > 0) {
m_buffer.write(buffer, n);
+
+ // if we don't yet have the next packet size then get it, if possible.
+ // Note that we can't wait for whole pending data to arrive because it may be huge in
+ // case of malicious or erroneous peer.
+ if (!readPacketSize()) {
+ break;
+ }
+
n = getStream()->read(buffer, sizeof(buffer));
}
- // if we don't yet have the next packet size then get it,
- // if possible.
- readPacketSize();
-
// note if we now have a whole packet
bool isReady = isReadyNoLock();
diff --git a/src/lib/barrier/PacketStreamFilter.h b/src/lib/barrier/PacketStreamFilter.h
index bcbd604..0c4bb04 100644
--- a/src/lib/barrier/PacketStreamFilter.h
+++ b/src/lib/barrier/PacketStreamFilter.h
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2004 Chris Schoeneman
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -24,7 +24,7 @@
class IEventQueue;
-//! Packetizing stream filter
+//! Packetizing stream filter
/*!
Filters a stream to read and write packets.
*/
@@ -47,7 +47,9 @@ protected:
private:
bool isReadyNoLock() const;
- void readPacketSize();
+
+ // returns false on erroneous packet size
+ bool readPacketSize();
bool readMore();
private:
diff --git a/src/lib/barrier/PlatformScreen.cpp b/src/lib/barrier/PlatformScreen.cpp
index b0fdc75..d72e69a 100644
--- a/src/lib/barrier/PlatformScreen.cpp
+++ b/src/lib/barrier/PlatformScreen.cpp
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2004 Chris Schoeneman
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
diff --git a/src/lib/barrier/PlatformScreen.h b/src/lib/barrier/PlatformScreen.h
index 38bf8de..19a3da1 100644
--- a/src/lib/barrier/PlatformScreen.h
+++ b/src/lib/barrier/PlatformScreen.h
@@ -101,6 +101,7 @@ public:
virtual void fakeDraggingFiles(DragFileList fileList) { throw std::runtime_error("fakeDraggingFiles not implemented"); }
virtual const String&
getDropTarget() const { throw std::runtime_error("getDropTarget not implemented"); }
+ virtual void setDropTarget(const String&) { throw std::runtime_error("setDropTarget not implemented"); }
protected:
//! Update mouse buttons
diff --git a/src/lib/barrier/PortableTaskBarReceiver.cpp b/src/lib/barrier/PortableTaskBarReceiver.cpp
index 384cacd..e9a5f40 100644
--- a/src/lib/barrier/PortableTaskBarReceiver.cpp
+++ b/src/lib/barrier/PortableTaskBarReceiver.cpp
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2003 Chris Schoeneman
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -111,7 +111,7 @@ PortableTaskBarReceiver::getToolTip() const
case kNotWorking:
return barrier::string::sprintf("%s: %s",
kAppVersion, m_errorMessage.c_str());
-
+
case kNotConnected:
return barrier::string::sprintf("%s: Unknown", kAppVersion);
diff --git a/src/lib/barrier/PortableTaskBarReceiver.h b/src/lib/barrier/PortableTaskBarReceiver.h
index d335e44..3db27ba 100644
--- a/src/lib/barrier/PortableTaskBarReceiver.h
+++ b/src/lib/barrier/PortableTaskBarReceiver.h
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2003 Chris Schoeneman
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
diff --git a/src/lib/barrier/ProtocolUtil.cpp b/src/lib/barrier/ProtocolUtil.cpp
index e742687..5a71010 100644
--- a/src/lib/barrier/ProtocolUtil.cpp
+++ b/src/lib/barrier/ProtocolUtil.cpp
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -19,6 +19,8 @@
#include "barrier/ProtocolUtil.h"
#include "io/IStream.h"
#include "base/Log.h"
+#include "barrier/protocol_types.h"
+#include "barrier/XBarrier.h"
#include "common/stdvector.h"
#include "base/String.h"
@@ -80,7 +82,7 @@ ProtocolUtil::vwritef(barrier::IStream* stream,
// fill buffer
UInt8* buffer = new UInt8[size];
- writef(buffer, fmt, args);
+ writef_void(buffer, fmt, args);
try {
// write buffer
@@ -159,6 +161,10 @@ ProtocolUtil::vreadf(barrier::IStream* stream, const char* fmt, va_list args)
(static_cast<UInt32>(buffer[2]) << 8) |
static_cast<UInt32>(buffer[3]);
+ if (n > PROTOCOL_MAX_LIST_LENGTH) {
+ throw XBadClient("Too long message received");
+ }
+
// convert it
void* v = va_arg(args, void*);
switch (len) {
@@ -211,6 +217,10 @@ ProtocolUtil::vreadf(barrier::IStream* stream, const char* fmt, va_list args)
(static_cast<UInt32>(buffer[2]) << 8) |
static_cast<UInt32>(buffer[3]);
+ if (len > PROTOCOL_MAX_STRING_LENGTH) {
+ throw XBadClient("Too long message received");
+ }
+
// use a fixed size buffer if its big enough
const bool useFixed = (len <= sizeof(buffer));
@@ -339,7 +349,7 @@ ProtocolUtil::getLength(const char* fmt, va_list args)
}
void
-ProtocolUtil::writef(void* buffer, const char* fmt, va_list args)
+ProtocolUtil::writef_void(void* buffer, const char* fmt, va_list args)
{
UInt8* dst = static_cast<UInt8*>(buffer);
diff --git a/src/lib/barrier/ProtocolUtil.h b/src/lib/barrier/ProtocolUtil.h
index 9930cfc..af4fea8 100644
--- a/src/lib/barrier/ProtocolUtil.h
+++ b/src/lib/barrier/ProtocolUtil.h
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -38,7 +38,7 @@ public:
regular characters and format specifiers. Format specifiers
begin with \%. All characters not part of a format specifier
are regular and are transmitted unchanged.
-
+
Format specifiers are:
- \%\% -- literal `\%'
- \%1i -- converts integer argument to 1 byte integer
@@ -58,7 +58,7 @@ public:
Read formatted binary data from a buffer. This performs the
reverse operation of writef(). Returns true if the entire
format was successfully parsed, false otherwise.
-
+
Format specifiers are:
- \%\% -- read (and discard) a literal `\%'
- \%1i -- reads a 1 byte integer; argument is a SInt32* or UInt32*
@@ -79,7 +79,7 @@ private:
const char* fmt, va_list);
static UInt32 getLength(const char* fmt, va_list);
- static void writef(void*, const char* fmt, va_list);
+ static void writef_void(void*, const char* fmt, va_list);
static UInt32 eatLength(const char** fmt);
static void read(barrier::IStream*, void*, UInt32);
};
diff --git a/src/lib/barrier/Screen.cpp b/src/lib/barrier/Screen.cpp
index 32442f6..2a2c877 100644
--- a/src/lib/barrier/Screen.cpp
+++ b/src/lib/barrier/Screen.cpp
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2003 Chris Schoeneman
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -376,7 +376,7 @@ Screen::isLockedToScreen() const
if (buttonID != kButtonLeft) {
LOG((CLOG_DEBUG "locked by mouse buttonID: %d", buttonID));
}
-
+
if (m_enableDragDrop) {
return (buttonID == kButtonLeft) ? false : true;
}
@@ -466,6 +466,12 @@ Screen::getDropTarget() const
return m_screen->getDropTarget();
}
+void
+Screen::setDropTarget(const String& target)
+{
+ return m_screen->setDropTarget(target);
+}
+
void*
Screen::getEventTarget() const
{
diff --git a/src/lib/barrier/Screen.h b/src/lib/barrier/Screen.h
index b16feff..1c8e7de 100644
--- a/src/lib/barrier/Screen.h
+++ b/src/lib/barrier/Screen.h
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -42,7 +42,7 @@ public:
Screen(IPlatformScreen* platformScreen, IEventQueue* events);
virtual ~Screen();
-#ifdef TEST_ENV
+#ifdef BARRIER_TEST_ENV
Screen() : m_mock(true) { }
#endif
@@ -223,7 +223,7 @@ public:
//! Change dragging status
void setDraggingStarted(bool started);
-
+
//! Fake a files dragging operation
void startDraggingFiles(DragFileList& fileList);
@@ -278,7 +278,7 @@ public:
//! Test if file is dragged on primary screen
bool isDraggingStarted() const;
-
+
//! Test if file is dragged on secondary screen
bool isFakeDraggingStarted() const;
@@ -290,6 +290,8 @@ public:
//! Get the drop target directory
const String& getDropTarget() const;
+ //! Set the drop target directory
+ void setDropTarget(const String&);
//@}
@@ -299,7 +301,7 @@ public:
virtual void getShape(SInt32& x, SInt32& y,
SInt32& width, SInt32& height) const;
virtual void getCursorPos(SInt32& x, SInt32& y) const;
-
+
IPlatformScreen* getPlatformScreen() { return m_screen; }
protected:
diff --git a/src/lib/barrier/ServerApp.cpp b/src/lib/barrier/ServerApp.cpp
index 18cf935..71158ce 100644
--- a/src/lib/barrier/ServerApp.cpp
+++ b/src/lib/barrier/ServerApp.cpp
@@ -34,13 +34,11 @@
#include "base/EventQueue.h"
#include "base/log_outputters.h"
#include "base/FunctionEventJob.h"
-#include "base/TMethodJob.h"
#include "base/IEventQueue.h"
#include "base/Log.h"
#include "base/TMethodEventJob.h"
#include "common/Version.h"
#include "common/DataDirectories.h"
-#include "common/PathUtilities.h"
#if SYSAPI_WIN32
#include "arch/win32/ArchMiscWindows.h"
@@ -128,30 +126,43 @@ ServerApp::help()
# define WINAPI_INFO ""
#endif
+ // refer to custom profile directory even if not saved yet
+ barrier::fs::path profile_path = argsBase().m_profileDirectory;
+ if (profile_path.empty()) {
+ profile_path = barrier::DataDirectories::profile();
+ }
+
+ auto usr_config_path = (profile_path / barrier::fs::u8path(USR_CONFIG_NAME)).u8string();
+ auto sys_config_path = (barrier::DataDirectories::systemconfig() /
+ barrier::fs::u8path(SYS_CONFIG_NAME)).u8string();
+
std::ostringstream buffer;
- buffer << "Start the barrier server component." << std::endl
- << std::endl
+ buffer << "Start the barrier server component.\n"
+ << "\n"
<< "Usage: " << args().m_exename
<< " [--address <address>]"
<< " [--config <pathname>]"
- << WINAPI_ARGS << HELP_SYS_ARGS << HELP_COMMON_ARGS << std::endl
- << std::endl
- << "Options:" << std::endl
- << " -a, --address <address> listen for clients on the given address." << std::endl
- << " -c, --config <pathname> use the named configuration file instead." << std::endl
- << HELP_COMMON_INFO_1 << WINAPI_INFO << HELP_SYS_INFO << HELP_COMMON_INFO_2 << std::endl
- << "Default options are marked with a *" << std::endl
- << std::endl
- << "The argument for --address is of the form: [<hostname>][:<port>]. The" << std::endl
- << "hostname must be the address or hostname of an interface on the system." << std::endl
- << "Placing brackets around an IPv6 address is required when also specifying " << std::endl
- << "a port number and optional otherwise. The default is to listen on all" << std::endl
- << "interfaces using port number " << kDefaultPort << "." << std::endl
- << std::endl
- << "If no configuration file pathname is provided then the first of the" << std::endl
- << "following to load successfully sets the configuration:" << std::endl
- << " " << PathUtilities::concat(DataDirectories::profile(), USR_CONFIG_NAME) << std::endl
- << " " << PathUtilities::concat(DataDirectories::systemconfig(), SYS_CONFIG_NAME) << std::endl;
+ << WINAPI_ARGS << HELP_SYS_ARGS << HELP_COMMON_ARGS << "\n"
+ << "\n"
+ << "Options:\n"
+ << " -a, --address <address> listen for clients on the given address.\n"
+ << " -c, --config <pathname> use the named configuration file instead.\n"
+ << HELP_COMMON_INFO_1
+ << " --disable-client-cert-checking disable client SSL certificate \n"
+ " checking (deprecated)\n"
+ << WINAPI_INFO << HELP_SYS_INFO << HELP_COMMON_INFO_2 << "\n"
+ << "Default options are marked with a *\n"
+ << "\n"
+ << "The argument for --address is of the form: [<hostname>][:<port>]. The\n"
+ << "hostname must be the address or hostname of an interface on the system.\n"
+ << "Placing brackets around an IPv6 address is required when also specifying \n"
+ << "a port number and optional otherwise. The default is to listen on all\n"
+ << "interfaces using port number " << kDefaultPort << ".\n"
+ << "\n"
+ << "If no configuration file pathname is provided then the first of the\n"
+ << "following to load successfully sets the configuration:\n"
+ << " " << usr_config_path << "\n"
+ << " " << sys_config_path << "\n";
LOG((CLOG_PRINT "%s", buffer.str().c_str()));
}
@@ -188,25 +199,25 @@ ServerApp::loadConfig()
// load the default configuration if no explicit file given
else {
- String path = DataDirectories::profile();
+ auto path = barrier::DataDirectories::profile();
if (!path.empty()) {
// complete path
- path = PathUtilities::concat(path, USR_CONFIG_NAME);
+ path /= barrier::fs::u8path(USR_CONFIG_NAME);
// now try loading the user's configuration
- if (loadConfig(path)) {
+ if (loadConfig(path.u8string())) {
loaded = true;
- args().m_configFile = path;
+ args().m_configFile = path.u8string();
}
}
if (!loaded) {
// try the system-wide config file
- path = DataDirectories::systemconfig();
+ path = barrier::DataDirectories::systemconfig();
if (!path.empty()) {
- path = PathUtilities::concat(path, SYS_CONFIG_NAME);
- if (loadConfig(path)) {
+ path /= barrier::fs::u8path(SYS_CONFIG_NAME);
+ if (loadConfig(path.u8string())) {
loaded = true;
- args().m_configFile = path;
+ args().m_configFile = path.u8string();
}
}
}
@@ -496,6 +507,9 @@ barrier::Screen*
ServerApp::openServerScreen()
{
barrier::Screen* screen = createScreen();
+ if (!argsBase().m_dropTarget.empty()) {
+ screen->setDropTarget(argsBase().m_dropTarget);
+ }
screen->setEnableDragDrop(argsBase().m_enableDragDrop);
m_events->adoptHandler(m_events->forIScreen().error(),
screen->getEventTarget(),
@@ -643,11 +657,18 @@ ServerApp::handleResume(const Event&, void*)
ClientListener*
ServerApp::openClientListener(const NetworkAddress& address)
{
+ auto security_level = ConnectionSecurityLevel::PLAINTEXT;
+ if (args().m_enableCrypto) {
+ security_level = ConnectionSecurityLevel::ENCRYPTED;
+ if (args().check_client_certificates) {
+ security_level = ConnectionSecurityLevel::ENCRYPTED_AUTHENTICATED;
+ }
+ }
+
ClientListener* listen = new ClientListener(
address,
new TCPSocketFactory(m_events, getSocketMultiplexer()),
- m_events,
- args().m_enableCrypto);
+ m_events, security_level);
m_events->adoptHandler(
m_events->forClientListener().connected(), listen,
@@ -775,10 +796,7 @@ ServerApp::mainLoop()
#if defined(MAC_OS_X_VERSION_10_7)
- Thread thread(
- new TMethodJob<ServerApp>(
- this, &ServerApp::runEventsLoop,
- NULL));
+ Thread thread([this](){ run_events_loop(); });
// wait until carbon loop is ready
OSXScreen* screen = dynamic_cast<OSXScreen*>(
@@ -823,7 +841,7 @@ ServerApp::runInner(int argc, char** argv, ILogOutputter* outputter, StartupFunc
// general initialization
m_barrierAddress = new NetworkAddress;
args().m_config = new Config(m_events);
- args().m_exename = PathUtilities::basename(argv[0]);
+ args().m_exename = ArgParser::parse_exename(argv[0]);
// install caller's output filter
if (outputter != NULL) {
diff --git a/src/lib/barrier/ServerApp.h b/src/lib/barrier/ServerApp.h
index 528aa24..ca38568 100644
--- a/src/lib/barrier/ServerApp.h
+++ b/src/lib/barrier/ServerApp.h
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -51,7 +51,7 @@ class ServerApp : public App {
public:
ServerApp(IEventQueue* events, CreateTaskBarReceiverFunc createTaskBarReceiver);
virtual ~ServerApp();
-
+
// Parse server specific command line arguments.
void parseArgs(int argc, const char* const* argv);
@@ -104,7 +104,7 @@ public:
static ServerApp& instance() { return (ServerApp&)App::instance(); }
Server* getServerPtr() { return m_server; }
-
+
Server* m_server;
EServerState m_serverState;
barrier::Screen* m_serverScreen;
diff --git a/src/lib/barrier/ServerArgs.h b/src/lib/barrier/ServerArgs.h
index 6d91233..6323705 100644
--- a/src/lib/barrier/ServerArgs.h
+++ b/src/lib/barrier/ServerArgs.h
@@ -30,4 +30,5 @@ public:
String m_configFile;
Config* m_config;
String m_screenChangeScript;
+ bool check_client_certificates = true;
};
diff --git a/src/lib/barrier/ServerTaskBarReceiver.cpp b/src/lib/barrier/ServerTaskBarReceiver.cpp
index b427cd1..c3ba7cf 100644
--- a/src/lib/barrier/ServerTaskBarReceiver.cpp
+++ b/src/lib/barrier/ServerTaskBarReceiver.cpp
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2003 Chris Schoeneman
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -125,7 +125,7 @@ ServerTaskBarReceiver::getToolTip() const
case kNotWorking:
return barrier::string::sprintf("%s: %s",
kAppVersion, m_errorMessage.c_str());
-
+
case kNotConnected:
return barrier::string::sprintf("%s: Waiting for clients", kAppVersion);
diff --git a/src/lib/barrier/ServerTaskBarReceiver.h b/src/lib/barrier/ServerTaskBarReceiver.h
index 3cef9c0..086de8c 100644
--- a/src/lib/barrier/ServerTaskBarReceiver.h
+++ b/src/lib/barrier/ServerTaskBarReceiver.h
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2003 Chris Schoeneman
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
diff --git a/src/lib/barrier/StreamChunker.cpp b/src/lib/barrier/StreamChunker.cpp
index 579d02f..0f6c0a9 100644
--- a/src/lib/barrier/StreamChunker.cpp
+++ b/src/lib/barrier/StreamChunker.cpp
@@ -1,11 +1,11 @@
/*
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2013-2016 Symless Ltd.
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -42,14 +42,13 @@ bool StreamChunker::s_interruptFile = false;
Mutex* StreamChunker::s_interruptMutex = NULL;
void
-StreamChunker::sendFile(
- char* filename,
+StreamChunker::sendFile(const char* filename,
IEventQueue* events,
void* eventTarget)
{
s_isChunkingFile = true;
-
- std::fstream file(static_cast<char*>(filename), std::ios::in | std::ios::binary);
+
+ std::fstream file(filename, std::ios::in | std::ios::binary);
if (!file.is_open()) {
throw runtime_error("failed to open file");
@@ -76,9 +75,9 @@ StreamChunker::sendFile(
LOG((CLOG_DEBUG "file transmission interrupted"));
break;
}
-
+
events->addEvent(Event(events->forFile().keepAlive(), eventTarget));
-
+
// make sure we don't read too much from the mock data.
if (sentLength + chunkSize > size) {
chunkSize = size - sentLength;
@@ -106,7 +105,7 @@ StreamChunker::sendFile(
events->addEvent(Event(events->forFile().fileChunkSending(), eventTarget, end));
file.close();
-
+
s_isChunkingFile = false;
}
@@ -122,16 +121,16 @@ StreamChunker::sendClipboard(
// send first message (data size)
String dataSize = barrier::string::sizeTypeToString(size);
ClipboardChunk* sizeMessage = ClipboardChunk::start(id, sequence, dataSize);
-
+
events->addEvent(Event(events->forClipboard().clipboardSending(), eventTarget, sizeMessage));
// send clipboard chunk with a fixed size
size_t sentLength = 0;
size_t chunkSize = g_chunkSize;
-
+
while (true) {
events->addEvent(Event(events->forFile().keepAlive(), eventTarget));
-
+
// make sure we don't read too much from the mock data.
if (sentLength + chunkSize > size) {
chunkSize = size - sentLength;
@@ -139,7 +138,7 @@ StreamChunker::sendClipboard(
String chunk(data.substr(sentLength, chunkSize).c_str(), chunkSize);
ClipboardChunk* dataChunk = ClipboardChunk::data(id, sequence, chunk);
-
+
events->addEvent(Event(events->forClipboard().clipboardSending(), eventTarget, dataChunk));
sentLength += chunkSize;
@@ -152,7 +151,7 @@ StreamChunker::sendClipboard(
ClipboardChunk* end = ClipboardChunk::end(id, sequence);
events->addEvent(Event(events->forClipboard().clipboardSending(), eventTarget, end));
-
+
LOG((CLOG_DEBUG "sent clipboard size=%d", sentLength));
}
diff --git a/src/lib/barrier/StreamChunker.h b/src/lib/barrier/StreamChunker.h
index ab57c7e..ed5d83c 100644
--- a/src/lib/barrier/StreamChunker.h
+++ b/src/lib/barrier/StreamChunker.h
@@ -1,11 +1,11 @@
/*
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2013-2016 Symless Ltd.
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -25,10 +25,7 @@ class Mutex;
class StreamChunker {
public:
- static void sendFile(
- char* filename,
- IEventQueue* events,
- void* eventTarget);
+ static void sendFile(const char* filename, IEventQueue* events, void* eventTarget);
static void sendClipboard(
String& data,
size_t size,
@@ -37,7 +34,7 @@ public:
IEventQueue* events,
void* eventTarget);
static void interruptFile();
-
+
private:
static bool s_isChunkingFile;
static bool s_interruptFile;
diff --git a/src/lib/barrier/XBarrier.cpp b/src/lib/barrier/XBarrier.cpp
index 7fe3577..44593d1 100644
--- a/src/lib/barrier/XBarrier.cpp
+++ b/src/lib/barrier/XBarrier.cpp
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -118,6 +118,6 @@ int XExitApp::getCode() const noexcept
String XExitApp::getWhat() const noexcept
{
return format(
- "XExitApp", "exiting with code %{1}",
+ "XExitApp", "exiting with code %{1}",
barrier::string::sprintf("%d", m_code).c_str());
}
diff --git a/src/lib/barrier/XBarrier.h b/src/lib/barrier/XBarrier.h
index fef931e..b7a3891 100644
--- a/src/lib/barrier/XBarrier.h
+++ b/src/lib/barrier/XBarrier.h
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -113,8 +113,8 @@ private:
//! Generic exit eception
/*!
-Thrown when we want to abort, with the opportunity to clean up. This is a
-little bit of a hack, but it's a better way of exiting, than just calling
+Thrown when we want to abort, with the opportunity to clean up. This is a
+little bit of a hack, but it's a better way of exiting, than just calling
exit(int).
*/
class XExitApp : public XBarrier {
@@ -127,7 +127,7 @@ public:
protected:
virtual std::string getWhat() const noexcept;
-
+
private:
int m_code;
};
diff --git a/src/lib/barrier/XScreen.cpp b/src/lib/barrier/XScreen.cpp
index 3398423..bb5c860 100644
--- a/src/lib/barrier/XScreen.cpp
+++ b/src/lib/barrier/XScreen.cpp
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
diff --git a/src/lib/barrier/XScreen.h b/src/lib/barrier/XScreen.h
index f8fe7a7..7033556 100644
--- a/src/lib/barrier/XScreen.h
+++ b/src/lib/barrier/XScreen.h
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
diff --git a/src/lib/barrier/clipboard_types.h b/src/lib/barrier/clipboard_types.h
index 54f2732..7de608c 100644
--- a/src/lib/barrier/clipboard_types.h
+++ b/src/lib/barrier/clipboard_types.h
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
diff --git a/src/lib/barrier/key_types.cpp b/src/lib/barrier/key_types.cpp
index 902670d..33ee3eb 100644
--- a/src/lib/barrier/key_types.cpp
+++ b/src/lib/barrier/key_types.cpp
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -17,6 +17,7 @@
*/
#include "barrier/key_types.h"
+#include <cstddef>
const KeyNameMapEntry kKeyNameMap[] = {
{ "AltGr", kKeyAltGr },
@@ -43,6 +44,7 @@ const KeyNameMapEntry kKeyNameMap[] = {
{ "Control_R", kKeyControl_R },
{ "Delete", kKeyDelete },
{ "Down", kKeyDown },
+ { "EisuToggle", kKeyEisuToggle },
{ "Eject", kKeyEject },
{ "End", kKeyEnd },
{ "Escape", kKeyEscape },
@@ -89,6 +91,7 @@ const KeyNameMapEntry kKeyNameMap[] = {
{ "Hyper_L", kKeyHyper_L },
{ "Hyper_R", kKeyHyper_R },
{ "Insert", kKeyInsert },
+ { "Kana", kKeyKana },
{ "KP_0", kKeyKP_0 },
{ "KP_1", kKeyKP_1 },
{ "KP_2", kKeyKP_2 },
@@ -130,6 +133,7 @@ const KeyNameMapEntry kKeyNameMap[] = {
{ "Menu", kKeyMenu },
{ "Meta_L", kKeyMeta_L },
{ "Meta_R", kKeyMeta_R },
+ { "Muhenkan", kKeyMuhenkan },
{ "NumLock", kKeyNumLock },
{ "PageDown", kKeyPageDown },
{ "PageUp", kKeyPageUp },
@@ -191,6 +195,12 @@ const KeyNameMapEntry kKeyNameMap[] = {
{ "Bar", 0x007c },
{ "BraceR", 0x007d },
{ "Tilde", 0x007e },
+ { "Copy", kKeyCopy },
+ { "Cut", kKeyCut },
+ { "Open", kKeyOpen },
+ { "Paste", kKeyPaste },
+ { "Props", kKeyProps },
+ { "Front", kKeyFront },
{ NULL, 0 },
};
diff --git a/src/lib/barrier/key_types.h b/src/lib/barrier/key_types.h
index 7a8ea53..863dc17 100644
--- a/src/lib/barrier/key_types.h
+++ b/src/lib/barrier/key_types.h
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -109,11 +109,13 @@ static const KeyID kKeyPause = 0xEF13; /* Pause, hold */
static const KeyID kKeyScrollLock = 0xEF14;
static const KeyID kKeySysReq = 0xEF15;
static const KeyID kKeyEscape = 0xEF1B;
+static const KeyID kKeyMuhenkan = 0xEF22; /* Cancel Conversion */
static const KeyID kKeyHenkan = 0xEF23; /* Start/Stop Conversion */
static const KeyID kKeyKana = 0xEF26; /* Kana */
static const KeyID kKeyHiraganaKatakana = 0xEF27; /* Hiragana/Katakana toggle */
static const KeyID kKeyZenkaku = 0xEF2A; /* Zenkaku/Hankaku */
static const KeyID kKeyKanzi = 0xEF2A; /* Kanzi */
+static const KeyID kKeyEisuToggle = 0xEF30; /* Alphanumeric toggle */
static const KeyID kKeyHangul = 0xEF31; /* Hangul */
static const KeyID kKeyHanja = 0xEF34; /* Hanja */
static const KeyID kKeyDelete = 0xEFFF; /* Delete, rubout */
@@ -170,7 +172,7 @@ static const KeyID kKeyKP_Separator= 0xEFAC; /* separator, often comma */
static const KeyID kKeyKP_Subtract = 0xEFAD;
static const KeyID kKeyKP_Decimal = 0xEFAE;
static const KeyID kKeyKP_Divide = 0xEFAF;
-static const KeyID kKeyKP_0 = 0xEFB0;
+static const KeyID kKeyKP_0 = 0xEFB0;
static const KeyID kKeyKP_1 = 0xEFB1;
static const KeyID kKeyKP_2 = 0xEFB2;
static const KeyID kKeyKP_3 = 0xEFB3;
@@ -234,6 +236,13 @@ static const KeyID kKeySuper_R = 0xEFEC; /* Right super */
static const KeyID kKeyHyper_L = 0xEFED; /* Left hyper */
static const KeyID kKeyHyper_R = 0xEFEE; /* Right hyper */
+static const KeyID kKeyCopy = 0x1008EF57;
+static const KeyID kKeyCut = 0x1008EF58;
+static const KeyID kKeyOpen = 0x1008EF6b;
+static const KeyID kKeyPaste = 0x1008EF6d;
+static const KeyID kKeyProps = 0x1005EF70;
+static const KeyID kKeyFront = 0x1005EF71;
+
// multi-key character composition
static const KeyID kKeyCompose = 0xEF20;
static const KeyID kKeyDeadGrave = 0x0300;
@@ -284,6 +293,8 @@ static const KeyID kKeyAppUser1 = 0xE0B6;
static const KeyID kKeyAppUser2 = 0xE0B7;
static const KeyID kKeyBrightnessDown = 0xE0B8;
static const KeyID kKeyBrightnessUp = 0xE0B9;
+static const KeyID kKeyKbdBrightnessDown = 0xE0BA;
+static const KeyID kKeyKbdBrightnessUp = 0xE0BB;
static const KeyID kKeyMissionControl = 0xE0C0;
static const KeyID kKeyLaunchpad = 0xE0C1;
diff --git a/src/lib/barrier/mouse_types.h b/src/lib/barrier/mouse_types.h
index 62a2396..ccb18ac 100644
--- a/src/lib/barrier/mouse_types.h
+++ b/src/lib/barrier/mouse_types.h
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
diff --git a/src/lib/barrier/option_types.h b/src/lib/barrier/option_types.h
index 6323e37..42103d4 100644
--- a/src/lib/barrier/option_types.h
+++ b/src/lib/barrier/option_types.h
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
diff --git a/src/lib/barrier/protocol_types.cpp b/src/lib/barrier/protocol_types.cpp
index 07acf61..9710841 100644
--- a/src/lib/barrier/protocol_types.cpp
+++ b/src/lib/barrier/protocol_types.cpp
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
diff --git a/src/lib/barrier/protocol_types.h b/src/lib/barrier/protocol_types.h
index bc5e037..f730606 100644
--- a/src/lib/barrier/protocol_types.h
+++ b/src/lib/barrier/protocol_types.h
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -20,6 +20,8 @@
#include "base/EventTypes.h"
+#include <cstdint>
+
// protocol version number
// 1.0: initial protocol
// 1.1: adds KeyCode to key press, release, and repeat
@@ -51,6 +53,12 @@ static const double kKeepAlivesUntilDeath = 3.0;
static const double kHeartRate = -1.0;
static const double kHeartBeatsUntilDeath = 3.0;
+// Messages of very large size indicate a likely protocol error. We don't parse such messages and
+// drop connection instead. Note that e.g. the clipboard messages are already limited to 32kB.
+static constexpr std::uint32_t PROTOCOL_MAX_MESSAGE_LENGTH = 4 * 1024 * 1024;
+static constexpr std::uint32_t PROTOCOL_MAX_LIST_LENGTH = 1024 * 1024;
+static constexpr std::uint32_t PROTOCOL_MAX_STRING_LENGTH = 1024 * 1024;
+
// direction constants
enum EDirection {
kNoDirection,
@@ -267,8 +275,8 @@ extern const char* kMsgDSetOptions;
// 2 means the file transfer is finished.
extern const char* kMsgDFileTransfer;
-// drag infomation: primary <-> secondary
-// transfer drag infomation. The first 2 bytes are used for storing
+// drag information: primary <-> secondary
+// transfer drag information. The first 2 bytes are used for storing
// the number of dragging objects. Then the following string consists
// of each object's directory.
extern const char* kMsgDDragInfo;
diff --git a/src/lib/barrier/unix/AppUtilUnix.cpp b/src/lib/barrier/unix/AppUtilUnix.cpp
index a1548d8..272dcf4 100644
--- a/src/lib/barrier/unix/AppUtilUnix.cpp
+++ b/src/lib/barrier/unix/AppUtilUnix.cpp
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
diff --git a/src/lib/barrier/unix/AppUtilUnix.h b/src/lib/barrier/unix/AppUtilUnix.h
index fefcfea..9555ccd 100644
--- a/src/lib/barrier/unix/AppUtilUnix.h
+++ b/src/lib/barrier/unix/AppUtilUnix.h
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -28,7 +28,7 @@ class AppUtilUnix : public AppUtil {
public:
AppUtilUnix(IEventQueue* events);
virtual ~AppUtilUnix();
-
+
int run(int argc, char** argv);
void startNode();
};
diff --git a/src/lib/barrier/win32/AppUtilWindows.cpp b/src/lib/barrier/win32/AppUtilWindows.cpp
index 560b029..b19cf15 100644
--- a/src/lib/barrier/win32/AppUtilWindows.cpp
+++ b/src/lib/barrier/win32/AppUtilWindows.cpp
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -60,13 +60,13 @@ BOOL WINAPI AppUtilWindows::consoleHandler(DWORD)
}
static
-int
-mainLoopStatic()
+int
+mainLoopStatic()
{
return AppUtil::instance().app().mainLoop();
}
-int
+int
AppUtilWindows::daemonNTMainLoop(int argc, const char** argv)
{
app().initApp(argc, argv);
@@ -74,11 +74,11 @@ AppUtilWindows::daemonNTMainLoop(int argc, const char** argv)
// NB: what the hell does this do?!
app().argsBase().m_backend = false;
-
+
return ArchMiscWindows::runDaemon(mainLoopStatic);
}
-void
+void
AppUtilWindows::exitApp(int code)
{
switch (m_exitMode) {
@@ -97,7 +97,7 @@ int daemonNTMainLoopStatic(int argc, const char** argv)
return AppUtilWindows::instance().daemonNTMainLoop(argc, argv);
}
-int
+int
AppUtilWindows::daemonNTStartup(int, char**)
{
SystemLogger sysLogger(app().daemonName(), false);
@@ -126,7 +126,7 @@ AppUtilWindows::beforeAppExit()
// a new console window, and will normally close on exit (making it so
// that we can't see error messages).
if (app().argsBase().m_pauseOnExit) {
- std::cout << std::endl << "press any key to exit..." << std::endl;
+ std::cout << "\n" << "press any key to exit...\n";
int c = _getch();
}
}
@@ -155,13 +155,13 @@ AppUtilWindows::run(int argc, char** argv)
return app().runInner(argc, argv, NULL, startup);
}
-AppUtilWindows&
+AppUtilWindows&
AppUtilWindows::instance()
{
return (AppUtilWindows&)AppUtil::instance();
}
-void
+void
AppUtilWindows::debugServiceWait()
{
if (app().argsBase().m_debugServiceWait)
@@ -169,8 +169,8 @@ AppUtilWindows::debugServiceWait()
while(true)
{
// this code is only executed when the process is launched via the
- // windows service controller (and --debug-service-wait arg is
- // used). to debug, set a breakpoint on this line so that
+ // windows service controller (and --debug-service-wait arg is
+ // used). to debug, set a breakpoint on this line so that
// execution is delayed until the debugger is attached.
ARCH->sleep(1);
LOG((CLOG_INFO "waiting for debugger to attach"));
@@ -178,7 +178,7 @@ AppUtilWindows::debugServiceWait()
}
}
-void
+void
AppUtilWindows::startNode()
{
app().startNode();
diff --git a/src/lib/barrier/win32/AppUtilWindows.h b/src/lib/barrier/win32/AppUtilWindows.h
index c5da228..23e7919 100644
--- a/src/lib/barrier/win32/AppUtilWindows.h
+++ b/src/lib/barrier/win32/AppUtilWindows.h
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2002 Chris Schoeneman
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -39,7 +39,7 @@ public:
virtual ~AppUtilWindows();
int daemonNTStartup(int, char**);
-
+
int daemonNTMainLoop(int argc, const char** argv);
void debugServiceWait();
diff --git a/src/lib/barrier/win32/DaemonApp.cpp b/src/lib/barrier/win32/DaemonApp.cpp
index 482c465..81ec5ff 100644
--- a/src/lib/barrier/win32/DaemonApp.cpp
+++ b/src/lib/barrier/win32/DaemonApp.cpp
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2012 Nick Bolton
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -28,7 +28,6 @@
#include "net/SocketMultiplexer.h"
#include "arch/XArch.h"
#include "base/Log.h"
-#include "base/TMethodJob.h"
#include "base/TMethodEventJob.h"
#include "base/EventQueue.h"
#include "base/log_outputters.h"
@@ -87,7 +86,7 @@ DaemonApp::run(int argc, char** argv)
{
// win32 instance needed for threading, etc.
ArchMiscWindows::setInstanceWin32(GetModuleHandle(NULL));
-
+
Arch arch;
arch.init();
@@ -174,7 +173,7 @@ DaemonApp::mainLoop(bool daemonized)
try
{
DAEMON_RUNNING(true);
-
+
if (daemonized) {
m_fileLogOutputter = new FileLogOutputter(logFilename().c_str());
CLOG->insert(m_fileLogOutputter);
@@ -190,19 +189,19 @@ DaemonApp::mainLoop(bool daemonized)
// send logging to gui via ipc, log system adopts outputter.
m_ipcLogOutputter = new IpcLogOutputter(*m_ipcServer, kIpcClientGui, true);
CLOG->insert(m_ipcLogOutputter);
-
+
m_watchdog = new MSWindowsWatchdog(daemonized, false, *m_ipcServer, *m_ipcLogOutputter);
m_watchdog->setFileLogOutputter(m_fileLogOutputter);
-
+
m_events->adoptHandler(
m_events->forIpcServer().messageReceived(), m_ipcServer,
new TMethodEventJob<DaemonApp>(this, &DaemonApp::handleIpcMessage));
m_ipcServer->listen();
-
+
// install the platform event queue to handle service stop events.
m_events->adoptBuffer(new MSWindowsEventQueueBuffer(m_events));
-
+
String command = ARCH->setting("Command");
bool elevate = ARCH->setting("Elevate") == "1";
if (command != "") {
@@ -219,11 +218,11 @@ DaemonApp::mainLoop(bool daemonized)
m_events->removeHandler(
m_events->forIpcServer().messageReceived(), m_ipcServer);
-
+
CLOG->remove(m_ipcLogOutputter);
delete m_ipcLogOutputter;
delete m_ipcServer;
-
+
DAEMON_RUNNING(false);
}
catch (std::exception& e) {
@@ -245,7 +244,7 @@ DaemonApp::logFilename()
{
string logFilename = ARCH->setting("LogFilename");
if (logFilename.empty())
- logFilename = DataDirectories::global() + "\\" + LOG_FILENAME;
+ logFilename = (barrier::DataDirectories::global() / LOG_FILENAME).u8string();
MSWindowsUtil::createDirectory(logFilename, true);
return logFilename;
}
@@ -287,7 +286,7 @@ DaemonApp::handleIpcMessage(const Event& e, void*)
}
delete[] argv;
-
+
String logLevel(argBase->m_logFilter);
if (!logLevel.empty()) {
try {
diff --git a/src/lib/barrier/win32/DaemonApp.h b/src/lib/barrier/win32/DaemonApp.h
index 2a8484b..e0eb385 100644
--- a/src/lib/barrier/win32/DaemonApp.h
+++ b/src/lib/barrier/win32/DaemonApp.h
@@ -2,11 +2,11 @@
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2012 Nick Bolton
- *
+ *
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
- *
+ *
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
+
#pragma once
#include "arch/Arch.h"