forked from qt-creator/qt-creator
Madde: Make Maemo deployment module more self-contained.
Its old interface made outdated assumptions about data flow and would not be able to sensibly partake in higher-level refactorings. Change-Id: I553c64919ba36aae39d876ade73b824f01db2767 Reviewed-by: Christian Kandeler <christian.kandeler@nokia.com>
This commit is contained in:
@@ -35,7 +35,6 @@
|
|||||||
|
|
||||||
#include <projectexplorer/target.h>
|
#include <projectexplorer/target.h>
|
||||||
#include <projectexplorer/profileinformation.h>
|
#include <projectexplorer/profileinformation.h>
|
||||||
#include <remotelinux/remotelinuxusedportsgatherer.h>
|
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <ssh/sshconnection.h>
|
#include <ssh/sshconnection.h>
|
||||||
|
|
||||||
@@ -49,8 +48,7 @@ namespace Internal {
|
|||||||
MaemoDeploymentMounter::MaemoDeploymentMounter(QObject *parent)
|
MaemoDeploymentMounter::MaemoDeploymentMounter(QObject *parent)
|
||||||
: QObject(parent),
|
: QObject(parent),
|
||||||
m_state(Inactive),
|
m_state(Inactive),
|
||||||
m_mounter(new MaemoRemoteMounter(this)),
|
m_mounter(new MaemoRemoteMounter(this))
|
||||||
m_portsGatherer(new RemoteLinuxUsedPortsGatherer(this))
|
|
||||||
{
|
{
|
||||||
connect(m_mounter, SIGNAL(error(QString)), SLOT(handleMountError(QString)));
|
connect(m_mounter, SIGNAL(error(QString)), SLOT(handleMountError(QString)));
|
||||||
connect(m_mounter, SIGNAL(mounted()), SLOT(handleMounted()));
|
connect(m_mounter, SIGNAL(mounted()), SLOT(handleMounted()));
|
||||||
@@ -59,11 +57,6 @@ MaemoDeploymentMounter::MaemoDeploymentMounter(QObject *parent)
|
|||||||
SIGNAL(reportProgress(QString)));
|
SIGNAL(reportProgress(QString)));
|
||||||
connect(m_mounter, SIGNAL(debugOutput(QString)),
|
connect(m_mounter, SIGNAL(debugOutput(QString)),
|
||||||
SIGNAL(debugOutput(QString)));
|
SIGNAL(debugOutput(QString)));
|
||||||
|
|
||||||
connect(m_portsGatherer, SIGNAL(error(QString)),
|
|
||||||
SLOT(handlePortsGathererError(QString)));
|
|
||||||
connect(m_portsGatherer, SIGNAL(portListReady()),
|
|
||||||
SLOT(handlePortListReady()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MaemoDeploymentMounter::~MaemoDeploymentMounter() {}
|
MaemoDeploymentMounter::~MaemoDeploymentMounter() {}
|
||||||
@@ -78,7 +71,7 @@ void MaemoDeploymentMounter::setupMounts(SshConnection *connection,
|
|||||||
m_connection = connection;
|
m_connection = connection;
|
||||||
m_profile = profile;
|
m_profile = profile;
|
||||||
m_devConf = DeviceProfileInformation::device(profile);
|
m_devConf = DeviceProfileInformation::device(profile);
|
||||||
m_mounter->setConnection(m_connection, m_devConf);
|
m_mounter->setParameters(m_devConf, MaemoGlobal::maddeRoot(profile));
|
||||||
connect(m_connection, SIGNAL(error(QSsh::SshError)), SLOT(handleConnectionError()));
|
connect(m_connection, SIGNAL(error(QSsh::SshError)), SLOT(handleConnectionError()));
|
||||||
setState(UnmountingOldDirs);
|
setState(UnmountingOldDirs);
|
||||||
unmount();
|
unmount();
|
||||||
@@ -99,7 +92,6 @@ void MaemoDeploymentMounter::setupMounter()
|
|||||||
setState(UnmountingCurrentDirs);
|
setState(UnmountingCurrentDirs);
|
||||||
|
|
||||||
m_mounter->resetMountSpecifications();
|
m_mounter->resetMountSpecifications();
|
||||||
m_mounter->setProfile(m_profile);
|
|
||||||
foreach (const MaemoMountSpecification &mountSpec, m_mountSpecs)
|
foreach (const MaemoMountSpecification &mountSpec, m_mountSpecs)
|
||||||
m_mounter->addMountSpecification(mountSpec, true);
|
m_mounter->addMountSpecification(mountSpec, true);
|
||||||
unmount();
|
unmount();
|
||||||
@@ -137,8 +129,8 @@ void MaemoDeploymentMounter::handleUnmounted()
|
|||||||
setupMounter();
|
setupMounter();
|
||||||
break;
|
break;
|
||||||
case UnmountingCurrentDirs:
|
case UnmountingCurrentDirs:
|
||||||
setState(GatheringPorts);
|
setState(Mounting);
|
||||||
m_portsGatherer->start(m_devConf);
|
m_mounter->mount();
|
||||||
break;
|
break;
|
||||||
case UnmountingCurrentMounts:
|
case UnmountingCurrentMounts:
|
||||||
setState(Inactive);
|
setState(Inactive);
|
||||||
@@ -150,30 +142,6 @@ void MaemoDeploymentMounter::handleUnmounted()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaemoDeploymentMounter::handlePortsGathererError(const QString &errorMsg)
|
|
||||||
{
|
|
||||||
QTC_ASSERT(m_state == GatheringPorts || m_state == Inactive, return);
|
|
||||||
|
|
||||||
if (m_state == Inactive)
|
|
||||||
return;
|
|
||||||
|
|
||||||
setState(Inactive);
|
|
||||||
m_mounter->resetMountSpecifications();
|
|
||||||
emit error(errorMsg);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MaemoDeploymentMounter::handlePortListReady()
|
|
||||||
{
|
|
||||||
QTC_ASSERT(m_state == GatheringPorts || m_state == Inactive, return);
|
|
||||||
|
|
||||||
if (m_state == Inactive)
|
|
||||||
return;
|
|
||||||
|
|
||||||
setState(Mounting);
|
|
||||||
m_freePorts = MaemoGlobal::freePorts(m_profile);
|
|
||||||
m_mounter->mount(&m_freePorts, m_portsGatherer);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MaemoDeploymentMounter::handleMountError(const QString &errorMsg)
|
void MaemoDeploymentMounter::handleMountError(const QString &errorMsg)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_state == UnmountingOldDirs || m_state == UnmountingCurrentDirs
|
QTC_ASSERT(m_state == UnmountingOldDirs || m_state == UnmountingCurrentDirs
|
||||||
|
@@ -40,7 +40,7 @@
|
|||||||
|
|
||||||
namespace ProjectExplorer { class Profile; }
|
namespace ProjectExplorer { class Profile; }
|
||||||
namespace QSsh { class SshConnection; }
|
namespace QSsh { class SshConnection; }
|
||||||
namespace RemoteLinux { class RemoteLinuxUsedPortsGatherer; }
|
namespace Utils { class FileName; }
|
||||||
|
|
||||||
namespace Madde {
|
namespace Madde {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -70,13 +70,11 @@ private slots:
|
|||||||
void handleMounted();
|
void handleMounted();
|
||||||
void handleUnmounted();
|
void handleUnmounted();
|
||||||
void handleMountError(const QString &errorMsg);
|
void handleMountError(const QString &errorMsg);
|
||||||
void handlePortsGathererError(const QString &errorMsg);
|
|
||||||
void handlePortListReady();
|
|
||||||
void handleConnectionError();
|
void handleConnectionError();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum State {
|
enum State {
|
||||||
Inactive, UnmountingOldDirs, UnmountingCurrentDirs, GatheringPorts,
|
Inactive, UnmountingOldDirs, UnmountingCurrentDirs,
|
||||||
Mounting, Mounted, UnmountingCurrentMounts
|
Mounting, Mounted, UnmountingCurrentMounts
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -88,8 +86,6 @@ private:
|
|||||||
QSsh::SshConnection *m_connection;
|
QSsh::SshConnection *m_connection;
|
||||||
ProjectExplorer::IDevice::ConstPtr m_devConf;
|
ProjectExplorer::IDevice::ConstPtr m_devConf;
|
||||||
MaemoRemoteMounter * const m_mounter;
|
MaemoRemoteMounter * const m_mounter;
|
||||||
RemoteLinux::RemoteLinuxUsedPortsGatherer * const m_portsGatherer;
|
|
||||||
Utils::PortList m_freePorts;
|
|
||||||
QList<MaemoMountSpecification> m_mountSpecs;
|
QList<MaemoMountSpecification> m_mountSpecs;
|
||||||
const ProjectExplorer::Profile *m_profile;
|
const ProjectExplorer::Profile *m_profile;
|
||||||
};
|
};
|
||||||
|
@@ -176,6 +176,11 @@ QString MaemoGlobal::maddeRoot(const QString &qmakePath)
|
|||||||
return dir.absolutePath();
|
return dir.absolutePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Utils::FileName MaemoGlobal::maddeRoot(const Profile *profile)
|
||||||
|
{
|
||||||
|
return SysRootProfileInformation::sysRoot(profile).parentDir().parentDir();
|
||||||
|
}
|
||||||
|
|
||||||
QString MaemoGlobal::targetRoot(const QString &qmakePath)
|
QString MaemoGlobal::targetRoot(const QString &qmakePath)
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
|
@@ -33,6 +33,7 @@
|
|||||||
|
|
||||||
#include <coreplugin/id.h>
|
#include <coreplugin/id.h>
|
||||||
#include <coreplugin/idocument.h>
|
#include <coreplugin/idocument.h>
|
||||||
|
#include <utils/fileutils.h>
|
||||||
#include <utils/portlist.h>
|
#include <utils/portlist.h>
|
||||||
#include <utils/environment.h>
|
#include <utils/environment.h>
|
||||||
|
|
||||||
@@ -98,6 +99,7 @@ public:
|
|||||||
static void addMaddeEnvironment(Utils::Environment &env, const QString &qmakePath);
|
static void addMaddeEnvironment(Utils::Environment &env, const QString &qmakePath);
|
||||||
static void transformMaddeCall(QString &command, QStringList &args, const QString &qmakePath);
|
static void transformMaddeCall(QString &command, QStringList &args, const QString &qmakePath);
|
||||||
static QString maddeRoot(const QString &qmakePath);
|
static QString maddeRoot(const QString &qmakePath);
|
||||||
|
static Utils::FileName maddeRoot(const ProjectExplorer::Profile *profile);
|
||||||
static QString targetRoot(const QString &qmakePath);
|
static QString targetRoot(const QString &qmakePath);
|
||||||
static QString targetName(const QString &qmakePath);
|
static QString targetName(const QString &qmakePath);
|
||||||
static QString madCommand(const QString &qmakePath);
|
static QString madCommand(const QString &qmakePath);
|
||||||
|
@@ -33,10 +33,7 @@
|
|||||||
#include "maemoglobal.h"
|
#include "maemoglobal.h"
|
||||||
#include "maddedevice.h"
|
#include "maddedevice.h"
|
||||||
|
|
||||||
#include <projectexplorer/profileinformation.h>
|
#include <ssh/sshremoteprocessrunner.h>
|
||||||
#include <projectexplorer/target.h>
|
|
||||||
#include <ssh/sshconnection.h>
|
|
||||||
#include <ssh/sshremoteprocess.h>
|
|
||||||
#include <remotelinux/remotelinuxusedportsgatherer.h>
|
#include <remotelinux/remotelinuxusedportsgatherer.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
@@ -51,10 +48,19 @@ namespace Madde {
|
|||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
MaemoRemoteMounter::MaemoRemoteMounter(QObject *parent)
|
MaemoRemoteMounter::MaemoRemoteMounter(QObject *parent)
|
||||||
: QObject(parent), m_utfsServerTimer(new QTimer(this)), m_state(Inactive)
|
: QObject(parent),
|
||||||
|
m_utfsServerTimer(new QTimer(this)),
|
||||||
|
m_mountProcess(new SshRemoteProcessRunner(this)),
|
||||||
|
m_unmountProcess(new SshRemoteProcessRunner(this)),
|
||||||
|
m_portsGatherer(new RemoteLinuxUsedPortsGatherer(this)),
|
||||||
|
m_state(Inactive)
|
||||||
{
|
{
|
||||||
connect(m_utfsServerTimer, SIGNAL(timeout()), this,
|
connect(m_utfsServerTimer, SIGNAL(timeout()), SLOT(handleUtfsServerTimeout()));
|
||||||
SLOT(handleUtfsServerTimeout()));
|
connect(m_portsGatherer, SIGNAL(error(QString)),
|
||||||
|
SLOT(handlePortsGathererError(QString)));
|
||||||
|
connect(m_portsGatherer, SIGNAL(portListReady()),
|
||||||
|
SLOT(handlePortListReady()));
|
||||||
|
|
||||||
m_utfsServerTimer->setSingleShot(true);
|
m_utfsServerTimer->setSingleShot(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,22 +69,12 @@ MaemoRemoteMounter::~MaemoRemoteMounter()
|
|||||||
killAllUtfsServers();
|
killAllUtfsServers();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaemoRemoteMounter::setConnection(SshConnection *connection,
|
void MaemoRemoteMounter::setParameters(const IDevice::ConstPtr &devConf, const FileName &maddeRoot)
|
||||||
const IDevice::ConstPtr &devConf)
|
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_state == Inactive, return);
|
QTC_ASSERT(m_state == Inactive, return);
|
||||||
|
|
||||||
m_connection = connection;
|
|
||||||
m_devConf = devConf;
|
m_devConf = devConf;
|
||||||
}
|
m_maddeRoot = maddeRoot;
|
||||||
|
|
||||||
void MaemoRemoteMounter::setProfile(const Profile *profile)
|
|
||||||
{
|
|
||||||
QTC_ASSERT(m_state == Inactive, return);
|
|
||||||
|
|
||||||
Core::Id typeId = DeviceTypeProfileInformation::deviceTypeId(profile);
|
|
||||||
m_remoteMountsAllowed = MaddeDevice::allowsRemoteMounts(typeId);
|
|
||||||
m_maddeRoot = SysRootProfileInformation::sysRoot(profile).parentDir().parentDir();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaemoRemoteMounter::addMountSpecification(const MaemoMountSpecification &mountSpec,
|
void MaemoRemoteMounter::addMountSpecification(const MaemoMountSpecification &mountSpec,
|
||||||
@@ -86,7 +82,7 @@ void MaemoRemoteMounter::addMountSpecification(const MaemoMountSpecification &mo
|
|||||||
{
|
{
|
||||||
QTC_ASSERT(m_state == Inactive, return);
|
QTC_ASSERT(m_state == Inactive, return);
|
||||||
|
|
||||||
if (m_remoteMountsAllowed && mountSpec.isValid())
|
if (MaddeDevice::allowsRemoteMounts(m_devConf->type()) && mountSpec.isValid())
|
||||||
m_mountSpecs << MountInfo(mountSpec, mountAsRoot);
|
m_mountSpecs << MountInfo(mountSpec, mountAsRoot);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,22 +91,18 @@ bool MaemoRemoteMounter::hasValidMountSpecifications() const
|
|||||||
return !m_mountSpecs.isEmpty();
|
return !m_mountSpecs.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaemoRemoteMounter::mount(PortList *freePorts,
|
void MaemoRemoteMounter::mount()
|
||||||
const RemoteLinuxUsedPortsGatherer *portsGatherer)
|
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_state == Inactive, return);
|
QTC_ASSERT(m_state == Inactive, return);
|
||||||
|
|
||||||
Q_ASSERT(m_utfsServers.isEmpty());
|
Q_ASSERT(m_utfsServers.isEmpty());
|
||||||
Q_ASSERT(m_connection);
|
|
||||||
|
|
||||||
if (m_mountSpecs.isEmpty()) {
|
if (m_mountSpecs.isEmpty()) {
|
||||||
setState(Inactive);
|
setState(Inactive);
|
||||||
emit reportProgress(tr("No directories to mount"));
|
emit reportProgress(tr("No directories to mount"));
|
||||||
emit mounted();
|
emit mounted();
|
||||||
} else {
|
} else {
|
||||||
m_freePorts = freePorts;
|
m_portsGatherer->start(m_devConf);
|
||||||
m_portsGatherer = portsGatherer;
|
|
||||||
startUtfsClients();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,17 +118,15 @@ void MaemoRemoteMounter::unmount()
|
|||||||
|
|
||||||
QString remoteCall;
|
QString remoteCall;
|
||||||
const QString remoteSudo = MaemoGlobal::remoteSudo(m_devConf->type(),
|
const QString remoteSudo = MaemoGlobal::remoteSudo(m_devConf->type(),
|
||||||
m_connection->connectionParameters().userName);
|
m_devConf->sshParameters().userName);
|
||||||
for (int i = 0; i < m_mountSpecs.count(); ++i) {
|
for (int i = 0; i < m_mountSpecs.count(); ++i) {
|
||||||
remoteCall += QString::fromLatin1("%1 umount %2 && %1 rmdir %2;")
|
remoteCall += QString::fromLatin1("%1 umount %2 && %1 rmdir %2;")
|
||||||
.arg(remoteSudo, m_mountSpecs.at(i).mountSpec.remoteMountPoint);
|
.arg(remoteSudo, m_mountSpecs.at(i).mountSpec.remoteMountPoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_unmountProcess = m_connection->createRemoteProcess(remoteCall.toUtf8());
|
|
||||||
connect(m_unmountProcess.data(), SIGNAL(closed(int)), this,
|
|
||||||
SLOT(handleUnmountProcessFinished(int)));
|
|
||||||
setState(Unmounting);
|
setState(Unmounting);
|
||||||
m_unmountProcess->start();
|
connect(m_unmountProcess, SIGNAL(processClosed(int)), SLOT(handleUnmountProcessFinished(int)));
|
||||||
|
m_unmountProcess->run(remoteCall.toUtf8(), m_devConf->sshParameters());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaemoRemoteMounter::handleUnmountProcessFinished(int exitStatus)
|
void MaemoRemoteMounter::handleUnmountProcessFinished(int exitStatus)
|
||||||
@@ -153,8 +143,7 @@ void MaemoRemoteMounter::handleUnmountProcessFinished(int exitStatus)
|
|||||||
errorMsg = tr("Could not execute unmount request.");
|
errorMsg = tr("Could not execute unmount request.");
|
||||||
break;
|
break;
|
||||||
case SshRemoteProcess::CrashExit:
|
case SshRemoteProcess::CrashExit:
|
||||||
errorMsg = tr("Failure unmounting: %1")
|
errorMsg = tr("Failure unmounting: %1").arg(m_unmountProcess->processErrorString());
|
||||||
.arg(m_unmountProcess->errorString());
|
|
||||||
break;
|
break;
|
||||||
case SshRemoteProcess::NormalExit:
|
case SshRemoteProcess::NormalExit:
|
||||||
break;
|
break;
|
||||||
@@ -183,17 +172,19 @@ void MaemoRemoteMounter::stop()
|
|||||||
|
|
||||||
void MaemoRemoteMounter::startUtfsClients()
|
void MaemoRemoteMounter::startUtfsClients()
|
||||||
{
|
{
|
||||||
const QString userName = m_connection->connectionParameters().userName;
|
QTC_ASSERT(m_state == GatheringPorts, return);
|
||||||
|
|
||||||
|
const QString userName = m_devConf->sshParameters().userName;
|
||||||
const QString chmodFuse = MaemoGlobal::remoteSudo(m_devConf->type(),
|
const QString chmodFuse = MaemoGlobal::remoteSudo(m_devConf->type(),
|
||||||
userName) + QLatin1String(" chmod a+r+w /dev/fuse");
|
userName) + QLatin1String(" chmod a+r+w /dev/fuse");
|
||||||
const QString chmodUtfsClient
|
const QString chmodUtfsClient
|
||||||
= QLatin1String("chmod a+x ") + utfsClientOnDevice();
|
= QLatin1String("chmod a+x ") + utfsClientOnDevice();
|
||||||
const QLatin1String andOp(" && ");
|
const QLatin1String andOp(" && ");
|
||||||
QString remoteCall = chmodFuse + andOp + chmodUtfsClient;
|
QString remoteCall = chmodFuse + andOp + chmodUtfsClient;
|
||||||
|
PortList ports = m_devConf->freePorts();
|
||||||
for (int i = 0; i < m_mountSpecs.count(); ++i) {
|
for (int i = 0; i < m_mountSpecs.count(); ++i) {
|
||||||
MountInfo &mountInfo = m_mountSpecs[i];
|
MountInfo &mountInfo = m_mountSpecs[i];
|
||||||
mountInfo.remotePort
|
mountInfo.remotePort = m_portsGatherer->getNextFreePort(&ports);
|
||||||
= m_portsGatherer->getNextFreePort(m_freePorts);
|
|
||||||
if (mountInfo.remotePort == -1) {
|
if (mountInfo.remotePort == -1) {
|
||||||
setState(Inactive);
|
setState(Inactive);
|
||||||
emit error(tr("Error: Not enough free ports on device to fulfill all mount requests."));
|
emit error(tr("Error: Not enough free ports on device to fulfill all mount requests."));
|
||||||
@@ -221,14 +212,10 @@ void MaemoRemoteMounter::startUtfsClients()
|
|||||||
}
|
}
|
||||||
|
|
||||||
emit reportProgress(tr("Starting remote UTFS clients..."));
|
emit reportProgress(tr("Starting remote UTFS clients..."));
|
||||||
m_mountProcess = m_connection->createRemoteProcess(remoteCall.toUtf8());
|
|
||||||
connect(m_mountProcess.data(), SIGNAL(started()), this,
|
|
||||||
SLOT(handleUtfsClientsStarted()));
|
|
||||||
connect(m_mountProcess.data(), SIGNAL(closed(int)), this,
|
|
||||||
SLOT(handleUtfsClientsFinished(int)));
|
|
||||||
m_mountProcess->start();
|
|
||||||
|
|
||||||
setState(UtfsClientsStarting);
|
setState(UtfsClientsStarting);
|
||||||
|
connect(m_mountProcess, SIGNAL(processStarted()), SLOT(handleUtfsClientsStarted()));
|
||||||
|
connect(m_mountProcess, SIGNAL(processClosed(int)), SLOT(handleUtfsClientsFinished(int)));
|
||||||
|
m_mountProcess->run(remoteCall.toUtf8(), m_devConf->sshParameters());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaemoRemoteMounter::handleUtfsClientsStarted()
|
void MaemoRemoteMounter::handleUtfsClientsStarted()
|
||||||
@@ -250,13 +237,12 @@ void MaemoRemoteMounter::handleUtfsClientsFinished(int exitStatus)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
setState(Inactive);
|
setState(Inactive);
|
||||||
if (exitStatus == SshRemoteProcess::NormalExit
|
if (exitStatus == SshRemoteProcess::NormalExit && m_mountProcess->processExitCode() == 0) {
|
||||||
&& m_mountProcess->exitCode() == 0) {
|
|
||||||
emit reportProgress(tr("Mount operation succeeded."));
|
emit reportProgress(tr("Mount operation succeeded."));
|
||||||
emit mounted();
|
emit mounted();
|
||||||
} else {
|
} else {
|
||||||
QString errMsg = tr("Failure running UTFS client: %1")
|
QString errMsg = tr("Failure running UTFS client: %1")
|
||||||
.arg(m_mountProcess->errorString());
|
.arg(m_mountProcess->processErrorString());
|
||||||
const QByteArray &mountStderr = m_mountProcess->readAllStandardError();
|
const QByteArray &mountStderr = m_mountProcess->readAllStandardError();
|
||||||
if (!mountStderr.isEmpty())
|
if (!mountStderr.isEmpty())
|
||||||
errMsg += tr("\nstderr was: '%1'").arg(QString::fromUtf8(mountStderr));
|
errMsg += tr("\nstderr was: '%1'").arg(QString::fromUtf8(mountStderr));
|
||||||
@@ -282,7 +268,7 @@ void MaemoRemoteMounter::startUtfsServers()
|
|||||||
const QString remoteSecretOpt = QLatin1String("-r");
|
const QString remoteSecretOpt = QLatin1String("-r");
|
||||||
const QStringList utfsServerArgs = QStringList() << localSecretOpt
|
const QStringList utfsServerArgs = QStringList() << localSecretOpt
|
||||||
<< port << remoteSecretOpt << port << QLatin1String("-c")
|
<< port << remoteSecretOpt << port << QLatin1String("-c")
|
||||||
<< (m_connection->connectionParameters().host + QLatin1Char(':') + port)
|
<< (m_devConf->sshParameters().host + QLatin1Char(':') + port)
|
||||||
<< mountSpec.localDir;
|
<< mountSpec.localDir;
|
||||||
connect(utfsServerProc.data(),
|
connect(utfsServerProc.data(),
|
||||||
SIGNAL(finished(int,QProcess::ExitStatus)), this,
|
SIGNAL(finished(int,QProcess::ExitStatus)), this,
|
||||||
@@ -298,6 +284,21 @@ void MaemoRemoteMounter::startUtfsServers()
|
|||||||
setState(UtfsServersStarted);
|
setState(UtfsServersStarted);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MaemoRemoteMounter::handlePortsGathererError(const QString &errorMsg)
|
||||||
|
{
|
||||||
|
QTC_ASSERT(m_state == GatheringPorts, return);
|
||||||
|
|
||||||
|
setState(Inactive);
|
||||||
|
emit error(errorMsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MaemoRemoteMounter::handlePortListReady()
|
||||||
|
{
|
||||||
|
QTC_ASSERT(m_state == GatheringPorts, return);
|
||||||
|
|
||||||
|
startUtfsClients();
|
||||||
|
}
|
||||||
|
|
||||||
void MaemoRemoteMounter::handleUtfsServerStderr()
|
void MaemoRemoteMounter::handleUtfsServerStderr()
|
||||||
{
|
{
|
||||||
if (m_state != Inactive) {
|
if (m_state != Inactive) {
|
||||||
@@ -373,16 +374,14 @@ void MaemoRemoteMounter::handleUtfsServerTimeout()
|
|||||||
|
|
||||||
void MaemoRemoteMounter::setState(State newState)
|
void MaemoRemoteMounter::setState(State newState)
|
||||||
{
|
{
|
||||||
|
if (newState == m_state)
|
||||||
|
return;
|
||||||
if (newState == Inactive) {
|
if (newState == Inactive) {
|
||||||
m_utfsServerTimer->stop();
|
m_utfsServerTimer->stop();
|
||||||
if (m_mountProcess) {
|
disconnect(m_mountProcess, 0, this, 0);
|
||||||
disconnect(m_mountProcess.data(), 0, this, 0);
|
m_mountProcess->cancel();
|
||||||
m_mountProcess->close();
|
disconnect(m_unmountProcess, 0, this, 0);
|
||||||
}
|
m_unmountProcess->cancel();
|
||||||
if (m_unmountProcess) {
|
|
||||||
disconnect(m_unmountProcess.data(), 0, this, 0);
|
|
||||||
m_unmountProcess->close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
m_state = newState;
|
m_state = newState;
|
||||||
}
|
}
|
||||||
|
@@ -44,14 +44,9 @@
|
|||||||
|
|
||||||
QT_FORWARD_DECLARE_CLASS(QTimer)
|
QT_FORWARD_DECLARE_CLASS(QTimer)
|
||||||
|
|
||||||
namespace QSsh {
|
namespace QSsh { class SshRemoteProcessRunner; }
|
||||||
class SshConnection;
|
|
||||||
class SshRemoteProcess;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace ProjectExplorer { class Profile; }
|
|
||||||
namespace RemoteLinux { class RemoteLinuxUsedPortsGatherer; }
|
namespace RemoteLinux { class RemoteLinuxUsedPortsGatherer; }
|
||||||
namespace Utils { class PortList; }
|
|
||||||
|
|
||||||
namespace Madde {
|
namespace Madde {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -60,20 +55,16 @@ class MaemoRemoteMounter : public QObject
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
MaemoRemoteMounter(QObject *parent);
|
MaemoRemoteMounter(QObject *parent = 0);
|
||||||
~MaemoRemoteMounter();
|
~MaemoRemoteMounter();
|
||||||
|
|
||||||
// Must already be connected.
|
void setParameters(const ProjectExplorer::IDevice::ConstPtr &devConf,
|
||||||
void setConnection(QSsh::SshConnection *connection,
|
const Utils::FileName &fileName);
|
||||||
const ProjectExplorer::IDevice::ConstPtr &devConf);
|
|
||||||
|
|
||||||
void setProfile(const ProjectExplorer::Profile *profile);
|
|
||||||
void 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(); }
|
||||||
void mount(Utils::PortList *freePorts,
|
void mount();
|
||||||
const RemoteLinux::RemoteLinuxUsedPortsGatherer *portsGatherer);
|
|
||||||
void unmount();
|
void unmount();
|
||||||
void stop();
|
void stop();
|
||||||
|
|
||||||
@@ -94,11 +85,13 @@ private slots:
|
|||||||
void handleUtfsServerTimeout();
|
void handleUtfsServerTimeout();
|
||||||
void handleUtfsServerStderr();
|
void handleUtfsServerStderr();
|
||||||
void startUtfsServers();
|
void startUtfsServers();
|
||||||
|
void handlePortsGathererError(const QString &errorMsg);
|
||||||
|
void handlePortListReady();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum State {
|
enum State {
|
||||||
Inactive, Unmounting, UtfsClientsStarting, UtfsClientsStarted,
|
Inactive, Unmounting, UtfsClientsStarting, UtfsClientsStarted,
|
||||||
UtfsServersStarted
|
UtfsServersStarted, GatheringPorts
|
||||||
};
|
};
|
||||||
|
|
||||||
void setState(State newState);
|
void setState(State newState);
|
||||||
@@ -119,18 +112,15 @@ private:
|
|||||||
int remotePort;
|
int remotePort;
|
||||||
};
|
};
|
||||||
|
|
||||||
QSsh::SshConnection *m_connection;
|
|
||||||
ProjectExplorer::IDevice::ConstPtr m_devConf;
|
ProjectExplorer::IDevice::ConstPtr m_devConf;
|
||||||
QList<MountInfo> m_mountSpecs;
|
QList<MountInfo> m_mountSpecs;
|
||||||
QSharedPointer<QSsh::SshRemoteProcess> m_mountProcess;
|
QSsh::SshRemoteProcessRunner * const m_mountProcess;
|
||||||
QSharedPointer<QSsh::SshRemoteProcess> m_unmountProcess;
|
QSsh::SshRemoteProcessRunner * const m_unmountProcess;
|
||||||
|
|
||||||
typedef QSharedPointer<QProcess> ProcPtr;
|
typedef QSharedPointer<QProcess> ProcPtr;
|
||||||
QList<ProcPtr> m_utfsServers;
|
QList<ProcPtr> m_utfsServers;
|
||||||
|
|
||||||
Utils::PortList *m_freePorts;
|
RemoteLinux::RemoteLinuxUsedPortsGatherer * const m_portsGatherer;
|
||||||
const RemoteLinux::RemoteLinuxUsedPortsGatherer *m_portsGatherer;
|
|
||||||
bool m_remoteMountsAllowed;
|
|
||||||
Utils::FileName m_maddeRoot;
|
Utils::FileName m_maddeRoot;
|
||||||
|
|
||||||
State m_state;
|
State m_state;
|
||||||
|
@@ -28,6 +28,7 @@
|
|||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
#include "maemosshrunner.h"
|
#include "maemosshrunner.h"
|
||||||
|
|
||||||
|
#include "maemoglobal.h"
|
||||||
#include "maemoqemumanager.h"
|
#include "maemoqemumanager.h"
|
||||||
#include "maemoremotemounter.h"
|
#include "maemoremotemounter.h"
|
||||||
#include "maemoremotemountsmodel.h"
|
#include "maemoremotemountsmodel.h"
|
||||||
@@ -55,7 +56,7 @@ MaemoSshRunner::MaemoSshRunner(QObject *parent, MaemoRunConfiguration *runConfig
|
|||||||
const BuildConfiguration * const bc = runConfig->target()->activeBuildConfiguration();
|
const BuildConfiguration * const bc = runConfig->target()->activeBuildConfiguration();
|
||||||
Profile *profile = bc ? bc->target()->profile() : 0;
|
Profile *profile = bc ? bc->target()->profile() : 0;
|
||||||
m_qtId = QtSupport::QtProfileInformation::qtVersionId(profile);
|
m_qtId = QtSupport::QtProfileInformation::qtVersionId(profile);
|
||||||
m_mounter->setProfile(profile);
|
m_mounter->setParameters(devConfig(), MaemoGlobal::maddeRoot(profile));
|
||||||
connect(m_mounter, SIGNAL(mounted()), this, SLOT(handleMounted()));
|
connect(m_mounter, SIGNAL(mounted()), this, SLOT(handleMounted()));
|
||||||
connect(m_mounter, SIGNAL(unmounted()), this, SLOT(handleUnmounted()));
|
connect(m_mounter, SIGNAL(unmounted()), this, SLOT(handleUnmounted()));
|
||||||
connect(m_mounter, SIGNAL(error(QString)), this,
|
connect(m_mounter, SIGNAL(error(QString)), this,
|
||||||
@@ -98,7 +99,6 @@ void MaemoSshRunner::doAdditionalInitialCleanup()
|
|||||||
{
|
{
|
||||||
QTC_ASSERT(m_mountState == InactiveMountState, return);
|
QTC_ASSERT(m_mountState == InactiveMountState, return);
|
||||||
|
|
||||||
m_mounter->setConnection(connection(), devConfig());
|
|
||||||
m_mounter->resetMountSpecifications();
|
m_mounter->resetMountSpecifications();
|
||||||
for (int i = 0; i < m_mountSpecs.count(); ++i)
|
for (int i = 0; i < m_mountSpecs.count(); ++i)
|
||||||
m_mounter->addMountSpecification(m_mountSpecs.at(i), false);
|
m_mounter->addMountSpecification(m_mountSpecs.at(i), false);
|
||||||
@@ -181,7 +181,7 @@ void MaemoSshRunner::mount()
|
|||||||
m_mountState = Mounting;
|
m_mountState = Mounting;
|
||||||
if (m_mounter->hasValidMountSpecifications()) {
|
if (m_mounter->hasValidMountSpecifications()) {
|
||||||
emit reportProgress(tr("Mounting host directories..."));
|
emit reportProgress(tr("Mounting host directories..."));
|
||||||
m_mounter->mount(freePorts(), usedPortsGatherer());
|
m_mounter->mount();
|
||||||
} else {
|
} else {
|
||||||
handleMounted();
|
handleMounted();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user