forked from qt-creator/qt-creator
Move SSH support into a dedicated library.
It does not belong into libUtils, which is a collection of small unrelated utility classes. Task-number: QTCREATORBUG-7218 Change-Id: Id92b9f28678afec93e6f07166adfde6550f38072 Reviewed-by: Eike Ziller <eike.ziller@nokia.com>
This commit is contained in:
@@ -38,7 +38,7 @@
|
||||
#include <valgrindprocess.h>
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/ssh/sftpchannel.h>
|
||||
#include <ssh/sftpchannel.h>
|
||||
|
||||
#include <QTemporaryFile>
|
||||
|
||||
@@ -236,8 +236,8 @@ void CallgrindController::foundRemoteFile()
|
||||
m_remoteFile = m_findRemoteFile->readAllStandardOutput().trimmed();
|
||||
|
||||
m_sftp = m_ssh->createSftpChannel();
|
||||
connect(m_sftp.data(), SIGNAL(finished(Utils::SftpJobId,QString)),
|
||||
this, SLOT(sftpJobFinished(Utils::SftpJobId,QString)));
|
||||
connect(m_sftp.data(), SIGNAL(finished(QSsh::SftpJobId,QString)),
|
||||
this, SLOT(sftpJobFinished(QSsh::SftpJobId,QString)));
|
||||
connect(m_sftp.data(), SIGNAL(initialized()), this, SLOT(sftpInitialized()));
|
||||
m_sftp->initialize();
|
||||
}
|
||||
@@ -251,10 +251,10 @@ void CallgrindController::sftpInitialized()
|
||||
dataFile.setAutoRemove(false);
|
||||
dataFile.close();
|
||||
|
||||
m_downloadJob = m_sftp->downloadFile(m_remoteFile, m_tempDataFile, Utils::SftpOverwriteExisting);
|
||||
m_downloadJob = m_sftp->downloadFile(m_remoteFile, m_tempDataFile, QSsh::SftpOverwriteExisting);
|
||||
}
|
||||
|
||||
void CallgrindController::sftpJobFinished(Utils::SftpJobId job, const QString &error)
|
||||
void CallgrindController::sftpJobFinished(QSsh::SftpJobId job, const QString &error)
|
||||
{
|
||||
QTC_ASSERT(job == m_downloadJob, return);
|
||||
|
||||
|
||||
@@ -37,9 +37,9 @@
|
||||
|
||||
#include <qprocess.h>
|
||||
|
||||
#include <utils/ssh/sshconnection.h>
|
||||
#include <utils/ssh/sshremoteprocess.h>
|
||||
#include <utils/ssh/sftpchannel.h>
|
||||
#include <ssh/sshconnection.h>
|
||||
#include <ssh/sshremoteprocess.h>
|
||||
#include <ssh/sftpchannel.h>
|
||||
|
||||
namespace Valgrind {
|
||||
|
||||
@@ -89,7 +89,7 @@ private Q_SLOTS:
|
||||
|
||||
void foundRemoteFile();
|
||||
void sftpInitialized();
|
||||
void sftpJobFinished(Utils::SftpJobId job, const QString &error);
|
||||
void sftpJobFinished(QSsh::SftpJobId job, const QString &error);
|
||||
|
||||
private:
|
||||
void cleanupTempFile();
|
||||
@@ -102,11 +102,11 @@ private:
|
||||
Option m_lastOption;
|
||||
|
||||
// remote callgrind support
|
||||
Utils::SshConnection::Ptr m_ssh;
|
||||
QSsh::SshConnection::Ptr m_ssh;
|
||||
QString m_tempDataFile;
|
||||
Utils::SshRemoteProcess::Ptr m_findRemoteFile;
|
||||
Utils::SftpChannel::Ptr m_sftp;
|
||||
Utils::SftpJobId m_downloadJob;
|
||||
QSsh::SshRemoteProcess::Ptr m_findRemoteFile;
|
||||
QSsh::SftpChannel::Ptr m_sftp;
|
||||
QSsh::SftpJobId m_downloadJob;
|
||||
QByteArray m_remoteFile;
|
||||
};
|
||||
|
||||
|
||||
@@ -148,7 +148,7 @@ void LocalValgrindProcess::readyReadStandardOutput()
|
||||
|
||||
////////////////////////
|
||||
|
||||
RemoteValgrindProcess::RemoteValgrindProcess(const Utils::SshConnectionParameters &sshParams,
|
||||
RemoteValgrindProcess::RemoteValgrindProcess(const QSsh::SshConnectionParameters &sshParams,
|
||||
QObject *parent)
|
||||
: ValgrindProcess(parent)
|
||||
, m_params(sshParams)
|
||||
@@ -156,7 +156,7 @@ RemoteValgrindProcess::RemoteValgrindProcess(const Utils::SshConnectionParameter
|
||||
, m_pid(0)
|
||||
{}
|
||||
|
||||
RemoteValgrindProcess::RemoteValgrindProcess(const Utils::SshConnection::Ptr &connection, QObject *parent)
|
||||
RemoteValgrindProcess::RemoteValgrindProcess(const QSsh::SshConnection::Ptr &connection, QObject *parent)
|
||||
: ValgrindProcess(parent)
|
||||
, m_params(connection->connectionParameters())
|
||||
, m_connection(connection)
|
||||
@@ -179,14 +179,14 @@ void RemoteValgrindProcess::run(const QString &valgrindExecutable, const QString
|
||||
|
||||
// connect to host and wait for connection
|
||||
if (!m_connection)
|
||||
m_connection = Utils::SshConnection::create(m_params);
|
||||
m_connection = QSsh::SshConnection::create(m_params);
|
||||
|
||||
if (m_connection->state() != Utils::SshConnection::Connected) {
|
||||
if (m_connection->state() != QSsh::SshConnection::Connected) {
|
||||
connect(m_connection.data(), SIGNAL(connected()),
|
||||
this, SLOT(connected()));
|
||||
connect(m_connection.data(), SIGNAL(error(Utils::SshError)),
|
||||
this, SLOT(error(Utils::SshError)));
|
||||
if (m_connection->state() == Utils::SshConnection::Unconnected)
|
||||
connect(m_connection.data(), SIGNAL(error(QSsh::SshError)),
|
||||
this, SLOT(error(QSsh::SshError)));
|
||||
if (m_connection->state() == QSsh::SshConnection::Unconnected)
|
||||
m_connection->connectToHost();
|
||||
} else {
|
||||
connected();
|
||||
@@ -195,7 +195,7 @@ void RemoteValgrindProcess::run(const QString &valgrindExecutable, const QString
|
||||
|
||||
void RemoteValgrindProcess::connected()
|
||||
{
|
||||
QTC_ASSERT(m_connection->state() == Utils::SshConnection::Connected, return);
|
||||
QTC_ASSERT(m_connection->state() == QSsh::SshConnection::Connected, return);
|
||||
|
||||
// connected, run command
|
||||
QString cmd;
|
||||
@@ -219,14 +219,14 @@ void RemoteValgrindProcess::connected()
|
||||
m_process->start();
|
||||
}
|
||||
|
||||
Utils::SshConnection::Ptr RemoteValgrindProcess::connection() const
|
||||
QSsh::SshConnection::Ptr RemoteValgrindProcess::connection() const
|
||||
{
|
||||
return m_connection;
|
||||
}
|
||||
|
||||
void RemoteValgrindProcess::processStarted()
|
||||
{
|
||||
QTC_ASSERT(m_connection->state() == Utils::SshConnection::Connected, return);
|
||||
QTC_ASSERT(m_connection->state() == QSsh::SshConnection::Connected, return);
|
||||
|
||||
// find out what PID our process has
|
||||
|
||||
@@ -278,10 +278,10 @@ void RemoteValgrindProcess::standardError()
|
||||
emit processOutput(m_process->readAllStandardError(), Utils::StdErrFormat);
|
||||
}
|
||||
|
||||
void RemoteValgrindProcess::error(Utils::SshError error)
|
||||
void RemoteValgrindProcess::error(QSsh::SshError error)
|
||||
{
|
||||
switch (error) {
|
||||
case Utils::SshTimeoutError:
|
||||
case QSsh::SshTimeoutError:
|
||||
m_error = QProcess::Timedout;
|
||||
break;
|
||||
default:
|
||||
@@ -294,7 +294,7 @@ void RemoteValgrindProcess::error(Utils::SshError error)
|
||||
|
||||
void RemoteValgrindProcess::close()
|
||||
{
|
||||
QTC_ASSERT(m_connection->state() == Utils::SshConnection::Connected, return);
|
||||
QTC_ASSERT(m_connection->state() == QSsh::SshConnection::Connected, return);
|
||||
if (m_process) {
|
||||
if (m_pid) {
|
||||
const QString killTemplate = QString("kill -%2 %1" // kill
|
||||
@@ -304,7 +304,7 @@ void RemoteValgrindProcess::close()
|
||||
const QString brutalKill = killTemplate.arg("SIGKILL");
|
||||
const QString remoteCall = niceKill + QLatin1String("; sleep 1; ") + brutalKill;
|
||||
|
||||
Utils::SshRemoteProcess::Ptr cleanup = m_connection->createRemoteProcess(remoteCall.toUtf8());
|
||||
QSsh::SshRemoteProcess::Ptr cleanup = m_connection->createRemoteProcess(remoteCall.toUtf8());
|
||||
cleanup->start();
|
||||
}
|
||||
}
|
||||
@@ -315,12 +315,12 @@ void RemoteValgrindProcess::closed(int status)
|
||||
QTC_ASSERT(m_process, return);
|
||||
|
||||
m_errorString = m_process->errorString();
|
||||
if (status == Utils::SshRemoteProcess::FailedToStart) {
|
||||
if (status == QSsh::SshRemoteProcess::FailedToStart) {
|
||||
m_error = QProcess::FailedToStart;
|
||||
emit ValgrindProcess::error(QProcess::FailedToStart);
|
||||
} else if (status == Utils::SshRemoteProcess::ExitedNormally) {
|
||||
} else if (status == QSsh::SshRemoteProcess::ExitedNormally) {
|
||||
emit finished(m_process->exitCode(), QProcess::NormalExit);
|
||||
} else if (status == Utils::SshRemoteProcess::KilledBySignal) {
|
||||
} else if (status == QSsh::SshRemoteProcess::KilledBySignal) {
|
||||
m_error = QProcess::Crashed;
|
||||
emit finished(m_process->exitCode(), QProcess::CrashExit);
|
||||
}
|
||||
|
||||
@@ -36,8 +36,8 @@
|
||||
#define VALGRIND_RUNNER_P_H
|
||||
|
||||
#include <utils/qtcprocess.h>
|
||||
#include <utils/ssh/sshremoteprocess.h>
|
||||
#include <utils/ssh/sshconnection.h>
|
||||
#include <ssh/sshremoteprocess.h>
|
||||
#include <ssh/sshconnection.h>
|
||||
#include <utils/outputformat.h>
|
||||
|
||||
namespace Valgrind {
|
||||
@@ -118,9 +118,9 @@ class RemoteValgrindProcess : public ValgrindProcess
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit RemoteValgrindProcess(const Utils::SshConnectionParameters &sshParams,
|
||||
explicit RemoteValgrindProcess(const QSsh::SshConnectionParameters &sshParams,
|
||||
QObject *parent = 0);
|
||||
explicit RemoteValgrindProcess(const Utils::SshConnection::Ptr &connection,
|
||||
explicit RemoteValgrindProcess(const QSsh::SshConnection::Ptr &connection,
|
||||
QObject *parent = 0);
|
||||
|
||||
virtual bool isRunning() const;
|
||||
@@ -139,21 +139,21 @@ public:
|
||||
|
||||
virtual qint64 pid() const;
|
||||
|
||||
Utils::SshConnection::Ptr connection() const;
|
||||
QSsh::SshConnection::Ptr connection() const;
|
||||
|
||||
private slots:
|
||||
void closed(int);
|
||||
void connected();
|
||||
void error(Utils::SshError error);
|
||||
void error(QSsh::SshError error);
|
||||
void processStarted();
|
||||
void findPIDOutputReceived();
|
||||
void standardOutput();
|
||||
void standardError();
|
||||
|
||||
private:
|
||||
Utils::SshConnectionParameters m_params;
|
||||
Utils::SshConnection::Ptr m_connection;
|
||||
Utils::SshRemoteProcess::Ptr m_process;
|
||||
QSsh::SshConnectionParameters m_params;
|
||||
QSsh::SshConnection::Ptr m_connection;
|
||||
QSsh::SshRemoteProcess::Ptr m_process;
|
||||
QString m_workingDir;
|
||||
QString m_valgrindExe;
|
||||
QStringList m_valgrindArgs;
|
||||
@@ -162,7 +162,7 @@ private:
|
||||
QString m_errorString;
|
||||
QProcess::ProcessError m_error;
|
||||
qint64 m_pid;
|
||||
Utils::SshRemoteProcess::Ptr m_findPID;
|
||||
QSsh::SshRemoteProcess::Ptr m_findPID;
|
||||
};
|
||||
|
||||
} // namespace Valgrind
|
||||
|
||||
@@ -38,8 +38,8 @@
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <utils/environment.h>
|
||||
#include <utils/ssh/sshconnection.h>
|
||||
#include <utils/ssh/sshremoteprocess.h>
|
||||
#include <ssh/sshconnection.h>
|
||||
#include <ssh/sshremoteprocess.h>
|
||||
|
||||
#include <QEventLoop>
|
||||
|
||||
@@ -70,7 +70,7 @@ public:
|
||||
QString debuggeeArguments;
|
||||
QString workingdir;
|
||||
Analyzer::StartMode startMode;
|
||||
Utils::SshConnectionParameters connParams;
|
||||
QSsh::SshConnectionParameters connParams;
|
||||
};
|
||||
|
||||
void ValgrindRunner::Private::run(ValgrindProcess *_process)
|
||||
@@ -178,12 +178,12 @@ void ValgrindRunner::setStartMode(Analyzer::StartMode startMode)
|
||||
d->startMode = startMode;
|
||||
}
|
||||
|
||||
const Utils::SshConnectionParameters &ValgrindRunner::connectionParameters() const
|
||||
const QSsh::SshConnectionParameters &ValgrindRunner::connectionParameters() const
|
||||
{
|
||||
return d->connParams;
|
||||
}
|
||||
|
||||
void ValgrindRunner::setConnectionParameters(const Utils::SshConnectionParameters &connParams)
|
||||
void ValgrindRunner::setConnectionParameters(const QSsh::SshConnectionParameters &connParams)
|
||||
{
|
||||
d->connParams = connParams;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
#include <analyzerbase/analyzerconstants.h>
|
||||
|
||||
#include <utils/outputformat.h>
|
||||
#include <utils/ssh/sshconnection.h>
|
||||
#include <ssh/sshconnection.h>
|
||||
|
||||
#include <QProcess>
|
||||
|
||||
@@ -76,8 +76,8 @@ public:
|
||||
void setStartMode(Analyzer::StartMode startMode);
|
||||
Analyzer::StartMode startMode() const;
|
||||
|
||||
void setConnectionParameters(const Utils::SshConnectionParameters &connParams);
|
||||
const Utils::SshConnectionParameters &connectionParameters() const;
|
||||
void setConnectionParameters(const QSsh::SshConnectionParameters &connParams);
|
||||
const QSsh::SshConnectionParameters &connectionParameters() const;
|
||||
|
||||
void waitForFinished() const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user