Commit 983bc5d2 authored by Christian Kandeler's avatar Christian Kandeler
Browse files

Maemo: Only mention mounting stuff to user when it's actually done.

Otherwise, we clutter the output window with potentially confusing
messages.

Reviewed-by: kh1
parent 81c521eb
......@@ -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
......
......@@ -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();
......
......@@ -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();
}
}
......
......@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment