2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2011-02-18 10:36:52 +01:00
|
|
|
**
|
2016-01-15 14:58:39 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2011-02-18 10:36:52 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2011-02-18 10:36:52 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** 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
|
2016-01-15 14:58:39 +01:00
|
|
|
** 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.
|
2011-02-18 10:36:52 +01:00
|
|
|
**
|
2016-01-15 14:58:39 +01:00
|
|
|
** 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.
|
2011-02-18 10:36:52 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2011-02-18 10:36:52 +01:00
|
|
|
|
2016-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
2010-10-12 11:07:06 +02:00
|
|
|
|
|
|
|
|
#include "sshconnection.h"
|
|
|
|
|
#include "sshremoteprocess.h"
|
|
|
|
|
|
2012-05-18 10:49:35 +02:00
|
|
|
namespace QSsh {
|
2014-02-11 21:55:42 +02:00
|
|
|
namespace Internal { class SshRemoteProcessRunnerPrivate; }
|
2010-10-12 11:07:06 +02:00
|
|
|
|
2012-05-18 10:49:35 +02:00
|
|
|
class QSSH_EXPORT SshRemoteProcessRunner : public QObject
|
2010-10-12 11:07:06 +02:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
2011-07-13 18:02:35 +02:00
|
|
|
|
2010-10-12 11:07:06 +02:00
|
|
|
public:
|
2011-11-09 14:19:50 +01:00
|
|
|
SshRemoteProcessRunner(QObject *parent = 0);
|
2011-11-17 10:56:27 +01:00
|
|
|
~SshRemoteProcessRunner();
|
2010-10-12 11:07:06 +02:00
|
|
|
|
2011-11-17 10:56:27 +01:00
|
|
|
void run(const QByteArray &command, const SshConnectionParameters &sshParams);
|
2011-11-09 14:19:50 +01:00
|
|
|
void runInTerminal(const QByteArray &command, const SshPseudoTerminal &terminal,
|
2011-11-17 10:56:27 +01:00
|
|
|
const SshConnectionParameters &sshParams);
|
2010-10-12 11:07:06 +02:00
|
|
|
QByteArray command() const;
|
|
|
|
|
|
2012-05-18 10:49:35 +02:00
|
|
|
QSsh::SshError lastConnectionError() const;
|
2011-11-09 17:38:19 +01:00
|
|
|
QString lastConnectionErrorString() const;
|
|
|
|
|
|
2011-11-30 14:39:17 +01:00
|
|
|
bool isProcessRunning() const;
|
|
|
|
|
void writeDataToProcess(const QByteArray &data);
|
2012-01-20 14:35:13 +01:00
|
|
|
void sendSignalToProcess(SshRemoteProcess::Signal signal); // No effect with OpenSSH server.
|
2011-11-30 14:39:17 +01:00
|
|
|
void cancel(); // Does not stop remote process, just frees SSH-related process resources.
|
|
|
|
|
SshRemoteProcess::ExitStatus processExitStatus() const;
|
2012-01-20 14:35:13 +01:00
|
|
|
SshRemoteProcess::Signal processExitSignal() const;
|
2011-11-30 14:39:17 +01:00
|
|
|
int processExitCode() const;
|
|
|
|
|
QString processErrorString() const;
|
2012-06-08 09:42:32 +02:00
|
|
|
QByteArray readAllStandardOutput();
|
|
|
|
|
QByteArray readAllStandardError();
|
|
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
void connectionError();
|
|
|
|
|
void processStarted();
|
|
|
|
|
void readyReadStandardOutput();
|
|
|
|
|
void readyReadStandardError();
|
|
|
|
|
void processClosed(int exitStatus); // values are of type SshRemoteProcess::ExitStatus
|
2010-10-12 11:07:06 +02:00
|
|
|
|
2016-06-07 22:04:26 +03:00
|
|
|
private:
|
2011-11-17 10:56:27 +01:00
|
|
|
void handleConnected();
|
2012-05-18 10:49:35 +02:00
|
|
|
void handleConnectionError(QSsh::SshError error);
|
2011-11-17 10:56:27 +01:00
|
|
|
void handleDisconnected();
|
|
|
|
|
void handleProcessStarted();
|
|
|
|
|
void handleProcessFinished(int exitStatus);
|
|
|
|
|
void handleStdout();
|
|
|
|
|
void handleStderr();
|
2012-05-18 10:49:35 +02:00
|
|
|
void runInternal(const QByteArray &command, const QSsh::SshConnectionParameters &sshParams);
|
2011-11-17 10:56:27 +01:00
|
|
|
void setState(int newState);
|
2010-10-12 11:07:06 +02:00
|
|
|
|
2011-11-09 14:19:50 +01:00
|
|
|
Internal::SshRemoteProcessRunnerPrivate * const d;
|
2010-10-12 11:07:06 +02:00
|
|
|
};
|
|
|
|
|
|
2012-05-18 10:49:35 +02:00
|
|
|
} // namespace QSsh
|