chore: remove unused gui/CommandProcess
This commit is contained in:
parent
86c8c66b6e
commit
973cc76927
6 changed files with 0 additions and 136 deletions
|
|
@ -50,8 +50,6 @@ add_library(${target} STATIC
|
||||||
config/ServerConfig.h
|
config/ServerConfig.h
|
||||||
core/ClientConnection.cpp
|
core/ClientConnection.cpp
|
||||||
core/ClientConnection.h
|
core/ClientConnection.h
|
||||||
core/CommandProcess.cpp
|
|
||||||
core/CommandProcess.h
|
|
||||||
core/CoreProcess.cpp
|
core/CoreProcess.cpp
|
||||||
core/CoreProcess.h
|
core/CoreProcess.h
|
||||||
core/NetworkMonitor.cpp
|
core/NetworkMonitor.cpp
|
||||||
|
|
|
||||||
|
|
@ -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 <QProcess>
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
@ -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 <QObject>
|
|
||||||
#include <QStringList>
|
|
||||||
|
|
||||||
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;
|
|
||||||
};
|
|
||||||
|
|
@ -1,13 +1,6 @@
|
||||||
# SPDX-FileCopyrightText: (C) 2025 Deskflow Developers
|
# SPDX-FileCopyrightText: (C) 2025 Deskflow Developers
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
create_test(
|
|
||||||
NAME CommandProcessTests
|
|
||||||
DEPENDS gui
|
|
||||||
SOURCE CommandProcessTests.cpp
|
|
||||||
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/src/lib/gui"
|
|
||||||
)
|
|
||||||
|
|
||||||
create_test(
|
create_test(
|
||||||
NAME ClientConnectionTests
|
NAME ClientConnectionTests
|
||||||
DEPENDS gui
|
DEPENDS gui
|
||||||
|
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
||||||
/*
|
|
||||||
* Deskflow -- mouse and keyboard sharing utility
|
|
||||||
* SPDX-FileCopyrightText: (C) 2025 Chris Rizzitello <sithlord48@gmail.com>
|
|
||||||
* 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)
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
/*
|
|
||||||
* Deskflow -- mouse and keyboard sharing utility
|
|
||||||
* SPDX-FileCopyrightText: (C) 2025 Chris Rizzitello <sithlord48@gmail.com>
|
|
||||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <QTest>
|
|
||||||
|
|
||||||
class CommandProcessTests : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
private Q_SLOTS:
|
|
||||||
// Test are run in order top to bottom
|
|
||||||
// void initTestCase();
|
|
||||||
void runCommand();
|
|
||||||
};
|
|
||||||
Loading…
Reference in a new issue