forked from qt-creator/qt-creator
Maemo: Use new SSH convenience class for fetching device environment.
This commit is contained in:
@@ -37,8 +37,7 @@
|
|||||||
#include "maemoglobal.h"
|
#include "maemoglobal.h"
|
||||||
#include "maemorunconfiguration.h"
|
#include "maemorunconfiguration.h"
|
||||||
|
|
||||||
#include <coreplugin/ssh/sshconnection.h>
|
#include <coreplugin/ssh/sshremoteprocessrunner.h>
|
||||||
#include <coreplugin/ssh/sshremoteprocess.h>
|
|
||||||
|
|
||||||
namespace Qt4ProjectManager {
|
namespace Qt4ProjectManager {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -60,71 +59,52 @@ MaemoDeviceEnvReader::~MaemoDeviceEnvReader()
|
|||||||
void MaemoDeviceEnvReader::start()
|
void MaemoDeviceEnvReader::start()
|
||||||
{
|
{
|
||||||
m_stop = false;
|
m_stop = false;
|
||||||
if (m_connection)
|
if (!m_remoteProcessRunner
|
||||||
disconnect(m_connection.data(), 0, this, 0);
|
|| m_remoteProcessRunner->connection()->state() != Core::SshConnection::Connected
|
||||||
|
|| m_remoteProcessRunner->connection()->connectionParameters() != m_devConfig.server) {
|
||||||
const bool reuse = m_connection
|
m_remoteProcessRunner
|
||||||
&& m_connection->state() == Core::SshConnection::Connected
|
= Core::SshRemoteProcessRunner::create(m_devConfig.server);
|
||||||
&& m_connection->connectionParameters() == m_devConfig.server;
|
}
|
||||||
|
connect(m_remoteProcessRunner.data(),
|
||||||
if (!reuse)
|
SIGNAL(connectionError(Core::SshError)), this,
|
||||||
m_connection = Core::SshConnection::create();
|
|
||||||
|
|
||||||
connect(m_connection.data(), SIGNAL(connected()), this,
|
|
||||||
SLOT(executeRemoteCall()));
|
|
||||||
connect(m_connection.data(), SIGNAL(error(Core::SshError)), this,
|
|
||||||
SLOT(handleConnectionFailure()));
|
SLOT(handleConnectionFailure()));
|
||||||
|
connect(m_remoteProcessRunner.data(), SIGNAL(processClosed(int)), this,
|
||||||
if (reuse)
|
SLOT(remoteProcessFinished(int)));
|
||||||
executeRemoteCall();
|
connect(m_remoteProcessRunner.data(),
|
||||||
else
|
SIGNAL(processOutputAvailable(QByteArray)), this,
|
||||||
m_connection->connectToHost(m_devConfig.server);
|
SLOT(remoteOutput(QByteArray)));
|
||||||
|
connect(m_remoteProcessRunner.data(),
|
||||||
|
SIGNAL(processErrorOutputAvailable(QByteArray)), this,
|
||||||
|
SLOT(remoteErrorOutput(QByteArray)));
|
||||||
|
const QByteArray remoteCall = MaemoGlobal::remoteSourceProfilesCommand()
|
||||||
|
.toUtf8() + "; env";
|
||||||
|
m_remoteOutput.clear();
|
||||||
|
m_remoteProcessRunner->run(remoteCall);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaemoDeviceEnvReader::stop()
|
void MaemoDeviceEnvReader::stop()
|
||||||
{
|
{
|
||||||
m_stop = true;
|
m_stop = true;
|
||||||
|
if (m_remoteProcessRunner)
|
||||||
if (m_connection)
|
disconnect(m_remoteProcessRunner.data(), 0, this, 0);
|
||||||
disconnect(m_connection.data(), 0, this, 0);
|
|
||||||
if (m_remoteProcess) {
|
|
||||||
disconnect(m_remoteProcess.data());
|
|
||||||
m_remoteProcess->closeChannel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MaemoDeviceEnvReader::executeRemoteCall()
|
|
||||||
{
|
|
||||||
if (m_stop)
|
|
||||||
return;
|
|
||||||
|
|
||||||
const QByteArray remoteCall = MaemoGlobal::remoteSourceProfilesCommand()
|
|
||||||
.toUtf8() + "; env";
|
|
||||||
m_remoteProcess = m_connection->createRemoteProcess(remoteCall);
|
|
||||||
|
|
||||||
connect(m_remoteProcess.data(), SIGNAL(closed(int)), this,
|
|
||||||
SLOT(remoteProcessFinished(int)));
|
|
||||||
connect(m_remoteProcess.data(), SIGNAL(outputAvailable(QByteArray)), this,
|
|
||||||
SLOT(remoteOutput(QByteArray)));
|
|
||||||
connect(m_remoteProcess.data(), SIGNAL(errorOutputAvailable(QByteArray)), this,
|
|
||||||
SLOT(remoteErrorOutput(QByteArray)));
|
|
||||||
|
|
||||||
m_remoteOutput.clear();
|
|
||||||
m_remoteErrorOutput.clear();
|
|
||||||
m_remoteProcess->start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaemoDeviceEnvReader::handleConnectionFailure()
|
void MaemoDeviceEnvReader::handleConnectionFailure()
|
||||||
{
|
{
|
||||||
emit error(tr("Could not connect to host: %1")
|
if (m_stop)
|
||||||
.arg(m_connection->errorString()));
|
return;
|
||||||
setFinished();
|
|
||||||
|
disconnect(m_remoteProcessRunner.data(), 0, this, 0);
|
||||||
|
emit error(tr("Connection error: %1")
|
||||||
|
.arg(m_remoteProcessRunner->connection()->errorString()));
|
||||||
|
emit finished();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaemoDeviceEnvReader::handleCurrentDeviceConfigChanged()
|
void MaemoDeviceEnvReader::handleCurrentDeviceConfigChanged()
|
||||||
{
|
{
|
||||||
m_devConfig = m_runConfig->deviceConfig();
|
m_devConfig = m_runConfig->deviceConfig();
|
||||||
|
|
||||||
|
disconnect(m_remoteProcessRunner.data(), 0, this, 0);
|
||||||
m_env.clear();
|
m_env.clear();
|
||||||
setFinished();
|
setFinished();
|
||||||
}
|
}
|
||||||
@@ -138,6 +118,7 @@ void MaemoDeviceEnvReader::remoteProcessFinished(int exitCode)
|
|||||||
if (m_stop)
|
if (m_stop)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
disconnect(m_remoteProcessRunner.data(), 0, this, 0);
|
||||||
m_env.clear();
|
m_env.clear();
|
||||||
if (exitCode == Core::SshRemoteProcess::ExitedNormally) {
|
if (exitCode == Core::SshRemoteProcess::ExitedNormally) {
|
||||||
if (!m_remoteOutput.isEmpty()) {
|
if (!m_remoteOutput.isEmpty()) {
|
||||||
@@ -146,7 +127,7 @@ void MaemoDeviceEnvReader::remoteProcessFinished(int exitCode)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
QString errorMsg = tr("Error running remote process: %1")
|
QString errorMsg = tr("Error running remote process: %1")
|
||||||
.arg(m_remoteProcess->errorString());
|
.arg(m_remoteProcessRunner->process()->errorString());
|
||||||
if (!m_remoteErrorOutput.isEmpty()) {
|
if (!m_remoteErrorOutput.isEmpty()) {
|
||||||
errorMsg += tr("\nRemote stderr was: '%1'")
|
errorMsg += tr("\nRemote stderr was: '%1'")
|
||||||
.arg(QString::fromUtf8(m_remoteErrorOutput));
|
.arg(QString::fromUtf8(m_remoteErrorOutput));
|
||||||
|
|||||||
@@ -42,8 +42,7 @@
|
|||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
class SshConnection;
|
class SshRemoteProcessRunner;
|
||||||
class SshRemoteProcess;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Qt4ProjectManager {
|
namespace Qt4ProjectManager {
|
||||||
@@ -68,7 +67,6 @@ signals:
|
|||||||
void error(const QString &error);
|
void error(const QString &error);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void executeRemoteCall();
|
|
||||||
void handleConnectionFailure();
|
void handleConnectionFailure();
|
||||||
void handleCurrentDeviceConfigChanged();
|
void handleCurrentDeviceConfigChanged();
|
||||||
|
|
||||||
@@ -85,8 +83,7 @@ private:
|
|||||||
Utils::Environment m_env;
|
Utils::Environment m_env;
|
||||||
MaemoDeviceConfig m_devConfig;
|
MaemoDeviceConfig m_devConfig;
|
||||||
MaemoRunConfiguration *m_runConfig;
|
MaemoRunConfiguration *m_runConfig;
|
||||||
QSharedPointer<Core::SshConnection> m_connection;
|
QSharedPointer<Core::SshRemoteProcessRunner> m_remoteProcessRunner;
|
||||||
QSharedPointer<Core::SshRemoteProcess> m_remoteProcess;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // Internal
|
} // Internal
|
||||||
|
|||||||
Reference in New Issue
Block a user