Maemo: Device configurations now have a list of free ports.

The device configuration widget is now the only place the user
ever has to specify ports.
This commit is contained in:
ck
2010-08-13 15:25:22 +02:00
parent c2da3f682e
commit 378ad4de3d
30 changed files with 223 additions and 266 deletions

View File

@@ -68,8 +68,6 @@ 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 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

@@ -83,7 +83,7 @@ RunControl *MaemoDebugSupport::createDebugRunControl(MaemoRunConfiguration *runC
params.executable = runConfig->localExecutableFilePath(); params.executable = runConfig->localExecutableFilePath();
params.debuggerCommand = runConfig->gdbCmd(); params.debuggerCommand = runConfig->gdbCmd();
params.remoteChannel = devConf.server.host + QLatin1Char(':') params.remoteChannel = devConf.server.host + QLatin1Char(':')
+ gdbServerPort(runConfig, devConf); + QString::number(gdbServerPort(runConfig));
params.remoteArchitecture = QLatin1String("arm"); params.remoteArchitecture = QLatin1String("arm");
} }
params.processArgs = runConfig->arguments(); params.processArgs = runConfig->arguments();
@@ -231,7 +231,7 @@ void MaemoDebugSupport::startDebugging()
const QString &remoteExe = m_runConfig->remoteExecutableFilePath(); const QString &remoteExe = m_runConfig->remoteExecutableFilePath();
m_runner->startExecution(QString::fromLocal8Bit("%1 gdbserver :%2 %3 %4") m_runner->startExecution(QString::fromLocal8Bit("%1 gdbserver :%2 %3 %4")
.arg(MaemoGlobal::remoteCommandPrefix(remoteExe)) .arg(MaemoGlobal::remoteCommandPrefix(remoteExe))
.arg(gdbServerPort(m_runConfig, m_deviceConfig)) .arg(gdbServerPort(m_runConfig))
.arg(remoteExe).arg(m_runConfig->arguments() .arg(remoteExe).arg(m_runConfig->arguments()
.join(QLatin1String(" "))).toUtf8()); .join(QLatin1String(" "))).toUtf8());
} }
@@ -293,15 +293,9 @@ void MaemoDebugSupport::handleAdapterSetupDone()
qobject_cast<RemoteGdbServerAdapter*>(m_gdbAdapter)->handleSetupDone(); qobject_cast<RemoteGdbServerAdapter*>(m_gdbAdapter)->handleSetupDone();
} }
QString MaemoDebugSupport::gdbServerPort(const MaemoRunConfiguration *rc, int MaemoDebugSupport::gdbServerPort(const MaemoRunConfiguration *rc)
const MaemoDeviceConfig &devConf)
{ {
// During configuration we don't know which port to use, so we display return rc->freePorts().getNext();
// something in the config dialog, but we will make sure we use
// the right port from the information file.
return devConf.type == MaemoDeviceConfig::Physical
? QString::number(devConf.debuggingPort)
: rc->runtimeGdbServerPort();
} }
QString MaemoDebugSupport::uploadDir(const MaemoDeviceConfig &devConf) QString MaemoDebugSupport::uploadDir(const MaemoDeviceConfig &devConf)

View File

@@ -69,8 +69,6 @@ public:
Debugger::DebuggerRunControl *runControl); Debugger::DebuggerRunControl *runControl);
~MaemoDebugSupport(); ~MaemoDebugSupport();
static QString gdbServerPort(const MaemoRunConfiguration *rc,
const MaemoDeviceConfig &devConf);
static QString uploadDir(const MaemoDeviceConfig &devConf); static QString uploadDir(const MaemoDeviceConfig &devConf);
private slots: private slots:
@@ -87,6 +85,8 @@ private slots:
void handleProgressReport(const QString &progressOutput); void handleProgressReport(const QString &progressOutput);
private: private:
static int gdbServerPort(const MaemoRunConfiguration *rc);
void stopSsh(); void stopSsh();
void handleAdapterSetupFailed(const QString &error); void handleAdapterSetupFailed(const QString &error);
void handleAdapterSetupDone(); void handleAdapterSetupDone();

View File

@@ -99,7 +99,7 @@ void MaemoDeployStep::ctor()
= qobject_cast<Qt4BuildConfiguration *>(buildConfiguration()); = qobject_cast<Qt4BuildConfiguration *>(buildConfiguration());
const MaemoToolChain * const toolchain const MaemoToolChain * const toolchain
= dynamic_cast<MaemoToolChain *>(buildConfig->toolChain()); = dynamic_cast<MaemoToolChain *>(buildConfig->toolChain());
m_mounter = new MaemoRemoteMounter(this,toolchain); m_mounter = new MaemoRemoteMounter(this, toolchain);
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,
@@ -131,9 +131,6 @@ 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;
@@ -162,9 +159,6 @@ 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;
@@ -574,15 +568,16 @@ void MaemoDeployStep::handleUnmounted()
} }
if (m_needsInstall || !m_filesToCopy.isEmpty()) { if (m_needsInstall || !m_filesToCopy.isEmpty()) {
m_mounter->setPortList(deviceConfig().freePorts());
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(), m_mountPort); deployMountPoint());
m_mounter->addMountSpecification(mountSpec, true); if (!addMountSpecification(mountSpec))
return;
} else { } else {
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
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;
@@ -602,13 +597,15 @@ void MaemoDeployStep::handleUnmounted()
const QString mountPoint = deployMountPoint() const QString mountPoint = deployMountPoint()
+ QLatin1Char('/') + QLatin1Char(driveLetter); + QLatin1Char('/') + QLatin1Char(driveLetter);
const MaemoMountSpecification mountSpec(localDir.left(3), const MaemoMountSpecification mountSpec(localDir.left(3),
mountPoint, port++); mountPoint);
m_mounter->addMountSpecification(mountSpec, true); if (!addMountSpecification(mountSpec))
return;
drivesToMount[index] = true; drivesToMount[index] = true;
} }
#else #else
m_mounter->addMountSpecification(MaemoMountSpecification(QLatin1String("/"), if (!addMountSpecification(MaemoMountSpecification(QLatin1String("/"),
deployMountPoint(), m_mountPort), true); deployMountPoint())))
return;
#endif #endif
} }
m_mounter->mount(); m_mounter->mount();
@@ -660,6 +657,15 @@ void MaemoDeployStep::deployNextFile()
copyProcess->start(); 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) void MaemoDeployStep::handleCopyProcessFinished(int exitStatus)
{ {
if (m_stopped) { if (m_stopped) {

View File

@@ -32,6 +32,7 @@
#include "maemodeployable.h" #include "maemodeployable.h"
#include "maemodeviceconfigurations.h" #include "maemodeviceconfigurations.h"
#include "maemomountspecification.h"
#include <coreplugin/ssh/sftpdefs.h> #include <coreplugin/ssh/sftpdefs.h>
#include <projectexplorer/buildstep.h> #include <projectexplorer/buildstep.h>
@@ -81,10 +82,6 @@ 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();
@@ -131,6 +128,7 @@ private:
#ifdef DEPLOY_VIA_MOUNT #ifdef DEPLOY_VIA_MOUNT
QString deployMountPoint() const; QString deployMountPoint() const;
void deployNextFile(); void deployNextFile();
bool addMountSpecification(const MaemoMountSpecification &mountSpec);
#else #else
bool deploy(const MaemoDeployable &deployable); bool deploy(const MaemoDeployable &deployable);
#endif #endif
@@ -150,7 +148,6 @@ 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

@@ -33,20 +33,13 @@ 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*)),
this, SLOT(handleDeviceConfigModelChanged())); this, SLOT(handleDeviceConfigModelChanged()));
connect(ui->deviceConfigComboBox, SIGNAL(activated(int)), this, connect(ui->deviceConfigComboBox, SIGNAL(activated(int)), this,
SLOT(setCurrentDeviceConfig(int))); SLOT(setCurrentDeviceConfig(int)));
handleDeviceConfigModelChanged();
} }
void MaemoDeployStepWidget::handleDeviceConfigModelChanged() void MaemoDeployStepWidget::handleDeviceConfigModelChanged()
@@ -98,14 +91,5 @@ 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);
#else
Q_UNUSED(newPort);
#endif
}
} // namespace Internal } // namespace Internal
} // namespace Qt4ProjectManager } // namespace Qt4ProjectManager

