From 2856091c757c61aeff1ec6e3981d4ed9c8b0a6b6 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Fri, 6 May 2022 02:26:52 +0200 Subject: Get rid of SshRemoteProcess It's being replaced by QtcProcess with path on device. Change-Id: I29eb038d1b17151683f86855eb547e47f7f7dea5 Reviewed-by: Qt CI Bot Reviewed-by: hjk --- tests/manual/ssh/shell/shell.cpp | 111 --------------------------------------- 1 file changed, 111 deletions(-) delete mode 100644 tests/manual/ssh/shell/shell.cpp (limited to 'tests/manual/ssh/shell/shell.cpp') 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 - -#include - -#include -#include -#include - -#include -#include - -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()); -} -- cgit v1.2.1