diff options
author | Jarek Kobus <jaroslaw.kobus@qt.io> | 2022-05-06 02:26:52 +0200 |
---|---|---|
committer | Jarek Kobus <jaroslaw.kobus@qt.io> | 2022-05-09 07:42:13 +0000 |
commit | 2856091c757c61aeff1ec6e3981d4ed9c8b0a6b6 (patch) | |
tree | 7249ac4733dd53db0d8707859eec23cff5d1c839 | |
parent | d8ee25ec3db039368ac0440af647fd7afd80079b (diff) |
Get rid of SshRemoteProcess
It's being replaced by QtcProcess with path on device.
Change-Id: I29eb038d1b17151683f86855eb547e47f7f7dea5
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: hjk <hjk@qt.io>
-rw-r--r-- | src/libs/ssh/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/libs/ssh/ssh.qbs | 2 | ||||
-rw-r--r-- | src/libs/ssh/sshconnection.cpp | 13 | ||||
-rw-r--r-- | src/libs/ssh/sshconnection.h | 5 | ||||
-rw-r--r-- | src/libs/ssh/sshremoteprocess.cpp | 116 | ||||
-rw-r--r-- | src/libs/ssh/sshremoteprocess.h | 59 | ||||
-rw-r--r-- | tests/auto/ssh/tst_ssh.cpp | 42 | ||||
-rw-r--r-- | tests/manual/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/manual/manual.qbs | 1 | ||||
-rw-r--r-- | tests/manual/ssh/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/manual/ssh/shell/CMakeLists.txt | 13 | ||||
-rw-r--r-- | tests/manual/ssh/shell/argumentscollector.cpp | 135 | ||||
-rw-r--r-- | tests/manual/ssh/shell/argumentscollector.h | 50 | ||||
-rw-r--r-- | tests/manual/ssh/shell/main.cpp | 56 | ||||
-rw-r--r-- | tests/manual/ssh/shell/shell.cpp | 111 | ||||
-rw-r--r-- | tests/manual/ssh/shell/shell.h | 60 | ||||
-rw-r--r-- | tests/manual/ssh/shell/shell.pro | 6 | ||||
-rw-r--r-- | tests/manual/ssh/shell/shell.qbs | 27 | ||||
-rw-r--r-- | tests/manual/ssh/ssh.pri | 17 | ||||
-rw-r--r-- | tests/manual/ssh/ssh.pro | 8 |
20 files changed, 0 insertions, 724 deletions
diff --git a/src/libs/ssh/CMakeLists.txt b/src/libs/ssh/CMakeLists.txt index d4613851e6..0358b30d1e 100644 --- a/src/libs/ssh/CMakeLists.txt +++ b/src/libs/ssh/CMakeLists.txt @@ -13,6 +13,5 @@ add_qtc_library(QtcSsh sshconnectionmanager.cpp sshconnectionmanager.h sshkeycreationdialog.cpp sshkeycreationdialog.h sshkeycreationdialog.ui sshlogging.cpp sshlogging_p.h - sshremoteprocess.cpp sshremoteprocess.h sshsettings.cpp sshsettings.h ) diff --git a/src/libs/ssh/ssh.qbs b/src/libs/ssh/ssh.qbs index b853cc8b66..9f7c880b95 100644 --- a/src/libs/ssh/ssh.qbs +++ b/src/libs/ssh/ssh.qbs @@ -31,8 +31,6 @@ Project { "sshkeycreationdialog.ui", "sshlogging.cpp", "sshlogging_p.h", - "sshremoteprocess.cpp", - "sshremoteprocess.h", "sshsettings.cpp", "sshsettings.h", ] diff --git a/src/libs/ssh/sshconnection.cpp b/src/libs/ssh/sshconnection.cpp index 145a2f60bc..df4b9a0a0e 100644 --- a/src/libs/ssh/sshconnection.cpp +++ b/src/libs/ssh/sshconnection.cpp @@ -27,7 +27,6 @@ #include "sftptransfer.h" #include "sshlogging_p.h" -#include "sshremoteprocess.h" #include "sshsettings.h" #include <utils/fileutils.h> @@ -286,18 +285,6 @@ SshConnection::~SshConnection() delete d; } -SshRemoteProcessPtr SshConnection::createRemoteProcess(const QString &command) -{ - QTC_ASSERT(state() == Connected, return SshRemoteProcessPtr()); - return SshRemoteProcessPtr(new SshRemoteProcess(command, - d->connectionArgs(SshSettings::sshFilePath()))); -} - -SshRemoteProcessPtr SshConnection::createRemoteShell() -{ - return createRemoteProcess({}); -} - SftpTransferPtr SshConnection::createUpload(const FilesToTransfer &files, FileTransferErrorHandling errorHandlingMode) { diff --git a/src/libs/ssh/sshconnection.h b/src/libs/ssh/sshconnection.h index b2d2abc27a..633e620791 100644 --- a/src/libs/ssh/sshconnection.h +++ b/src/libs/ssh/sshconnection.h @@ -41,7 +41,6 @@ namespace Utils { class QtcProcess; } namespace QSsh { -class SshRemoteProcess; enum SshHostKeyCheckingMode { SshHostKeyCheckingNone, @@ -82,8 +81,6 @@ public: QSSH_EXPORT bool operator==(const SshConnectionParameters &p1, const SshConnectionParameters &p2); QSSH_EXPORT bool operator!=(const SshConnectionParameters &p1, const SshConnectionParameters &p2); -using SshRemoteProcessPtr = std::unique_ptr<SshRemoteProcess>; - class QSSH_EXPORT SshConnection : public QObject { Q_OBJECT @@ -102,8 +99,6 @@ public: bool sharingEnabled() const; ~SshConnection(); - SshRemoteProcessPtr createRemoteProcess(const QString &command); - SshRemoteProcessPtr createRemoteShell(); SftpTransferPtr createUpload(const FilesToTransfer &files, FileTransferErrorHandling errorHandlingMode); SftpTransferPtr createDownload(const FilesToTransfer &files, diff --git a/src/libs/ssh/sshremoteprocess.cpp b/src/libs/ssh/sshremoteprocess.cpp deleted file mode 100644 index f0b52d5ff2..0000000000 --- a/src/libs/ssh/sshremoteprocess.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#include "sshremoteprocess.h" - -#include "sshconnection.h" -#include "sshlogging_p.h" -#include "sshsettings.h" - -#include <utils/commandline.h> -#include <utils/processinterface.h> -#include <utils/qtcassert.h> - -#include <QTimer> - -/*! - \class QSsh::SshRemoteProcess - - \brief The SshRemoteProcess class implements an SSH channel for running a - remote process. - - Objects are created via SshConnection::createRemoteProcess. - The process is started via the start() member function. - If the process needs a pseudo terminal, you can request one - via requestTerminal() before calling start(). - */ - -using namespace QSsh::Internal; -using namespace Utils; - -namespace QSsh { - -SshRemoteProcess::SshRemoteProcess(const QString &command, const QStringList &connectionArgs) - : QtcProcess() -{ - SshConnectionParameters::setupSshEnvironment(this); - m_remoteCommand = command; - m_connectionArgs = connectionArgs; -} - -void SshRemoteProcess::emitFinished() -{ - if (exitStatus() == QProcess::CrashExit) - m_errorString = tr("The ssh process crashed: %1").arg(errorString()); - QtcProcess::emitFinished(); -} - -void SshRemoteProcess::startImpl() -{ - QTC_ASSERT(!isRunning(), return); - m_errorString.clear(); - const CommandLine cmd = fullLocalCommandLine(); - if (!m_displayName.isEmpty()) { - Environment env = environment(); - env.set("DISPLAY", m_displayName); - setEnvironment(env); - } - qCDebug(sshLog) << "starting remote process:" << cmd.toUserOutput(); - setCommand(cmd); - QtcProcess::startImpl(); -} - -ProcessResultData SshRemoteProcess::resultData() const -{ - ProcessResultData result = QtcProcess::resultData(); - if (!m_errorString.isEmpty()) - result.m_errorString = m_errorString; - return result; -} - -void SshRemoteProcess::requestX11Forwarding(const QString &displayName) -{ - m_displayName = displayName; -} - -CommandLine SshRemoteProcess::fullLocalCommandLine(bool inTerminal) const -{ - CommandLine cmd {SshSettings::sshFilePath()}; - - if (!m_displayName.isEmpty()) - cmd.addArg("-X"); - if (inTerminal) - cmd.addArg("-tt"); - - cmd.addArg("-q"); - cmd.addArgs(m_connectionArgs); - - if (!m_remoteCommand.isEmpty()) - cmd.addArg(m_remoteCommand); - - return cmd; -} - -} // namespace QSsh diff --git a/src/libs/ssh/sshremoteprocess.h b/src/libs/ssh/sshremoteprocess.h deleted file mode 100644 index cfd6427c73..0000000000 --- a/src/libs/ssh/sshremoteprocess.h +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#pragma once - -#include "ssh_global.h" - -#include <utils/qtcprocess.h> - -namespace Utils { class CommandLine; } - -namespace QSsh { - -class QSSH_EXPORT SshRemoteProcess : public Utils::QtcProcess -{ - Q_OBJECT - -public: - SshRemoteProcess(const QString &command, const QStringList &connectionArgs); - - void requestX11Forwarding(const QString &displayName); - void startImpl() override; - Utils::ProcessResultData resultData() const override; - - Utils::CommandLine fullLocalCommandLine(bool inTerminal = false) const; - -protected: - void emitFinished() override; - -private: - QString m_remoteCommand; - QStringList m_connectionArgs; - QString m_displayName; - QString m_errorString; -}; - -} // namespace QSsh diff --git a/tests/auto/ssh/tst_ssh.cpp b/tests/auto/ssh/tst_ssh.cpp index c7c6a85249..35527a080c 100644 --- a/tests/auto/ssh/tst_ssh.cpp +++ b/tests/auto/ssh/tst_ssh.cpp @@ -25,7 +25,6 @@ #include <ssh/sftptransfer.h> #include <ssh/sshconnection.h> -#include <ssh/sshremoteprocess.h> #include <ssh/sshsettings.h> #include <utils/algorithm.h> @@ -59,7 +58,6 @@ private slots: void errorHandling_data(); void errorHandling(); void pristineConnectionObject(); - void remoteProcessChannels(); void remoteProcessInput(); void sftp(); @@ -145,46 +143,6 @@ void tst_Ssh::pristineConnectionObject() QRegularExpression assertToIgnore( "SOFT ASSERT: \"state\\(\\) == Connected\" in file .*[/\\\\]sshconnection.cpp, line \\d*"); QTest::ignoreMessage(QtDebugMsg, assertToIgnore); - QVERIFY(!connection.createRemoteProcess("")); -} - -void tst_Ssh::remoteProcessChannels() -{ - const SshConnectionParameters params = SshTest::getParameters(); - if (!SshTest::checkParameters(params)) - QSKIP("Insufficient setup - set QTC_SSH_TEST_* variables."); - SshConnection connection(params); - QVERIFY(waitForConnection(connection)); - - static const QByteArray testString("ChannelTest"); - QByteArray remoteStdout; - QByteArray remoteStderr; - QByteArray remoteData; - SshRemoteProcessPtr echoProcess - = connection.createRemoteProcess("printf " + QString::fromUtf8(testString) + " >&2"); - QEventLoop loop; - connect(echoProcess.get(), &QtcProcess::done, &loop, &QEventLoop::quit); - connect(echoProcess.get(), &QtcProcess::readyReadStandardError, - [&remoteData, p = echoProcess.get()] { remoteData += p->readAllStandardError(); }); - connect(echoProcess.get(), &QtcProcess::readyReadStandardOutput, - [&remoteStdout, p = echoProcess.get()] { remoteStdout += p->readAllStandardOutput(); }); - connect(echoProcess.get(), &QtcProcess::readyReadStandardError, - [&remoteStderr] { remoteStderr = testString; }); - echoProcess->start(); - QTimer timer; - QObject::connect(&timer, &QTimer::timeout, &loop, &QEventLoop::quit); - timer.setSingleShot(true); - timer.setInterval((params.timeout + 5) * 1000); - timer.start(); - loop.exec(); - QVERIFY(timer.isActive()); - timer.stop(); - QVERIFY(!echoProcess->isRunning()); - QCOMPARE(echoProcess->exitStatus(), QProcess::NormalExit); - QCOMPARE(echoProcess->exitCode(), 0); - QVERIFY(remoteStdout.isEmpty()); - QCOMPARE(remoteData, testString); - QCOMPARE(remoteData, remoteStderr); } void tst_Ssh::remoteProcessInput() diff --git a/tests/manual/CMakeLists.txt b/tests/manual/CMakeLists.txt index 436263a7e8..48bd9648fa 100644 --- a/tests/manual/CMakeLists.txt +++ b/tests/manual/CMakeLists.txt @@ -16,5 +16,4 @@ add_subdirectory(proparser) # add_subdirectory(qt4projectmanager) # add_subdirectory(search) add_subdirectory(shootout) -add_subdirectory(ssh) add_subdirectory(widgets) diff --git a/tests/manual/manual.qbs b/tests/manual/manual.qbs index 625138c49a..717d3745d5 100644 --- a/tests/manual/manual.qbs +++ b/tests/manual/manual.qbs @@ -13,7 +13,6 @@ Project { "process/process.qbs", "proparser/testreader.qbs", "shootout/shootout.qbs", - "ssh/shell/shell.qbs", "widgets/widgets.qbs", ] } diff --git a/tests/manual/ssh/CMakeLists.txt b/tests/manual/ssh/CMakeLists.txt deleted file mode 100644 index b6b516e634..0000000000 --- a/tests/manual/ssh/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -add_subdirectory(shell) diff --git a/tests/manual/ssh/shell/CMakeLists.txt b/tests/manual/ssh/shell/CMakeLists.txt deleted file mode 100644 index f7748f2e96..0000000000 --- a/tests/manual/ssh/shell/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -file(RELATIVE_PATH RELATIVE_TEST_PATH "${PROJECT_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}") -file(RELATIVE_PATH TEST_RELATIVE_LIBEXEC_PATH "/${RELATIVE_TEST_PATH}" "/${IDE_LIBEXEC_PATH}") - -add_qtc_test(tst_manual_shell - MANUALTEST - CONDITION UNIX - DEPENDS Utils QtcSsh Qt5::Network - DEFINES "TEST_RELATIVE_LIBEXEC_PATH=\"${TEST_RELATIVE_LIBEXEC_PATH}\"" - SOURCES - argumentscollector.cpp argumentscollector.h - main.cpp - shell.cpp shell.h -) diff --git a/tests/manual/ssh/shell/argumentscollector.cpp b/tests/manual/ssh/shell/argumentscollector.cpp deleted file mode 100644 index e9e7e61888..0000000000 --- a/tests/manual/ssh/shell/argumentscollector.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#include "argumentscollector.h" - -#include <QDir> -#include <QProcessEnvironment> - -#include <iostream> - -using namespace QSsh; - -using namespace std; - -ArgumentsCollector::ArgumentsCollector(const QStringList &args) - : m_arguments(args) -{ -} - -SshConnectionParameters ArgumentsCollector::collect(bool &success) const -{ - SshConnectionParameters parameters; - try { - bool authTypeGiven = false; - bool portGiven = false; - bool timeoutGiven = false; - int pos; - int port = 22; - - for (pos = 1; pos < m_arguments.count() - 1; ++pos) { - QString str; - if (checkAndSetStringArg(pos, str, "-h")) { - parameters.setHost(str); - } else if (checkAndSetStringArg(pos, str, "-u")) { - parameters.setUserName(str); - } else if (checkAndSetIntArg(pos, port, portGiven, "-p") - || checkAndSetIntArg(pos, parameters.timeout, timeoutGiven, "-t")) { - continue; - } else if (checkAndSetStringArg(pos, str, "-k")) { - parameters.privateKeyFile = Utils::FilePath::fromString(str); - parameters.authenticationType - = SshConnectionParameters::AuthenticationTypeSpecificKey; - authTypeGiven = true; - } - } - - Q_ASSERT(pos <= m_arguments.count()); - - if (!authTypeGiven) - parameters.authenticationType = SshConnectionParameters::AuthenticationTypeAll; - - if (parameters.userName().isEmpty()) - parameters.setUserName(QProcessEnvironment::systemEnvironment().value("USER")); - if (parameters.userName().isEmpty()) - throw ArgumentErrorException(QLatin1String("No user name given.")); - - if (parameters.host().isEmpty()) - throw ArgumentErrorException(QLatin1String("No host given.")); - - parameters.setPort(portGiven ? port : 22); - if (!timeoutGiven) - parameters.timeout = 30; - success = true; - } catch (ArgumentErrorException &ex) { - cerr << "Error: " << qPrintable(ex.error) << endl; - printUsage(); - success = false; - } - return parameters; -} - -void ArgumentsCollector::printUsage() const -{ - cerr << "Usage: " << qPrintable(m_arguments.first()) - << " -h <host> [ -u <user> ] " - << "[ -k <private key file> ] [ -p <port> ] " - << "[ -t <timeout> ] [ -no-proxy ]" << endl; -} - -bool ArgumentsCollector::checkAndSetStringArg(int &pos, QString &arg, const char *opt) const -{ - if (m_arguments.at(pos) == QLatin1String(opt)) { - if (!arg.isEmpty()) { - throw ArgumentErrorException(QLatin1String("option ") + QLatin1String(opt) - + QLatin1String(" was given twice.")); - } - arg = m_arguments.at(++pos); - if (arg.isEmpty() && QLatin1String(opt) != QLatin1String("-pwd")) - throw ArgumentErrorException(QLatin1String("empty argument not allowed here.")); - return true; - } - return false; -} - -bool ArgumentsCollector::checkAndSetIntArg(int &pos, int &val, - bool &alreadyGiven, const char *opt) const -{ - if (m_arguments.at(pos) == QLatin1String(opt)) { - if (alreadyGiven) { - throw ArgumentErrorException(QLatin1String("option ") + QLatin1String(opt) - + QLatin1String(" was given twice.")); - } - bool isNumber; - val = m_arguments.at(++pos).toInt(&isNumber); - if (!isNumber) { - throw ArgumentErrorException(QLatin1String("option ") + QLatin1String(opt) - + QLatin1String(" needs integer argument")); - } - alreadyGiven = true; - return true; - } - return false; -} diff --git a/tests/manual/ssh/shell/argumentscollector.h b/tests/manual/ssh/shell/argumentscollector.h deleted file mode 100644 index 4d36ca1802..0000000000 --- a/tests/manual/ssh/shell/argumentscollector.h +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#pragma once - -#include <ssh/sshconnection.h> - -#include <QStringList> - -class ArgumentsCollector -{ -public: - ArgumentsCollector(const QStringList &args); - QSsh::SshConnectionParameters collect(bool &success) const; -private: - struct ArgumentErrorException - { - ArgumentErrorException(const QString &error) : error(error) {} - const QString error; - }; - - void printUsage() const; - bool checkAndSetStringArg(int &pos, QString &arg, const char *opt) const; - bool checkAndSetIntArg(int &pos, int &val, bool &alreadyGiven, - const char *opt) const; - - const QStringList m_arguments; -}; diff --git a/tests/manual/ssh/shell/main.cpp b/tests/manual/ssh/shell/main.cpp deleted file mode 100644 index c47471ae7d..0000000000 --- a/tests/manual/ssh/shell/main.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#include "argumentscollector.h" -#include "shell.h" - -#include <ssh/sshconnection.h> -#include <utils/launcherinterface.h> -#include <utils/temporarydirectory.h> - -#include <QCoreApplication> -#include <QDir> -#include <QObject> -#include <QStringList> - -#include <cstdlib> -#include <iostream> - -int main(int argc, char *argv[]) -{ - QCoreApplication app(argc, argv); - Utils::LauncherInterface::setPathToLauncher(qApp->applicationDirPath() + '/' - + QLatin1String(TEST_RELATIVE_LIBEXEC_PATH)); - bool parseSuccess; - const QSsh::SshConnectionParameters ¶meters - = ArgumentsCollector(app.arguments()).collect(parseSuccess); - if (!parseSuccess) - return EXIT_FAILURE; - Utils::TemporaryDirectory::setMasterTemporaryDirectory(QDir::tempPath() - + "/qtc-ssh-shelltest-XXXXXX"); - Shell shell(parameters); - shell.run(); - return app.exec(); -} diff --git a/tests/manual/ssh/shell/shell.cpp b/tests/manual/ssh/shell/shell.cpp deleted file mode 100644 index b85e61b970..0000000000 --- a/tests/manual/ssh/shell/shell.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#include "shell.h" - -#include <ssh/sshremoteprocess.h> - -#include <utils/qtcprocess.h> - -#include <QCoreApplication> -#include <QFile> -#include <QSocketNotifier> - -#include <cstdlib> -#include <iostream> - -using namespace QSsh; -using namespace Utils; - -Shell::Shell(const SshConnectionParameters ¶meters, QObject *parent) - : QObject(parent), - m_connection(new SshConnection(parameters)), - m_stdin(new QFile(this)) -{ - connect(m_connection, &SshConnection::connected, this, &Shell::handleConnected); - connect(m_connection, &SshConnection::errorOccurred, this, &Shell::handleConnectionError); -} - -Shell::~Shell() -{ - delete m_connection; -} - -void Shell::run() -{ - if (!m_stdin->open(stdin, QIODevice::ReadOnly | QIODevice::Unbuffered)) { - std::cerr << "Error: Cannot read from standard input." << std::endl; - QCoreApplication::exit(EXIT_FAILURE); - return; - } - - m_connection->connectToHost(); -} - -void Shell::handleConnectionError() -{ - std::cerr << "SSH connection error: " << qPrintable(m_connection->errorString()) << std::endl; - QCoreApplication::exit(EXIT_FAILURE); -} - -void Shell::handleConnected() -{ - m_shell = m_connection->createRemoteShell(); - connect(m_shell.get(), &QtcProcess::started, this, &Shell::handleShellStarted); - connect(m_shell.get(), &QtcProcess::readyReadStandardOutput, - this, &Shell::handleRemoteStdout); - connect(m_shell.get(), &QtcProcess::readyReadStandardError, - this, &Shell::handleRemoteStderr); - connect(m_shell.get(), &QtcProcess::done, this, &Shell::handleChannelClosed); - m_shell->start(); -} - -void Shell::handleShellStarted() -{ - QSocketNotifier * const notifier = new QSocketNotifier(0, QSocketNotifier::Read, this); - connect(notifier, &QSocketNotifier::activated, this, &Shell::handleStdin); -} - -void Shell::handleRemoteStdout() -{ - std::cout << m_shell->readAllStandardOutput().data() << std::flush; -} - -void Shell::handleRemoteStderr() -{ - std::cerr << m_shell->readAllStandardError().data() << std::flush; -} - -void Shell::handleChannelClosed() -{ - std::cerr << "Shell closed. Exit code was " << m_shell->exitCode() << "." << std::endl; - QCoreApplication::exit(m_shell->errorString().isEmpty() && m_shell->exitCode() == 0 - ? EXIT_SUCCESS : EXIT_FAILURE); -} - -void Shell::handleStdin() -{ - m_shell->write(m_stdin->readLine()); -} diff --git a/tests/manual/ssh/shell/shell.h b/tests/manual/ssh/shell/shell.h deleted file mode 100644 index db8bcce9ca..0000000000 --- a/tests/manual/ssh/shell/shell.h +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#pragma once - -#include <ssh/sshconnection.h> - -#include <QObject> - -QT_BEGIN_NAMESPACE -class QByteArray; -class QFile; -class QString; -QT_END_NAMESPACE - -class Shell : public QObject -{ - Q_OBJECT -public: - Shell(const QSsh::SshConnectionParameters ¶meters, QObject *parent = 0); - ~Shell(); - - void run(); - -private: - void handleConnected(); - void handleConnectionError(); - void handleRemoteStdout(); - void handleRemoteStderr(); - void handleShellMessage(const QString &message); - void handleChannelClosed(); - void handleShellStarted(); - void handleStdin(); - - QSsh::SshConnection *m_connection; - QSsh::SshRemoteProcessPtr m_shell; - QFile * const m_stdin; -}; diff --git a/tests/manual/ssh/shell/shell.pro b/tests/manual/ssh/shell/shell.pro deleted file mode 100644 index f7d0b174f0..0000000000 --- a/tests/manual/ssh/shell/shell.pro +++ /dev/null @@ -1,6 +0,0 @@ -include(../ssh.pri) -QT += network - -TARGET=shell -SOURCES=main.cpp shell.cpp argumentscollector.cpp -HEADERS=shell.h argumentscollector.h diff --git a/tests/manual/ssh/shell/shell.qbs b/tests/manual/ssh/shell/shell.qbs deleted file mode 100644 index f8cc41a022..0000000000 --- a/tests/manual/ssh/shell/shell.qbs +++ /dev/null @@ -1,27 +0,0 @@ -import qbs -import qbs.FileInfo - -QtcManualtest { - name: "Manual ssh shell test" - condition: qbs.targetOS.contains("unix") - Depends { name: "Utils" } - Depends { name: "QtcSsh" } - Depends { name: "Qt.network" } - - cpp.defines: { - var defines = base; - var absLibExecPath = FileInfo.joinPaths(qbs.installRoot, qbs.installPrefix, - qtc.ide_libexec_path); - var relLibExecPath = FileInfo.relativePath(destinationDirectory, absLibExecPath); - defines.push('TEST_RELATIVE_LIBEXEC_PATH="' + relLibExecPath + '"'); - return defines; - } - - files: [ - "argumentscollector.cpp", - "argumentscollector.h", - "main.cpp", - "shell.cpp", - "shell.h", - ] -} diff --git a/tests/manual/ssh/ssh.pri b/tests/manual/ssh/ssh.pri deleted file mode 100644 index b7927278b8..0000000000 --- a/tests/manual/ssh/ssh.pri +++ /dev/null @@ -1,17 +0,0 @@ -QT = core network - -QTC_LIB_DEPENDS += ssh utils -include (../../../qtcreator.pri) - -macx:QMAKE_LFLAGS += -Wl,-rpath,\"$$IDE_BIN_PATH/..\" -LIBS *= -L$$IDE_LIBRARY_PATH -unix { - QMAKE_LFLAGS += -Wl,-rpath,\"$$IDE_LIBRARY_PATH\" -} - -CONFIG += console -CONFIG -= app_bundle -TEMPLATE = app - -DEPENDPATH+=. -INCLUDEPATH+=. diff --git a/tests/manual/ssh/ssh.pro b/tests/manual/ssh/ssh.pro deleted file mode 100644 index 9efd266c1e..0000000000 --- a/tests/manual/ssh/ssh.pro +++ /dev/null @@ -1,8 +0,0 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2010-07-01T09:44:44 -# -#------------------------------------------------- - -TEMPLATE = subdirs -SUBDIRS = shell |