Maemo: Make deploy mount port user-settable.

This commit is contained in:
qt-info@nokia.com
2010-08-12 10:31:52 +02:00
committed by ck
parent db5a61d3cf
commit 724ecfcafb
7 changed files with 89 additions and 21 deletions

View File

@@ -68,7 +68,8 @@ static const QLatin1String LastDeployedTimesKey(PREFIX ".LastDeployedTimes");
static const QLatin1String ProFileKey(PREFIX ".ProFile"); static const QLatin1String ProFileKey(PREFIX ".ProFile");
static const QLatin1String ExportedLocalDirsKey(PREFIX ".ExportedLocalDirs"); static const QLatin1String ExportedLocalDirsKey(PREFIX ".ExportedLocalDirs");
static const QLatin1String RemoteMountPointsKey(PREFIX ".RemoteMountPoints"); static const QLatin1String RemoteMountPointsKey(PREFIX ".RemoteMountPoints");
static const QLatin1String MountPortsKey(PREFIX ".MountPorts"); static const QLatin1String UserDefinedMountPortsKey(PREFIX ".MountPorts");
static const QLatin1String DeployMountPortKey(PREFIX ".DeployMountPort");
static const QLatin1String BaseEnvironmentBaseKey(PREFIX ".BaseEnvironmentBase"); static const QLatin1String BaseEnvironmentBaseKey(PREFIX ".BaseEnvironmentBase");
static const QLatin1String UserEnvironmentChangesKey(PREFIX ".UserEnvironmentChanges"); static const QLatin1String UserEnvironmentChangesKey(PREFIX ".UserEnvironmentChanges");
static const QLatin1String UseRemoteGdbKey(PREFIX ".UseRemoteGdb"); static const QLatin1String UseRemoteGdbKey(PREFIX ".UseRemoteGdb");

View File

