remove: argsBase
This commit is contained in:
parent
37827f0540
commit
d98f8a524d
14 changed files with 5 additions and 97 deletions
|
|
@ -15,7 +15,6 @@
|
||||||
#include "common/Constants.h"
|
#include "common/Constants.h"
|
||||||
#include "common/ExitCodes.h"
|
#include "common/ExitCodes.h"
|
||||||
#include "common/Settings.h"
|
#include "common/Settings.h"
|
||||||
#include "deskflow/ArgsBase.h"
|
|
||||||
#include "deskflow/Config.h"
|
#include "deskflow/Config.h"
|
||||||
#include "deskflow/DeskflowException.h"
|
#include "deskflow/DeskflowException.h"
|
||||||
#include "deskflow/ProtocolTypes.h"
|
#include "deskflow/ProtocolTypes.h"
|
||||||
|
|
@ -48,10 +47,9 @@ App *App::s_instance = nullptr;
|
||||||
// App
|
// App
|
||||||
//
|
//
|
||||||
|
|
||||||
App::App(IEventQueue *events, const QString &processName, deskflow::ArgsBase *args)
|
App::App(IEventQueue *events, const QString &processName)
|
||||||
: m_bye(&exit),
|
: m_bye(&exit),
|
||||||
m_events(events),
|
m_events(events),
|
||||||
m_args(args),
|
|
||||||
m_appUtil(events),
|
m_appUtil(events),
|
||||||
m_pname(processName)
|
m_pname(processName)
|
||||||
{
|
{
|
||||||
|
|
@ -65,7 +63,6 @@ App::App(IEventQueue *events, const QString &processName, deskflow::ArgsBase *ar
|
||||||
App::~App()
|
App::~App()
|
||||||
{
|
{
|
||||||
s_instance = nullptr;
|
s_instance = nullptr;
|
||||||
delete m_args;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int App::run(int argc, char **argv)
|
int App::run(int argc, char **argv)
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
App(IEventQueue *events, const QString &processName, deskflow::ArgsBase *args);
|
App(IEventQueue *events, const QString &processName);
|
||||||
App(App const &) = delete;
|
App(App const &) = delete;
|
||||||
App(App &&) = delete;
|
App(App &&) = delete;
|
||||||
~App() override;
|
~App() override;
|
||||||
|
|
@ -75,10 +75,7 @@ public:
|
||||||
{
|
{
|
||||||
return m_appUtil;
|
return m_appUtil;
|
||||||
}
|
}
|
||||||
deskflow::ArgsBase &argsBase() const override
|
|
||||||
{
|
|
||||||
return *m_args;
|
|
||||||
}
|
|
||||||
int run(int argc, char **argv);
|
int run(int argc, char **argv);
|
||||||
int daemonMainLoop(int, const char **);
|
int daemonMainLoop(int, const char **);
|
||||||
void setupFileLogging();
|
void setupFileLogging();
|
||||||
|
|
@ -121,7 +118,6 @@ protected:
|
||||||
private:
|
private:
|
||||||
void (*m_bye)(int);
|
void (*m_bye)(int);
|
||||||
IEventQueue *m_events = nullptr;
|
IEventQueue *m_events = nullptr;
|
||||||
deskflow::ArgsBase *m_args;
|
|
||||||
static App *s_instance;
|
static App *s_instance;
|
||||||
FileLogOutputter *m_fileLog = nullptr;
|
FileLogOutputter *m_fileLog = nullptr;
|
||||||
ARCH_APP_UTIL m_appUtil;
|
ARCH_APP_UTIL m_appUtil;
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@
|
||||||
|
|
||||||
#include "base/Log.h"
|
#include "base/Log.h"
|
||||||
#include "deskflow/App.h"
|
#include "deskflow/App.h"
|
||||||
#include "deskflow/ArgsBase.h"
|
|
||||||
|
|
||||||
#ifdef WINAPI_MSWINDOWS
|
#ifdef WINAPI_MSWINDOWS
|
||||||
#include <VersionHelpers.h>
|
#include <VersionHelpers.h>
|
||||||
|
|
@ -17,8 +16,6 @@
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QSysInfo>
|
#include <QSysInfo>
|
||||||
|
|
||||||
deskflow::ArgsBase *ArgParser::m_argsBase = nullptr;
|
|
||||||
|
|
||||||
ArgParser::ArgParser(App *app) : m_app(app)
|
ArgParser::ArgParser(App *app) : m_app(app)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
@ -29,7 +26,6 @@ bool ArgParser::parseGenericArgs(int argc, const char *const *argv, int &i) cons
|
||||||
if (m_app) {
|
if (m_app) {
|
||||||
m_app->help();
|
m_app->help();
|
||||||
}
|
}
|
||||||
argsBase().m_shouldExitOk = true;
|
|
||||||
} else {
|
} else {
|
||||||
// option not supported here
|
// option not supported here
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -62,7 +58,6 @@ bool ArgParser::isArg(
|
||||||
// match. check args left.
|
// match. check args left.
|
||||||
if (argi + minRequiredParameters >= argc) {
|
if (argi + minRequiredParameters >= argc) {
|
||||||
LOG_PRINT("%s: missing arguments for `%s'" BYE, "deskflow-core", argv[argi], "deskflow-core");
|
LOG_PRINT("%s: missing arguments for `%s'" BYE, "deskflow-core", argv[argi], "deskflow-core");
|
||||||
argsBase().m_shouldExitFail = true;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace deskflow {
|
namespace deskflow {
|
||||||
class ArgsBase;
|
|
||||||
class ServerArgs;
|
class ServerArgs;
|
||||||
} // namespace deskflow
|
} // namespace deskflow
|
||||||
|
|
||||||
|
|
@ -24,10 +23,6 @@ public:
|
||||||
|
|
||||||
bool parseGenericArgs(int argc, const char *const *argv, int &i) const;
|
bool parseGenericArgs(int argc, const char *const *argv, int &i) const;
|
||||||
bool parseDeprecatedArgs(int argc, const char *const *argv, int &i) const;
|
bool parseDeprecatedArgs(int argc, const char *const *argv, int &i) const;
|
||||||
void setArgsBase(deskflow::ArgsBase &argsBase) const
|
|
||||||
{
|
|
||||||
m_argsBase = &argsBase;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool isArg(
|
static bool isArg(
|
||||||
int argi, int argc, const char *const *argv, const char *name1, const char *name2, int minRequiredParameters = 0
|
int argi, int argc, const char *const *argv, const char *name1, const char *name2, int minRequiredParameters = 0
|
||||||
|
|
@ -41,16 +36,9 @@ public:
|
||||||
int parametersRequired = 0
|
int parametersRequired = 0
|
||||||
);
|
);
|
||||||
|
|
||||||
static deskflow::ArgsBase &argsBase()
|
|
||||||
{
|
|
||||||
return *m_argsBase;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool checkUnexpectedArgs() const;
|
bool checkUnexpectedArgs() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
App *m_app;
|
App *m_app;
|
||||||
|
|
||||||
static deskflow::ArgsBase *m_argsBase;
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,49 +0,0 @@
|
||||||
/*
|
|
||||||
* Deskflow -- mouse and keyboard sharing utility
|
|
||||||
* SPDX-FileCopyrightText: (C) 2012 Symless Ltd.
|
|
||||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace deskflow {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief This is the base Argument class that will store the generic
|
|
||||||
* arguments passed into the applications this will be derived
|
|
||||||
* from and expanded to include application specific arguments
|
|
||||||
*/
|
|
||||||
class ArgsBase
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ArgsBase() = default;
|
|
||||||
virtual ~ArgsBase() = default;
|
|
||||||
|
|
||||||
/// @brief This sets the type of the derived class
|
|
||||||
enum class ClassType
|
|
||||||
{
|
|
||||||
Base,
|
|
||||||
Server,
|
|
||||||
Client
|
|
||||||
};
|
|
||||||
|
|
||||||
/// @brief Stores what type of object this is
|
|
||||||
ClassType m_classType = ClassType::Base;
|
|
||||||
|
|
||||||
/// @brief Will cause the application to exit with OK code when set to true
|
|
||||||
bool m_shouldExitOk = false;
|
|
||||||
|
|
||||||
/// @brief Will cause the application to exit with fail code when set to true
|
|
||||||
bool m_shouldExitFail = false;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
/// @brief deletes pointers and sets the value to null
|
|
||||||
template <class T> static inline void destroy(T *&p)
|
|
||||||
{
|
|
||||||
delete p;
|
|
||||||
p = 0;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} // namespace deskflow
|
|
||||||
|
|
@ -69,7 +69,6 @@ add_library(${lib_name} STATIC ${PLATFORM_CODE}
|
||||||
AppUtil.h
|
AppUtil.h
|
||||||
ArgParser.cpp
|
ArgParser.cpp
|
||||||
ArgParser.h
|
ArgParser.h
|
||||||
ArgsBase.h
|
|
||||||
Chunk.cpp
|
Chunk.cpp
|
||||||
Chunk.h
|
Chunk.h
|
||||||
ClientApp.cpp
|
ClientApp.cpp
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@
|
||||||
#include "common/ExitCodes.h"
|
#include "common/ExitCodes.h"
|
||||||
#include "common/Settings.h"
|
#include "common/Settings.h"
|
||||||
#include "deskflow/ArgParser.h"
|
#include "deskflow/ArgParser.h"
|
||||||
#include "deskflow/ArgsBase.h"
|
|
||||||
#include "deskflow/ProtocolTypes.h"
|
#include "deskflow/ProtocolTypes.h"
|
||||||
#include "deskflow/Screen.h"
|
#include "deskflow/Screen.h"
|
||||||
#include "deskflow/ScreenException.h"
|
#include "deskflow/ScreenException.h"
|
||||||
|
|
@ -62,8 +61,7 @@
|
||||||
|
|
||||||
constexpr static auto s_retryTime = 1.0;
|
constexpr static auto s_retryTime = 1.0;
|
||||||
|
|
||||||
ClientApp::ClientApp(IEventQueue *events, const QString &processName)
|
ClientApp::ClientApp(IEventQueue *events, const QString &processName) : App(events, processName)
|
||||||
: App(events, processName, new deskflow::ArgsBase())
|
|
||||||
{
|
{
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@
|
||||||
using StartupFunc = int (*)(int, char **);
|
using StartupFunc = int (*)(int, char **);
|
||||||
|
|
||||||
namespace deskflow {
|
namespace deskflow {
|
||||||
class ArgsBase;
|
|
||||||
class Screen;
|
class Screen;
|
||||||
} // namespace deskflow
|
} // namespace deskflow
|
||||||
|
|
||||||
|
|
@ -22,7 +21,6 @@ class IApp
|
||||||
public:
|
public:
|
||||||
virtual ~IApp() = default;
|
virtual ~IApp() = default;
|
||||||
virtual void setByeFunc(void (*bye)(int)) = 0;
|
virtual void setByeFunc(void (*bye)(int)) = 0;
|
||||||
virtual deskflow::ArgsBase &argsBase() const = 0;
|
|
||||||
virtual int start(int argc, char **argv) = 0;
|
virtual int start(int argc, char **argv) = 0;
|
||||||
virtual int runInner(int argc, char **argv, StartupFunc startup) = 0;
|
virtual int runInner(int argc, char **argv, StartupFunc startup) = 0;
|
||||||
virtual void startNode() = 0;
|
virtual void startNode() = 0;
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,6 @@
|
||||||
#include "common/Settings.h"
|
#include "common/Settings.h"
|
||||||
#include "deskflow/App.h"
|
#include "deskflow/App.h"
|
||||||
#include "deskflow/ArgParser.h"
|
#include "deskflow/ArgParser.h"
|
||||||
#include "deskflow/ArgsBase.h"
|
|
||||||
#include "deskflow/Screen.h"
|
#include "deskflow/Screen.h"
|
||||||
#include "deskflow/ScreenException.h"
|
#include "deskflow/ScreenException.h"
|
||||||
#include "net/SocketException.h"
|
#include "net/SocketException.h"
|
||||||
|
|
@ -69,8 +68,7 @@ using namespace deskflow::server;
|
||||||
// ServerApp
|
// ServerApp
|
||||||
//
|
//
|
||||||
|
|
||||||
ServerApp::ServerApp(IEventQueue *events, const QString &processName)
|
ServerApp::ServerApp(IEventQueue *events, const QString &processName) : App(events, processName)
|
||||||
: App(events, processName, new deskflow::ArgsBase())
|
|
||||||
{
|
{
|
||||||
m_name = Settings::value(Settings::Core::ScreenName).toString().toStdString();
|
m_name = Settings::value(Settings::Core::ScreenName).toString().toStdString();
|
||||||
// do nothing
|
// do nothing
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,6 @@
|
||||||
#include "base/LogOutputters.h"
|
#include "base/LogOutputters.h"
|
||||||
#include "common/Constants.h"
|
#include "common/Constants.h"
|
||||||
#include "deskflow/App.h"
|
#include "deskflow/App.h"
|
||||||
#include "deskflow/ArgsBase.h"
|
|
||||||
#include "deskflow/DeskflowException.h"
|
#include "deskflow/DeskflowException.h"
|
||||||
#include "deskflow/Screen.h"
|
#include "deskflow/Screen.h"
|
||||||
#include "platform/MSWindowsScreen.h"
|
#include "platform/MSWindowsScreen.h"
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@
|
||||||
#include "base/String.h"
|
#include "base/String.h"
|
||||||
#include "common/Settings.h"
|
#include "common/Settings.h"
|
||||||
#include "deskflow/ArgParser.h"
|
#include "deskflow/ArgParser.h"
|
||||||
#include "deskflow/ArgsBase.h"
|
|
||||||
#include "net/NetworkAddress.h"
|
#include "net/NetworkAddress.h"
|
||||||
#include "net/SocketMultiplexer.h"
|
#include "net/SocketMultiplexer.h"
|
||||||
#include "net/TSocketMultiplexerMethodJob.h"
|
#include "net/TSocketMultiplexerMethodJob.h"
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@
|
||||||
#include "common/Constants.h"
|
#include "common/Constants.h"
|
||||||
#include "common/Settings.h"
|
#include "common/Settings.h"
|
||||||
#include "deskflow/App.h"
|
#include "deskflow/App.h"
|
||||||
#include "deskflow/ArgsBase.h"
|
|
||||||
#include "deskflow/ClientApp.h"
|
#include "deskflow/ClientApp.h"
|
||||||
#include "deskflow/Clipboard.h"
|
#include "deskflow/Clipboard.h"
|
||||||
#include "deskflow/KeyMap.h"
|
#include "deskflow/KeyMap.h"
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,6 @@
|
||||||
#include "base/Log.h"
|
#include "base/Log.h"
|
||||||
#include "base/Stopwatch.h"
|
#include "base/Stopwatch.h"
|
||||||
#include "deskflow/App.h"
|
#include "deskflow/App.h"
|
||||||
#include "deskflow/ArgsBase.h"
|
|
||||||
#include "deskflow/ClientApp.h"
|
#include "deskflow/ClientApp.h"
|
||||||
#include "deskflow/Clipboard.h"
|
#include "deskflow/Clipboard.h"
|
||||||
#include "deskflow/KeyMap.h"
|
#include "deskflow/KeyMap.h"
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,6 @@
|
||||||
|
|
||||||
#include "ArgParserTests.h"
|
#include "ArgParserTests.h"
|
||||||
|
|
||||||
#include "deskflow/ArgsBase.h"
|
|
||||||
|
|
||||||
// This file is generated at build time
|
// This file is generated at build time
|
||||||
#include <common/Constants.h>
|
#include <common/Constants.h>
|
||||||
|
|
||||||
|
|
@ -16,8 +14,6 @@ void ArgParserTests::initTestCase()
|
||||||
{
|
{
|
||||||
m_arch.init();
|
m_arch.init();
|
||||||
m_log.setFilter(LogLevel::Debug2);
|
m_log.setFilter(LogLevel::Debug2);
|
||||||
static deskflow::ArgsBase base;
|
|
||||||
m_parser.setArgsBase(base);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArgParserTests::isArg()
|
void ArgParserTests::isArg()
|
||||||
|
|
@ -36,12 +32,8 @@ void ArgParserTests::missingArg()
|
||||||
int i = 1;
|
int i = 1;
|
||||||
const int argc = 2;
|
const int argc = 2;
|
||||||
const char *argv[argc] = {"stub", "-t"};
|
const char *argv[argc] = {"stub", "-t"};
|
||||||
static deskflow::ArgsBase argsBase;
|
|
||||||
|
|
||||||
m_parser.setArgsBase(argsBase);
|
|
||||||
|
|
||||||
QVERIFY(!ArgParser::isArg(i, argc, argv, "-t", NULL, 1));
|
QVERIFY(!ArgParser::isArg(i, argc, argv, "-t", NULL, 1));
|
||||||
QVERIFY(argsBase.m_shouldExitFail);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArgParserTests::withQuotes()
|
void ArgParserTests::withQuotes()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue