diff --git a/src/lib/deskflow/ArgParser.cpp b/src/lib/deskflow/ArgParser.cpp index 341a8e9d3..9881dec34 100644 --- a/src/lib/deskflow/ArgParser.cpp +++ b/src/lib/deskflow/ArgParser.cpp @@ -10,7 +10,6 @@ #include "deskflow/App.h" #include "deskflow/ArgsBase.h" #include "deskflow/ClientArgs.h" -#include "deskflow/ServerArgs.h" #ifdef WINAPI_MSWINDOWS #include diff --git a/src/lib/deskflow/CMakeLists.txt b/src/lib/deskflow/CMakeLists.txt index d79d35e04..755856651 100644 --- a/src/lib/deskflow/CMakeLists.txt +++ b/src/lib/deskflow/CMakeLists.txt @@ -126,8 +126,6 @@ add_library(${lib_name} STATIC ${PLATFORM_CODE} ScreenException.h ServerApp.cpp ServerApp.h - ServerArgs.cpp - ServerArgs.h StreamChunker.cpp StreamChunker.h languages/LanguageManager.cpp diff --git a/src/lib/deskflow/ServerApp.cpp b/src/lib/deskflow/ServerApp.cpp index f39baa982..8b80e5bc3 100644 --- a/src/lib/deskflow/ServerApp.cpp +++ b/src/lib/deskflow/ServerApp.cpp @@ -18,7 +18,6 @@ #include "deskflow/ArgParser.h" #include "deskflow/Screen.h" #include "deskflow/ScreenException.h" -#include "deskflow/ServerArgs.h" #include "net/SocketException.h" #include "net/SocketMultiplexer.h" #include "net/TCPSocketFactory.h" @@ -70,13 +69,13 @@ using namespace deskflow::server; // ServerApp::ServerApp(IEventQueue *events, const QString &processName) - : App(events, processName, new deskflow::ServerArgs()) + : App(events, processName, new deskflow::ArgsBase()) { m_name = Settings::value(Settings::Core::ScreenName).toString().toStdString(); // do nothing } -void ServerApp::parseArgs(int argc, const char *const *argv) +void ServerApp::parseArgs(int, const char *const *) { if (const auto address = Settings::value(Settings::Core::Interface).toString(); !address.isEmpty()) { try { @@ -105,7 +104,7 @@ void ServerApp::reloadConfig() LOG_DEBUG("reload configuration"); if (loadConfig(Settings::value(Settings::Server::ExternalConfigFile).toString().toStdString())) { if (m_server != nullptr) { - m_server->setConfig(*args().m_config); + m_server->setConfig(*m_config); } LOG_NOTE("reloaded configuration"); } @@ -135,7 +134,7 @@ bool ServerApp::loadConfig(const std::string &pathname) LOG_ERR("cannot open configuration \"%s\"", pathname.c_str()); return false; } - configStream >> *args().m_config; + configStream >> *m_config; LOG_DEBUG("configuration read successfully"); return true; } catch (ServerConfigReadException &e) { @@ -316,7 +315,7 @@ bool ServerApp::initServer() deskflow::Screen *serverScreen = nullptr; PrimaryClient *primaryClient = nullptr; try { - std::string name = args().m_config->getCanonicalName(m_name); + std::string name = m_config->getCanonicalName(m_name); serverScreen = openServerScreen(); primaryClient = openPrimaryClient(name, serverScreen); m_serverScreen = serverScreen; @@ -391,8 +390,8 @@ bool ServerApp::startServer() ClientListener *listener = nullptr; try { - listener = openClientListener(args().m_config->getDeskflowAddress()); - m_server = openServer(*args().m_config, m_primaryClient); + listener = openClientListener(m_config->getDeskflowAddress()); + m_server = openServer(*m_config, m_primaryClient); listener->setServer(m_server); m_server->setListener(listener); m_listener = listener; @@ -504,7 +503,7 @@ ClientListener *ServerApp::openClientListener(const NetworkAddress &address) Server *ServerApp::openServer(ServerConfig &config, PrimaryClient *primaryClient) { - auto *server = new Server(config, primaryClient, m_serverScreen, getEvents(), args()); + auto *server = new Server(config, primaryClient, m_serverScreen, getEvents()); try { getEvents()->addHandler(EventTypes::ServerScreenSwitched, server, [this](const auto &) { handleScreenSwitched(); }); @@ -539,21 +538,21 @@ int ServerApp::mainLoop() // if configuration has no screens then add this system // as the default - if (args().m_config->begin() == args().m_config->end()) { - args().m_config->addScreen(m_name); + if (m_config->begin() == m_config->end()) { + m_config->addScreen(m_name); } // set the contact address, if provided, in the config. // otherwise, if the config doesn't have an address, use // the default. if (m_deskflowAddress->isValid()) { - args().m_config->setDeskflowAddress(*m_deskflowAddress); - } else if (!args().m_config->getDeskflowAddress().isValid()) { - args().m_config->setDeskflowAddress(NetworkAddress(kDefaultPort)); + m_config->setDeskflowAddress(*m_deskflowAddress); + } else if (!m_config->getDeskflowAddress().isValid()) { + m_config->setDeskflowAddress(NetworkAddress(kDefaultPort)); } // canonicalize the primary screen name - if (std::string primaryName = args().m_config->getCanonicalName(m_name); primaryName.empty()) { + if (std::string primaryName = m_config->getCanonicalName(m_name); primaryName.empty()) { LOG_CRIT("unknown screen name `%s'", m_name.c_str()); return s_exitFailed; } @@ -621,7 +620,7 @@ int ServerApp::runInner(int argc, char **argv, StartupFunc startup) { // general initialization m_deskflowAddress = new NetworkAddress; - args().m_config = std::make_shared(getEvents()); + m_config = std::make_shared(getEvents()); // run int result = startup(argc, argv); diff --git a/src/lib/deskflow/ServerApp.h b/src/lib/deskflow/ServerApp.h index 912c2bd9b..c7900c129 100644 --- a/src/lib/deskflow/ServerApp.h +++ b/src/lib/deskflow/ServerApp.h @@ -55,7 +55,7 @@ public: // IApp overrides // - void parseArgs(int argc, const char *const *argv) override; + void parseArgs(int, const char *const *) override; void help() override; const char *daemonName() const override; const char *daemonInfo() const override; @@ -105,11 +105,6 @@ public: return m_server; } - deskflow::ServerArgs &args() const - { - return (deskflow::ServerArgs &)argsBase(); - } - // // Static functions // @@ -134,4 +129,5 @@ private: EventQueueTimer *m_timer = nullptr; NetworkAddress *m_deskflowAddress = nullptr; std::string m_name; + std::shared_ptr m_config; }; diff --git a/src/lib/deskflow/ServerArgs.cpp b/src/lib/deskflow/ServerArgs.cpp deleted file mode 100644 index 3fb77573e..000000000 --- a/src/lib/deskflow/ServerArgs.cpp +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Deskflow -- mouse and keyboard sharing utility - * SPDX-FileCopyrightText: (C) 2014 - 2020 Symless Ltd. - * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception - */ - -#include "ServerArgs.h" - -namespace deskflow { - -ServerArgs::ServerArgs() -{ - m_classType = ClassType::Server; -} -} // namespace deskflow diff --git a/src/lib/deskflow/ServerArgs.h b/src/lib/deskflow/ServerArgs.h deleted file mode 100644 index b01afa613..000000000 --- a/src/lib/deskflow/ServerArgs.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Deskflow -- mouse and keyboard sharing utility - * SPDX-FileCopyrightText: (C) 2014 - 2020 Symless Ltd. - * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception - */ - -#pragma once - -#include "ArgsBase.h" -#include "server/Config.h" - -#include - -namespace deskflow { - -class ServerArgs : public ArgsBase -{ - using Config = deskflow::server::Config; - -public: - ServerArgs(); - ServerArgs(ServerArgs const &src) = default; - ServerArgs(ServerArgs &&) = default; - ~ServerArgs() override = default; - - ServerArgs &operator=(ServerArgs const &) = default; - ServerArgs &operator=(ServerArgs &&) = default; - -public: - std::shared_ptr m_config; -}; - -} // namespace deskflow diff --git a/src/lib/server/Server.cpp b/src/lib/server/Server.cpp index 2e095c498..2c47ab70e 100644 --- a/src/lib/server/Server.cpp +++ b/src/lib/server/Server.cpp @@ -43,17 +43,13 @@ using namespace deskflow::server; // Server // -Server::Server( - ServerConfig &config, PrimaryClient *primaryClient, deskflow::Screen *screen, IEventQueue *events, - deskflow::ServerArgs const &args -) +Server::Server(ServerConfig &config, PrimaryClient *primaryClient, deskflow::Screen *screen, IEventQueue *events) : m_primaryClient(primaryClient), m_active(primaryClient), m_config(&config), m_inputFilter(config.getInputFilter()), m_screen(screen), - m_events(events), - m_args(args) + m_events(events) { // must have a primary client and it must have a canonical name assert(m_primaryClient != nullptr); diff --git a/src/lib/server/Server.h b/src/lib/server/Server.h index 8760ce4d6..9b4f8d240 100644 --- a/src/lib/server/Server.h +++ b/src/lib/server/Server.h @@ -16,7 +16,6 @@ #include "deskflow/KeyTypes.h" #include "deskflow/MouseTypes.h" #include "deskflow/OptionTypes.h" -#include "deskflow/ServerArgs.h" #include "server/Config.h" #include @@ -120,10 +119,7 @@ public: client (local screen) \p primaryClient. The client retains ownership of \p primaryClient. */ - Server( - ServerConfig &config, PrimaryClient *primaryClient, deskflow::Screen *screen, IEventQueue *events, - deskflow::ServerArgs const &args - ); + Server(ServerConfig &config, PrimaryClient *primaryClient, deskflow::Screen *screen, IEventQueue *events); Server(Server const &) = delete; Server(Server &&) = delete; ~Server(); @@ -402,8 +398,6 @@ private: using OldClients = std::map; OldClients m_oldClients; - deskflow::ServerArgs m_args; - // clipboard cache ClipboardInfo m_clipboards[kClipboardEnd]; diff --git a/src/unittests/deskflow/ArgParserTests.cpp b/src/unittests/deskflow/ArgParserTests.cpp index 6afb325ab..aed28aa51 100644 --- a/src/unittests/deskflow/ArgParserTests.cpp +++ b/src/unittests/deskflow/ArgParserTests.cpp @@ -9,7 +9,6 @@ #include "deskflow/ArgsBase.h" #include "deskflow/ClientArgs.h" -#include "deskflow/ServerArgs.h" // This file is generated at build time #include diff --git a/src/unittests/deskflow/ServerAppTests.cpp b/src/unittests/deskflow/ServerAppTests.cpp index 764dd4e8f..e7f5b9cf4 100644 --- a/src/unittests/deskflow/ServerAppTests.cpp +++ b/src/unittests/deskflow/ServerAppTests.cpp @@ -8,12 +8,10 @@ #include "ServerAppTests.h" #include "deskflow/ServerApp.h" -#include "deskflow/ServerArgs.h" void ServerAppTests::section() { ServerApp app(nullptr); - QVERIFY(!app.args().m_config); QCOMPARE(app.configSection(), "server"); }