2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2011-02-18 10:36:52 +01:00
|
|
|
**
|
2014-01-07 13:27:11 +01:00
|
|
|
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
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
|
|
|
|
|
** a written agreement between you and Digia. For licensing terms and
|
|
|
|
|
** conditions see http://qt.digia.com/licensing. For further information
|
|
|
|
|
** use the contact form at http://qt.digia.com/contact-us.
|
2011-02-18 10:36:52 +01:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
2011-02-18 10:36:52 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2011-02-18 10:36:52 +01:00
|
|
|
|
2010-10-12 11:07:06 +02:00
|
|
|
#ifndef SSHREMOTEPROCESSRUNNER_H
|
|
|
|
|
#define SSHREMOTEPROCESSRUNNER_H
|
|
|
|
|
|
|
|
|
|
#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
|
|
|
|
2011-11-17 10:56:27 +01:00
|
|
|
private slots:
|
|
|
|
|
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();
|
|
|
|
|
|
2010-10-12 11:07:06 +02:00
|
|
|
private:
|
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
|
2010-10-12 11:07:06 +02:00
|
|
|
|
|
|
|
|
#endif // SSHREMOTEPROCESSRUNNER_H
|