diff --git a/.github/actions/install-dependencies/action.yml b/.github/actions/install-dependencies/action.yml index 2dfe1ba4b..7187323b7 100644 --- a/.github/actions/install-dependencies/action.yml +++ b/.github/actions/install-dependencies/action.yml @@ -38,26 +38,25 @@ runs: xorg-dev libx11-dev libxtst-dev libssl-dev \ libglib2.0-dev libxkbfile-dev qt6-base-dev qt6-tools-dev \ libgtk-3-dev libgtest-dev libgmock-dev \ - libei-dev libportal-dev libtomlplusplus-dev libcli11-dev \ + libei-dev libportal-dev libcli11-dev \ help2man -y >/dev/null elif [ ${{inputs.like}} == "fedora" ]; then dnf install -y cmake make ninja-build gcc-c++ \ rpm-build openssl-devel glib2-devel \ libXtst-devel libxkbfile-devel qt6-qtbase-devel qt6-qttools-devel \ gtk3-devel gtest-devel gmock-devel \ - libei-devel libportal-devel tomlplusplus-devel \ - cli11-devel help2man + libei-devel libportal-devel cli11-devel help2man elif [ ${{inputs.like}} == "suse" ]; then zypper refresh zypper install -y --force-resolution \ cmake make ninja gcc-c++ rpm-build libopenssl-devel \ glib2-devel libXtst-devel libxkbfile-devel qt6-base-devel qt6-tools-devel gtk3-devel \ googletest-devel googlemock-devel libei-devel \ - libportal-devel tomlplusplus-devel cli11-devel help2man + libportal-devel cli11-devel help2man elif [ ${{ inputs.like }} == "arch" ]; then pacman -Syu --noconfirm base-devel cmake ninja \ gcc openssl glib2 libxtst libxkbfile gtest libei libportal \ - qt6-base qt6-tools qt6-svg gtk3 tomlplusplus cli11 help2man doxygen graphviz rsync + qt6-base qt6-tools qt6-svg gtk3 cli11 help2man doxygen graphviz rsync else echo "Unknown like" fi diff --git a/deploy/linux/arch/PKGBUILD.in b/deploy/linux/arch/PKGBUILD.in index 69a187971..b5744a165 100644 --- a/deploy/linux/arch/PKGBUILD.in +++ b/deploy/linux/arch/PKGBUILD.in @@ -33,7 +33,6 @@ depends=( openssl qt6-base qt6-svg - tomlplusplus ) options=('!debug') diff --git a/deploy/linux/flatpak/org.deskflow.deskflow.yml b/deploy/linux/flatpak/org.deskflow.deskflow.yml index a5b549956..3ff68645d 100644 --- a/deploy/linux/flatpak/org.deskflow.deskflow.yml +++ b/deploy/linux/flatpak/org.deskflow.deskflow.yml @@ -17,7 +17,6 @@ cleanup: - /lib/cmake - /lib/pkgconfig - /share/pkgconfig - - /share/tomlplusplus - /share/cmake - /share/doc - /share/gir-1.0 @@ -72,13 +71,6 @@ modules: url: https://github.com/CLIUtils/CLI11 tag: v2.5.0 commit: 4160d259d961cd393fd8d67590a8c7d210207348 - - name: tomlplusplus - buildsystem: cmake-ninja - sources: - - type: git - url: https://github.com/marzer/tomlplusplus - tag: v3.4.0 - commit: 30172438cee64926dc41fdd9c11fb3ba5b2ba9de - name: gtest buildsystem: cmake-ninja sources: diff --git a/doc/dev/build.md b/doc/dev/build.md index 924dcf3d7..5b4630495 100644 --- a/doc/dev/build.md +++ b/doc/dev/build.md @@ -7,7 +7,6 @@ To build Deskflow you will a minimum of: - [libportal] 0.8+ (linux, bsd) - [libei] 1.3+ (linux, bsd) - [google_test] ^ - - [tomlplusplus] ^ - [cli11] ^ > ^ Will be fetched if not found on the host system. @@ -76,7 +75,6 @@ After configuring you should be able to run make to build all targets. [cmake]:https://cmake.org/ [openssl]:https://www.openssl.org/ [google_test]:https://github.com/google/googletest -[tomlplusplus]:https://github.com/marzer/tomlplusplus [cli11]:https://github.com/CLIUtils/CLI11 [libei]:https://gitlab.freedesktop.org/libinput/libei [libportal]:https://github.com/flatpak/libportal diff --git a/doc/user/configuration.md b/doc/user/configuration.md index adab7035a..b6b8b2b66 100644 --- a/doc/user/configuration.md +++ b/doc/user/configuration.md @@ -803,25 +803,6 @@ section: links end ``` -# Example file for `--config-toml` arg - -``` -[server.args] -no-daemon = true -no-tray = true -debug = "DEBUG" -name = "moe" -address = ":24800" - -[client.args] -no-daemon = true -no-tray = true -debug = "DEBUG2" -name = "larry" -_last = "moe:24800" -``` - - # Example `.env` file diff --git a/src/lib/deskflow/App.cpp b/src/lib/deskflow/App.cpp index f5f1ffd99..2f878f0ec 100644 --- a/src/lib/deskflow/App.cpp +++ b/src/lib/deskflow/App.cpp @@ -15,7 +15,6 @@ #include "common/Constants.h" #include "common/ExitCodes.h" #include "common/Settings.h" -#include "deskflow/Config.h" #include "deskflow/DeskflowException.h" #include "deskflow/ProtocolTypes.h" @@ -143,9 +142,7 @@ void App::loggingFilterWarning() const void App::initApp(int argc, const char **argv) { - std::string configFilename; CLI::App cliApp{kAppDescription}; - cliApp.add_option("--config-toml", configFilename, "Use TOML configuration file"); // Allow legacy args. cliApp.allow_extras(); @@ -157,14 +154,7 @@ void App::initApp(int argc, const char **argv) cliApp.exit(e); } - if (!configFilename.empty()) { - Config config(configFilename, configSection()); - if (config.load(argv[0])) { - parseArgs(); - } - } else { - parseArgs(); - } + parseArgs(); // set log filter if (const auto logLevel = qPrintable(Settings::logLevelText()); !CLOG->setFilter(logLevel)) { diff --git a/src/lib/deskflow/CMakeLists.txt b/src/lib/deskflow/CMakeLists.txt index 49da6c155..4b9e293ab 100644 --- a/src/lib/deskflow/CMakeLists.txt +++ b/src/lib/deskflow/CMakeLists.txt @@ -21,26 +21,6 @@ else() message(STATUS "CLI11 INC_DIR: ${cli11_inc_dir}") endif() -find_package(tomlplusplus QUIET) -if(tomlplusplus_FOUND) - message(STATUS "tomlplusplus [System] Version: ${tomlplusplus_VERSION}") - set(tomlPP_lib tomlplusplus::tomlplusplus) -else() - # Be sure to update the version and MD5 together - # Save our copy with .h not .hpp for compatibliy with system version < 3.4 - set(TOMLPP_VERSION 3.4.0) - set(TOMLPP_MD5 caefb3b60119731fb4b4d24b6339e7fb) - file( - DOWNLOAD "https://raw.githubusercontent.com/marzer/tomlplusplus/refs/tags/v${TOMLPP_VERSION}/toml.hpp" - "${CMAKE_BINARY_DIR}/include/toml++/toml.h" - SHOW_PROGRESS - EXPECTED_MD5 ${TOMLPP_MD5} - ) - set(tomlPP_inc_dir "${CMAKE_BINARY_DIR}/include") - message(STATUS "tomlplusplus [Downloaded] Version: 3.4.0") - message(STATUS "tomlplusplus INC DIR: ${tomlPP_inc_dir}") -endif() - ####################Start Making Library######################### set(lib_name app) @@ -76,8 +56,6 @@ add_library(${lib_name} STATIC ${PLATFORM_CODE} Clipboard.h ClipboardChunk.cpp ClipboardChunk.h - Config.cpp - Config.h CoreArgParser.cpp CoreArgParser.h CoreArgs.h @@ -132,14 +110,13 @@ add_library(${lib_name} STATIC ${PLATFORM_CODE} target_link_libraries(${lib_name} PUBLIC common Qt6::Core Qt6::Network) if(WIN32) - target_link_libraries(${lib_name} PRIVATE ${cli11_lib} ${tomlPP_lib}) + target_link_libraries(${lib_name} PRIVATE ${cli11_lib}) endif() target_include_directories( ${lib_name} PRIVATE ${cli11_inc_dir} - ${tomlPP_inc_dir} ) if(UNIX) @@ -154,7 +131,6 @@ if(UNIX) mt server ${cli11_lib} - ${tomlPP_lib} ) if(NOT APPLE) diff --git a/src/lib/deskflow/Config.cpp b/src/lib/deskflow/Config.cpp deleted file mode 100644 index 5dcbab41c..000000000 --- a/src/lib/deskflow/Config.cpp +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Deskflow -- mouse and keyboard sharing utility - * SPDX-FileCopyrightText: (C) 2024 Symless Ltd. - * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception - */ - -#include "Config.h" - -#include "base/Log.h" - -#include -#include -#include -#include - -// Use .h for fallback with 3.3.0 -#include - -namespace deskflow { - -Config::Config(const std::string &filename, const std::string §ion) : m_filename(filename), m_section(section) -{ - // do nothing -} - -const char *const *Config::argv() const -{ - return m_argv.data(); -} - -int Config::argc() const -{ - return static_cast(m_argv.size()); -} - -bool Config::load(const std::string &firstArg) -{ - - if (!firstArg.empty()) { - m_args.push_back(firstArg); - } - - if (m_filename.empty()) { - throw NoConfigFilenameError(); - } - - if (!std::filesystem::exists(m_filename)) { - LOG_ERR("config file not found: %s", m_filename.c_str()); - return false; - } - - toml::table configTable; - try { - LOG_INFO("loading config file: %s", m_filename.c_str()); - configTable = toml::parse_file(m_filename); - - } catch (const toml::parse_error &err) { - LOG_ERR("toml parse error: %s", err.what()); - throw ParseError(); - } catch (const std::exception &err) { - LOG_ERR("unknown parse error: %s", err.what()); - throw ParseError(); - } - - if (!configTable.contains(m_section)) { - LOG_WARN("no %s section found in config file", m_section.c_str()); - return false; - } - - const auto §ion = configTable[m_section]; - const auto args = section["args"]; - if (!args.is_table()) { - LOG_WARN("no args table found in config file"); - return false; - } - - std::string specialLastArg = ""; - const auto &table = *(args.as_table()); - for (const auto &pair : table) { - const auto &key = pair.first; - if (key.str() == "_last") { - specialLastArg = pair.second.as_string()->get(); - continue; - } - - m_args.push_back("--" + std::string(key.str())); - - if (pair.second.is_string()) { - const auto value = pair.second.as_string()->get(); - m_args.push_back(value); - } - } - - if (!specialLastArg.empty()) { - m_args.push_back(specialLastArg); - } - - if (m_args.empty()) { - LOG_WARN("no args loaded from config file"); - return false; - } - - for (const auto &arg : m_args) { - m_argv.push_back(arg.c_str()); - } - - return true; -} - -} // namespace deskflow diff --git a/src/lib/deskflow/Config.h b/src/lib/deskflow/Config.h deleted file mode 100644 index e0f6133bf..000000000 --- a/src/lib/deskflow/Config.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Deskflow -- mouse and keyboard sharing utility - * SPDX-FileCopyrightText: (C) 2024 Symless Ltd. - * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception - */ - -#pragma once - -#include -#include -#include - -namespace deskflow { - -//! App configuration -/*! -Parses a configuration file describing start args and potentially other -configuration options in future. The configuration file is in TOML format. - -Initially this class was created to as a developer convenience; it is a -convenient place to specify args without needing to fiddle with IDE configs. -*/ -class Config -{ -public: - class ParseError : public std::runtime_error - { - public: - explicit ParseError() : std::runtime_error("failed to parse config file") - { - // do nothing - } - }; - - class NoConfigFilenameError : public std::runtime_error - { - public: - explicit NoConfigFilenameError() : std::runtime_error("no config file specified") - { - // do nothing - } - }; - - explicit Config(const std::string &filename, const std::string §ion); - - bool load(const std::string &firstArg); - const char *const *argv() const; - int argc() const; - -private: - std::string m_filename; - std::string m_section; - std::vector m_args; - std::vector m_argv; -}; - -} // namespace deskflow diff --git a/src/unittests/deskflow/CMakeLists.txt b/src/unittests/deskflow/CMakeLists.txt index b7d136415..5a778ea98 100644 --- a/src/unittests/deskflow/CMakeLists.txt +++ b/src/unittests/deskflow/CMakeLists.txt @@ -29,14 +29,6 @@ create_test( WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/src/lib/deskflow" ) -create_test( - NAME ConfigTests - DEPENDS app - LIBS arch base ${extra_libs} - SOURCE ConfigTests.cpp - WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/src/lib/deskflow" -) - create_test( NAME IKeyStateTests DEPENDS app diff --git a/src/unittests/deskflow/ConfigTests.cpp b/src/unittests/deskflow/ConfigTests.cpp deleted file mode 100644 index 12e20083d..000000000 --- a/src/unittests/deskflow/ConfigTests.cpp +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Deskflow -- mouse and keyboard sharing utility - * SPDX-FileCopyrightText: (C) 2025 Chris Rizzitello - * SPDX-FileCopyrightText: (C) 2024 Symless Ltd. - * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception - */ - -#include "ConfigTests.h" - -#include "deskflow/Config.h" - -using namespace deskflow; -const auto kTestFilename = "tmp/test/test.toml"; - -void ConfigTests::initTestCase() -{ - QDir dir; - QVERIFY(dir.mkpath("tmp/test")); - - m_arch.init(); - m_log.setFilter(LogLevel::Debug2); -} - -void ConfigTests::loadFile() -{ - QFile testFile(kTestFilename); - QVERIFY(testFile.open(QIODevice::WriteOnly | QIODevice::Text)); - - QTextStream out(&testFile); - out << "[test.args]\n" - R"(test-arg = "test opt")"; - - testFile.close(); - QVERIFY(!testFile.isOpen()); - - Config config(kTestFilename, "test"); - - const auto result = config.load("test"); - QVERIFY(result); - QCOMPARE(config.argc(), 3); - QCOMPARE(config.argv()[0], "test"); - QCOMPARE(config.argv()[1], "--test-arg"); - QCOMPARE(config.argv()[2], "test opt"); -} - -void ConfigTests::load_EmptyFile() -{ - Config config("", "test"); - QVERIFY_THROWS_EXCEPTION(Config::NoConfigFilenameError, config.load("test")); -} - -void ConfigTests::load_NonExsitingFile() -{ - Config config("nonexistent.toml", "test"); - - const auto result = config.load("test"); - QVERIFY(!result); -} - -void ConfigTests::load_InvalidConfig() -{ - QFile testFile(kTestFilename); - QVERIFY(testFile.open(QIODevice::WriteOnly)); - - QVERIFY(testFile.write("foobar")); - - testFile.close(); - QVERIFY(!testFile.isOpen()); - - Config config(kTestFilename, "test"); - QVERIFY_THROWS_EXCEPTION(Config::ParseError, config.load("test")); -} - -void ConfigTests::load_missingSections() -{ - QFile testFile(kTestFilename); - QVERIFY(testFile.open(QIODevice::WriteOnly)); - - testFile.close(); - QVERIFY(!testFile.isOpen()); - - Config config(kTestFilename, "missing"); - const auto result = config.load("test"); - QVERIFY(!result); -} - -void ConfigTests::load_badTable() -{ - QFile testFile(kTestFilename); - QVERIFY(testFile.open(QIODevice::WriteOnly)); - - QVERIFY(testFile.write("[test]")); - - testFile.close(); - QVERIFY(!testFile.isOpen()); - - Config config(kTestFilename, "test"); - - const auto result = config.load("test"); - QVERIFY(!result); -} - -void ConfigTests::load_lastArg() -{ - QFile testFile(kTestFilename); - QVERIFY(testFile.open(QIODevice::WriteOnly)); - - QVERIFY(testFile.write( - "[test.args]\n" - R"(_last = "test last")" - "\n" - R"(test-second = true)" - )); - - testFile.close(); - QVERIFY(!testFile.isOpen()); - - deskflow::Config config(kTestFilename, "test"); - - const auto result = config.load("test-first"); - QVERIFY(result); - QCOMPARE(config.argc(), 3); - QCOMPARE(config.argv()[0], "test-first"); - QCOMPARE(config.argv()[1], "--test-second"); - QCOMPARE(config.argv()[2], "test last"); -} - -void ConfigTests::load_noArgs() -{ - QFile testFile(kTestFilename); - QVERIFY(testFile.open(QIODevice::WriteOnly)); - - QVERIFY(testFile.write("[test.args]")); - - testFile.close(); - QVERIFY(!testFile.isOpen()); - - deskflow::Config config(kTestFilename, "test"); - - const auto result = config.load(""); - QVERIFY(!result); -} - -QTEST_MAIN(ConfigTests) diff --git a/src/unittests/deskflow/ConfigTests.h b/src/unittests/deskflow/ConfigTests.h deleted file mode 100644 index c66d5dd8b..000000000 --- a/src/unittests/deskflow/ConfigTests.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Deskflow -- mouse and keyboard sharing utility - * SPDX-FileCopyrightText: (C) 2025 Chris Rizzitello - * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception - */ - -#include "base/Log.h" - -#include - -class ConfigTests : public QObject -{ - Q_OBJECT -private Q_SLOTS: - // Test are run in order top to bottom - void initTestCase(); - void loadFile(); - void load_EmptyFile(); - void load_NonExsitingFile(); - void load_InvalidConfig(); - void load_missingSections(); - void load_badTable(); - void load_lastArg(); - void load_noArgs(); - -private: - Arch m_arch; - Log m_log; -};