forked from qt-creator/qt-creator
Maemo: Implement deploying via SSH library (instead of scp).
The code is #ifdef'ed out for now, but has been successfully tested.
This commit is contained in:
@@ -32,6 +32,7 @@
|
|||||||
#include "maemodeviceconfigurations.h"
|
#include "maemodeviceconfigurations.h"
|
||||||
#include "maemomanager.h"
|
#include "maemomanager.h"
|
||||||
#include "maemosettingspage.h"
|
#include "maemosettingspage.h"
|
||||||
|
#include "maemosshthread.h"
|
||||||
#include "maemotoolchain.h"
|
#include "maemotoolchain.h"
|
||||||
#include "profilereader.h"
|
#include "profilereader.h"
|
||||||
#include "qt4project.h"
|
#include "qt4project.h"
|
||||||
@@ -52,7 +53,9 @@
|
|||||||
#include <QtCore/QFuture>
|
#include <QtCore/QFuture>
|
||||||
#include <QtCore/QPair>
|
#include <QtCore/QPair>
|
||||||
#include <QtCore/QProcess>
|
#include <QtCore/QProcess>
|
||||||
|
#include <QtCore/QScopedPointer>
|
||||||
#include <QtCore/QSharedPointer>
|
#include <QtCore/QSharedPointer>
|
||||||
|
#include <QtCore/QStringBuilder>
|
||||||
|
|
||||||
#include <QtGui/QComboBox>
|
#include <QtGui/QComboBox>
|
||||||
#include <QtGui/QCheckBox>
|
#include <QtGui/QCheckBox>
|
||||||
@@ -120,12 +123,19 @@ protected:
|
|||||||
const QString targetCmdLinePrefix() const;
|
const QString targetCmdLinePrefix() const;
|
||||||
const QString remoteDir() const;
|
const QString remoteDir() const;
|
||||||
const QStringList options() const;
|
const QStringList options() const;
|
||||||
|
// #ifndef USE_SSH_LIB
|
||||||
void deploymentFinished(bool success);
|
void deploymentFinished(bool success);
|
||||||
virtual bool setProcessEnvironment(QProcess &process);
|
virtual bool setProcessEnvironment(QProcess &process);
|
||||||
|
// #endif // USE_SSH_LIB
|
||||||
private slots:
|
private slots:
|
||||||
|
// #ifndef USE_SSH_LIB
|
||||||
void readStandardError();
|
void readStandardError();
|
||||||
void readStandardOutput();
|
void readStandardOutput();
|
||||||
|
// #endif // USE_SSH_LIB
|
||||||
void deployProcessFinished();
|
void deployProcessFinished();
|
||||||
|
#ifdef USE_SSH_LIB
|
||||||
|
void handleFileCopied();
|
||||||
|
#endif
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
ErrorDumper dumper;
|
ErrorDumper dumper;
|
||||||
@@ -136,7 +146,11 @@ private:
|
|||||||
virtual void handleDeploymentFinished(bool success)=0;
|
virtual void handleDeploymentFinished(bool success)=0;
|
||||||
|
|
||||||
QFutureInterface<void> m_progress;
|
QFutureInterface<void> m_progress;
|
||||||
|
#ifdef USE_SSH_LIB
|
||||||
|
QScopedPointer<MaemoSshDeployer> sshDeployer;
|
||||||
|
#else
|
||||||
QProcess deployProcess;
|
QProcess deployProcess;
|
||||||
|
#endif // USE_SSH_LIB
|
||||||
struct Deployable
|
struct Deployable
|
||||||
{
|
{
|
||||||
typedef void (MaemoRunConfiguration::*updateFunc)();
|
typedef void (MaemoRunConfiguration::*updateFunc)();
|
||||||
@@ -990,8 +1004,8 @@ AbstractMaemoRunControl::AbstractMaemoRunControl(RunConfiguration *rc)
|
|||||||
, runConfig(qobject_cast<MaemoRunConfiguration *>(rc))
|
, runConfig(qobject_cast<MaemoRunConfiguration *>(rc))
|
||||||
, devConfig(runConfig ? runConfig->deviceConfig() : MaemoDeviceConfig())
|
, devConfig(runConfig ? runConfig->deviceConfig() : MaemoDeviceConfig())
|
||||||
{
|
{
|
||||||
|
#ifndef USE_SSH_LIB
|
||||||
setProcessEnvironment(deployProcess);
|
setProcessEnvironment(deployProcess);
|
||||||
|
|
||||||
connect(&deployProcess, SIGNAL(readyReadStandardError()), this,
|
connect(&deployProcess, SIGNAL(readyReadStandardError()), this,
|
||||||
SLOT(readStandardError()));
|
SLOT(readStandardError()));
|
||||||
connect(&deployProcess, SIGNAL(readyReadStandardOutput()), this,
|
connect(&deployProcess, SIGNAL(readyReadStandardOutput()), this,
|
||||||
@@ -1000,14 +1014,17 @@ AbstractMaemoRunControl::AbstractMaemoRunControl(RunConfiguration *rc)
|
|||||||
SLOT(printToStream(QProcess::ProcessError)));
|
SLOT(printToStream(QProcess::ProcessError)));
|
||||||
connect(&deployProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this,
|
connect(&deployProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this,
|
||||||
SLOT(deployProcessFinished()));
|
SLOT(deployProcessFinished()));
|
||||||
|
#endif // USE_SSH_LIB
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbstractMaemoRunControl::startDeployment(bool forDebugging)
|
void AbstractMaemoRunControl::startDeployment(bool forDebugging)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(runConfig, return);
|
QTC_ASSERT(runConfig, return);
|
||||||
|
|
||||||
|
#ifndef USE_SSH_LIB
|
||||||
Core::ICore::instance()->progressManager()->addTask(m_progress.future(),
|
Core::ICore::instance()->progressManager()->addTask(m_progress.future(),
|
||||||
tr("Deploying"), QLatin1String("Maemo.Deploy"));
|
tr("Deploying"), QLatin1String("Maemo.Deploy"));
|
||||||
|
#endif // USE_SSH_LIB
|
||||||
if (devConfig.isValid()) {
|
if (devConfig.isValid()) {
|
||||||
deployables.clear();
|
deployables.clear();
|
||||||
if (runConfig->currentlyNeedsDeployment()) {
|
if (runConfig->currentlyNeedsDeployment()) {
|
||||||
@@ -1021,9 +1038,11 @@ void AbstractMaemoRunControl::startDeployment(bool forDebugging)
|
|||||||
&MaemoRunConfiguration::debuggingHelpersDeployed));
|
&MaemoRunConfiguration::debuggingHelpersDeployed));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef USE_SSH_LIB
|
||||||
m_progress.setProgressRange(0, deployables.count());
|
m_progress.setProgressRange(0, deployables.count());
|
||||||
m_progress.setProgressValue(0);
|
m_progress.setProgressValue(0);
|
||||||
m_progress.reportStarted();
|
m_progress.reportStarted();
|
||||||
|
#endif // USE_SSH_LIB
|
||||||
deploy();
|
deploy();
|
||||||
} else {
|
} else {
|
||||||
deploymentFinished(false);
|
deploymentFinished(false);
|
||||||
@@ -1032,6 +1051,32 @@ void AbstractMaemoRunControl::startDeployment(bool forDebugging)
|
|||||||
|
|
||||||
void AbstractMaemoRunControl::deploy()
|
void AbstractMaemoRunControl::deploy()
|
||||||
{
|
{
|
||||||
|
#ifdef USE_SSH_LIB
|
||||||
|
if (!deployables.isEmpty()) {
|
||||||
|
QStringList files;
|
||||||
|
QStringList targetDirs;
|
||||||
|
foreach (const Deployable &deployable, deployables) {
|
||||||
|
files << deployable.dir + QDir::separator() + deployable.fileName;
|
||||||
|
targetDirs << remoteDir();
|
||||||
|
}
|
||||||
|
emit addToOutputWindow(this, tr("Files to deploy: %1.").arg(files.join(" ")));
|
||||||
|
sshDeployer.reset(new MaemoSshDeployer(devConfig, files, targetDirs));
|
||||||
|
connect(sshDeployer.data(), SIGNAL(finished()),
|
||||||
|
this, SLOT(deployProcessFinished()));
|
||||||
|
connect(sshDeployer.data(), SIGNAL(fileCopied(QString)),
|
||||||
|
this, SLOT(handleFileCopied()));
|
||||||
|
Core::ICore::instance()->progressManager()
|
||||||
|
->addTask(m_progress.future(), tr("Deploying"),
|
||||||
|
QLatin1String("Maemo.Deploy"));
|
||||||
|
m_progress.setProgressRange(0, deployables.count());
|
||||||
|
m_progress.setProgressValue(0);
|
||||||
|
m_progress.reportStarted();
|
||||||
|
emit started();
|
||||||
|
sshDeployer->start();
|
||||||
|
} else {
|
||||||
|
handleDeploymentFinished(true);
|
||||||
|
}
|
||||||
|
#else
|
||||||
if (!deployables.isEmpty()) {
|
if (!deployables.isEmpty()) {
|
||||||
const Deployable &deployable = deployables.first();
|
const Deployable &deployable = deployables.first();
|
||||||
emit addToOutputWindow(this, tr("File to deploy: %1.").arg(deployable.fileName));
|
emit addToOutputWindow(this, tr("File to deploy: %1.").arg(deployable.fileName));
|
||||||
@@ -1051,20 +1096,49 @@ void AbstractMaemoRunControl::deploy()
|
|||||||
} else {
|
} else {
|
||||||
deploymentFinished(true);
|
deploymentFinished(true);
|
||||||
}
|
}
|
||||||
|
#endif // USE_SSH_LIB
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USE_SSH_LIB
|
||||||
|
void AbstractMaemoRunControl::handleFileCopied()
|
||||||
|
{
|
||||||
|
Deployable deployable = deployables.takeFirst();
|
||||||
|
(runConfig->*deployable.updateTimestamp)();
|
||||||
|
m_progress.setProgressValue(m_progress.progressValue() + 1);
|
||||||
|
}
|
||||||
|
#endif // USE_SSH_LIB
|
||||||
|
|
||||||
void AbstractMaemoRunControl::stopDeployment()
|
void AbstractMaemoRunControl::stopDeployment()
|
||||||
{
|
{
|
||||||
|
#ifdef USE_SSH_LIB
|
||||||
|
sshDeployer->stop();
|
||||||
|
#else
|
||||||
deployProcess.kill();
|
deployProcess.kill();
|
||||||
|
#endif // USE_SSH_LIB
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AbstractMaemoRunControl::isDeploying() const
|
bool AbstractMaemoRunControl::isDeploying() const
|
||||||
{
|
{
|
||||||
|
#ifdef USE_SSH_LIB
|
||||||
|
return !sshDeployer.isNull() && sshDeployer->isRunning();
|
||||||
|
#else
|
||||||
return deployProcess.state() != QProcess::NotRunning;
|
return deployProcess.state() != QProcess::NotRunning;
|
||||||
|
#endif // USE_SSH_LIB
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbstractMaemoRunControl::deployProcessFinished()
|
void AbstractMaemoRunControl::deployProcessFinished()
|
||||||
{
|
{
|
||||||
|
#if USE_SSH_LIB
|
||||||
|
const bool success = !sshDeployer->hasError();
|
||||||
|
if (success) {
|
||||||
|
emit addToOutputWindow(this, tr("Deployment finished."));
|
||||||
|
} else {
|
||||||
|
emit error(this, tr("Deployment failed: ") % sshDeployer->error());
|
||||||
|
m_progress.reportCanceled();
|
||||||
|
}
|
||||||
|
m_progress.reportFinished();
|
||||||
|
handleDeploymentFinished(success);
|
||||||
|
#else
|
||||||
bool success;
|
bool success;
|
||||||
if (deployProcess.exitCode() == 0) {
|
if (deployProcess.exitCode() == 0) {
|
||||||
emit addToOutputWindow(this, tr("Target deployed."));
|
emit addToOutputWindow(this, tr("Target deployed."));
|
||||||
@@ -1080,13 +1154,16 @@ void AbstractMaemoRunControl::deployProcessFinished()
|
|||||||
deploymentFinished(success);
|
deploymentFinished(success);
|
||||||
else
|
else
|
||||||
deploy();
|
deploy();
|
||||||
|
#endif // USE_SSH_LIB
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef USE_SSH_LIB
|
||||||
void AbstractMaemoRunControl::deploymentFinished(bool success)
|
void AbstractMaemoRunControl::deploymentFinished(bool success)
|
||||||
{
|
{
|
||||||
m_progress.reportFinished();
|
m_progress.reportFinished();
|
||||||
handleDeploymentFinished(success);
|
handleDeploymentFinished(success);
|
||||||
}
|
}
|
||||||
|
#endif // USE_SSH_LIB
|
||||||
|
|
||||||
const QString AbstractMaemoRunControl::executableOnHost() const
|
const QString AbstractMaemoRunControl::executableOnHost() const
|
||||||
{
|
{
|
||||||
@@ -1140,6 +1217,7 @@ const QString AbstractMaemoRunControl::targetCmdLinePrefix() const
|
|||||||
arg(executableOnTarget());
|
arg(executableOnTarget());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// #ifndef USE_SSH_LIB
|
||||||
bool AbstractMaemoRunControl::setProcessEnvironment(QProcess &process)
|
bool AbstractMaemoRunControl::setProcessEnvironment(QProcess &process)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(runConfig, return false);
|
QTC_ASSERT(runConfig, return false);
|
||||||
@@ -1168,7 +1246,7 @@ void AbstractMaemoRunControl::readStandardOutput()
|
|||||||
emit addToOutputWindow(this, QString::fromLocal8Bit(data.constData(),
|
emit addToOutputWindow(this, QString::fromLocal8Bit(data.constData(),
|
||||||
data.length()));
|
data.length()));
|
||||||
}
|
}
|
||||||
|
// #endif // USE_SSH_LIB
|
||||||
|
|
||||||
// #pragma mark -- MaemoRunControl
|
// #pragma mark -- MaemoRunControl
|
||||||
|
|
||||||
|
@@ -47,6 +47,7 @@
|
|||||||
|
|
||||||
#include "/opt/ne7ssh/include/ne7ssh.h"
|
#include "/opt/ne7ssh/include/ne7ssh.h"
|
||||||
|
|
||||||
|
#include <QtCore/QFileInfo>
|
||||||
#include <QtCore/QStringBuilder>
|
#include <QtCore/QStringBuilder>
|
||||||
#include <QtCore/QStringList>
|
#include <QtCore/QStringList>
|
||||||
|
|
||||||
@@ -159,14 +160,15 @@ void MaemoSftpConnection::transferFiles(const QStringList &filePaths,
|
|||||||
&std::fclose);
|
&std::fclose);
|
||||||
if (filePtr.isNull())
|
if (filePtr.isNull())
|
||||||
throw MaemoSshException(tr("Could not open file '%1'").arg(curFile));
|
throw MaemoSshException(tr("Could not open file '%1'").arg(curFile));
|
||||||
const QString &targetFile
|
const QString &targetFile = targetDirs.at(i) % QLatin1String("/")
|
||||||
= targetDirs.at(i) % QLatin1String("/") % curFile;
|
% QFileInfo(curFile).fileName();
|
||||||
if (!sftp->put(filePtr.data(), targetFile.toLatin1().data())) {
|
if (!sftp->put(filePtr.data(), targetFile.toLatin1().data())) {
|
||||||
const QString &error = tr("Could not copy local file '%1' "
|
const QString &error = tr("Could not copy local file '%1' "
|
||||||
"to remote file '%2': %3").arg(curFile, targetFile)
|
"to remote file '%2': %3").arg(curFile, targetFile)
|
||||||
.arg(lastError());
|
.arg(lastError());
|
||||||
throw MaemoSshException(error);
|
throw MaemoSshException(error);
|
||||||
}
|
}
|
||||||
|
emit fileCopied(curFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user