forked from qt-creator/qt-creator
SSH: Fix tests to adapt to new location (utils vs. core plugin).
This commit is contained in:
@@ -31,9 +31,9 @@
|
|||||||
**
|
**
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
#include <coreplugin/ssh/sftpchannel.h>
|
#include <utils/ssh/sftpchannel.h>
|
||||||
#include <coreplugin/ssh/sshconnection.h>
|
#include <utils/ssh/sshconnection.h>
|
||||||
#include <coreplugin/ssh/sshremoteprocess.h>
|
#include <utils/ssh/sshremoteprocess.h>
|
||||||
|
|
||||||
#include <QtCore/QCoreApplication>
|
#include <QtCore/QCoreApplication>
|
||||||
#include <QtCore/QList>
|
#include <QtCore/QList>
|
||||||
@@ -41,7 +41,7 @@
|
|||||||
#include <QtCore/QPair>
|
#include <QtCore/QPair>
|
||||||
#include <QtCore/QTimer>
|
#include <QtCore/QTimer>
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Utils;
|
||||||
|
|
||||||
class Test : public QObject {
|
class Test : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -69,24 +69,24 @@ public:
|
|||||||
noUser.host = QLatin1String("localhost");
|
noUser.host = QLatin1String("localhost");
|
||||||
noUser.port = 22;
|
noUser.port = 22;
|
||||||
noUser.timeout = 30;
|
noUser.timeout = 30;
|
||||||
noUser.authType = SshConnectionParameters::AuthByPwd;
|
noUser.authenticationType = SshConnectionParameters::AuthenticationByPassword;
|
||||||
noUser.uname = QLatin1String("dumdidumpuffpuff");
|
noUser.userName = QLatin1String("dumdidumpuffpuff");
|
||||||
noUser.uname = QLatin1String("whatever");
|
noUser.password = QLatin1String("whatever");
|
||||||
|
|
||||||
SshConnectionParameters wrongPwd=SshConnectionParameters(SshConnectionParameters::DefaultProxy);
|
SshConnectionParameters wrongPwd=SshConnectionParameters(SshConnectionParameters::DefaultProxy);
|
||||||
wrongPwd.host = QLatin1String("localhost");
|
wrongPwd.host = QLatin1String("localhost");
|
||||||
wrongPwd.port = 22;
|
wrongPwd.port = 22;
|
||||||
wrongPwd.timeout = 30;
|
wrongPwd.timeout = 30;
|
||||||
wrongPwd.authType = SshConnectionParameters::AuthByPwd;
|
wrongPwd.authenticationType = SshConnectionParameters::AuthenticationByPassword;
|
||||||
wrongPwd.uname = QLatin1String("root");
|
wrongPwd.userName = QLatin1String("root");
|
||||||
noUser.uname = QLatin1String("thiscantpossiblybeapasswordcanit");
|
noUser.password = QLatin1String("thiscantpossiblybeapasswordcanit");
|
||||||
|
|
||||||
SshConnectionParameters invalidKeyFile=SshConnectionParameters(SshConnectionParameters::DefaultProxy);
|
SshConnectionParameters invalidKeyFile=SshConnectionParameters(SshConnectionParameters::DefaultProxy);
|
||||||
invalidKeyFile.host = QLatin1String("localhost");
|
invalidKeyFile.host = QLatin1String("localhost");
|
||||||
invalidKeyFile.port = 22;
|
invalidKeyFile.port = 22;
|
||||||
invalidKeyFile.timeout = 30;
|
invalidKeyFile.timeout = 30;
|
||||||
invalidKeyFile.authType = SshConnectionParameters::AuthByKey;
|
invalidKeyFile.authenticationType = SshConnectionParameters::AuthenticationByKey;
|
||||||
invalidKeyFile.uname = QLatin1String("root");
|
invalidKeyFile.userName = QLatin1String("root");
|
||||||
invalidKeyFile.privateKeyFile
|
invalidKeyFile.privateKeyFile
|
||||||
= QLatin1String("somefilenamethatwedontexpecttocontainavalidkey");
|
= QLatin1String("somefilenamethatwedontexpecttocontainavalidkey");
|
||||||
|
|
||||||
@@ -129,7 +129,7 @@ private slots:
|
|||||||
qApp->quit();
|
qApp->quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleError(Core::SshError error)
|
void handleError(Utils::SshError error)
|
||||||
{
|
{
|
||||||
if (m_testSet.isEmpty()) {
|
if (m_testSet.isEmpty()) {
|
||||||
qDebug("Error: Received error %d, but no test was running.", error);
|
qDebug("Error: Received error %d, but no test was running.", error);
|
||||||
@@ -173,8 +173,8 @@ private:
|
|||||||
SLOT(handleDisconnected()));
|
SLOT(handleDisconnected()));
|
||||||
connect(m_connection.data(), SIGNAL(dataAvailable(QString)), this,
|
connect(m_connection.data(), SIGNAL(dataAvailable(QString)), this,
|
||||||
SLOT(handleDataAvailable(QString)));
|
SLOT(handleDataAvailable(QString)));
|
||||||
connect(m_connection.data(), SIGNAL(error(Core::SshError)), this,
|
connect(m_connection.data(), SIGNAL(error(Utils::SshError)), this,
|
||||||
SLOT(handleError(Core::SshError)));
|
SLOT(handleError(Utils::SshError)));
|
||||||
const TestItem &nextItem = m_testSet.first();
|
const TestItem &nextItem = m_testSet.first();
|
||||||
m_timeoutTimer.stop();
|
m_timeoutTimer.stop();
|
||||||
m_timeoutTimer.setInterval(qMax(10000, nextItem.params.timeout * 1000));
|
m_timeoutTimer.setInterval(qMax(10000, nextItem.params.timeout * 1000));
|
||||||
|
@@ -36,16 +36,16 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace Core;
|
using namespace Utils;
|
||||||
|
|
||||||
ArgumentsCollector::ArgumentsCollector(const QStringList &args)
|
ArgumentsCollector::ArgumentsCollector(const QStringList &args)
|
||||||
: m_arguments(args)
|
: m_arguments(args)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::SshConnectionParameters ArgumentsCollector::collect(bool &success) const
|
Utils::SshConnectionParameters ArgumentsCollector::collect(bool &success) const
|
||||||
{
|
{
|
||||||
SshConnectionParameters parameters(Core::SshConnectionParameters::NoProxy);
|
SshConnectionParameters parameters(Utils::SshConnectionParameters::NoProxy);
|
||||||
try {
|
try {
|
||||||
bool authTypeGiven = false;
|
bool authTypeGiven = false;
|
||||||
bool portGiven = false;
|
bool portGiven = false;
|
||||||
@@ -55,24 +55,24 @@ Core::SshConnectionParameters ArgumentsCollector::collect(bool &success) const
|
|||||||
int port;
|
int port;
|
||||||
for (pos = 1; pos < m_arguments.count() - 1; ++pos) {
|
for (pos = 1; pos < m_arguments.count() - 1; ++pos) {
|
||||||
if (checkAndSetStringArg(pos, parameters.host, "-h")
|
if (checkAndSetStringArg(pos, parameters.host, "-h")
|
||||||
|| checkAndSetStringArg(pos, parameters.uname, "-u"))
|
|| checkAndSetStringArg(pos, parameters.userName, "-u"))
|
||||||
continue;
|
continue;
|
||||||
if (checkAndSetIntArg(pos, port, portGiven, "-p")
|
if (checkAndSetIntArg(pos, port, portGiven, "-p")
|
||||||
|| checkAndSetIntArg(pos, parameters.timeout, timeoutGiven, "-t"))
|
|| checkAndSetIntArg(pos, parameters.timeout, timeoutGiven, "-t"))
|
||||||
continue;
|
continue;
|
||||||
if (checkAndSetStringArg(pos, parameters.pwd, "-pwd")) {
|
if (checkAndSetStringArg(pos, parameters.password, "-pwd")) {
|
||||||
if (!parameters.privateKeyFile.isEmpty())
|
if (!parameters.privateKeyFile.isEmpty())
|
||||||
throw ArgumentErrorException(QLatin1String("-pwd and -k are mutually exclusive."));
|
throw ArgumentErrorException(QLatin1String("-pwd and -k are mutually exclusive."));
|
||||||
parameters.authType
|
parameters.authenticationType
|
||||||
= SshConnectionParameters::AuthByPwd;
|
= SshConnectionParameters::AuthenticationByPassword;
|
||||||
authTypeGiven = true;
|
authTypeGiven = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (checkAndSetStringArg(pos, parameters.privateKeyFile, "-k")) {
|
if (checkAndSetStringArg(pos, parameters.privateKeyFile, "-k")) {
|
||||||
if (!parameters.pwd.isEmpty())
|
if (!parameters.password.isEmpty())
|
||||||
throw ArgumentErrorException(QLatin1String("-pwd and -k are mutually exclusive."));
|
throw ArgumentErrorException(QLatin1String("-pwd and -k are mutually exclusive."));
|
||||||
parameters.authType
|
parameters.authenticationType
|
||||||
= SshConnectionParameters::AuthByKey;
|
= SshConnectionParameters::AuthenticationByKey;
|
||||||
authTypeGiven = true;
|
authTypeGiven = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -90,7 +90,7 @@ Core::SshConnectionParameters ArgumentsCollector::collect(bool &success) const
|
|||||||
throw ArgumentErrorException(QLatin1String("No authentication argument given."));
|
throw ArgumentErrorException(QLatin1String("No authentication argument given."));
|
||||||
if (parameters.host.isEmpty())
|
if (parameters.host.isEmpty())
|
||||||
throw ArgumentErrorException(QLatin1String("No host given."));
|
throw ArgumentErrorException(QLatin1String("No host given."));
|
||||||
if (parameters.uname.isEmpty())
|
if (parameters.userName.isEmpty())
|
||||||
throw ArgumentErrorException(QLatin1String("No user name given."));
|
throw ArgumentErrorException(QLatin1String("No user name given."));
|
||||||
|
|
||||||
parameters.port = portGiven ? port : 22;
|
parameters.port = portGiven ? port : 22;
|
||||||
|
@@ -34,7 +34,7 @@
|
|||||||
#ifndef ARGUMENTSCOLLECTOR_H
|
#ifndef ARGUMENTSCOLLECTOR_H
|
||||||
#define ARGUMENTSCOLLECTOR_H
|
#define ARGUMENTSCOLLECTOR_H
|
||||||
|
|
||||||
#include <coreplugin/ssh/sshconnection.h>
|
#include <utils/ssh/sshconnection.h>
|
||||||
|
|
||||||
#include <QtCore/QStringList>
|
#include <QtCore/QStringList>
|
||||||
|
|
||||||
@@ -42,7 +42,7 @@ class ArgumentsCollector
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ArgumentsCollector(const QStringList &args);
|
ArgumentsCollector(const QStringList &args);
|
||||||
Core::SshConnectionParameters collect(bool &success) const;
|
Utils::SshConnectionParameters collect(bool &success) const;
|
||||||
private:
|
private:
|
||||||
struct ArgumentErrorException
|
struct ArgumentErrorException
|
||||||
{
|
{
|
||||||
@@ -55,7 +55,7 @@ private:
|
|||||||
bool checkAndSetIntArg(int &pos, int &val, bool &alreadyGiven,
|
bool checkAndSetIntArg(int &pos, int &val, bool &alreadyGiven,
|
||||||
const char *opt) const;
|
const char *opt) const;
|
||||||
bool checkForNoProxy(int &pos,
|
bool checkForNoProxy(int &pos,
|
||||||
Core::SshConnectionParameters::ProxyType &type,
|
Utils::SshConnectionParameters::ProxyType &type,
|
||||||
bool &alreadyGiven) const;
|
bool &alreadyGiven) const;
|
||||||
|
|
||||||
const QStringList m_arguments;
|
const QStringList m_arguments;
|
||||||
|
@@ -34,7 +34,7 @@
|
|||||||
#include "argumentscollector.h"
|
#include "argumentscollector.h"
|
||||||
#include "remoteprocesstest.h"
|
#include "remoteprocesstest.h"
|
||||||
|
|
||||||
#include <coreplugin/ssh/sshconnection.h>
|
#include <utils/ssh/sshconnection.h>
|
||||||
|
|
||||||
#include <QtCore/QCoreApplication>
|
#include <QtCore/QCoreApplication>
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
@@ -43,13 +43,13 @@
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Utils;
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QCoreApplication app(argc, argv);
|
QCoreApplication app(argc, argv);
|
||||||
bool parseSuccess;
|
bool parseSuccess;
|
||||||
const Core::SshConnectionParameters ¶meters
|
const Utils::SshConnectionParameters ¶meters
|
||||||
= ArgumentsCollector(app.arguments()).collect(parseSuccess);
|
= ArgumentsCollector(app.arguments()).collect(parseSuccess);
|
||||||
if (!parseSuccess)
|
if (!parseSuccess)
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
@@ -38,7 +38,7 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Utils;
|
||||||
|
|
||||||
RemoteProcessTest::RemoteProcessTest(const SshConnectionParameters ¶ms)
|
RemoteProcessTest::RemoteProcessTest(const SshConnectionParameters ¶ms)
|
||||||
: m_timeoutTimer(new QTimer(this)),
|
: m_timeoutTimer(new QTimer(this)),
|
||||||
@@ -53,7 +53,7 @@ RemoteProcessTest::~RemoteProcessTest() { }
|
|||||||
|
|
||||||
void RemoteProcessTest::run()
|
void RemoteProcessTest::run()
|
||||||
{
|
{
|
||||||
connect(m_remoteRunner.data(), SIGNAL(connectionError(Core::SshError)),
|
connect(m_remoteRunner.data(), SIGNAL(connectionError(Utils::SshError)),
|
||||||
SLOT(handleConnectionError()));
|
SLOT(handleConnectionError()));
|
||||||
connect(m_remoteRunner.data(), SIGNAL(processStarted()),
|
connect(m_remoteRunner.data(), SIGNAL(processStarted()),
|
||||||
SLOT(handleProcessStarted()));
|
SLOT(handleProcessStarted()));
|
||||||
@@ -88,7 +88,7 @@ void RemoteProcessTest::handleProcessStarted()
|
|||||||
} else {
|
} else {
|
||||||
m_started = true;
|
m_started = true;
|
||||||
if (m_state == TestingCrash) {
|
if (m_state == TestingCrash) {
|
||||||
Core::SshRemoteProcess::Ptr killer
|
Utils::SshRemoteProcess::Ptr killer
|
||||||
= m_remoteRunner->connection()->createRemoteProcess("pkill -9 sleep");
|
= m_remoteRunner->connection()->createRemoteProcess("pkill -9 sleep");
|
||||||
killer->start();
|
killer->start();
|
||||||
}
|
}
|
||||||
|
@@ -34,7 +34,7 @@
|
|||||||
#ifndef SFTPTEST_H
|
#ifndef SFTPTEST_H
|
||||||
#define SFTPTEST_H
|
#define SFTPTEST_H
|
||||||
|
|
||||||
#include <coreplugin/ssh/sshremoteprocessrunner.h>
|
#include <utils/ssh/sshremoteprocessrunner.h>
|
||||||
|
|
||||||
QT_FORWARD_DECLARE_CLASS(QTimer);
|
QT_FORWARD_DECLARE_CLASS(QTimer);
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
@@ -43,7 +43,7 @@ class RemoteProcessTest : public QObject
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
RemoteProcessTest(const Core::SshConnectionParameters ¶ms);
|
RemoteProcessTest(const Utils::SshConnectionParameters ¶ms);
|
||||||
~RemoteProcessTest();
|
~RemoteProcessTest();
|
||||||
void run();
|
void run();
|
||||||
|
|
||||||
@@ -59,7 +59,7 @@ private:
|
|||||||
enum State { Inactive, TestingSuccess, TestingFailure, TestingCrash };
|
enum State { Inactive, TestingSuccess, TestingFailure, TestingCrash };
|
||||||
|
|
||||||
QTimer * const m_timeoutTimer;
|
QTimer * const m_timeoutTimer;
|
||||||
const Core::SshRemoteProcessRunner::Ptr m_remoteRunner;
|
const Utils::SshRemoteProcessRunner::Ptr m_remoteRunner;
|
||||||
QByteArray m_remoteStdout;
|
QByteArray m_remoteStdout;
|
||||||
QByteArray m_remoteStderr;
|
QByteArray m_remoteStderr;
|
||||||
State m_state;
|
State m_state;
|
||||||
|
@@ -36,7 +36,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace Core;
|
using namespace Utils;
|
||||||
|
|
||||||
ArgumentsCollector::ArgumentsCollector(const QStringList &args)
|
ArgumentsCollector::ArgumentsCollector(const QStringList &args)
|
||||||
: m_arguments(args)
|
: m_arguments(args)
|
||||||
@@ -57,26 +57,26 @@ Parameters ArgumentsCollector::collect(bool &success) const
|
|||||||
int port;
|
int port;
|
||||||
for (pos = 1; pos < m_arguments.count() - 1; ++pos) {
|
for (pos = 1; pos < m_arguments.count() - 1; ++pos) {
|
||||||
if (checkAndSetStringArg(pos, parameters.sshParams.host, "-h")
|
if (checkAndSetStringArg(pos, parameters.sshParams.host, "-h")
|
||||||
|| checkAndSetStringArg(pos, parameters.sshParams.uname, "-u"))
|
|| checkAndSetStringArg(pos, parameters.sshParams.userName, "-u"))
|
||||||
continue;
|
continue;
|
||||||
if (checkAndSetIntArg(pos, port, portGiven, "-p")
|
if (checkAndSetIntArg(pos, port, portGiven, "-p")
|
||||||
|| checkAndSetIntArg(pos, parameters.sshParams.timeout, timeoutGiven, "-t")
|
|| checkAndSetIntArg(pos, parameters.sshParams.timeout, timeoutGiven, "-t")
|
||||||
|| checkAndSetIntArg(pos, parameters.smallFileCount, smallFileCountGiven, "-c")
|
|| checkAndSetIntArg(pos, parameters.smallFileCount, smallFileCountGiven, "-c")
|
||||||
|| checkAndSetIntArg(pos, parameters.bigFileSize, bigFileSizeGiven, "-s"))
|
|| checkAndSetIntArg(pos, parameters.bigFileSize, bigFileSizeGiven, "-s"))
|
||||||
continue;
|
continue;
|
||||||
if (checkAndSetStringArg(pos, parameters.sshParams.pwd, "-pwd")) {
|
if (checkAndSetStringArg(pos, parameters.sshParams.password, "-pwd")) {
|
||||||
if (!parameters.sshParams.privateKeyFile.isEmpty())
|
if (!parameters.sshParams.privateKeyFile.isEmpty())
|
||||||
throw ArgumentErrorException(QLatin1String("-pwd and -k are mutually exclusive."));
|
throw ArgumentErrorException(QLatin1String("-pwd and -k are mutually exclusive."));
|
||||||
parameters.sshParams.authType
|
parameters.sshParams.authenticationType
|
||||||
= SshConnectionParameters::AuthByPwd;
|
= SshConnectionParameters::AuthenticationByPassword;
|
||||||
authTypeGiven = true;
|
authTypeGiven = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (checkAndSetStringArg(pos, parameters.sshParams.privateKeyFile, "-k")) {
|
if (checkAndSetStringArg(pos, parameters.sshParams.privateKeyFile, "-k")) {
|
||||||
if (!parameters.sshParams.pwd.isEmpty())
|
if (!parameters.sshParams.password.isEmpty())
|
||||||
throw ArgumentErrorException(QLatin1String("-pwd and -k are mutually exclusive."));
|
throw ArgumentErrorException(QLatin1String("-pwd and -k are mutually exclusive."));
|
||||||
parameters.sshParams.authType
|
parameters.sshParams.authenticationType
|
||||||
= SshConnectionParameters::AuthByKey;
|
= SshConnectionParameters::AuthenticationByKey;
|
||||||
authTypeGiven = true;
|
authTypeGiven = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -94,7 +94,7 @@ Parameters ArgumentsCollector::collect(bool &success) const
|
|||||||
throw ArgumentErrorException(QLatin1String("No authentication argument given."));
|
throw ArgumentErrorException(QLatin1String("No authentication argument given."));
|
||||||
if (parameters.sshParams.host.isEmpty())
|
if (parameters.sshParams.host.isEmpty())
|
||||||
throw ArgumentErrorException(QLatin1String("No host given."));
|
throw ArgumentErrorException(QLatin1String("No host given."));
|
||||||
if (parameters.sshParams.uname.isEmpty())
|
if (parameters.sshParams.userName.isEmpty())
|
||||||
throw ArgumentErrorException(QLatin1String("No user name given."));
|
throw ArgumentErrorException(QLatin1String("No user name given."));
|
||||||
|
|
||||||
parameters.sshParams.port = portGiven ? port : 22;
|
parameters.sshParams.port = portGiven ? port : 22;
|
||||||
|
@@ -55,7 +55,7 @@ private:
|
|||||||
bool checkAndSetIntArg(int &pos, int &val, bool &alreadyGiven,
|
bool checkAndSetIntArg(int &pos, int &val, bool &alreadyGiven,
|
||||||
const char *opt) const;
|
const char *opt) const;
|
||||||
bool checkForNoProxy(int &pos,
|
bool checkForNoProxy(int &pos,
|
||||||
Core::SshConnectionParameters::ProxyType &type,
|
Utils::SshConnectionParameters::ProxyType &type,
|
||||||
bool &alreadyGiven) const;
|
bool &alreadyGiven) const;
|
||||||
|
|
||||||
const QStringList m_arguments;
|
const QStringList m_arguments;
|
||||||
|
@@ -34,8 +34,8 @@
|
|||||||
#include "argumentscollector.h"
|
#include "argumentscollector.h"
|
||||||
#include "sftptest.h"
|
#include "sftptest.h"
|
||||||
|
|
||||||
#include <coreplugin/ssh/sftpchannel.h>
|
#include <utils/ssh/sftpchannel.h>
|
||||||
#include <coreplugin/ssh/sshconnection.h>
|
#include <utils/ssh/sshconnection.h>
|
||||||
|
|
||||||
#include <QtCore/QCoreApplication>
|
#include <QtCore/QCoreApplication>
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
@@ -44,7 +44,7 @@
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Utils;
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
@@ -34,12 +34,12 @@
|
|||||||
#ifndef PARAMETERS_H
|
#ifndef PARAMETERS_H
|
||||||
#define PARAMETERS_H
|
#define PARAMETERS_H
|
||||||
|
|
||||||
#include <coreplugin/ssh/sshconnection.h>
|
#include <utils/ssh/sshconnection.h>
|
||||||
|
|
||||||
struct Parameters {
|
struct Parameters {
|
||||||
Parameters() : sshParams(Core::SshConnectionParameters::DefaultProxy) {}
|
Parameters() : sshParams(Utils::SshConnectionParameters::DefaultProxy) {}
|
||||||
|
|
||||||
Core::SshConnectionParameters sshParams;
|
Utils::SshConnectionParameters sshParams;
|
||||||
int smallFileCount;
|
int smallFileCount;
|
||||||
int bigFileSize;
|
int bigFileSize;
|
||||||
};
|
};
|
||||||
|
@@ -41,7 +41,7 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Utils;
|
||||||
|
|
||||||
SftpTest::SftpTest(const Parameters ¶ms)
|
SftpTest::SftpTest(const Parameters ¶ms)
|
||||||
: m_parameters(params), m_state(Inactive), m_error(false),
|
: m_parameters(params), m_state(Inactive), m_error(false),
|
||||||
@@ -61,7 +61,7 @@ void SftpTest::run()
|
|||||||
m_connection = SshConnection::create();
|
m_connection = SshConnection::create();
|
||||||
connect(m_connection.data(), SIGNAL(connected()), this,
|
connect(m_connection.data(), SIGNAL(connected()), this,
|
||||||
SLOT(handleConnected()));
|
SLOT(handleConnected()));
|
||||||
connect(m_connection.data(), SIGNAL(error(Core::SshError)), this,
|
connect(m_connection.data(), SIGNAL(error(Utils::SshError)), this,
|
||||||
SLOT(handleError()));
|
SLOT(handleError()));
|
||||||
connect(m_connection.data(), SIGNAL(disconnected()), this,
|
connect(m_connection.data(), SIGNAL(disconnected()), this,
|
||||||
SLOT(handleDisconnected()));
|
SLOT(handleDisconnected()));
|
||||||
@@ -84,8 +84,8 @@ void SftpTest::handleConnected()
|
|||||||
SLOT(handleChannelInitialized()));
|
SLOT(handleChannelInitialized()));
|
||||||
connect(m_channel.data(), SIGNAL(initializationFailed(QString)), this,
|
connect(m_channel.data(), SIGNAL(initializationFailed(QString)), this,
|
||||||
SLOT(handleChannelInitializationFailure(QString)));
|
SLOT(handleChannelInitializationFailure(QString)));
|
||||||
connect(m_channel.data(), SIGNAL(finished(Core::SftpJobId, QString)),
|
connect(m_channel.data(), SIGNAL(finished(Utils::SftpJobId, QString)),
|
||||||
this, SLOT(handleJobFinished(Core::SftpJobId, QString)));
|
this, SLOT(handleJobFinished(Utils::SftpJobId, QString)));
|
||||||
connect(m_channel.data(), SIGNAL(closed()), this,
|
connect(m_channel.data(), SIGNAL(closed()), this,
|
||||||
SLOT(handleChannelClosed()));
|
SLOT(handleChannelClosed()));
|
||||||
m_state = InitializingChannel;
|
m_state = InitializingChannel;
|
||||||
@@ -192,7 +192,7 @@ void SftpTest::handleChannelClosed()
|
|||||||
m_connection->disconnectFromHost();
|
m_connection->disconnectFromHost();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SftpTest::handleJobFinished(Core::SftpJobId job, const QString &error)
|
void SftpTest::handleJobFinished(Utils::SftpJobId job, const QString &error)
|
||||||
{
|
{
|
||||||
switch (m_state) {
|
switch (m_state) {
|
||||||
case UploadingSmall:
|
case UploadingSmall:
|
||||||
|
@@ -36,8 +36,8 @@
|
|||||||
|
|
||||||
#include "parameters.h"
|
#include "parameters.h"
|
||||||
|
|
||||||
#include <coreplugin/ssh/sftpchannel.h>
|
#include <utils/ssh/sftpchannel.h>
|
||||||
#include <coreplugin/ssh/sshconnection.h>
|
#include <utils/ssh/sshconnection.h>
|
||||||
|
|
||||||
#include <QtCore/QElapsedTimer>
|
#include <QtCore/QElapsedTimer>
|
||||||
#include <QtCore/QHash>
|
#include <QtCore/QHash>
|
||||||
@@ -61,11 +61,11 @@ private slots:
|
|||||||
void handleDisconnected();
|
void handleDisconnected();
|
||||||
void handleChannelInitialized();
|
void handleChannelInitialized();
|
||||||
void handleChannelInitializationFailure(const QString &reason);
|
void handleChannelInitializationFailure(const QString &reason);
|
||||||
void handleJobFinished(Core::SftpJobId job, const QString &error);
|
void handleJobFinished(Utils::SftpJobId job, const QString &error);
|
||||||
void handleChannelClosed();
|
void handleChannelClosed();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef QHash<Core::SftpJobId, QString> JobMap;
|
typedef QHash<Utils::SftpJobId, QString> JobMap;
|
||||||
typedef QSharedPointer<QFile> FilePtr;
|
typedef QSharedPointer<QFile> FilePtr;
|
||||||
enum State { Inactive, Connecting, InitializingChannel, UploadingSmall,
|
enum State { Inactive, Connecting, InitializingChannel, UploadingSmall,
|
||||||
DownloadingSmall, RemovingSmall, UploadingBig, DownloadingBig,
|
DownloadingSmall, RemovingSmall, UploadingBig, DownloadingBig,
|
||||||
@@ -77,25 +77,25 @@ private:
|
|||||||
QString cmpFileName(const QString &localFileName) const;
|
QString cmpFileName(const QString &localFileName) const;
|
||||||
QString remoteFilePath(const QString &localFileName) const;
|
QString remoteFilePath(const QString &localFileName) const;
|
||||||
void earlyDisconnectFromHost();
|
void earlyDisconnectFromHost();
|
||||||
bool handleJobFinished(Core::SftpJobId job, JobMap &jobMap,
|
bool handleJobFinished(Utils::SftpJobId job, JobMap &jobMap,
|
||||||
const QString &error, const char *activity);
|
const QString &error, const char *activity);
|
||||||
bool handleBigJobFinished(Core::SftpJobId job, Core::SftpJobId expectedJob,
|
bool handleBigJobFinished(Utils::SftpJobId job, Utils::SftpJobId expectedJob,
|
||||||
const QString &error, const char *activity);
|
const QString &error, const char *activity);
|
||||||
bool compareFiles(QFile *orig, QFile *copy);
|
bool compareFiles(QFile *orig, QFile *copy);
|
||||||
|
|
||||||
const Parameters m_parameters;
|
const Parameters m_parameters;
|
||||||
State m_state;
|
State m_state;
|
||||||
bool m_error;
|
bool m_error;
|
||||||
Core::SshConnection::Ptr m_connection;
|
Utils::SshConnection::Ptr m_connection;
|
||||||
Core::SftpChannel::Ptr m_channel;
|
Utils::SftpChannel::Ptr m_channel;
|
||||||
QList<FilePtr> m_localSmallFiles;
|
QList<FilePtr> m_localSmallFiles;
|
||||||
JobMap m_smallFilesUploadJobs;
|
JobMap m_smallFilesUploadJobs;
|
||||||
JobMap m_smallFilesDownloadJobs;
|
JobMap m_smallFilesDownloadJobs;
|
||||||
JobMap m_smallFilesRemovalJobs;
|
JobMap m_smallFilesRemovalJobs;
|
||||||
FilePtr m_localBigFile;
|
FilePtr m_localBigFile;
|
||||||
Core::SftpJobId m_bigFileUploadJob;
|
Utils::SftpJobId m_bigFileUploadJob;
|
||||||
Core::SftpJobId m_bigFileDownloadJob;
|
Utils::SftpJobId m_bigFileDownloadJob;
|
||||||
Core::SftpJobId m_bigFileRemovalJob;
|
Utils::SftpJobId m_bigFileRemovalJob;
|
||||||
QElapsedTimer m_bigJobTimer;
|
QElapsedTimer m_bigJobTimer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user