View File

@@ -26,7 +26,6 @@ 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

@@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>469</width> <width>460</width>
<height>330</height> <height>277</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@@ -43,39 +43,8 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="1" column="0">
<widget class="QLabel" name="mountPortLabel">
<property name="toolTip">
<string/>
</property>
<property name="text">
<string>Mount port:</string>
</property>
</widget>
</item>
<item row="1" column="1"> <item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2"> <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> </item>
</layout> </layout>
</item> </item>

View File

@@ -42,9 +42,10 @@ namespace Internal {
MaemoDeviceConfigListModel::MaemoDeviceConfigListModel(QObject *parent) MaemoDeviceConfigListModel::MaemoDeviceConfigListModel(QObject *parent)
: QAbstractListModel(parent), m_currentIndex(-1) : QAbstractListModel(parent), m_currentIndex(-1)
{ {
setupList();
const MaemoDeviceConfigurations &devConfs const MaemoDeviceConfigurations &devConfs
= MaemoDeviceConfigurations::instance(); = MaemoDeviceConfigurations::instance();
if (devConfs.devConfigs().isEmpty()) if (m_devConfigs.isEmpty())
setInvalid(); setInvalid();
else else
setCurrentIndex(0); setCurrentIndex(0);
@@ -52,27 +53,35 @@ MaemoDeviceConfigListModel::MaemoDeviceConfigListModel(QObject *parent)
SLOT(handleDeviceConfigListChange())); SLOT(handleDeviceConfigListChange()));
} }
void MaemoDeviceConfigListModel::setupList()
{
m_devConfigs.clear();
const MaemoDeviceConfigurations &devConfs
= MaemoDeviceConfigurations::instance();
foreach (const MaemoDeviceConfig &devConfig, devConfs.devConfigs()) {
if (devConfig.freePorts().hasMore())
m_devConfigs << devConfig;
}
}
void MaemoDeviceConfigListModel::setCurrentIndex(int index) void MaemoDeviceConfigListModel::setCurrentIndex(int index)
{ {
if (index != m_currentIndex) { if (index != m_currentIndex) {
m_currentIndex = index; m_currentIndex = index;
m_currentId = MaemoDeviceConfigurations::instance().devConfigs() m_currentId = m_devConfigs.at(m_currentIndex).internalId;
.at(m_currentIndex).internalId;
emit currentChanged(); emit currentChanged();
} }
} }
void MaemoDeviceConfigListModel::resetCurrentIndex() void MaemoDeviceConfigListModel::resetCurrentIndex()
{ {
const QList<MaemoDeviceConfig> &devConfigs if (m_devConfigs.isEmpty()) {
= MaemoDeviceConfigurations::instance().devConfigs();
if (devConfigs.isEmpty()) {
setInvalid(); setInvalid();
return; return;
} }
for (int i = 0; i < devConfigs.count(); ++i) { for (int i = 0; i < m_devConfigs.count(); ++i) {
if (devConfigs.at(i).internalId == m_currentId) { if (m_devConfigs.at(i).internalId == m_currentId) {
setCurrentIndex(i); setCurrentIndex(i);
return; return;
} }
@@ -110,6 +119,7 @@ void MaemoDeviceConfigListModel::fromMap(const QVariantMap &map)
void MaemoDeviceConfigListModel::handleDeviceConfigListChange() void MaemoDeviceConfigListModel::handleDeviceConfigListChange()
{ {
setupList();
resetCurrentIndex(); resetCurrentIndex();
reset(); reset();
emit currentChanged(); emit currentChanged();
@@ -117,8 +127,7 @@ void MaemoDeviceConfigListModel::handleDeviceConfigListChange()
int MaemoDeviceConfigListModel::rowCount(const QModelIndex &parent) const int MaemoDeviceConfigListModel::rowCount(const QModelIndex &parent) const
{ {
return parent.isValid() ? 0 return parent.isValid() ? 0 : m_devConfigs.count();
: MaemoDeviceConfigurations::instance().devConfigs().count();
} }
QVariant MaemoDeviceConfigListModel::data(const QModelIndex &index, int role) const QVariant MaemoDeviceConfigListModel::data(const QModelIndex &index, int role) const
@@ -126,7 +135,7 @@ QVariant MaemoDeviceConfigListModel::data(const QModelIndex &index, int role) co
if (!index.isValid() || index.row() >= rowCount() if (!index.isValid() || index.row() >= rowCount()
|| role != Qt::DisplayRole) || role != Qt::DisplayRole)
return QVariant(); return QVariant();
return MaemoDeviceConfigurations::instance().devConfigs().at(index.row()).name; return m_devConfigs.at(index.row()).name;
} }
} // namespace Internal } // namespace Internal

View File

@@ -38,6 +38,7 @@
#include "maemodeviceconfigurations.h" #include "maemodeviceconfigurations.h"
#include <QtCore/QAbstractListModel> #include <QtCore/QAbstractListModel>
#include <QtCore/QList>
#include <QtCore/QVariantMap> #include <QtCore/QVariantMap>
namespace Qt4ProjectManager { namespace Qt4ProjectManager {
@@ -66,7 +67,9 @@ private:
Q_SLOT void handleDeviceConfigListChange(); Q_SLOT void handleDeviceConfigListChange();
void resetCurrentIndex(); void resetCurrentIndex();
void setInvalid(); void setInvalid();
void setupList();
QList<MaemoDeviceConfig> m_devConfigs;
quint64 m_currentId; quint64 m_currentId;
int m_currentIndex; int m_currentIndex;
}; };

View File

@@ -56,7 +56,6 @@ namespace {
const QLatin1String TypeKey("Type"); const QLatin1String TypeKey("Type");
const QLatin1String HostKey("Host"); const QLatin1String HostKey("Host");
const QLatin1String SshPortKey("SshPort"); const QLatin1String SshPortKey("SshPort");
const QLatin1String DebuggingPortKey("GdbServerPort");
const QLatin1String PortsSpecKey("FreePortsSpec"); const QLatin1String PortsSpecKey("FreePortsSpec");
const QLatin1String UserNameKey("Uname"); const QLatin1String UserNameKey("Uname");
const QLatin1String AuthKey("Authentication"); const QLatin1String AuthKey("Authentication");
@@ -177,7 +176,6 @@ private:
MaemoDeviceConfig::MaemoDeviceConfig(const QString &name, MaemoDeviceConfig::DeviceType devType) MaemoDeviceConfig::MaemoDeviceConfig(const QString &name, MaemoDeviceConfig::DeviceType devType)
: name(name), : name(name),
type(devType), type(devType),
debuggingPort(defaultDebuggingPort(type)),
portsSpec(defaultPortsSpec(type)), portsSpec(defaultPortsSpec(type)),
internalId(MaemoDeviceConfigurations::instance().m_nextId++) internalId(MaemoDeviceConfigurations::instance().m_nextId++)
{ {
@@ -193,7 +191,6 @@ MaemoDeviceConfig::MaemoDeviceConfig(const QSettings &settings,
quint64 &nextId) quint64 &nextId)
: name(settings.value(NameKey).toString()), : name(settings.value(NameKey).toString()),
type(static_cast<DeviceType>(settings.value(TypeKey, DefaultDeviceType).toInt())), type(static_cast<DeviceType>(settings.value(TypeKey, DefaultDeviceType).toInt())),
debuggingPort(settings.value(DebuggingPortKey, defaultDebuggingPort(type)).toInt()),
portsSpec(settings.value(PortsSpecKey, defaultPortsSpec(type)).toString()), portsSpec(settings.value(PortsSpecKey, defaultPortsSpec(type)).toString()),
internalId(settings.value(InternalIdKey, nextId).toULongLong()) internalId(settings.value(InternalIdKey, nextId).toULongLong())
{ {
@@ -228,11 +225,6 @@ int MaemoDeviceConfig::defaultSshPort(DeviceType type) const
return type == Physical ? DefaultSshPortHW : DefaultSshPortSim; return type == Physical ? DefaultSshPortHW : DefaultSshPortSim;
} }
int MaemoDeviceConfig::defaultDebuggingPort(DeviceType type) const
{
return type == Physical ? DefaultGdbServerPortHW : DefaultGdbServerPortSim;
}
QString MaemoDeviceConfig::defaultPortsSpec(DeviceType type) const QString MaemoDeviceConfig::defaultPortsSpec(DeviceType type) const
{ {
return QLatin1String(type == Physical ? "10000-10100" : "13219,14168"); return QLatin1String(type == Physical ? "10000-10100" : "13219,14168");
@@ -259,7 +251,6 @@ void MaemoDeviceConfig::save(QSettings &settings) const
settings.setValue(TypeKey, type); settings.setValue(TypeKey, type);
settings.setValue(HostKey, server.host); settings.setValue(HostKey, server.host);
settings.setValue(SshPortKey, server.port); settings.setValue(SshPortKey, server.port);
settings.setValue(DebuggingPortKey, debuggingPort);
settings.setValue(PortsSpecKey, portsSpec); settings.setValue(PortsSpecKey, portsSpec);
settings.setValue(UserNameKey, server.uname); settings.setValue(UserNameKey, server.uname);
settings.setValue(AuthKey, server.authType); settings.setValue(AuthKey, server.authType);

View File

@@ -94,13 +94,11 @@ public:
Core::SshConnectionParameters server; Core::SshConnectionParameters server;
QString name; QString name;
DeviceType type; DeviceType type;
int debuggingPort;
QString portsSpec; QString portsSpec;
quint64 internalId; quint64 internalId;
private: private:
int defaultSshPort(DeviceType type) const; int defaultSshPort(DeviceType type) const;
int defaultDebuggingPort(DeviceType type) const;
QString defaultPortsSpec(DeviceType type) const; QString defaultPortsSpec(DeviceType type) const;
QString defaultHost(DeviceType type) const; QString defaultHost(DeviceType type) const;

View File

@@ -35,8 +35,8 @@ namespace Internal {
const QLatin1String MaemoMountSpecification::InvalidMountPoint("/"); const QLatin1String MaemoMountSpecification::InvalidMountPoint("/");
MaemoMountSpecification::MaemoMountSpecification(const QString &localDir, MaemoMountSpecification::MaemoMountSpecification(const QString &localDir,
const QString &remoteDir, int remotePort) const QString &remoteDir)
: localDir(localDir), remoteMountPoint(remoteDir), remotePort(remotePort) : localDir(localDir), remoteMountPoint(remoteDir)
{ {
} }

View File

@@ -36,16 +36,13 @@ namespace Qt4ProjectManager {
namespace Internal { namespace Internal {
struct MaemoMountSpecification { struct MaemoMountSpecification {
MaemoMountSpecification(const QString &localDir, const QString &remoteDir, MaemoMountSpecification(const QString &localDir, const QString &remoteDir);
int remotePort);
bool isValid() const { return remoteMountPoint != InvalidMountPoint; } bool isValid() const { return remoteMountPoint != InvalidMountPoint; }
static const QLatin1String InvalidMountPoint; static const QLatin1String InvalidMountPoint;
QString localDir; QString localDir;
QString remoteMountPoint; QString remoteMountPoint;
int remotePort;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -590,7 +590,15 @@ bool MaemoQemuManager::fillRuntimeInformation(Runtime *runtime) const
runtime->m_libPath = runtime->m_libPath =
libPathSpec.mid(libPathSpec.indexOf(QLatin1Char('=')) + 1); libPathSpec.mid(libPathSpec.indexOf(QLatin1Char('=')) + 1);
runtime->m_sshPort = map.value(QLatin1String("sshport")); runtime->m_sshPort = map.value(QLatin1String("sshport"));
runtime->m_gdbServerPort = map.value(QLatin1String("redirport2")); runtime->m_freePorts = MaemoPortList();
int i = 2;
while (true) {
const QString port = map.value(QLatin1String("redirport")
+ QString::number(i++));
if (port.isEmpty())
break;
runtime->m_freePorts.addPort(port.toInt());
}
return true; return true;
} }
} }

View File

@@ -31,6 +31,7 @@
#define QEMURUNTIMEMANAGER_H #define QEMURUNTIMEMANAGER_H
#include "maemoconstants.h" #include "maemoconstants.h"
#include "maemodeviceconfigurations.h"
#include <QtCore/QMap> #include <QtCore/QMap>
#include <QtCore/QObject> #include <QtCore/QObject>
@@ -64,7 +65,7 @@ struct Runtime
QString m_args; QString m_args;
QString m_libPath; QString m_libPath;
QString m_sshPort; QString m_sshPort;
QString m_gdbServerPort; MaemoPortList m_freePorts;
}; };
class MaemoQemuManager : public QObject class MaemoQemuManager : public QObject

View File

@@ -57,11 +57,16 @@ void MaemoRemoteMounter::setConnection(const Core::SshConnection::Ptr &connectio
m_connection = connection; m_connection = connection;
} }
void MaemoRemoteMounter::addMountSpecification(const MaemoMountSpecification &mountSpec, bool MaemoRemoteMounter::addMountSpecification(const MaemoMountSpecification &mountSpec,
bool mountAsRoot) bool mountAsRoot)
{ {
if (mountSpec.isValid()) if (mountSpec.isValid()) {
m_mountSpecs << MountInfo(mountSpec, mountAsRoot); if (!m_portList.hasMore())
return false;
else
m_mountSpecs << MountInfo(mountSpec, m_portList.getNext(), mountAsRoot);
}
return true;
} }
void MaemoRemoteMounter::mount() void MaemoRemoteMounter::mount()
@@ -223,16 +228,17 @@ void MaemoRemoteMounter::startUtfsClients()
const QLatin1String andOp(" && "); const QLatin1String andOp(" && ");
QString remoteCall = chmodFuse + andOp + chmodUtfsClient; QString remoteCall = chmodFuse + andOp + chmodUtfsClient;
for (int i = 0; i < m_mountSpecs.count(); ++i) { for (int i = 0; i < m_mountSpecs.count(); ++i) {
const MaemoMountSpecification &mountSpec = m_mountSpecs.at(i).mountSpec; const MountInfo &mountInfo = m_mountSpecs.at(i);
const MaemoMountSpecification &mountSpec = mountInfo.mountSpec;
const QString mkdir = QString::fromLocal8Bit("%1 mkdir -p %2") const QString mkdir = QString::fromLocal8Bit("%1 mkdir -p %2")
.arg(MaemoGlobal::remoteSudo(), mountSpec.remoteMountPoint); .arg(MaemoGlobal::remoteSudo(), mountSpec.remoteMountPoint);
const QString chmod = QString::fromLocal8Bit("%1 chmod a+r+w+x %2") const QString chmod = QString::fromLocal8Bit("%1 chmod a+r+w+x %2")
.arg(MaemoGlobal::remoteSudo(), mountSpec.remoteMountPoint); .arg(MaemoGlobal::remoteSudo(), mountSpec.remoteMountPoint);
QString utfsClient QString utfsClient
= QString::fromLocal8Bit("%1 --detach -l %2 -r %2 -b %2 %4") = QString::fromLocal8Bit("%1 --detach -l %2 -r %2 -b %2 %4")
.arg(utfsClientOnDevice()).arg(mountSpec.remotePort) .arg(utfsClientOnDevice()).arg(mountInfo.remotePort)
.arg(mountSpec.remoteMountPoint); .arg(mountSpec.remoteMountPoint);
if (m_mountSpecs.at(i).mountAsRoot) if (mountInfo.mountAsRoot)
utfsClient.prepend(MaemoGlobal::remoteSudo() + QLatin1Char(' ')); utfsClient.prepend(MaemoGlobal::remoteSudo() + QLatin1Char(' '));
remoteCall += andOp + mkdir + andOp + chmod + andOp + utfsClient; remoteCall += andOp + mkdir + andOp + chmod + andOp + utfsClient;
} }
@@ -269,9 +275,10 @@ void MaemoRemoteMounter::startUtfsServers()
{ {
emit reportProgress(tr("Starting UTFS servers...")); emit reportProgress(tr("Starting UTFS servers..."));
for (int i = 0; i < m_mountSpecs.count(); ++i) { for (int i = 0; i < m_mountSpecs.count(); ++i) {
const MaemoMountSpecification &mountSpec = m_mountSpecs.at(i).mountSpec; const MountInfo &mountInfo = m_mountSpecs.at(i);
const MaemoMountSpecification &mountSpec = mountInfo.mountSpec;
const ProcPtr utfsServerProc(new QProcess); const ProcPtr utfsServerProc(new QProcess);
const QString port = QString::number(mountSpec.remotePort); const QString port = QString::number(mountInfo.remotePort);
const QString localSecretOpt = QLatin1String("-l"); const QString localSecretOpt = QLatin1String("-l");
const QString remoteSecretOpt = QLatin1String("-r"); const QString remoteSecretOpt = QLatin1String("-r");
const QStringList utfsServerArgs = QStringList() const QStringList utfsServerArgs = QStringList()

View File

@@ -30,6 +30,7 @@
#ifndef MAEMOREMOTEMOUNTER_H #ifndef MAEMOREMOTEMOUNTER_H
#define MAEMOREMOTEMOUNTER_H #define MAEMOREMOTEMOUNTER_H
#include "maemodeviceconfigurations.h"
#include "maemomountspecification.h" #include "maemomountspecification.h"
#include <coreplugin/ssh/sftpdefs.h> #include <coreplugin/ssh/sftpdefs.h>
@@ -57,7 +58,8 @@ class MaemoRemoteMounter : public QObject
public: public:
MaemoRemoteMounter(QObject *parent, const MaemoToolChain *toolchain); MaemoRemoteMounter(QObject *parent, const MaemoToolChain *toolchain);
~MaemoRemoteMounter(); ~MaemoRemoteMounter();
void addMountSpecification(const MaemoMountSpecification &mountSpec, void setPortList(const MaemoPortList &portList) { m_portList = portList; }
bool addMountSpecification(const MaemoMountSpecification &mountSpec,
bool mountAsRoot); bool mountAsRoot);
void mount(); void mount();
void unmount(); void unmount();
@@ -91,9 +93,10 @@ private:
const MaemoToolChain * const m_toolChain; const MaemoToolChain * const m_toolChain;
struct MountInfo { struct MountInfo {
MountInfo(const MaemoMountSpecification &m, bool root) MountInfo(const MaemoMountSpecification &m, int port, bool root)
: mountSpec(m), mountAsRoot(root) {} : mountSpec(m), remotePort(port), mountAsRoot(root) {}
MaemoMountSpecification mountSpec; MaemoMountSpecification mountSpec;
int remotePort;
bool mountAsRoot; bool mountAsRoot;
}; };
@@ -109,6 +112,7 @@ private:
bool m_stop; bool m_stop;
QByteArray m_utfsClientStderr; QByteArray m_utfsClientStderr;
QByteArray m_umountStderr; QByteArray m_umountStderr;
MaemoPortList m_portList;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -41,20 +41,9 @@ MaemoRemoteMountsModel::MaemoRemoteMountsModel(QObject *parent) :
void MaemoRemoteMountsModel::addMountSpecification(const QString &localDir) void MaemoRemoteMountsModel::addMountSpecification(const QString &localDir)
{ {
int port = 10100;
int i = 0;
while (i < rowCount()) {
if (mountSpecificationAt(i).remotePort == port) {
++port;
i = 0;
} else {
++i;
}
}
beginInsertRows(QModelIndex(), rowCount(), rowCount()); beginInsertRows(QModelIndex(), rowCount(), rowCount());
m_mountSpecs << MaemoMountSpecification(localDir, m_mountSpecs << MaemoMountSpecification(localDir,
MaemoMountSpecification::InvalidMountPoint, port); MaemoMountSpecification::InvalidMountPoint);
endInsertRows(); endInsertRows();
} }
@@ -98,15 +87,12 @@ QVariantMap MaemoRemoteMountsModel::toMap() const
QVariantMap map; QVariantMap map;
QVariantList localDirsList; QVariantList localDirsList;
QVariantList remoteMountPointsList; QVariantList remoteMountPointsList;
QVariantList mountPortsList;
foreach (const MaemoMountSpecification &mountSpec, m_mountSpecs) { foreach (const MaemoMountSpecification &mountSpec, m_mountSpecs) {
localDirsList << mountSpec.localDir; localDirsList << mountSpec.localDir;
remoteMountPointsList << mountSpec.remoteMountPoint; remoteMountPointsList << mountSpec.remoteMountPoint;
mountPortsList << mountSpec.remotePort;
} }
map.insert(ExportedLocalDirsKey, localDirsList); map.insert(ExportedLocalDirsKey, localDirsList);
map.insert(RemoteMountPointsKey, remoteMountPointsList); map.insert(RemoteMountPointsKey, remoteMountPointsList);
map.insert(UserDefinedMountPortsKey, mountPortsList);
return map; return map;
} }
@@ -116,22 +102,20 @@ 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(UserDefinedMountPortsKey).toList(); const int count
const int count = qMin(qMin(localDirsList.count(), = qMin(localDirsList.count(), remoteMountPointsList.count());
remoteMountPointsList.count()), mountPortsList.count());
for (int i = 0; i < count; ++i) { for (int i = 0; i < count; ++i) {
const QString &localDir = localDirsList.at(i).toString(); const QString &localDir = localDirsList.at(i).toString();
const QString &remoteMountPoint const QString &remoteMountPoint
= remoteMountPointsList.at(i).toString(); = remoteMountPointsList.at(i).toString();
const int port = mountPortsList.at(i).toInt(); m_mountSpecs << MaemoMountSpecification(localDir, remoteMountPoint);
m_mountSpecs << MaemoMountSpecification(localDir, remoteMountPoint, port);
} }
} }
Qt::ItemFlags MaemoRemoteMountsModel::flags(const QModelIndex &index) const Qt::ItemFlags MaemoRemoteMountsModel::flags(const QModelIndex &index) const
{ {
Qt::ItemFlags ourFlags = QAbstractTableModel::flags(index); Qt::ItemFlags ourFlags = QAbstractTableModel::flags(index);
if (index.column() == RemoteMountPointRow || index.column() == PortRow) if (index.column() == RemoteMountPointRow)
ourFlags |= Qt::ItemIsEditable; ourFlags |= Qt::ItemIsEditable;
return ourFlags; return ourFlags;
} }
@@ -145,7 +129,6 @@ QVariant MaemoRemoteMountsModel::headerData(int section,
switch (section) { switch (section) {
case LocalDirRow: return tr("Local directory"); case LocalDirRow: return tr("Local directory");
case RemoteMountPointRow: return tr("Remote mount point"); case RemoteMountPointRow: return tr("Remote mount point");
case PortRow: return tr("Remote port");
default: return QVariant(); default: return QVariant();
} }
} }
@@ -165,10 +148,6 @@ QVariant MaemoRemoteMountsModel::data(const QModelIndex &index, int role) const
if (role == Qt::DisplayRole || role == Qt::EditRole) if (role == Qt::DisplayRole || role == Qt::EditRole)
return mountSpec.remoteMountPoint; return mountSpec.remoteMountPoint;
break; break;
case PortRow:
if (role == Qt::DisplayRole || role == Qt::EditRole)
return mountSpec.remotePort;
break;
} }
return QVariant(); return QVariant();
} }
@@ -193,16 +172,6 @@ bool MaemoRemoteMountsModel::setData(const QModelIndex &index,
set = true; set = true;
break; break;
} }
case PortRow: {
const int newPort = value.toInt();
for (int i = 0; i < m_mountSpecs.count(); ++i) {
if (i != index.row() && m_mountSpecs.at(i).remotePort == newPort)
return false;
}
m_mountSpecs[index.row()].remotePort = newPort;
set = true;
break;
}
case LocalDirRow: case LocalDirRow:
default: default:
set = false; set = false;

