diff options
Diffstat (limited to 'src/lib/barrier')
| -rw-r--r-- | src/lib/barrier/App.cpp | 24 | ||||
| -rw-r--r-- | src/lib/barrier/ArgParser.cpp | 54 | ||||
| -rw-r--r-- | src/lib/barrier/ArgParser.h | 2 | ||||
| -rw-r--r-- | src/lib/barrier/ArgsBase.cpp | 1 | ||||
| -rw-r--r-- | src/lib/barrier/ArgsBase.h | 2 | ||||
| -rw-r--r-- | src/lib/barrier/ClientApp.cpp | 18 | ||||
| -rw-r--r-- | src/lib/barrier/ServerApp.cpp | 44 | ||||
| -rw-r--r-- | src/lib/barrier/ToolApp.cpp | 205 | ||||
| -rw-r--r-- | src/lib/barrier/ToolApp.h | 37 | ||||
| -rw-r--r-- | src/lib/barrier/ToolArgs.cpp | 29 | ||||
| -rw-r--r-- | src/lib/barrier/ToolArgs.h | 34 | ||||
| -rw-r--r-- | src/lib/barrier/win32/DaemonApp.cpp | 20 |
12 files changed, 61 insertions, 409 deletions
diff --git a/src/lib/barrier/App.cpp b/src/lib/barrier/App.cpp index 1f4eda3..f4293b6 100644 --- a/src/lib/barrier/App.cpp +++ b/src/lib/barrier/App.cpp @@ -21,9 +21,7 @@ #include "base/Log.h" #include "common/Version.h" #include "barrier/protocol_types.h" -#include "arch/Arch.h" #include "base/XBase.h" -#include "arch/XArch.h" #include "base/log_outputters.h" #include "barrier/XBarrier.h" #include "barrier/ArgsBase.h" @@ -32,9 +30,9 @@ #include "ipc/IpcMessage.h" #include "ipc/Ipc.h" #include "base/EventQueue.h" +#include "common/DataDirectories.h" #if SYSAPI_WIN32 -#include "arch/win32/ArchMiscWindows.h" #include "base/IEventQueue.h" #include "base/TMethodJob.h" #endif @@ -81,18 +79,9 @@ App::~App() void App::version() { - char buffer[500]; - sprintf( - buffer, - "%s %s, protocol version %d.%d\n%s", - argsBase().m_pname, - kVersion, - kProtocolMajorVersion, - kProtocolMinorVersion, - kCopyright - ); - - std::cout << buffer << std::endl; + std::cout << argsBase().m_exename << " " << kVersion << std::endl; + std::cout <<"Protocol version " << kProtocolMajorVersion << "." << kProtocolMinorVersion << std::endl; + std::cout << kCopyright << std::endl; } int @@ -175,13 +164,12 @@ App::initApp(int argc, const char** argv) // parse command line parseArgs(argc, argv); - ARCH->setProfileDirectory(argsBase().m_profileDirectory); - ARCH->setPluginDirectory(argsBase().m_pluginDirectory); + DataDirectories::profile(argsBase().m_profileDirectory); // set log filter if (!CLOG->setFilter(argsBase().m_logFilter)) { LOG((CLOG_PRINT "%s: unrecognized log level `%s'" BYE, - argsBase().m_pname, argsBase().m_logFilter, argsBase().m_pname)); + argsBase().m_exename.c_str(), argsBase().m_logFilter, argsBase().m_exename.c_str())); m_bye(kExitArgs); } loggingFilterWarning(); diff --git a/src/lib/barrier/ArgParser.cpp b/src/lib/barrier/ArgParser.cpp index 20e849c..b20b33f 100644 --- a/src/lib/barrier/ArgParser.cpp +++ b/src/lib/barrier/ArgParser.cpp @@ -21,10 +21,10 @@ #include "barrier/App.h" #include "barrier/ServerArgs.h" #include "barrier/ClientArgs.h" -#include "barrier/ToolArgs.h" #include "barrier/ArgsBase.h" #include "base/Log.h" #include "base/String.h" +#include "common/PathUtilities.h" #ifdef WINAPI_MSWINDOWS #include <VersionHelpers.h> @@ -62,7 +62,7 @@ ArgParser::parseServerArgs(ServerArgs& args, int argc, const char* const* argv) args.m_configFile = argv[++i]; } else { - LOG((CLOG_PRINT "%s: unrecognized option `%s'" BYE, args.m_pname, argv[i], args.m_pname)); + LOG((CLOG_PRINT "%s: unrecognized option `%s'" BYE, args.m_exename.c_str(), argv[i], args.m_exename.c_str())); return false; } } @@ -107,7 +107,7 @@ ArgParser::parseClientArgs(ClientArgs& args, int argc, const char* const* argv) return true; } - LOG((CLOG_PRINT "%s: unrecognized option `%s'" BYE, args.m_pname, argv[i], args.m_pname)); + LOG((CLOG_PRINT "%s: unrecognized option `%s'" BYE, args.m_exename.c_str(), argv[i], args.m_exename.c_str())); return false; } } @@ -118,7 +118,7 @@ ArgParser::parseClientArgs(ClientArgs& args, int argc, const char* const* argv) // exactly one non-option argument (server-address) if (i == argc) { LOG((CLOG_PRINT "%s: a server address or name is required" BYE, - args.m_pname, args.m_pname)); + args.m_exename.c_str(), args.m_exename.c_str())); return false; } @@ -172,46 +172,6 @@ ArgParser::parsePlatformArg(ArgsBase& argsBase, const int& argc, const char* con } bool -ArgParser::parseToolArgs(ToolArgs& args, int argc, const char* const* argv) -{ - for (int i = 1; i < argc; ++i) { - if (isArg(i, argc, argv, NULL, "--get-active-desktop", 0)) { - args.m_printActiveDesktopName = true; - return true; - } - else if (isArg(i, argc, argv, NULL, "--login-auth", 0)) { - args.m_loginAuthenticate = true; - return true; - } - else if (isArg(i, argc, argv, NULL, "--get-installed-dir", 0)) { - args.m_getInstalledDir = true; - return true; - } - else if (isArg(i, argc, argv, NULL, "--get-profile-dir", 0)) { - args.m_getProfileDir = true; - return true; - } - else if (isArg(i, argc, argv, NULL, "--get-arch", 0)) { - args.m_getArch = true; - return true; - } - else if (isArg(i, argc, argv, NULL, "--notify-activation", 0)) { - args.m_notifyActivation = true; - return true; - } - else if (isArg(i, argc, argv, NULL, "--notify-update", 0)) { - args.m_notifyUpdate = true; - return true; - } - else { - return false; - } - } - - return false; -} - -bool ArgParser::parseGenericArgs(int argc, const char* const* argv, int& i) { if (isArg(i, argc, argv, "-d", "--debug", 1)) { @@ -353,7 +313,7 @@ ArgParser::isArg( // match. check args left. if (argi + minRequiredParameters >= argc) { LOG((CLOG_PRINT "%s: missing arguments for `%s'" BYE, - argsBase().m_pname, argv[argi], argsBase().m_pname)); + argsBase().m_exename.c_str(), argv[argi], argsBase().m_exename.c_str())); argsBase().m_shouldExit = true; return false; } @@ -496,7 +456,7 @@ void ArgParser::updateCommonArgs(const char* const* argv) { argsBase().m_name = ARCH->getHostName(); - argsBase().m_pname = ARCH->getBasename(argv[0]); + argsBase().m_exename = PathUtilities::basename(argv[0]); } bool @@ -510,7 +470,7 @@ ArgParser::checkUnexpectedArgs() LOG((CLOG_ERR "the --daemon argument is not supported on windows. " "instead, install %s as a service (--service install)", - argsBase().m_pname)); + argsBase().m_exename.c_str())); return true; } #endif diff --git a/src/lib/barrier/ArgParser.h b/src/lib/barrier/ArgParser.h index 5fc2649..32300c6 100644 --- a/src/lib/barrier/ArgParser.h +++ b/src/lib/barrier/ArgParser.h @@ -22,7 +22,6 @@ class ServerArgs; class ClientArgs; -class ToolArgs; class ArgsBase; class App; @@ -34,7 +33,6 @@ public: bool parseServerArgs(ServerArgs& args, int argc, const char* const* argv); bool parseClientArgs(ClientArgs& args, int argc, const char* const* argv); bool parsePlatformArg(ArgsBase& argsBase, const int& argc, const char* const* argv, int& i); - bool parseToolArgs(ToolArgs& args, int argc, const char* const* argv); bool parseGenericArgs(int argc, const char* const* argv, int& i); bool parseDeprecatedArgs(int argc, const char* const* argv, int& i); void setArgsBase(ArgsBase& argsBase) { m_argsBase = &argsBase; } diff --git a/src/lib/barrier/ArgsBase.cpp b/src/lib/barrier/ArgsBase.cpp index eedb312..eb63150 100644 --- a/src/lib/barrier/ArgsBase.cpp +++ b/src/lib/barrier/ArgsBase.cpp @@ -33,7 +33,6 @@ m_disableXInitThreads(false), m_backend(false), m_restartable(true), m_noHooks(false), -m_pname(NULL), m_logFilter(NULL), m_logFile(NULL), m_display(NULL), diff --git a/src/lib/barrier/ArgsBase.h b/src/lib/barrier/ArgsBase.h index 1f49984..99929b3 100644 --- a/src/lib/barrier/ArgsBase.h +++ b/src/lib/barrier/ArgsBase.h @@ -30,7 +30,7 @@ public: bool m_backend; bool m_restartable; bool m_noHooks; - const char* m_pname; + std::string m_exename; const char* m_logFilter; const char* m_logFile; const char* m_display; diff --git a/src/lib/barrier/ClientApp.cpp b/src/lib/barrier/ClientApp.cpp index 87686f2..17de18e 100644 --- a/src/lib/barrier/ClientApp.cpp +++ b/src/lib/barrier/ClientApp.cpp @@ -40,10 +40,7 @@ #include "base/TMethodJob.h" #include "base/Log.h" #include "common/Version.h" - -#if SYSAPI_WIN32 -#include "arch/win32/ArchMiscWindows.h" -#endif +#include "common/PathUtilities.h" #if WINAPI_MSWINDOWS #include "platform/MSWindowsScreen.h" @@ -98,7 +95,7 @@ ClientApp::parseArgs(int argc, const char* const* argv) // Priddy. if (!args().m_restartable || e.getError() == XSocketAddress::kBadPort) { LOG((CLOG_PRINT "%s: %s" BYE, - args().m_pname, e.what(), args().m_pname)); + args().m_exename.c_str(), e.what(), args().m_exename.c_str())); m_bye(kExitFailed); } } @@ -123,7 +120,7 @@ ClientApp::help() std::ostringstream buffer; buffer << "Start the barrier client and connect to a remote server component." << std::endl << std::endl - << "Usage: " << args().m_pname << " [--yscroll <delta>]" << WINAPI_ARG << HELP_SYS_ARGS + << "Usage: " << args().m_exename << " [--yscroll <delta>]" << WINAPI_ARG << HELP_SYS_ARGS << HELP_COMMON_ARGS << " <server-address>" << std::endl << std::endl << "Options:" << std::endl @@ -134,9 +131,10 @@ ClientApp::help() << 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. The port overrides the" << std::endl - << "default port, " << kDefaultPort << "." << 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; LOG((CLOG_PRINT "%s", buffer.str().c_str())); } @@ -519,7 +517,7 @@ ClientApp::runInner(int argc, char** argv, ILogOutputter* outputter, StartupFunc { // general initialization m_serverAddress = new NetworkAddress; - args().m_pname = ARCH->getBasename(argv[0]); + args().m_exename = PathUtilities::basename(argv[0]); // install caller's output filter if (outputter != NULL) { diff --git a/src/lib/barrier/ServerApp.cpp b/src/lib/barrier/ServerApp.cpp index 112f290..6d8d7cd 100644 --- a/src/lib/barrier/ServerApp.cpp +++ b/src/lib/barrier/ServerApp.cpp @@ -39,6 +39,8 @@ #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" @@ -99,7 +101,7 @@ ServerApp::parseArgs(int argc, const char* const* argv) } catch (XSocketAddress& e) { LOG((CLOG_PRINT "%s: %s" BYE, - args().m_pname, e.what(), args().m_pname)); + args().m_exename.c_str(), e.what(), args().m_exename.c_str())); m_bye(kExitArgs); } } @@ -124,7 +126,7 @@ ServerApp::help() std::ostringstream buffer; buffer << "Start the barrier server component." << std::endl << std::endl - << "Usage: " << args().m_pname + << "Usage: " << args().m_exename << " [--address <address>]" << " [--config <pathname>]" << WINAPI_ARGS << HELP_SYS_ARGS << HELP_COMMON_ARGS << std::endl @@ -137,13 +139,14 @@ ServerApp::help() << 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 - << "The default is to listen on all interfaces. The port overrides the" << std::endl - << "default port, " << kDefaultPort << "." << 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 - << " $HOME/" << USR_CONFIG_NAME << std::endl - << " " << ARCH->concatPath(ARCH->getSystemDirectory(), SYS_CONFIG_NAME) << std::endl; + << " " << PathUtilities::concat(DataDirectories::profile(), SYS_CONFIG_NAME) << std::endl + << " " << PathUtilities::concat(DataDirectories::systemconfig(), SYS_CONFIG_NAME) << std::endl; LOG((CLOG_PRINT "%s", buffer.str().c_str())); } @@ -180,11 +183,10 @@ ServerApp::loadConfig() // load the default configuration if no explicit file given else { - // get the user's home directory - String path = ARCH->getUserDirectory(); + String path = DataDirectories::profile(); if (!path.empty()) { // complete path - path = ARCH->concatPath(path, USR_CONFIG_NAME); + path = PathUtilities::concat(path, USR_CONFIG_NAME); // now try loading the user's configuration if (loadConfig(path)) { @@ -194,9 +196,9 @@ ServerApp::loadConfig() } if (!loaded) { // try the system-wide config file - path = ARCH->getSystemDirectory(); + path = DataDirectories::systemconfig(); if (!path.empty()) { - path = ARCH->concatPath(path, SYS_CONFIG_NAME); + path = PathUtilities::concat(path, SYS_CONFIG_NAME); if (loadConfig(path)) { loaded = true; args().m_configFile = path; @@ -206,7 +208,7 @@ ServerApp::loadConfig() } if (!loaded) { - LOG((CLOG_PRINT "%s: no configuration available", args().m_pname)); + LOG((CLOG_PRINT "%s: no configuration available", args().m_exename.c_str())); m_bye(kExitConfig); } } @@ -505,6 +507,16 @@ ServerApp::openServerScreen() return screen; } +static const char* const family_string(IArchNetwork::EAddressFamily family) +{ + if (family == IArchNetwork::kINET) + return "IPv4"; + if (family == IArchNetwork::kINET6) + // assume IPv6 sockets are setup to support IPv4 traffic as well + return "IPv4/IPv6"; + return "Unknown"; +} + bool ServerApp::startServer() { @@ -530,13 +542,15 @@ ServerApp::startServer() double retryTime; ClientListener* listener = NULL; try { - listener = openClientListener(args().m_config->getBarrierAddress()); + auto listenAddress = args().m_config->getBarrierAddress(); + auto family = family_string(ARCH->getAddrFamily(listenAddress.getAddress())); + listener = openClientListener(listenAddress); m_server = openServer(*args().m_config, m_primaryClient); listener->setServer(m_server); m_server->setListener(listener); m_listener = listener; updateStatus(); - LOG((CLOG_NOTE "started server, waiting for clients")); + LOG((CLOG_NOTE "started server (%s), waiting for clients", family)); m_serverState = kStarted; return true; } @@ -779,7 +793,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_pname = ARCH->getBasename(argv[0]); + args().m_exename = PathUtilities::basename(argv[0]); // install caller's output filter if (outputter != NULL) { diff --git a/src/lib/barrier/ToolApp.cpp b/src/lib/barrier/ToolApp.cpp deleted file mode 100644 index ae85e6d..0000000 --- a/src/lib/barrier/ToolApp.cpp +++ /dev/null @@ -1,205 +0,0 @@ -/* - * 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 - * 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/>. - */ - -#include "barrier/ToolApp.h" - -#include "barrier/ArgParser.h" -#include "arch/Arch.h" -#include "base/Log.h" -#include "base/String.h" - -#include <iostream> -#include <sstream> - -#if SYSAPI_WIN32 -#include "platform/MSWindowsSession.h" -#endif - -#define JSON_URL "https://symless.com/account/json/" - -enum { - kErrorOk, - kErrorArgs, - kErrorException, - kErrorUnknown -}; - -UInt32 -ToolApp::run(int argc, char** argv) -{ - if (argc <= 1) { - std::cerr << "no args" << std::endl; - return kErrorArgs; - } - - try { - ArgParser argParser(this); - bool result = argParser.parseToolArgs(m_args, argc, argv); - - if (!result) { - m_bye(kExitArgs); - } - - if (m_args.m_printActiveDesktopName) { -#if SYSAPI_WIN32 - MSWindowsSession session; - String name = session.getActiveDesktopName(); - if (name.empty()) { - LOG((CLOG_CRIT "failed to get active desktop name")); - return kExitFailed; - } - else { - String output = barrier::string::sprintf("activeDesktop:%s", name.c_str()); - LOG((CLOG_INFO "%s", output.c_str())); - } -#endif - } - else if (m_args.m_loginAuthenticate) { - loginAuth(); - } - else if (m_args.m_getInstalledDir) { - std::cout << ARCH->getInstalledDirectory() << std::endl; - } - else if (m_args.m_getProfileDir) { - std::cout << ARCH->getProfileDirectory() << std::endl; - } - else if (m_args.m_getArch) { - std::cout << ARCH->getPlatformName() << std::endl; - } - else if (m_args.m_notifyUpdate) { - notifyUpdate(); - } - else if (m_args.m_notifyActivation) { - notifyActivation(); - } - else { - throw XBarrier("Nothing to do"); - } - } - catch (std::exception& e) { - LOG((CLOG_CRIT "An error occurred: %s\n", e.what())); - return kExitFailed; - } - catch (...) { - LOG((CLOG_CRIT "An unknown error occurred.\n")); - return kExitFailed; - } - -#if WINAPI_XWINDOWS - // HACK: avoid sigsegv on linux - m_bye(kErrorOk); -#endif - - return kErrorOk; -} - -void -ToolApp::help() -{ -} - -void -ToolApp::loginAuth() -{ - String credentials; - std::cin >> credentials; - - std::vector<String> parts = barrier::string::splitString(credentials, ':'); - size_t count = parts.size(); - - if (count == 2 ) { - String email = parts[0]; - String password = parts[1]; - - std::stringstream ss; - ss << JSON_URL << "auth/"; - ss << "?email=" << ARCH->internet().urlEncode(email); - ss << "&password=" << password; - - std::cout << ARCH->internet().get(ss.str()) << std::endl; - } - else { - throw XBarrier("Invalid credentials."); - } -} - -void -ToolApp::notifyUpdate() -{ - String data; - std::cin >> data; - - std::vector<String> parts = barrier::string::splitString(data, ':'); - size_t count = parts.size(); - - if (count == 3) { - std::stringstream ss; - ss << JSON_URL << "notify/update"; - ss << "?from=" << parts[0]; - ss << "&to=" << parts[1]; - - std::cout << ARCH->internet().get(ss.str()) << std::endl; - } - else { - throw XBarrier("Invalid update data."); - } -} - -void -ToolApp::notifyActivation() -{ - String info; - std::cin >> info; - - std::vector<String> parts = barrier::string::splitString(info, ':'); - size_t count = parts.size(); - - if (count == 3 || count == 4) { - String action = parts[0]; - String identity = parts[1]; - String macHash = parts[2]; - String os; - - if (count == 4) { - os = parts[3]; - } - else { - os = ARCH->getOSName(); - } - - std::stringstream ss; - ss << JSON_URL << "notify/"; - ss << "?action=" << action; - ss << "&identity=" << ARCH->internet().urlEncode(identity); - ss << "&mac=" << ARCH->internet().urlEncode(macHash); - ss << "&os=" << ARCH->internet().urlEncode(ARCH->getOSName()); - ss << "&arch=" << ARCH->internet().urlEncode(ARCH->getPlatformName()); - - try { - std::cout << ARCH->internet().get(ss.str()) << std::endl; - } - catch (std::exception& e) { - LOG((CLOG_NOTE "An error occurred during notification: %s\n", e.what())); - } - catch (...) { - LOG((CLOG_NOTE "An unknown error occurred during notification.\n")); - } - } - else { - LOG((CLOG_NOTE "notification failed")); - } -} diff --git a/src/lib/barrier/ToolApp.h b/src/lib/barrier/ToolApp.h deleted file mode 100644 index 5cb9a7c..0000000 --- a/src/lib/barrier/ToolApp.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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 - * 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/>. - */ - -#pragma once - -#include "barrier/App.h" -#include "barrier/ToolArgs.h" -#include "common/basic_types.h" - -class ToolApp : public MinimalApp -{ -public: - UInt32 run(int argc, char** argv); - void help(); - -private: - void loginAuth(); - void notifyActivation(); - void notifyUpdate(); - -private: - ToolArgs m_args; -}; diff --git a/src/lib/barrier/ToolArgs.cpp b/src/lib/barrier/ToolArgs.cpp deleted file mode 100644 index 634a784..0000000 --- a/src/lib/barrier/ToolArgs.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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 - * 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/>. - */ - -#include "barrier/ToolArgs.h" - -ToolArgs::ToolArgs() : - m_printActiveDesktopName(false), - m_loginAuthenticate(false), - m_getInstalledDir(false), - m_getProfileDir(false), - m_getArch(false), - m_notifyActivation(false), - m_notifyUpdate(false) -{ -} diff --git a/src/lib/barrier/ToolArgs.h b/src/lib/barrier/ToolArgs.h deleted file mode 100644 index 36b4be3..0000000 --- a/src/lib/barrier/ToolArgs.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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 - * 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/>. - */ - -#pragma once - -#include "base/String.h" - -class ToolArgs { -public: - ToolArgs(); - -public: - bool m_printActiveDesktopName; - bool m_loginAuthenticate; - bool m_getInstalledDir; - bool m_getProfileDir; - bool m_getArch; - bool m_notifyActivation; - bool m_notifyUpdate; -}; diff --git a/src/lib/barrier/win32/DaemonApp.cpp b/src/lib/barrier/win32/DaemonApp.cpp index 62fecf8..eafd893 100644 --- a/src/lib/barrier/win32/DaemonApp.cpp +++ b/src/lib/barrier/win32/DaemonApp.cpp @@ -33,6 +33,7 @@ #include "base/EventQueue.h" #include "base/log_outputters.h" #include "base/Log.h" +#include "common/DataDirectories.h" #include "arch/win32/ArchMiscWindows.h" #include "arch/win32/XArchWindows.h" @@ -41,6 +42,7 @@ #include "platform/MSWindowsDebugOutputter.h" #include "platform/MSWindowsWatchdog.h" #include "platform/MSWindowsEventQueueBuffer.h" +#include "platform/MSWindowsUtil.h" #define WIN32_LEAN_AND_MEAN #include <Windows.h> @@ -130,8 +132,10 @@ DaemonApp::run(int argc, char** argv) } if (foreground) { - // run process in foreground instead of daemonizing. - // useful for debugging. + // add a console to catch Ctrl+C and run process in foreground + // instead of daemonizing. useful for debugging. + if (IsDebuggerPresent()) + AllocConsole(); mainLoop(false); } else { @@ -239,14 +243,10 @@ DaemonApp::foregroundError(const char* message) std::string DaemonApp::logFilename() { - string logFilename; - logFilename = ARCH->setting("LogFilename"); - if (logFilename.empty()) { - logFilename = ARCH->getLogDirectory(); - logFilename.append("/"); - logFilename.append(LOG_FILENAME); - } - + string logFilename = ARCH->setting("LogFilename"); + if (logFilename.empty()) + logFilename = DataDirectories::global() + "\\" + LOG_FILENAME; + MSWindowsUtil::createDirectory(logFilename, true); return logFilename; } |
