diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemoremotemounter.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemoremotemounter.cpp index 11ad3ab24e60c865d9b2a3682a80adf683b01250..84fdd1cb614607f53a254085405f8083c73bf8b0 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemoremotemounter.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemoremotemounter.cpp @@ -47,7 +47,7 @@ namespace Qt4ProjectManager { namespace Internal { MaemoRemoteMounter::MaemoRemoteMounter(QObject *parent) - : QObject(parent), m_utfsServerTimer(new QTimer(this)), + : QObject(parent), m_toolChain(0), m_utfsServerTimer(new QTimer(this)), m_uploadJobId(SftpInvalidJob), m_state(Inactive) { connect(m_utfsServerTimer, SIGNAL(timeout()), this, @@ -69,9 +69,10 @@ void MaemoRemoteMounter::setConnection(const Core::SshConnection::Ptr &connectio bool MaemoRemoteMounter::addMountSpecification(const MaemoMountSpecification &mountSpec, bool mountAsRoot) { + Q_ASSERT(m_toolChain); ASSERT_STATE(Inactive); - if (mountSpec.isValid()) { + if (m_toolChain->allowsRemoteMounts() && mountSpec.isValid()) { if (!m_portList.hasMore()) return false; else @@ -80,14 +81,17 @@ bool MaemoRemoteMounter::addMountSpecification(const MaemoMountSpecification &mo return true; } +bool MaemoRemoteMounter::hasValidMountSpecifications() const +{ + return !m_mountSpecs.isEmpty(); +} + void MaemoRemoteMounter::mount() { ASSERT_STATE(Inactive); Q_ASSERT(m_utfsServers.isEmpty()); Q_ASSERT(m_connection); - if (!m_toolChain->allowsRemoteMounts()) - m_mountSpecs.clear(); if (m_mountSpecs.isEmpty()) { setState(Inactive); emit reportProgress(tr("No directories to mount")); @@ -114,7 +118,6 @@ void MaemoRemoteMounter::unmount() m_mountSpecs.at(i).mountSpec.remoteMountPoint); } - emit reportProgress(tr("Unmounting remote mount points...")); m_umountStderr.clear(); m_unmountProcess = m_connection->createRemoteProcess(remoteCall.toUtf8()); connect(m_unmountProcess.data(), SIGNAL(closed(int)), this, @@ -458,6 +461,8 @@ void MaemoRemoteMounter::setState(State newState) m_state = newState; } +// TODO: Perhaps remove this one again, since it might interfere with +// an unrelated application void MaemoRemoteMounter::killUtfsClients() { const SshRemoteProcess::Ptr utfsClientKiller diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemoremotemounter.h b/src/plugins/qt4projectmanager/qt-maemo/maemoremotemounter.h index 9445d3d050d8c2fba92d59b7229efac39ddc1313..8e297be80dff983e3c7011cb894a25f0a2951187 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemoremotemounter.h +++ b/src/plugins/qt4projectmanager/qt-maemo/maemoremotemounter.h @@ -63,6 +63,7 @@ public: void setPortList(const MaemoPortList &portList) { m_portList = portList; } bool addMountSpecification(const MaemoMountSpecification &mountSpec, bool mountAsRoot); + bool hasValidMountSpecifications() const; void resetMountSpecifications() { m_mountSpecs.clear(); } void mount(); void unmount(); diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemosshrunner.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemosshrunner.cpp index 75d2bc716ebac642eb55115332f675953b3d6c49..bc7989abd3db2945b8d0df019f0e8d648e182cda 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemosshrunner.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemosshrunner.cpp @@ -168,7 +168,7 @@ void MaemoSshRunner::handleCleanupFinished(int exitStatus) << StopRequested); if (m_state == StopRequested || m_state == PostRunCleaning) { - m_mounter->unmount(); + unmount(); return; } @@ -177,7 +177,7 @@ void MaemoSshRunner::handleCleanupFinished(int exitStatus) .arg(m_cleaner->errorString())); } else { m_mounter->setConnection(m_connection); - m_mounter->unmount(); + unmount(); } } @@ -211,12 +211,11 @@ void MaemoSshRunner::handleUnmounted() return; } setState(PreMountUnmounting); - m_mounter->unmount(); + unmount(); break; } case PreMountUnmounting: - setState(Mounting); - m_mounter->mount(); + mount(); break; case PostRunCleaning: case StopRequested: @@ -333,8 +332,46 @@ void MaemoSshRunner::setState(State newState) void MaemoSshRunner::emitError(const QString &errorMsg) { - emit error(errorMsg); - setState(Inactive); + if (m_state != Inactive) { + emit error(errorMsg); + setState(Inactive); + } +} + +void MaemoSshRunner::mount() +{ + setState(Mounting); + if (m_mounter->hasValidMountSpecifications()) { + emit reportProgress(tr("Mounting host directories...")); + m_mounter->mount(); + } else { + handleMounted(); + } +} + +void MaemoSshRunner::unmount() +{ + ASSERT_STATE(QList<State>() << PreRunCleaning << PreMountUnmounting + << PostRunCleaning << StopRequested); + if (m_mounter->hasValidMountSpecifications()) { + QString message; + switch (m_state) { + case PreRunCleaning: + message = tr("Unmounting left-over host directory mounts..."); + break; + case PreMountUnmounting: + message = tr("Potentially unmounting left-over host directory mounts..."); + case StopRequested: case PostRunCleaning: + message = tr("Unmounting host directories..."); + break; + default: + break; + } + emit reportProgress(message); + m_mounter->unmount(); + } else { + handleUnmounted(); + } } diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemosshrunner.h b/src/plugins/qt4projectmanager/qt-maemo/maemosshrunner.h index 74a36453a4591236641ddb1646f580cb3f5dea0b..2c756a2382b2b8db4e1d862de1e9a3cda17e7b24 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemosshrunner.h +++ b/src/plugins/qt4projectmanager/qt-maemo/maemosshrunner.h @@ -102,6 +102,8 @@ private: void cleanup(); bool addMountSpecification(const MaemoMountSpecification &mountSpec); bool isConnectionUsable() const; + void mount(); + void unmount(); MaemoRunConfiguration * const m_runConfig; // TODO this pointer can be invalid MaemoRemoteMounter * const m_mounter;