View File

@@ -59,7 +59,6 @@ public:
static const int LocalDirRow = 0; static const int LocalDirRow = 0;
static const int RemoteMountPointRow = 1; static const int RemoteMountPointRow = 1;
static const int PortRow = 2;
private: private:
virtual int columnCount(const QModelIndex& = QModelIndex()) const; virtual int columnCount(const QModelIndex& = QModelIndex()) const;
@@ -77,7 +76,7 @@ private:
inline int MaemoRemoteMountsModel::columnCount(const QModelIndex &) const inline int MaemoRemoteMountsModel::columnCount(const QModelIndex &) const
{ {
return 3; return 2;
} }
inline int MaemoRemoteMountsModel::rowCount(const QModelIndex &parent) const inline int MaemoRemoteMountsModel::rowCount(const QModelIndex &parent) const

View File

@@ -278,15 +278,17 @@ QString MaemoRunConfiguration::remoteExecutableFilePath() const
->remoteExecutableFilePath(localExecutableFilePath()); ->remoteExecutableFilePath(localExecutableFilePath());
} }
QString MaemoRunConfiguration::runtimeGdbServerPort() const MaemoPortList MaemoRunConfiguration::freePorts() const
{ {
if (Qt4BuildConfiguration *qt4bc = activeQt4BuildConfiguration()) { const MaemoDeviceConfig &devConfig = deviceConfig();
const Qt4BuildConfiguration * const qt4bc = activeQt4BuildConfiguration();
if (devConfig.type == MaemoDeviceConfig::Simulator && qt4bc) {
Runtime rt; Runtime rt;
const int id = qt4bc->qtVersion()->uniqueId(); const int id = qt4bc->qtVersion()->uniqueId();
if (MaemoQemuManager::instance().runtimeForQtVersion(id, &rt)) if (MaemoQemuManager::instance().runtimeForQtVersion(id, &rt))
return rt.m_gdbServerPort; return rt.m_freePorts;
} }
return QLatin1String("13219"); return devConfig.freePorts();
} }
void MaemoRunConfiguration::setArguments(const QStringList &args) void MaemoRunConfiguration::setArguments(const QStringList &args)

