diff --git a/src/cmd/CMakeLists.txt b/src/cmd/CMakeLists.txt index 0fdfe339..ebf2a0d2 100644 --- a/src/cmd/CMakeLists.txt +++ b/src/cmd/CMakeLists.txt @@ -16,7 +16,6 @@ add_subdirectory(barrierc) add_subdirectory(barriers) -add_subdirectory(syntool) if (WIN32) add_subdirectory(barrierd) diff --git a/src/cmd/syntool/CMakeLists.txt b/src/cmd/syntool/CMakeLists.txt deleted file mode 100644 index 863d4f48..00000000 --- a/src/cmd/syntool/CMakeLists.txt +++ /dev/null @@ -1,27 +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 . - -file(GLOB headers "*.h") -file(GLOB sources "*.cpp") - -add_executable(syntool ${sources}) -target_link_libraries(syntool - synlib arch base client common io ipc mt net platform server ${libs} ${OPENSSL_LIBS}) - -if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - install (TARGETS syntool DESTINATION ${BARRIER_BUNDLE_BINARY_DIR}) -elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux") - install (TARGETS syntool DESTINATION bin) -endif() diff --git a/src/cmd/syntool/syntool.cpp b/src/cmd/syntool/syntool.cpp deleted file mode 100644 index 72d35b9d..00000000 --- a/src/cmd/syntool/syntool.cpp +++ /dev/null @@ -1,31 +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 . - */ - -#include "barrier/ToolApp.h" -#include "arch/Arch.h" - -int -main(int argc, char** argv) -{ -#if SYSAPI_WIN32 - // record window instance for tray icon, etc - ArchMiscWindows::setInstanceWin32(GetModuleHandle(NULL)); -#endif - - ToolApp app; - return app.run(argc, argv); -} diff --git a/src/gui/src/CoreInterface.cpp b/src/gui/src/CoreInterface.cpp deleted file mode 100644 index d5ed40d2..00000000 --- a/src/gui/src/CoreInterface.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/* - * 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 - * 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 . - */ - -#include "CoreInterface.h" - -#include "CommandProcess.h" -#include "QUtility.h" - -#include -#include -#include -#include -#include - -static const char kCoreBinary[] = "syntool"; - -#ifdef Q_WS_WIN -static const char kSerialKeyFilename[] = "Barrier.subkey"; -#else -static const char kSerialKeyFilename[] = ".barrier.subkey"; -#endif - -CoreInterface::CoreInterface() -{ -} - -QString CoreInterface::getProfileDir() -{ - QStringList args("--get-profile-dir"); - return run(args); -} - -QString CoreInterface::getInstalledDir() -{ - QStringList args("--get-installed-dir"); - return run(args); -} - -QString CoreInterface::getArch() -{ - QStringList args("--get-arch"); - return run(args); -} - -QString CoreInterface::getSerialKeyFilePath() -{ - QString filename = getProfileDir() + QDir::separator() + kSerialKeyFilename; - return filename; -} - -QString CoreInterface::notifyUpdate (QString const& fromVersion, - QString const& toVersion, - QString const& serialKey) { - QStringList args("--notify-update"); - QString input(fromVersion + ":" + toVersion + ":" + serialKey); - input.append("\n"); - return run(args, input); -} - -QString CoreInterface::notifyActivation(const QString& identity) -{ - QStringList args("--notify-activation"); - - QString input(identity + ":" + hash(getFirstMacAddress())); - QString os= getOSInformation(); - if (!os.isEmpty()) { - input.append(":").append(os); - } - input.append("\n"); - - return run(args, input); -} - -QString CoreInterface::run(const QStringList& args, const QString& input) -{ - QString program( - QCoreApplication::applicationDirPath() - + "/" + kCoreBinary); - - CommandProcess commandProcess(program, args, input); - return commandProcess.run(); -} diff --git a/src/gui/src/CoreInterface.h b/src/gui/src/CoreInterface.h deleted file mode 100644 index 26b9c0ab..00000000 --- a/src/gui/src/CoreInterface.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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 - * 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 . - */ - -#pragma once - -#include - -class CoreInterface -{ -public: - CoreInterface(); - - QString getProfileDir(); - QString getInstalledDir(); - QString getArch(); - QString getSerialKeyFilePath(); - QString notifyActivation(const QString& identity); - QString notifyUpdate (QString const& fromVersion, - QString const& toVersion, - QString const& serialKey); - QString run(const QStringList& args, const QString& input = ""); -}; diff --git a/src/gui/src/WebClient.cpp b/src/gui/src/WebClient.cpp deleted file mode 100644 index 8cded2cb..00000000 --- a/src/gui/src/WebClient.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* - * 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 - * 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 . - */ - -#include "WebClient.h" - -#include "QUtility.h" - -#include -#include -#include -#include - -bool -WebClient::getEdition (int& edition, QString& errorOut) { - QString responseJson = request(); - - /* TODO: This is horrible and should be ripped out as soon as we move - * to Qt 5. See issue #5630 - */ - - QRegExp resultRegex(".*\"result\".*:.*(true|false).*"); - if (resultRegex.exactMatch (responseJson)) { - QString boolString = resultRegex.cap(1); - if (boolString == "true") { - QRegExp editionRegex(".*\"edition\".*:.*\"([^\"]+)\".*"); - if (editionRegex.exactMatch(responseJson)) { - QString e = editionRegex.cap(1); - edition = e.toInt(); - return true; - } else { - throw std::runtime_error ("Unrecognised server response."); - } - } else { - errorOut = tr("Login failed. Invalid email address or password."); - return false; - } - } else { - QRegExp errorRegex(".*\"error\".*:.*\"([^\"]+)\".*"); - if (errorRegex.exactMatch (responseJson)) { - errorOut = errorRegex.cap(1).replace("\\n", "\n"); - return false; - } else { - throw std::runtime_error ("Unrecognised server response."); - } - } -} - -bool -WebClient::setEmail (QString email, QString& errorOut) { - if (email.isEmpty()) { - errorOut = tr("Your email address cannot be left blank."); - return false; - } - m_Email = email; - return true; -} - -bool -WebClient::setPassword (QString password, QString&) { - m_Password = password; - return true; -} - -QString -WebClient::request() { - QStringList args("--login-auth"); - QString credentials (m_Email + ":" + hash(m_Password) + "\n"); - return m_CoreInterface.run (args, credentials); -} diff --git a/src/gui/src/WebClient.h b/src/gui/src/WebClient.h deleted file mode 100644 index 9874bd58..00000000 --- a/src/gui/src/WebClient.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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 - * 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 . - */ - -#ifndef WEBCLIENT_H -#define WEBCLIENT_H - -#include -#include - -#include "CoreInterface.h" - -class QMessageBox; -class QWidget; -class QStringList; - -class WebClient : public QObject -{ - Q_OBJECT - -public: - bool getEdition (int& edition, QString& errorOut); - bool setEmail (QString email, QString& errorOut); - bool setPassword (QString password, QString& errorOut); -signals: - void error(QString e); - -private: - QString request(); - - QString m_Email; - QString m_Password; - CoreInterface m_CoreInterface; -}; - -#endif // WEBCLIENT_H diff --git a/src/lib/barrier/ArgParser.cpp b/src/lib/barrier/ArgParser.cpp index 20e849cf..1ce918c7 100644 --- a/src/lib/barrier/ArgParser.cpp +++ b/src/lib/barrier/ArgParser.cpp @@ -21,7 +21,6 @@ #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" @@ -171,46 +170,6 @@ ArgParser::parsePlatformArg(ArgsBase& argsBase, const int& argc, const char* con #endif } -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) { diff --git a/src/lib/barrier/ArgParser.h b/src/lib/barrier/ArgParser.h index 5fc2649c..32300c61 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/ToolApp.cpp b/src/lib/barrier/ToolApp.cpp deleted file mode 100644 index ae85e6dc..00000000 --- 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 . - */ - -#include "barrier/ToolApp.h" - -#include "barrier/ArgParser.h" -#include "arch/Arch.h" -#include "base/Log.h" -#include "base/String.h" - -#include -#include - -#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 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 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 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 5cb9a7c4..00000000 --- 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 . - */ - -#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 634a7843..00000000 --- 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 . - */ - -#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 36b4be3e..00000000 --- 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 . - */ - -#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; -};