From f2d14996ad5b45b5d3933245a553e1299ba6db80 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Tue, 2 Nov 2010 14:18:12 +0100 Subject: [PATCH] Maemo: Add ports gatherer to deploy step. --- .../qt-maemo/maemodeploystep.cpp | 39 +++++++++++-------- .../qt-maemo/maemodeploystep.h | 6 ++- .../qt-maemo/maemoremotemounter.cpp | 3 +- .../qt-maemo/maemoremotemounter.h | 2 +- 4 files changed, 29 insertions(+), 21 deletions(-) diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemodeploystep.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemodeploystep.cpp index c53a7b0cdc9..8e085b11b3c 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemodeploystep.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemodeploystep.cpp @@ -37,6 +37,7 @@ #include "maemoremotemounter.h" #include "maemorunconfiguration.h" #include "maemotoolchain.h" +#include "maemousedportsgatherer.h" #include #include @@ -120,6 +121,11 @@ void MaemoDeployStep::ctor() SLOT(handleProgressReport(QString))); connect(m_mounter, SIGNAL(debugOutput(QString)), this, 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() @@ -424,7 +430,7 @@ void MaemoDeployStep::handleUnmounted() prepareSftpConnection(); break; case CurrentDirsUnmount: - // m_mounter->mount(); TODO: See above + m_portsGatherer->start(m_connection, deviceConfig().freePorts()); break; case CurrentMountsUnmount: writeOutput(tr("Deployment finished.")); @@ -456,8 +462,7 @@ void MaemoDeployStep::setupMount() const QString localDir = QFileInfo(packagingStep()->packageFilePath()).absolutePath(); const MaemoMountSpecification mountSpec(localDir, deployMountPoint()); - if (!addMountSpecification(mountSpec)) - return; + m_mounter->addMountSpecification(mountSpec, true); } else { #ifdef Q_OS_WIN bool drivesToMount[26]; @@ -479,14 +484,12 @@ void MaemoDeployStep::setupMount() + QLatin1Char(driveLetter); const MaemoMountSpecification mountSpec(localDir.left(3), mountPoint); - if (!addMountSpecification(mountSpec)) - return; + m_mounter->addMountSpecification(mountSpec, true); drivesToMount[index] = true; } #else - if (!addMountSpecification(MaemoMountSpecification(QLatin1String("/"), - deployMountPoint()))) - return; + m_mounter->addMountSpecification(MaemoMountSpecification(QLatin1String("/"), + deployMountPoint()), true); #endif } m_unmountState = CurrentDirsUnmount; @@ -657,15 +660,6 @@ void MaemoDeployStep::copyNextFileToDevice() 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) { if (m_stopped) { @@ -759,6 +753,17 @@ void MaemoDeployStep::handleInstallationFinished(int exitStatus) 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) { writeOutput(QString::fromUtf8(output), NormalOutput); diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemodeploystep.h b/src/plugins/qt4projectmanager/qt-maemo/maemodeploystep.h index 7c1076c2e12..7b85450afb4 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemodeploystep.h +++ b/src/plugins/qt4projectmanager/qt-maemo/maemodeploystep.h @@ -62,6 +62,7 @@ class MaemoRemoteMounter; class MaemoDeviceConfigListModel; class MaemoPackageCreationStep; class MaemoToolChain; +class MaemoUsedPortsGatherer; class MaemoDeployStep : public ProjectExplorer::BuildStep { @@ -107,6 +108,8 @@ private slots: void handleInstallationFinished(int exitStatus); void handleDeviceInstallerOutput(const QByteArray &output); void handleDeviceInstallerErrorOutput(const QByteArray &output); + void handlePortsGathererError(const QString &errorMsg); + void handlePortListReady(); private: MaemoDeployStep(ProjectExplorer::BuildStepList *bc, @@ -127,7 +130,6 @@ private: QString deployMountPoint() const; const MaemoToolChain *toolChain() const; void copyNextFileToDevice(); - bool addMountSpecification(const MaemoMountSpecification &mountSpec); void installToSysroot(); QString uploadDir() const; void connectToDevice(); @@ -159,6 +161,8 @@ private: typedef QPair DeployablePerHost; QHash m_lastDeployed; MaemoDeviceConfigListModel *m_deviceConfigModel; + MaemoUsedPortsGatherer *m_portsGatherer; + MaemoPortList m_freePorts; }; class MaemoDeployEventHandler : public QObject diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemoremotemounter.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemoremotemounter.cpp index fbeb2a7c28a..22d7bd469db 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemoremotemounter.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemoremotemounter.cpp @@ -67,7 +67,7 @@ void MaemoRemoteMounter::setConnection(const Core::SshConnection::Ptr &connectio m_connection = connection; } -bool MaemoRemoteMounter::addMountSpecification(const MaemoMountSpecification &mountSpec, +void MaemoRemoteMounter::addMountSpecification(const MaemoMountSpecification &mountSpec, bool mountAsRoot) { Q_ASSERT(m_toolChain); @@ -75,7 +75,6 @@ bool MaemoRemoteMounter::addMountSpecification(const MaemoMountSpecification &mo if (m_toolChain->allowsRemoteMounts() && mountSpec.isValid()) m_mountSpecs << MountInfo(mountSpec, mountAsRoot); - return true; // TODO: Function can't fail anymore. Make void and remove all checks } bool MaemoRemoteMounter::hasValidMountSpecifications() const diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemoremotemounter.h b/src/plugins/qt4projectmanager/qt-maemo/maemoremotemounter.h index 3dde32df41d..1e2e90a634b 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemoremotemounter.h +++ b/src/plugins/qt4projectmanager/qt-maemo/maemoremotemounter.h @@ -61,7 +61,7 @@ public: MaemoRemoteMounter(QObject *parent); ~MaemoRemoteMounter(); void setToolchain(const MaemoToolChain *toolchain) { m_toolChain = toolchain; } - bool addMountSpecification(const MaemoMountSpecification &mountSpec, + void addMountSpecification(const MaemoMountSpecification &mountSpec, bool mountAsRoot); bool hasValidMountSpecifications() const; void resetMountSpecifications() { m_mountSpecs.clear(); }