remove: argsBase

This commit is contained in:
sithlord48
2025-09-25 22:10:49 -04:00
committed by Chris Rizzitello
parent 37827f0540
commit d98f8a524d
14 changed files with 5 additions and 97 deletions

View File

@ -15,7 +15,6 @@
#include "common/Constants.h"
#include "common/ExitCodes.h"
#include "common/Settings.h"
#include "deskflow/ArgsBase.h"
#include "deskflow/Config.h"
#include "deskflow/DeskflowException.h"
#include "deskflow/ProtocolTypes.h"
@ -48,10 +47,9 @@ App *App::s_instance = nullptr;
// App
//
App::App(IEventQueue *events, const QString &processName, deskflow::ArgsBase *args)
App::App(IEventQueue *events, const QString &processName)
: m_bye(&exit),
m_events(events),
m_args(args),
m_appUtil(events),
m_pname(processName)
{
@ -65,7 +63,6 @@ App::App(IEventQueue *events, const QString &processName, deskflow::ArgsBase *ar
App::~App()
{
s_instance = nullptr;
delete m_args;
}
int App::run(int argc, char **argv)

View File

@ -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 &&) = delete;
~App() override;
@ -75,10 +75,7 @@ public:
{
return m_appUtil;
}
deskflow::ArgsBase &argsBase() const override
{
return *m_args;
}
int run(int argc, char **argv);
int daemonMainLoop(int, const char **);
void setupFileLogging();
@ -121,7 +118,6 @@ protected:
private:
void (*m_bye)(int);
IEventQueue *m_events = nullptr;
deskflow::ArgsBase *m_args;
static App *s_instance;
FileLogOutputter *m_fileLog = nullptr;
ARCH_APP_UTIL m_appUtil;

View File

@ -8,7 +8,6 @@
#include "base/Log.h"
#include "deskflow/App.h"
#include "deskflow/ArgsBase.h"
#ifdef WINAPI_MSWINDOWS
#include <VersionHelpers.h>
@ -17,8 +16,6 @@
#include <QFileInfo>
#include <QSysInfo>
deskflow::ArgsBase *ArgParser::m_argsBase = nullptr;
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) {
m_app->help();
}
argsBase().m_shouldExitOk = true;
} else {
// option not supported here
return false;
@ -62,7 +58,6 @@ bool ArgParser::isArg(
// match. check args left.
if (argi + minRequiredParameters >= argc) {
LOG_PRINT("%s: missing arguments for `%s'" BYE, "deskflow-core", argv[argi], "deskflow-core");
argsBase().m_shouldExitFail = true;
return false;
}
return true;

View File

@ -10,7 +10,6 @@
#include <vector>
namespace deskflow {
class ArgsBase;
class ServerArgs;
} // namespace deskflow
@ -24,10 +23,6 @@ public:
bool parseGenericArgs(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(
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
);
static deskflow::ArgsBase &argsBase()
{
return *m_argsBase;
}
private:
bool checkUnexpectedArgs() const;
private:
App *m_app;
static deskflow::ArgsBase *m_argsBase;
};

View File

@ -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

View File

@ -69,7 +69,6 @@ add_library(${lib_name} STATIC ${PLATFORM_CODE}
AppUtil.h
ArgParser.cpp
ArgParser.h
ArgsBase.h
Chunk.cpp
Chunk.h
ClientApp.cpp

View File

@ -17,7 +17,6 @@
#include "common/ExitCodes.h"
#include "common/Settings.h"
#include "deskflow/ArgParser.h"
#include "deskflow/ArgsBase.h"
#include "deskflow/ProtocolTypes.h"
#include "deskflow/Screen.h"
#include "deskflow/ScreenException.h"
@ -62,8 +61,7 @@
constexpr static auto s_retryTime = 1.0;
ClientApp::ClientApp(IEventQueue *events, const QString &processName)
: App(events, processName, new deskflow::ArgsBase())
ClientApp::ClientApp(IEventQueue *events, const QString &processName) : App(events, processName)
{
// do nothing
}

View File

@ -11,7 +11,6 @@
using StartupFunc = int (*)(int, char **);
namespace deskflow {
class ArgsBase;
class Screen;
} // namespace deskflow
@ -22,7 +21,6 @@ class IApp
public:
virtual ~IApp() = default;
virtual void setByeFunc(void (*bye)(int)) = 0;
virtual deskflow::ArgsBase &argsBase() const = 0;
virtual int start(int argc, char **argv) = 0;
virtual int runInner(int argc, char **argv, StartupFunc startup) = 0;
virtual void startNode() = 0;

View File

@ -16,7 +16,6 @@
#include "common/Settings.h"
#include "deskflow/App.h"
#include "deskflow/ArgParser.h"
#include "deskflow/ArgsBase.h"
#include "deskflow/Screen.h"
#include "deskflow/ScreenException.h"
#include "net/SocketException.h"
@ -69,8 +68,7 @@ using namespace deskflow::server;
// ServerApp
//
ServerApp::ServerApp(IEventQueue *events, const QString &processName)
: App(events, processName, new deskflow::ArgsBase())
ServerApp::ServerApp(IEventQueue *events, const QString &processName) : App(events, processName)
{
m_name = Settings::value(Settings::Core::ScreenName).toString().toStdString();
// do nothing

View File

@ -16,7 +16,6 @@
#include "base/LogOutputters.h"
#include "common/Constants.h"
#include "deskflow/App.h"
#include "deskflow/ArgsBase.h"
#include "deskflow/DeskflowException.h"
#include "deskflow/Screen.h"
#include "platform/MSWindowsScreen.h"

View File

@ -12,7 +12,6 @@
#include "base/String.h"
#include "common/Settings.h"
#include "deskflow/ArgParser.h"
#include "deskflow/ArgsBase.h"
#include "net/NetworkAddress.h"
#include "net/SocketMultiplexer.h"
#include "net/TSocketMultiplexerMethodJob.h"

View File

@ -18,7 +18,6 @@
#include "common/Constants.h"
#include "common/Settings.h"
#include "deskflow/App.h"
#include "deskflow/ArgsBase.h"
#include "deskflow/ClientApp.h"
#include "deskflow/Clipboard.h"
#include "deskflow/KeyMap.h"

View File

@ -16,7 +16,6 @@
#include "base/Log.h"
#include "base/Stopwatch.h"
#include "deskflow/App.h"
#include "deskflow/ArgsBase.h"
#include "deskflow/ClientApp.h"
#include "deskflow/Clipboard.h"
#include "deskflow/KeyMap.h"

View File

@ -7,8 +7,6 @@
#include "ArgParserTests.h"
#include "deskflow/ArgsBase.h"
// This file is generated at build time
#include <common/Constants.h>
@ -16,8 +14,6 @@ void ArgParserTests::initTestCase()
{
m_arch.init();
m_log.setFilter(LogLevel::Debug2);
static deskflow::ArgsBase base;
m_parser.setArgsBase(base);
}
void ArgParserTests::isArg()
@ -36,12 +32,8 @@ void ArgParserTests::missingArg()
int i = 1;
const int argc = 2;
const char *argv[argc] = {"stub", "-t"};
static deskflow::ArgsBase argsBase;
m_parser.setArgsBase(argsBase);
QVERIFY(!ArgParser::isArg(i, argc, argv, "-t", NULL, 1));
QVERIFY(argsBase.m_shouldExitFail);
}
void ArgParserTests::withQuotes()