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 ExportedLocalDirsKey(PREFIX ".ExportedLocalDirs");
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 UserEnvironmentChangesKey(PREFIX ".UserEnvironmentChanges");
static const QLatin1String UseRemoteGdbKey(PREFIX ".UseRemoteGdb");

View File

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

View File

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

View File

@@ -99,7 +99,7 @@ void MaemoDeployStep::ctor()
= qobject_cast<Qt4BuildConfiguration *>(buildConfiguration());
const MaemoToolChain * const 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(unmounted()), this, SLOT(handleUnmounted()));
connect(m_mounter, SIGNAL(error(QString)), this,
@@ -131,9 +131,6 @@ BuildStepConfigWidget *MaemoDeployStep::createConfigWidget()
QVariantMap MaemoDeployStep::toMap() const
{
QVariantMap map(BuildStep::toMap());
#ifdef DEPLOY_VIA_MOUNT
map.insert(DeployMountPortKey, m_mountPort);
#endif
addDeployTimesToMap(map);
map.unite(m_deviceConfigModel->toMap());
return map;
@@ -162,9 +159,6 @@ bool MaemoDeployStep::fromMap(const QVariantMap &map)
{
if (!BuildStep::fromMap(map))
return false;
#ifdef DEPLOY_VIA_MOUNT
m_mountPort = map.value(DeployMountPortKey, DefaultMountPort).toInt();
#endif
getDeployTimesFromMap(map);
m_deviceConfigModel->fromMap(map);
return true;
@@ -574,15 +568,16 @@ void MaemoDeployStep::handleUnmounted()
}
if (m_needsInstall || !m_filesToCopy.isEmpty()) {
m_mounter->setPortList(deviceConfig().freePorts());
if (m_needsInstall) {
const QString localDir = QFileInfo(packagingStep()->packageFilePath())
.absolutePath();
const MaemoMountSpecification mountSpec(localDir,
deployMountPoint(), m_mountPort);
m_mounter->addMountSpecification(mountSpec, true);
deployMountPoint());
if (!addMountSpecification(mountSpec))
return;
} else {
#ifdef Q_OS_WIN
int port = m_mountPort;
bool drivesToMount[26];
for (int i = 0; i < sizeof drivesToMount / drivesToMount[0]; ++i)
drivesToMount[i] = false;
@@ -602,13 +597,15 @@ void MaemoDeployStep::handleUnmounted()
const QString mountPoint = deployMountPoint()
+ QLatin1Char('/') + QLatin1Char(driveLetter);
const MaemoMountSpecification mountSpec(localDir.left(3),
mountPoint, port++);
m_mounter->addMountSpecification(mountSpec, true);
mountPoint);
if (!addMountSpecification(mountSpec))
return;
drivesToMount[index] = true;
}
#else
m_mounter->addMountSpecification(MaemoMountSpecification(QLatin1String("/"),
deployMountPoint(), m_mountPort), true);
if (!addMountSpecification(MaemoMountSpecification(QLatin1String("/"),
deployMountPoint())))
return;
#endif
}
m_mounter->mount();
@@ -660,6 +657,15 @@ void MaemoDeployStep::deployNextFile()
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)
{
if (m_stopped) {

View File

@@ -32,6 +32,7 @@
#include "maemodeployable.h"
#include "maemodeviceconfigurations.h"
#include "maemomountspecification.h"
#include <coreplugin/ssh/sftpdefs.h>
#include <projectexplorer/buildstep.h>
@@ -81,10 +82,6 @@ public:
const MaemoDeployable &deployable) const;
void setDeployed(const QString &host, const MaemoDeployable &deployable);
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:
void done();
@@ -131,6 +128,7 @@ private:
#ifdef DEPLOY_VIA_MOUNT
QString deployMountPoint() const;
void deployNextFile();
bool addMountSpecification(const MaemoMountSpecification &mountSpec);
#else
bool deploy(const MaemoDeployable &deployable);
#endif
@@ -150,7 +148,6 @@ private:
MaemoRemoteMounter *m_mounter;
QTimer *m_cleanupTimer;
bool m_canStart;
int m_mountPort;
#else
QSharedPointer<Core::SftpChannel> m_uploader;
typedef QPair<MaemoDeployable, QString> DeployInfo;

View File

@@ -33,20 +33,13 @@ MaemoDeployStepWidget::~MaemoDeployStepWidget()
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();
connect(m_step->buildConfiguration()->target(),
SIGNAL(activeRunConfigurationChanged(ProjectExplorer::RunConfiguration*)),
this, SLOT(handleDeviceConfigModelChanged()));
connect(ui->deviceConfigComboBox, SIGNAL(activated(int)), this,
SLOT(setCurrentDeviceConfig(int)));
handleDeviceConfigModelChanged();
}
void MaemoDeployStepWidget::handleDeviceConfigModelChanged()
@@ -98,14 +91,5 @@ void MaemoDeployStepWidget::setCurrentDeviceConfig(int 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 Qt4ProjectManager

View File

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

View File

@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>469</width>
<height>330</height>
<width>460</width>
<height>277</height>
</rect>
</property>
<property name="windowTitle">
@@ -43,39 +43,8 @@
</item>
</layout>
</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">
<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>
<layout class="QHBoxLayout" name="horizontalLayout_2"/>
</item>
</layout>
</item>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -590,7 +590,15 @@ bool MaemoQemuManager::fillRuntimeInformation(Runtime *runtime) const
runtime->m_libPath =
libPathSpec.mid(libPathSpec.indexOf(QLatin1Char('=')) + 1);
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;
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -278,15 +278,17 @@ QString MaemoRunConfiguration::remoteExecutableFilePath() const
->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;
const int id = qt4bc->qtVersion()->uniqueId();
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)