View File

@@ -93,9 +93,10 @@ public:
void setArguments(const QStringList &args); void setArguments(const QStringList &args);
MaemoDeviceConfig deviceConfig() const; MaemoDeviceConfig deviceConfig() const;
MaemoDeviceConfigListModel *deviceConfigModel() const; MaemoDeviceConfigListModel *deviceConfigModel() const;
QString runtimeGdbServerPort() const; MaemoPortList freePorts() const;
bool useRemoteGdb() const { return m_useRemoteGdb; } bool useRemoteGdb() const { return m_useRemoteGdb; }
void setUseRemoteGdb(bool useRemoteGdb) { m_useRemoteGdb = useRemoteGdb; } void setUseRemoteGdb(bool useRemoteGdb) { m_useRemoteGdb = useRemoteGdb; }
void updateFactoryState() { emit isEnabledChanged(true); }
const QString gdbCmd() const; const QString gdbCmd() const;
const QString dumperLib() const; const QString dumperLib() const;

View File

@@ -78,6 +78,9 @@ MaemoRunConfigurationWidget::MaemoRunConfigurationWidget(
addDebuggingWidgets(mainLayout); addDebuggingWidgets(mainLayout);
addMountWidgets(mainLayout); addMountWidgets(mainLayout);
addEnvironmentWidgets(mainLayout); addEnvironmentWidgets(mainLayout);
connect(m_runConfiguration->deviceConfigModel(), SIGNAL(currentChanged()),
this, SLOT(handleCurrentDeviceConfigChanged()));
handleCurrentDeviceConfigChanged();
} }
void MaemoRunConfigurationWidget::addGenericWidgets(QVBoxLayout *mainLayout) void MaemoRunConfigurationWidget::addGenericWidgets(QVBoxLayout *mainLayout)
@@ -124,13 +127,10 @@ void MaemoRunConfigurationWidget::addGenericWidgets(QVBoxLayout *mainLayout)
SLOT(argumentsEdited(QString))); SLOT(argumentsEdited(QString)));
connect(m_devConfBox, SIGNAL(activated(int)), this, connect(m_devConfBox, SIGNAL(activated(int)), this,
SLOT(setCurrentDeviceConfig(int))); SLOT(setCurrentDeviceConfig(int)));
connect(m_runConfiguration->deviceConfigModel(), SIGNAL(currentChanged()),
this, SLOT(handleCurrentDeviceConfigChanged()));
connect(m_runConfiguration, SIGNAL(targetInformationChanged()), this, connect(m_runConfiguration, SIGNAL(targetInformationChanged()), this,
SLOT(updateTargetInformation())); SLOT(updateTargetInformation()));
connect(m_runConfiguration->deployStep()->deployables(), connect(m_runConfiguration->deployStep()->deployables(),
SIGNAL(modelsCreated()), this, SLOT(handleDeploySpecsChanged())); SIGNAL(modelsCreated()), this, SLOT(handleDeploySpecsChanged()));
handleCurrentDeviceConfigChanged();
} }
void MaemoRunConfigurationWidget::addDebuggingWidgets(QVBoxLayout *mainLayout) void MaemoRunConfigurationWidget::addDebuggingWidgets(QVBoxLayout *mainLayout)
@@ -162,6 +162,8 @@ void MaemoRunConfigurationWidget::addMountWidgets(QVBoxLayout *mainLayout)
m_mountDetailsContainer->setWidget(mountViewWidget); m_mountDetailsContainer->setWidget(mountViewWidget);
mainLayout->addWidget(m_mountDetailsContainer); mainLayout->addWidget(m_mountDetailsContainer);
QVBoxLayout *mountViewLayout = new QVBoxLayout(mountViewWidget); QVBoxLayout *mountViewLayout = new QVBoxLayout(mountViewWidget);
m_mountWarningLabel = new QLabel;
mountViewLayout->addWidget(m_mountWarningLabel);
QHBoxLayout *tableLayout = new QHBoxLayout; QHBoxLayout *tableLayout = new QHBoxLayout;
mountViewLayout->addLayout(tableLayout); mountViewLayout->addLayout(tableLayout);
m_mountView = new QTableView; m_mountView = new QTableView;
@@ -278,6 +280,7 @@ void MaemoRunConfigurationWidget::handleCurrentDeviceConfigChanged()
{ {
m_devConfBox->setCurrentIndex(m_runConfiguration->deviceConfigModel() m_devConfBox->setCurrentIndex(m_runConfiguration->deviceConfigModel()
->currentIndex()); ->currentIndex());
updateMountWarning();
} }
void MaemoRunConfigurationWidget::setCurrentDeviceConfig(int index) void MaemoRunConfigurationWidget::setCurrentDeviceConfig(int index)
@@ -407,6 +410,38 @@ void MaemoRunConfigurationWidget::handleRemoteMountsChanged()
} }
m_mountDetailsContainer->setSummaryText(QLatin1String("<b>") + text m_mountDetailsContainer->setSummaryText(QLatin1String("<b>") + text
+ QLatin1String("</b>")); + QLatin1String("</b>"));
updateMountWarning();
}
void MaemoRunConfigurationWidget::updateMountWarning()
{
QString mountWarning;
const MaemoPortList &portList = m_runConfiguration->freePorts();
if (portList.hasMore()) {
const int availablePortCount = portList.count();
const int mountDirCount
= m_runConfiguration->remoteMounts()->validMountSpecificationCount();
if (mountDirCount > availablePortCount) {
mountWarning = tr("WARNING: You want to mount %1 directories, but "
"your device has only %2 free ports.<br>You will not be able "
"to run this configuration.")
.arg(mountDirCount).arg(availablePortCount);
} else if (mountDirCount > 0 && mountDirCount == availablePortCount) {
mountWarning = tr("WARNING: The directories you want to mount will "
"use all %1 free ports on the device.<br>You will not be able "
"to debug your application with this configuration.")
.arg(availablePortCount);
}
}
if (mountWarning.isEmpty()) {
m_mountWarningLabel->hide();
} else {
m_mountWarningLabel->setText(QLatin1String("<font color=\"red\">")
+ mountWarning + QLatin1String("</font>"));
m_mountWarningLabel->show();
m_mountDetailsContainer->setState(Utils::DetailsWidget::Expanded);
}
m_runConfiguration->updateFactoryState();
} }
} // namespace Internal } // namespace Internal

