From 973cc76927b71b47c64415fbd15ff4225450e908 Mon Sep 17 00:00:00 2001 From: sithlord48 Date: Fri, 23 Jan 2026 21:35:49 -0500 Subject: [PATCH] chore: remove unused gui/CommandProcess --- src/lib/gui/CMakeLists.txt | 2 - src/lib/gui/core/CommandProcess.cpp | 49 ------------------- src/lib/gui/core/CommandProcess.h | 29 ----------- src/unittests/gui/core/CMakeLists.txt | 7 --- .../gui/core/CommandProcessTests.cpp | 33 ------------- src/unittests/gui/core/CommandProcessTests.h | 16 ------ 6 files changed, 136 deletions(-) delete mode 100644 src/lib/gui/core/CommandProcess.cpp delete mode 100644 src/lib/gui/core/CommandProcess.h delete mode 100644 src/unittests/gui/core/CommandProcessTests.cpp delete mode 100644 src/unittests/gui/core/CommandProcessTests.h diff --git a/src/lib/gui/CMakeLists.txt b/src/lib/gui/CMakeLists.txt index bc78360a5..93c77a249 100644 --- a/src/lib/gui/CMakeLists.txt +++ b/src/lib/gui/CMakeLists.txt @@ -50,8 +50,6 @@ add_library(${target} STATIC config/ServerConfig.h core/ClientConnection.cpp core/ClientConnection.h - core/CommandProcess.cpp - core/CommandProcess.h core/CoreProcess.cpp core/CoreProcess.h core/NetworkMonitor.cpp diff --git a/src/lib/gui/core/CommandProcess.cpp b/src/lib/gui/core/CommandProcess.cpp deleted file mode 100644 index 2533e2bf3..000000000 --- a/src/lib/gui/core/CommandProcess.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Deskflow -- mouse and keyboard sharing utility - * SPDX-FileCopyrightText: (C) 2014 Symless Ltd. - * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception - */ - -#include "CommandProcess.h" - -#include - -CommandProcess::CommandProcess(QString command, QStringList arguments, QString input) - : m_Command(command), - m_Arguments(arguments), - m_Input(input) -{ - // do nothing -} - -QString CommandProcess::run() -{ - QProcess process; - process.setReadChannel(QProcess::StandardOutput); - process.start(m_Command, m_Arguments); - bool success = process.waitForStarted(); - - QString output; - QString error; - if (success) { - if (!m_Input.isEmpty()) { - process.write(qPrintable(m_Input)); - } - - if (process.waitForFinished()) { - output = process.readAllStandardOutput().trimmed(); - error = process.readAllStandardError().trimmed(); - } - } - - if (int code = process.exitCode(); !success || code != 0) { - qFatal( - "command failed: %s %s\ncode: %d\nerror: %s", qUtf8Printable(m_Command), qUtf8Printable(m_Arguments.join(" ")), - code, error.isEmpty() ? "none" : qUtf8Printable(error) - ); - } - - Q_EMIT finished(); - - return output; -} diff --git a/src/lib/gui/core/CommandProcess.h b/src/lib/gui/core/CommandProcess.h deleted file mode 100644 index 87d926d7c..000000000 --- a/src/lib/gui/core/CommandProcess.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Deskflow -- mouse and keyboard sharing utility - * SPDX-FileCopyrightText: (C) 2014 Symless Ltd. - * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception - */ - -#pragma once - -#include -#include - -class CommandProcess : public QObject -{ - Q_OBJECT - -public: - CommandProcess(QString cmd, QStringList arguments, QString input = ""); - -Q_SIGNALS: - void finished(); - -public Q_SLOTS: - QString run(); - -private: - QString m_Command; - QStringList m_Arguments; - QString m_Input; -}; diff --git a/src/unittests/gui/core/CMakeLists.txt b/src/unittests/gui/core/CMakeLists.txt index 08872d21e..a2550ac49 100644 --- a/src/unittests/gui/core/CMakeLists.txt +++ b/src/unittests/gui/core/CMakeLists.txt @@ -1,13 +1,6 @@ # SPDX-FileCopyrightText: (C) 2025 Deskflow Developers # SPDX-License-Identifier: MIT -create_test( - NAME CommandProcessTests - DEPENDS gui - SOURCE CommandProcessTests.cpp - WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/src/lib/gui" -) - create_test( NAME ClientConnectionTests DEPENDS gui diff --git a/src/unittests/gui/core/CommandProcessTests.cpp b/src/unittests/gui/core/CommandProcessTests.cpp deleted file mode 100644 index 2e8a7d852..000000000 --- a/src/unittests/gui/core/CommandProcessTests.cpp +++ /dev/null @@ -1,33 +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 "CommandProcessTests.h" - -#include "gui/core/CommandProcess.h" - -void CommandProcessTests::runCommand() -{ - // it seems that on windows, you can sometimes just call echo (this worked - // with windows 2022), but on windows 10 you can't call echo directly. -#if defined(Q_OS_WIN) - const QString command = "cmd"; - const QStringList arguments = {"/C", "echo Hello, World!"}; - const QString input = ""; -#elif defined(Q_OS_UNIX) - const QString command = "echo"; - const QStringList arguments = {"Hello, World!"}; - const QString input = ""; -#endif // Q_OS_WIN - - CommandProcess commandProcess(command, arguments, input); - - const QString actual = commandProcess.run(); - - QCOMPARE(actual.toStdString(), "Hello, World!"); -} - -QTEST_MAIN(CommandProcessTests) diff --git a/src/unittests/gui/core/CommandProcessTests.h b/src/unittests/gui/core/CommandProcessTests.h deleted file mode 100644 index a683b6bef..000000000 --- a/src/unittests/gui/core/CommandProcessTests.h +++ /dev/null @@ -1,16 +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 - -class CommandProcessTests : public QObject -{ - Q_OBJECT -private Q_SLOTS: - // Test are run in order top to bottom - // void initTestCase(); - void runCommand(); -};