Maemo: Add ports gatherer to deploy step.

This commit is contained in:
Christian Kandeler
2010-11-02 14:18:12 +01:00
parent 548df9385b
commit f2d14996ad
4 changed files with 29 additions and 21 deletions

View File

@@ -37,6 +37,7 @@
#include "maemoremotemounter.h" #include "maemoremotemounter.h"
#include "maemorunconfiguration.h" #include "maemorunconfiguration.h"
#include "maemotoolchain.h" #include "maemotoolchain.h"
#include "maemousedportsgatherer.h"
#include <coreplugin/ssh/sftpchannel.h> #include <coreplugin/ssh/sftpchannel.h>
#include <coreplugin/ssh/sshconnection.h> #include <coreplugin/ssh/sshconnection.h>
@@ -120,6 +121,11 @@ void MaemoDeployStep::ctor()
SLOT(handleProgressReport(QString))); SLOT(handleProgressReport(QString)));
connect(m_mounter, SIGNAL(debugOutput(QString)), this, connect(m_mounter, SIGNAL(debugOutput(QString)), this,
SLOT(handleMountDebugOutput(QString))); SLOT(handleMountDebugOutput(QString)));
m_portsGatherer = new MaemoUsedPortsGatherer(this);
connect(m_portsGatherer, SIGNAL(error(QString)), this,
SLOT(handlePortsGathererError(QString)));
connect(m_portsGatherer, SIGNAL(portListReady()), this,
SLOT(handlePortListReady()));
} }
bool MaemoDeployStep::init() bool MaemoDeployStep::init()
@@ -424,7 +430,7 @@ void MaemoDeployStep::handleUnmounted()
prepareSftpConnection(); prepareSftpConnection();
break; break;
case CurrentDirsUnmount: case CurrentDirsUnmount:
// m_mounter->mount(); TODO: See above m_portsGatherer->start(m_connection, deviceConfig().freePorts());
break; break;
case CurrentMountsUnmount: case CurrentMountsUnmount:
writeOutput(tr("Deployment finished.")); writeOutput(tr("Deployment finished."));
@@ -456,8 +462,7 @@ void MaemoDeployStep::setupMount()
const QString localDir const QString localDir
= QFileInfo(packagingStep()->packageFilePath()).absolutePath(); = QFileInfo(packagingStep()->packageFilePath()).absolutePath();
const MaemoMountSpecification mountSpec(localDir, deployMountPoint()); const MaemoMountSpecification mountSpec(localDir, deployMountPoint());
if (!addMountSpecification(mountSpec)) m_mounter->addMountSpecification(mountSpec, true);
return;
} else { } else {
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
bool drivesToMount[26]; bool drivesToMount[26];
@@ -479,14 +484,12 @@ void MaemoDeployStep::setupMount()
+ QLatin1Char(driveLetter); + QLatin1Char(driveLetter);
const MaemoMountSpecification mountSpec(localDir.left(3), const MaemoMountSpecification mountSpec(localDir.left(3),
mountPoint); mountPoint);
if (!addMountSpecification(mountSpec)) m_mounter->addMountSpecification(mountSpec, true);
return;
drivesToMount[index] = true; drivesToMount[index] = true;
} }
#else #else
if (!addMountSpecification(MaemoMountSpecification(QLatin1String("/"), m_mounter->addMountSpecification(MaemoMountSpecification(QLatin1String("/"),
deployMountPoint()))) deployMountPoint()), true);
return;
#endif #endif
} }
m_unmountState = CurrentDirsUnmount; m_unmountState = CurrentDirsUnmount;
@@ -657,15 +660,6 @@ void MaemoDeployStep::copyNextFileToDevice()
copyProcess->start(); copyProcess->start();
} }
bool MaemoDeployStep::addMountSpecification(const MaemoMountSpecification &mountSpec)
{
if (!m_mounter->addMountSpecification(mountSpec, true)) {
raiseError(tr("Device has not enough free ports for deployment."));
return false;
}
return true;
}
void MaemoDeployStep::handleCopyProcessFinished(int exitStatus) void MaemoDeployStep::handleCopyProcessFinished(int exitStatus)
{ {
if (m_stopped) { if (m_stopped) {
@@ -759,6 +753,17 @@ void MaemoDeployStep::handleInstallationFinished(int exitStatus)
m_mounter->unmount(); m_mounter->unmount();
} }
void MaemoDeployStep::handlePortsGathererError(const QString &errorMsg)
{
raiseError(errorMsg);
}
void MaemoDeployStep::handlePortListReady()
{
m_freePorts = deviceConfig().freePorts();
m_mounter->mount(&m_freePorts, m_portsGatherer);
}
void MaemoDeployStep::handleDeviceInstallerOutput(const QByteArray &output) void MaemoDeployStep::handleDeviceInstallerOutput(const QByteArray &output)
{ {
writeOutput(QString::fromUtf8(output), NormalOutput); writeOutput(QString::fromUtf8(output), NormalOutput);

View File

@@ -62,6 +62,7 @@ class MaemoRemoteMounter;
class MaemoDeviceConfigListModel; class MaemoDeviceConfigListModel;
class MaemoPackageCreationStep; class MaemoPackageCreationStep;
class MaemoToolChain; class MaemoToolChain;
class MaemoUsedPortsGatherer;
class MaemoDeployStep : public ProjectExplorer::BuildStep class MaemoDeployStep : public ProjectExplorer::BuildStep
{ {
@@ -107,6 +108,8 @@ private slots:
void handleInstallationFinished(int exitStatus); void handleInstallationFinished(int exitStatus);
void handleDeviceInstallerOutput(const QByteArray &output); void handleDeviceInstallerOutput(const QByteArray &output);
void handleDeviceInstallerErrorOutput(const QByteArray &output); void handleDeviceInstallerErrorOutput(const QByteArray &output);
void handlePortsGathererError(const QString &errorMsg);
void handlePortListReady();
private: private:
MaemoDeployStep(ProjectExplorer::BuildStepList *bc, MaemoDeployStep(ProjectExplorer::BuildStepList *bc,
@@ -127,7 +130,6 @@ private:
QString deployMountPoint() const; QString deployMountPoint() const;
const MaemoToolChain *toolChain() const; const MaemoToolChain *toolChain() const;
void copyNextFileToDevice(); void copyNextFileToDevice();
bool addMountSpecification(const MaemoMountSpecification &mountSpec);
void installToSysroot(); void installToSysroot();
QString uploadDir() const; QString uploadDir() const;
void connectToDevice(); void connectToDevice();
@@ -159,6 +161,8 @@ private:
typedef QPair<MaemoDeployable, QString> DeployablePerHost; typedef QPair<MaemoDeployable, QString> DeployablePerHost;
QHash<DeployablePerHost, QDateTime> m_lastDeployed; QHash<DeployablePerHost, QDateTime> m_lastDeployed;
MaemoDeviceConfigListModel *m_deviceConfigModel; MaemoDeviceConfigListModel *m_deviceConfigModel;
MaemoUsedPortsGatherer *m_portsGatherer;
MaemoPortList m_freePorts;
}; };
class MaemoDeployEventHandler : public QObject class MaemoDeployEventHandler : public QObject

View File

@@ -67,7 +67,7 @@ void MaemoRemoteMounter::setConnection(const Core::SshConnection::Ptr &connectio
m_connection = connection; m_connection = connection;
} }
bool MaemoRemoteMounter::addMountSpecification(const MaemoMountSpecification &mountSpec, void MaemoRemoteMounter::addMountSpecification(const MaemoMountSpecification &mountSpec,
bool mountAsRoot) bool mountAsRoot)
{ {
Q_ASSERT(m_toolChain); Q_ASSERT(m_toolChain);
@@ -75,7 +75,6 @@ bool MaemoRemoteMounter::addMountSpecification(const MaemoMountSpecification &mo
if (m_toolChain->allowsRemoteMounts() && mountSpec.isValid()) if (m_toolChain->allowsRemoteMounts() && mountSpec.isValid())
m_mountSpecs << MountInfo(mountSpec, mountAsRoot); m_mountSpecs << MountInfo(mountSpec, mountAsRoot);
return true; // TODO: Function can't fail anymore. Make void and remove all checks
} }
bool MaemoRemoteMounter::hasValidMountSpecifications() const bool MaemoRemoteMounter::hasValidMountSpecifications() const

View File

@@ -61,7 +61,7 @@ public:
MaemoRemoteMounter(QObject *parent); MaemoRemoteMounter(QObject *parent);
~MaemoRemoteMounter(); ~MaemoRemoteMounter();
void setToolchain(const MaemoToolChain *toolchain) { m_toolChain = toolchain; } void setToolchain(const MaemoToolChain *toolchain) { m_toolChain = toolchain; }
bool addMountSpecification(const MaemoMountSpecification &mountSpec, void addMountSpecification(const MaemoMountSpecification &mountSpec,
bool mountAsRoot); bool mountAsRoot);
bool hasValidMountSpecifications() const; bool hasValidMountSpecifications() const;
void resetMountSpecifications() { m_mountSpecs.clear(); } void resetMountSpecifications() { m_mountSpecs.clear(); }