View File

@@ -95,12 +95,14 @@ private:
void addDebuggingWidgets(QVBoxLayout *mainLayout); void addDebuggingWidgets(QVBoxLayout *mainLayout);
void addMountWidgets(QVBoxLayout *mainLayout); void addMountWidgets(QVBoxLayout *mainLayout);
void addEnvironmentWidgets(QVBoxLayout *mainLayout); void addEnvironmentWidgets(QVBoxLayout *mainLayout);
void updateMountWarning();
QLineEdit *m_configNameLineEdit; QLineEdit *m_configNameLineEdit;
QLineEdit *m_argsLineEdit; QLineEdit *m_argsLineEdit;
QLabel *m_localExecutableLabel; QLabel *m_localExecutableLabel;
QLabel *m_remoteExecutableLabel; QLabel *m_remoteExecutableLabel;
QComboBox *m_devConfBox; QComboBox *m_devConfBox;
QLabel *m_mountWarningLabel;
QTableView *m_mountView; QTableView *m_mountView;
QToolButton *m_removeMountButton; QToolButton *m_removeMountButton;
Utils::DetailsWidget *m_mountDetailsContainer; Utils::DetailsWidget *m_mountDetailsContainer;

View File

@@ -36,6 +36,7 @@
#include "maemoconstants.h" #include "maemoconstants.h"
#include "maemodebugsupport.h" #include "maemodebugsupport.h"
#include "maemoremotemountsmodel.h"
#include "maemorunconfiguration.h" #include "maemorunconfiguration.h"
#include "maemoruncontrol.h" #include "maemoruncontrol.h"
@@ -158,9 +159,20 @@ MaemoRunControlFactory::~MaemoRunControlFactory()
bool MaemoRunControlFactory::canRun(RunConfiguration *runConfiguration, bool MaemoRunControlFactory::canRun(RunConfiguration *runConfiguration,
const QString &mode) const const QString &mode) const
{ {
return qobject_cast<MaemoRunConfiguration *>(runConfiguration) const MaemoRunConfiguration * const maemoRunConfig
&& (mode == ProjectExplorer::Constants::RUNMODE = qobject_cast<MaemoRunConfiguration *>(runConfiguration);
|| mode == ProjectExplorer::Constants::DEBUGMODE); if (!maemoRunConfig || !maemoRunConfig->deviceConfig().isValid())
return false;
const int freePortCount = maemoRunConfig->freePorts().count();
if (freePortCount == 0)
return false;
const int mountDirCount
= maemoRunConfig->remoteMounts()->validMountSpecificationCount();
if (mode == ProjectExplorer::Constants::DEBUGMODE)
return freePortCount > mountDirCount;
if (mode == ProjectExplorer::Constants::RUNMODE)
return freePortCount >= mountDirCount;
return false;
} }
RunControl* MaemoRunControlFactory::create(RunConfiguration *runConfig, RunControl* MaemoRunControlFactory::create(RunConfiguration *runConfig,

View File

@@ -117,7 +117,6 @@ QString MaemoSettingsWidget::searchKeywords() const
{ {
QString rc; QString rc;
QTextStream(&rc) << m_ui->configurationLabel->text() QTextStream(&rc) << m_ui->configurationLabel->text()
<< ' ' << m_ui->debuggingPortLabel->text()
<< ' ' << m_ui->sshPortLabel->text() << ' ' << m_ui->sshPortLabel->text()
<< ' ' << m_ui->keyButton->text() << ' ' << m_ui->keyButton->text()
<< ' ' << m_ui->passwordButton->text() << ' ' << m_ui->passwordButton->text()
@@ -131,7 +130,8 @@ QString MaemoSettingsWidget::searchKeywords() const
<< ' ' << m_ui->keyLabel->text() << ' ' << m_ui->keyLabel->text()
<< ' ' << m_ui->nameLineEdit->text() << ' ' << m_ui->nameLineEdit->text()
<< ' ' << m_ui->passwordLabel->text() << ' ' << m_ui->passwordLabel->text()
<< ' ' << m_ui->portsLabel->text() << ' ' << m_ui->freePortsLabel->text()
<< ' ' << m_ui->portsWarningLabel->text()
<< ' ' << m_ui->pwdLineEdit->text() << ' ' << m_ui->pwdLineEdit->text()
<< ' ' << m_ui->timeoutSpinBox->value() << ' ' << m_ui->timeoutSpinBox->value()
<< ' ' << m_ui->userLineEdit->text() << ' ' << m_ui->userLineEdit->text()
@@ -148,11 +148,6 @@ void MaemoSettingsWidget::initGui()
QRegExpValidator * const portsValidator QRegExpValidator * const portsValidator
= new QRegExpValidator(QRegExp(MaemoDeviceConfig::portsRegExpr()), this); = new QRegExpValidator(QRegExp(MaemoDeviceConfig::portsRegExpr()), this);
m_ui->portsLineEdit->setValidator(portsValidator); m_ui->portsLineEdit->setValidator(portsValidator);
#if 1
m_ui->freePortsLabel->hide();
m_ui->portsLineEdit->hide();
#endif
foreach (const MaemoDeviceConfig &devConf, m_devConfs) foreach (const MaemoDeviceConfig &devConf, m_devConfs)
m_ui->configurationComboBox->addItem(devConf.name); m_ui->configurationComboBox->addItem(devConf.name);
connect(m_ui->configurationComboBox, SIGNAL(currentIndexChanged(int)), connect(m_ui->configurationComboBox, SIGNAL(currentIndexChanged(int)),
@@ -223,19 +218,17 @@ void MaemoSettingsWidget::fillInValues()
m_ui->nameLineEdit->setText(currentConfig().name); m_ui->nameLineEdit->setText(currentConfig().name);
m_ui->hostLineEdit->setText(currentConfig().server.host); m_ui->hostLineEdit->setText(currentConfig().server.host);
m_ui->sshPortSpinBox->setValue(currentConfig().server.port); m_ui->sshPortSpinBox->setValue(currentConfig().server.port);
m_ui->gdbServerPortSpinBox->setValue(currentConfig().debuggingPort);
m_ui->portsLineEdit->setText(currentConfig().portsSpec); m_ui->portsLineEdit->setText(currentConfig().portsSpec);
m_ui->timeoutSpinBox->setValue(currentConfig().server.timeout); m_ui->timeoutSpinBox->setValue(currentConfig().server.timeout);
m_ui->userLineEdit->setText(currentConfig().server.uname); m_ui->userLineEdit->setText(currentConfig().server.uname);
m_ui->pwdLineEdit->setText(currentConfig().server.pwd); m_ui->pwdLineEdit->setText(currentConfig().server.pwd);
m_ui->keyFileLineEdit->setPath(currentConfig().server.privateKeyFile); m_ui->keyFileLineEdit->setPath(currentConfig().server.privateKeyFile);
m_ui->showPasswordCheckBox->setChecked(false); m_ui->showPasswordCheckBox->setChecked(false);
updatePortsWarningLabel();
const bool isSimulator const bool isSimulator
= currentConfig().type == MaemoDeviceConfig::Simulator; = currentConfig().type == MaemoDeviceConfig::Simulator;
m_ui->hostLineEdit->setReadOnly(isSimulator); m_ui->hostLineEdit->setReadOnly(isSimulator);
m_ui->sshPortSpinBox->setReadOnly(isSimulator); m_ui->sshPortSpinBox->setReadOnly(isSimulator);
m_ui->gdbServerPortSpinBox->setReadOnly(isSimulator);
} }
void MaemoSettingsWidget::saveSettings() void MaemoSettingsWidget::saveSettings()
@@ -305,14 +298,10 @@ void MaemoSettingsWidget::sshPortEditingFinished()
currentConfig().server.port = m_ui->sshPortSpinBox->value(); currentConfig().server.port = m_ui->sshPortSpinBox->value();
} }
void MaemoSettingsWidget::gdbServerPortEditingFinished()
{
currentConfig().debuggingPort = m_ui->gdbServerPortSpinBox->value();
}
void MaemoSettingsWidget::handleFreePortsChanged() void MaemoSettingsWidget::handleFreePortsChanged()
{ {
currentConfig().portsSpec = m_ui->portsLineEdit->text(); currentConfig().portsSpec = m_ui->portsLineEdit->text();
updatePortsWarningLabel();
} }
void MaemoSettingsWidget::timeoutEditingFinished() void MaemoSettingsWidget::timeoutEditingFinished()
@@ -479,10 +468,21 @@ void MaemoSettingsWidget::clearDetails()
{ {
m_ui->hostLineEdit->clear(); m_ui->hostLineEdit->clear();
m_ui->sshPortSpinBox->clear(); m_ui->sshPortSpinBox->clear();
m_ui->gdbServerPortSpinBox->clear();
m_ui->timeoutSpinBox->clear(); m_ui->timeoutSpinBox->clear();
m_ui->userLineEdit->clear(); m_ui->userLineEdit->clear();
m_ui->pwdLineEdit->clear(); m_ui->pwdLineEdit->clear();
m_ui->portsLineEdit->clear();
m_ui->portsWarningLabel->clear();
}
void MaemoSettingsWidget::updatePortsWarningLabel()
{
if (currentConfig().freePorts().hasMore()) {
m_ui->portsWarningLabel->clear();
} else {
m_ui->portsWarningLabel->setText(QLatin1String("<font color=\"red\">")
+ tr("You'll need at least one port!") + QLatin1String("</font>"));
}
} }
} // namespace Internal } // namespace Internal

View File

@@ -78,7 +78,6 @@ private slots:
void authenticationTypeChanged(); void authenticationTypeChanged();
void hostNameEditingFinished(); void hostNameEditingFinished();
void sshPortEditingFinished(); void sshPortEditingFinished();
void gdbServerPortEditingFinished();
void timeoutEditingFinished(); void timeoutEditingFinished();
void userNameEditingFinished(); void userNameEditingFinished();
void passwordEditingFinished(); void passwordEditingFinished();
@@ -106,6 +105,7 @@ private:
void clearDetails(); void clearDetails();
QString parseTestOutput(); QString parseTestOutput();
void fillInValues(); void fillInValues();
void updatePortsWarningLabel();
Ui_MaemoSettingsWidget *m_ui; Ui_MaemoSettingsWidget *m_ui;
QList<MaemoDeviceConfig> m_devConfs; QList<MaemoDeviceConfig> m_devConfs;

View File

@@ -64,6 +64,9 @@
</sizepolicy> </sizepolicy>
</property> </property>
<layout class="QFormLayout" name="formLayout_2"> <layout class="QFormLayout" name="formLayout_2">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="deviceNameLabel"> <widget class="QLabel" name="deviceNameLabel">
<property name="text"> <property name="text">
@@ -149,27 +152,14 @@
</widget> </widget>
</item> </item>
<item row="4" column="0"> <item row="4" column="0">
<widget class="QLabel" name="portsLabel"> <widget class="QLabel" name="sshPortLabel">
<property name="text"> <property name="text">
<string>Ports:</string> <string>SSH port:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="1"> <item row="4" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_4"> <layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="sshPortLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>SSH:</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QSpinBox" name="sshPortSpinBox"> <widget class="QSpinBox" name="sshPortSpinBox">
<property name="minimum"> <property name="minimum">
@@ -184,27 +174,17 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="debuggingPortLabel"> <spacer name="horizontalSpacer_3">
<property name="sizePolicy"> <property name="orientation">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred"> <enum>Qt::Horizontal</enum>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property> </property>
<property name="text"> <property name="sizeHint" stdset="0">
<string>Debugging:</string> <size>
<width>40</width>
<height>20</height>
</size>
</property> </property>
</widget> </spacer>
</item>
<item>
<widget class="QSpinBox" name="gdbServerPortSpinBox">
<property name="maximum">
<number>65535</number>
</property>
<property name="value">
<number>10000</number>
</property>
</widget>
</item> </item>
</layout> </layout>
</item> </item>
@@ -224,6 +204,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QLabel" name="portsWarningLabel">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item> <item>
<spacer name="horizontalSpacer_2"> <spacer name="horizontalSpacer_2">
<property name="orientation"> <property name="orientation">
@@ -684,38 +671,6 @@
</hint> </hint>
</hints> </hints>
</connection> </connection>
<connection>
<sender>gdbServerPortSpinBox</sender>
<signal>editingFinished()</signal>
<receiver>MaemoSettingsWidget</receiver>
<slot>gdbServerPortEditingFinished()</slot>
<hints>
<hint type="sourcelabel">
<x>375</x>
<y>190</y>
</hint>
<hint type="destinationlabel">
<x>593</x>
<y>184</y>
</hint>
</hints>
</connection>
<connection>
<sender>gdbServerPortSpinBox</sender>
<signal>valueChanged(int)</signal>
<receiver>MaemoSettingsWidget</receiver>
<slot>gdbServerPortEditingFinished()</slot>
<hints>
<hint type="sourcelabel">
<x>395</x>
<y>197</y>
</hint>
<hint type="destinationlabel">
<x>590</x>
<y>251</y>
</hint>
</hints>
</connection>
<connection> <connection>
<sender>sshPortSpinBox</sender> <sender>sshPortSpinBox</sender>
<signal>editingFinished()</signal> <signal>editingFinished()</signal>
@@ -739,8 +694,8 @@
<slot>sshPortEditingFinished()</slot> <slot>sshPortEditingFinished()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>243</x> <x>230</x>
<y>197</y> <y>204</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>3</x> <x>3</x>

View File

@@ -194,16 +194,21 @@ void MaemoSshRunner::handleUnmounted()
if (m_stop) if (m_stop)
return; return;
MaemoPortList portList = m_devConfig.freePorts();
if (m_debugging && !m_runConfig->useRemoteGdb())
portList.getNext(); // One has already been used for gdbserver.
m_mounter->setPortList(portList);
const MaemoRemoteMountsModel * const remoteMounts const MaemoRemoteMountsModel * const remoteMounts
= m_runConfig->remoteMounts(); = m_runConfig->remoteMounts();
for (int i = 0; i < remoteMounts->mountSpecificationCount(); ++i) for (int i = 0; i < remoteMounts->mountSpecificationCount(); ++i) {
m_mounter->addMountSpecification(remoteMounts->mountSpecificationAt(i), if (!addMountSpecification(remoteMounts->mountSpecificationAt(i)))
false); return;
}
if (m_debugging && m_runConfig->useRemoteGdb()) { if (m_debugging && m_runConfig->useRemoteGdb()) {
m_mounter->addMountSpecification(MaemoMountSpecification( if (!addMountSpecification(MaemoMountSpecification(
m_runConfig->localDirToMountForRemoteGdb(), m_runConfig->localDirToMountForRemoteGdb(),
MaemoGlobal::remoteProjectSourcesMountPoint(), MaemoGlobal::remoteProjectSourcesMountPoint())))
m_devConfig.debuggingPort), false); return;
} }
m_mounter->mount(); m_mounter->mount();
} }
@@ -250,6 +255,16 @@ void MaemoSshRunner::handleRemoteProcessFinished(int exitStatus)
cleanup(false); cleanup(false);
} }
bool MaemoSshRunner::addMountSpecification(const MaemoMountSpecification &mountSpec)
{
if (!m_mounter->addMountSpecification(mountSpec, false)) {
emit error(tr("The device does not have enough free ports "
"for this run configuration."));
return false;
}
return true;
}
} // namespace Internal } // namespace Internal
} // namespace Qt4ProjectManager } // namespace Qt4ProjectManager

View File

@@ -36,6 +36,7 @@
#define MAEMOSSHRUNNER_H #define MAEMOSSHRUNNER_H
#include "maemodeviceconfigurations.h" #include "maemodeviceconfigurations.h"
#include "maemomountspecification.h"
#include <QtCore/QObject> #include <QtCore/QObject>
#include <QtCore/QSharedPointer> #include <QtCore/QSharedPointer>
@@ -88,6 +89,7 @@ private slots:
private: private:
void cleanup(bool initialCleanup); void cleanup(bool initialCleanup);
bool addMountSpecification(const MaemoMountSpecification &mountSpec);
MaemoRunConfiguration * const m_runConfig; // TODO this pointer can be invalid MaemoRunConfiguration * const m_runConfig; // TODO this pointer can be invalid
MaemoRemoteMounter * const m_mounter; MaemoRemoteMounter * const m_mounter;