View File

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

View File

@@ -78,6 +78,9 @@ MaemoRunConfigurationWidget::MaemoRunConfigurationWidget(
addDebuggingWidgets(mainLayout);
addMountWidgets(mainLayout);
addEnvironmentWidgets(mainLayout);
connect(m_runConfiguration->deviceConfigModel(), SIGNAL(currentChanged()),
this, SLOT(handleCurrentDeviceConfigChanged()));
handleCurrentDeviceConfigChanged();
}
void MaemoRunConfigurationWidget::addGenericWidgets(QVBoxLayout *mainLayout)
@@ -124,13 +127,10 @@ void MaemoRunConfigurationWidget::addGenericWidgets(QVBoxLayout *mainLayout)
SLOT(argumentsEdited(QString)));
connect(m_devConfBox, SIGNAL(activated(int)), this,
SLOT(setCurrentDeviceConfig(int)));
connect(m_runConfiguration->deviceConfigModel(), SIGNAL(currentChanged()),
this, SLOT(handleCurrentDeviceConfigChanged()));
connect(m_runConfiguration, SIGNAL(targetInformationChanged()), this,
SLOT(updateTargetInformation()));
connect(m_runConfiguration->deployStep()->deployables(),
SIGNAL(modelsCreated()), this, SLOT(handleDeploySpecsChanged()));
handleCurrentDeviceConfigChanged();
}
void MaemoRunConfigurationWidget::addDebuggingWidgets(QVBoxLayout *mainLayout)
@@ -162,6 +162,8 @@ void MaemoRunConfigurationWidget::addMountWidgets(QVBoxLayout *mainLayout)
m_mountDetailsContainer->setWidget(mountViewWidget);
mainLayout->addWidget(m_mountDetailsContainer);
QVBoxLayout *mountViewLayout = new QVBoxLayout(mountViewWidget);
m_mountWarningLabel = new QLabel;
mountViewLayout->addWidget(m_mountWarningLabel);
QHBoxLayout *tableLayout = new QHBoxLayout;
mountViewLayout->addLayout(tableLayout);
m_mountView = new QTableView;
@@ -278,6 +280,7 @@ void MaemoRunConfigurationWidget::handleCurrentDeviceConfigChanged()
{
m_devConfBox->setCurrentIndex(m_runConfiguration->deviceConfigModel()
->currentIndex());
updateMountWarning();
}
void MaemoRunConfigurationWidget::setCurrentDeviceConfig(int index)
@@ -407,6 +410,38 @@ void MaemoRunConfigurationWidget::handleRemoteMountsChanged()
}
m_mountDetailsContainer->setSummaryText(QLatin1String("<b>") + text
+ 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

View File

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

View File

@@ -36,6 +36,7 @@
#include "maemoconstants.h"
#include "maemodebugsupport.h"
#include "maemoremotemountsmodel.h"
#include "maemorunconfiguration.h"
#include "maemoruncontrol.h"
@@ -158,9 +159,20 @@ MaemoRunControlFactory::~MaemoRunControlFactory()
bool MaemoRunControlFactory::canRun(RunConfiguration *runConfiguration,
const QString &mode) const
{
return qobject_cast<MaemoRunConfiguration *>(runConfiguration)
&& (mode == ProjectExplorer::Constants::RUNMODE
|| mode == ProjectExplorer::Constants::DEBUGMODE);
const MaemoRunConfiguration * const maemoRunConfig
= qobject_cast<MaemoRunConfiguration *>(runConfiguration);
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,

View File

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

View File

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

View File

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

View File

@@ -194,16 +194,21 @@ void MaemoSshRunner::handleUnmounted()
if (m_stop)
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
= m_runConfig->remoteMounts();
for (int i = 0; i < remoteMounts->mountSpecificationCount(); ++i)
m_mounter->addMountSpecification(remoteMounts->mountSpecificationAt(i),
false);
for (int i = 0; i < remoteMounts->mountSpecificationCount(); ++i) {
if (!addMountSpecification(remoteMounts->mountSpecificationAt(i)))
return;
}
if (m_debugging && m_runConfig->useRemoteGdb()) {
m_mounter->addMountSpecification(MaemoMountSpecification(
if (!addMountSpecification(MaemoMountSpecification(
m_runConfig->localDirToMountForRemoteGdb(),
MaemoGlobal::remoteProjectSourcesMountPoint(),
m_devConfig.debuggingPort), false);
MaemoGlobal::remoteProjectSourcesMountPoint())))
return;
}
m_mounter->mount();
}
@@ -250,6 +255,16 @@ void MaemoSshRunner::handleRemoteProcessFinished(int exitStatus)
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 Qt4ProjectManager

View File

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