@@ -60,6 +60,7 @@ using namespace ProjectExplorer;
namespace Qt4ProjectManager { namespace Qt4ProjectManager {
namespace Internal { namespace Internal {
namespace { const int DefaultMountPort = 1050; }
const QLatin1String MaemoDeployStep::Id("Qt4ProjectManager.MaemoDeployStep"); const QLatin1String MaemoDeployStep::Id("Qt4ProjectManager.MaemoDeployStep");
@@ -130,6 +131,9 @@ BuildStepConfigWidget *MaemoDeployStep::createConfigWidget()
QVariantMap MaemoDeployStep::toMap() const QVariantMap MaemoDeployStep::toMap() const
{ {
QVariantMap map(BuildStep::toMap()); QVariantMap map(BuildStep::toMap());
#ifdef DEPLOY_VIA_MOUNT
map.insert(DeployMountPortKey, m_mountPort);
#endif
addDeployTimesToMap(map); addDeployTimesToMap(map);
map.unite(m_deviceConfigModel->toMap()); map.unite(m_deviceConfigModel->toMap());
return map; return map;
@@ -158,6 +162,9 @@ bool MaemoDeployStep::fromMap(const QVariantMap &map)
{ {
if (!BuildStep::fromMap(map)) if (!BuildStep::fromMap(map))
return false; return false;
#ifdef DEPLOY_VIA_MOUNT
m_mountPort = map.value(DeployMountPortKey, DefaultMountPort).toInt();
#endif
getDeployTimesFromMap(map); getDeployTimesFromMap(map);
m_deviceConfigModel->fromMap(map); m_deviceConfigModel->fromMap(map);
return true; return true;
@@ -558,17 +565,16 @@ void MaemoDeployStep::handleUnmounted()
return; return;
} }
// TODO: port must come from user setting. (Call it "base port" on windows!)
if (m_needsInstall || !m_filesToCopy.isEmpty()) { if (m_needsInstall || !m_filesToCopy.isEmpty()) {
if (m_needsInstall) { if (m_needsInstall) {
const QString localDir = QFileInfo(packagingStep()->packageFilePath()) const QString localDir = QFileInfo(packagingStep()->packageFilePath())
.absolutePath(); .absolutePath();
const MaemoMountSpecification mountSpec(localDir, const MaemoMountSpecification mountSpec(localDir,
deployMountPoint(), 11000); deployMountPoint(), m_mountPort);
m_mounter->addMountSpecification(mountSpec, true); m_mounter->addMountSpecification(mountSpec, true);
} else { } else {
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
int port = 11000; int port = m_mountPort;
bool drivesToMount[26]; bool drivesToMount[26];
for (int i = 0; i < sizeof drivesToMount / drivesToMount[0]; ++i) for (int i = 0; i < sizeof drivesToMount / drivesToMount[0]; ++i)
drivesToMount[i] = false; drivesToMount[i] = false;
@@ -594,7 +600,7 @@ void MaemoDeployStep::handleUnmounted()
} }
#else #else
m_mounter->addMountSpecification(MaemoMountSpecification(QLatin1String("/"), m_mounter->addMountSpecification(MaemoMountSpecification(QLatin1String("/"),
deployMountPoint(), 11000), true); deployMountPoint(), m_mountPort), true);
#endif #endif
} }
m_mounter->mount(); m_mounter->mount();

View File

@@ -81,6 +81,10 @@ public:
const MaemoDeployable &deployable) const; const MaemoDeployable &deployable) const;
void setDeployed(const QString &host, const MaemoDeployable &deployable); void setDeployed(const QString &host, const MaemoDeployable &deployable);
MaemoDeployables *deployables() const { return m_deployables; } MaemoDeployables *deployables() const { return m_deployables; }
#ifdef DEPLOY_VIA_MOUNT
int mountPort() const { return m_mountPort; }
void setMountPort(int port) { m_mountPort = port; }
#endif
signals: signals:
void done(); void done();
@@ -146,6 +150,7 @@ private:
MaemoRemoteMounter *m_mounter; MaemoRemoteMounter *m_mounter;
QTimer *m_cleanupTimer; QTimer *m_cleanupTimer;
bool m_canStart; bool m_canStart;
int m_mountPort;
#else #else
QSharedPointer<Core::SftpChannel> m_uploader; QSharedPointer<Core::SftpChannel> m_uploader;
typedef QPair<MaemoDeployable, QString> DeployInfo; typedef QPair<MaemoDeployable, QString> DeployInfo;

View File

@@ -20,6 +20,7 @@ MaemoDeployStepWidget::MaemoDeployStepWidget(MaemoDeployStep *step) :
m_step(step) m_step(step)
{ {
ui->setupUi(this); ui->setupUi(this);
ui->mountPortSpinBox->setToolTip(ui->mountPortLabel->toolTip());
connect(m_step->deployables(), SIGNAL(modelsCreated()), this, connect(m_step->deployables(), SIGNAL(modelsCreated()), this,
SLOT(handleModelsCreated())); SLOT(handleModelsCreated()));
@@ -33,6 +34,14 @@ MaemoDeployStepWidget::~MaemoDeployStepWidget()
void MaemoDeployStepWidget::init() void MaemoDeployStepWidget::init()
{ {
#ifdef DEPLOY_VIA_MOUNT
ui->mountPortSpinBox->setValue(m_step->mountPort());
connect(ui->mountPortSpinBox, SIGNAL(valueChanged(int)), this,
SLOT(handleMountPortEdited(int)));
#else
ui->mountPortLabel->hide();
ui->mountPortSpinBox->hide();
#endif
handleDeviceConfigModelChanged(); handleDeviceConfigModelChanged();
connect(m_step->buildConfiguration()->target(), connect(m_step->buildConfiguration()->target(),
SIGNAL(activeRunConfigurationChanged(ProjectExplorer::RunConfiguration*)), SIGNAL(activeRunConfigurationChanged(ProjectExplorer::RunConfiguration*)),
@@ -90,5 +99,12 @@ void MaemoDeployStepWidget::setCurrentDeviceConfig(int index)
m_step->deviceConfigModel()->setCurrentIndex(index); m_step->deviceConfigModel()->setCurrentIndex(index);
} }
void MaemoDeployStepWidget::handleMountPortEdited(int newPort)
{
#ifdef DEPLOY_VIA_MOUNT
m_step->setMountPort(newPort);
#endif
}
} // namespace Internal } // namespace Internal
} // namespace Qt4ProjectManager } // namespace Qt4ProjectManager

View File

@@ -26,6 +26,7 @@ private:
Q_SLOT void handleModelsCreated(); Q_SLOT void handleModelsCreated();
Q_SLOT void handleDeviceConfigModelChanged(); Q_SLOT void handleDeviceConfigModelChanged();
Q_SLOT void setCurrentDeviceConfig(int index); Q_SLOT void setCurrentDeviceConfig(int index);
Q_SLOT void handleMountPortEdited(int newPort);
virtual void init(); virtual void init();
virtual QString summaryText() const; virtual QString summaryText() const;

View File

@@ -15,14 +15,16 @@
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QFormLayout" name="formLayout">
<item> <item row="0" column="0">
<widget class="QLabel" name="deviceConfigLabel"> <widget class="QLabel" name="deviceConfigLabel">
<property name="text"> <property name="text">
<string>Device configuration:</string> <string>Device configuration:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<widget class="QComboBox" name="deviceConfigComboBox"/> <widget class="QComboBox" name="deviceConfigComboBox"/>
</item> </item>
@@ -41,6 +43,43 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="1" column="0">
<widget class="QLabel" name="mountPortLabel">
<property name="toolTip">
<string>The port on the device to use for mounting the host disk during deployment.
Note: On Windows, several consecutive ports may be used, starting with the one set here.</string>
</property>
<property name="text">
<string>Mount port:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QSpinBox" name="mountPortSpinBox">
<property name="maximum">
<number>65535</number>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
<item> <item>
<widget class="QLabel" name="installLabel"> <widget class="QLabel" name="installLabel">
<property name="toolTip"> <property name="toolTip">

View File

@@ -106,7 +106,7 @@ QVariantMap MaemoRemoteMountsModel::toMap() const
} }
map.insert(ExportedLocalDirsKey, localDirsList); map.insert(ExportedLocalDirsKey, localDirsList);
map.insert(RemoteMountPointsKey, remoteMountPointsList); map.insert(RemoteMountPointsKey, remoteMountPointsList);
map.insert(MountPortsKey, mountPortsList); map.insert(UserDefinedMountPortsKey, mountPortsList);
return map; return map;
} }
@@ -116,7 +116,7 @@ void MaemoRemoteMountsModel::fromMap(const QVariantMap &map)
= map.value(ExportedLocalDirsKey).toList(); = map.value(ExportedLocalDirsKey).toList();
const QVariantList &remoteMountPointsList const QVariantList &remoteMountPointsList
= map.value(RemoteMountPointsKey).toList(); = map.value(RemoteMountPointsKey).toList();
const QVariantList &mountPortsList = map.value(MountPortsKey).toList(); const QVariantList &mountPortsList = map.value(UserDefinedMountPortsKey).toList();
const int count = qMin(qMin(localDirsList.count(), const int count = qMin(qMin(localDirsList.count(),
remoteMountPointsList.count()), mountPortsList.count()); remoteMountPointsList.count()), mountPortsList.count());
for (int i = 0; i < count; ++i) { for (int i = 0; i < count; ++i) {