Maemo: New project widget.

Most attributes have moved into the settings page.
This commit is contained in:
ck
2009-12-01 14:04:25 +01:00
parent 031acae3af
commit 0b49edbb5d
6 changed files with 207 additions and 333 deletions

View File

@@ -38,11 +38,14 @@
#include <QtCore/QSettings>
#include <algorithm>
namespace Qt4ProjectManager {
namespace Internal {
namespace {
const QLatin1String SettingsGroup("MaemoDeviceConfigs");
const QLatin1String IdCounterKey("IdCounter");
const QLatin1String ConfigListKey("ConfigList");
const QLatin1String NameKey("Name");
const QLatin1String TypeKey("Type");
@@ -51,10 +54,27 @@ namespace {
const QLatin1String UserNameKey("Uname");
const QLatin1String PasswordKey("Password");
const QLatin1String TimeoutKey("Timeout");
const QLatin1String InternalIdKey("InternalId");
};
class DevConfIdMatcher
{
public:
DevConfIdMatcher(quint64 id) : m_id(id) {}
bool operator()(const MaemoDeviceConfigurations::DeviceConfig &devConfig)
{
return devConfig.internalId == m_id;
}
private:
const quint64 m_id;
};
MaemoDeviceConfigurations::DeviceConfig::DeviceConfig(const QString &name)
: name(name), type(Physical), port(22), timeout(30)
: name(name),
type(Physical),
port(22),
timeout(30),
internalId(MaemoDeviceConfigurations::instance().m_nextId++)
{
}
@@ -65,8 +85,22 @@ MaemoDeviceConfigurations::DeviceConfig::DeviceConfig(const QSettings &settings)
port(settings.value(PortKey, 22).toInt()),
uname(settings.value(UserNameKey).toString()),
pwd(settings.value(PasswordKey).toString()),
timeout(settings.value(TimeoutKey, 30).toInt())
timeout(settings.value(TimeoutKey, 30).toInt()),
internalId(settings.value(InternalIdKey, MaemoDeviceConfigurations::instance().m_nextId).toInt())
{
if (internalId == MaemoDeviceConfigurations::instance().m_nextId)
++MaemoDeviceConfigurations::instance().m_nextId;
qDebug("%s: name = %s, id = %llu", Q_FUNC_INFO, qPrintable(name), internalId);
}
MaemoDeviceConfigurations::DeviceConfig::DeviceConfig()
: internalId(InvalidId)
{
}
bool MaemoDeviceConfigurations::DeviceConfig::isValid() const
{
return internalId != InvalidId;
}
void MaemoDeviceConfigurations::DeviceConfig::save(QSettings &settings) const
@@ -78,24 +112,28 @@ void MaemoDeviceConfigurations::DeviceConfig::save(QSettings &settings) const
settings.setValue(UserNameKey, uname);
settings.setValue(PasswordKey, pwd);
settings.setValue(TimeoutKey, timeout);
settings.setValue(InternalIdKey, internalId);
}
void MaemoDeviceConfigurations::setDevConfigs(const QList<DeviceConfig> &devConfigs)
{
m_devConfigs = devConfigs;
save();
emit updated();
}
MaemoDeviceConfigurations &MaemoDeviceConfigurations::instance()
MaemoDeviceConfigurations &MaemoDeviceConfigurations::instance(QObject *parent)
{
static MaemoDeviceConfigurations configs;
return configs;
if (m_instance == 0)
m_instance = new MaemoDeviceConfigurations(parent);
return *m_instance;
}
void MaemoDeviceConfigurations::save()
{
QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup(SettingsGroup);
settings->setValue(IdCounterKey, m_nextId);
settings->beginWriteArray(ConfigListKey, m_devConfigs.count());
for (int i = 0; i < m_devConfigs.count(); ++i) {
settings->setArrayIndex(i);
@@ -105,7 +143,8 @@ void MaemoDeviceConfigurations::save()
settings->endGroup();
}
MaemoDeviceConfigurations::MaemoDeviceConfigurations()
MaemoDeviceConfigurations::MaemoDeviceConfigurations(QObject *parent)
: QObject(parent)
{
load();
}
@@ -114,6 +153,7 @@ MaemoDeviceConfigurations::MaemoDeviceConfigurations()
void MaemoDeviceConfigurations::load()
{
QSettings *settings = Core::ICore::instance()->settings();
m_nextId = settings->value(IdCounterKey, 1).toULongLong();
settings->beginGroup(SettingsGroup);
int count = settings->beginReadArray(ConfigListKey);
for (int i = 0; i < count; ++i) {
@@ -124,5 +164,27 @@ void MaemoDeviceConfigurations::load()
settings->endGroup();
}
MaemoDeviceConfigurations::DeviceConfig MaemoDeviceConfigurations::find(const QString &name) const
{
qDebug("%s: Looking for name %s", Q_FUNC_INFO, qPrintable(name));
QList<DeviceConfig>::ConstIterator resultIt =
std::find_if(m_devConfigs.constBegin(), m_devConfigs.constEnd(),
DevConfNameMatcher(name));
qDebug("Found: %d", resultIt != m_devConfigs.constEnd());
return resultIt == m_devConfigs.constEnd() ? DeviceConfig() : *resultIt;
}
MaemoDeviceConfigurations::DeviceConfig MaemoDeviceConfigurations::find(int id) const
{
qDebug("%s: Looking for id %d", Q_FUNC_INFO, id);
QList<DeviceConfig>::ConstIterator resultIt =
std::find_if(m_devConfigs.constBegin(), m_devConfigs.constEnd(),
DevConfIdMatcher(id));
qDebug("Found: %d", resultIt != m_devConfigs.constEnd());
return resultIt == m_devConfigs.constEnd() ? DeviceConfig() : *resultIt;
}
MaemoDeviceConfigurations *MaemoDeviceConfigurations::m_instance = 0;
} // namespace Internal
} // namespace Qt4ProjectManager

View File

@@ -36,6 +36,7 @@
#define MAEMODEVICECONFIGURATIONS_H
#include <QtCore/QList>
#include <QtCore/QObject>
#include <QtCore/QString>
#include <QtCore/QtGlobal>
@@ -46,16 +47,20 @@ QT_END_NAMESPACE
namespace Qt4ProjectManager {
namespace Internal {
class MaemoDeviceConfigurations
class MaemoDeviceConfigurations : public QObject
{
Q_OBJECT
Q_DISABLE_COPY(MaemoDeviceConfigurations)
public:
class DeviceConfig
{
public:
enum DeviceType { Physical, Simulator };
DeviceConfig();
DeviceConfig(const QString &name);
DeviceConfig(const QSettings &settings);
void save(QSettings &settings) const;
bool isValid() const;
QString name;
DeviceType type;
QString host;
@@ -63,12 +68,16 @@ public:
QString uname;
QString pwd;
int timeout;
quint64 internalId;
private:
static const quint64 InvalidId = 0;
};
class DevConfMatcher
class DevConfNameMatcher
{
public:
DevConfMatcher(const QString &name) : m_name(name) {}
DevConfNameMatcher(const QString &name) : m_name(name) {}
bool operator()(const MaemoDeviceConfigurations::DeviceConfig &devConfig)
{
return devConfig.name == m_name;
@@ -77,18 +86,24 @@ public:
const QString m_name;
};
static MaemoDeviceConfigurations &instance();
static MaemoDeviceConfigurations &instance(QObject *parent = 0);
QList<DeviceConfig> devConfigs() const { return m_devConfigs; }
void setDevConfigs(const QList<DeviceConfig> &devConfigs);
DeviceConfig find(const QString &name) const;
DeviceConfig find(int id) const;
signals:
void updated();
private:
MaemoDeviceConfigurations();
MaemoDeviceConfigurations(const MaemoDeviceConfigurations &);
MaemoDeviceConfigurations& operator=(const MaemoDeviceConfigurations &);
MaemoDeviceConfigurations(QObject *parent);
void load();
void save();
static MaemoDeviceConfigurations *m_instance;
QList<DeviceConfig> m_devConfigs;
quint64 m_nextId;
friend class MaemoDeviceConfigurations::DeviceConfig;
};
} // namespace Internal

View File

@@ -29,6 +29,7 @@
#include "maemomanager.h"
#include "maemodeviceconfigurations.h"
#include "maemosettingspage.h"
#include "maemotoolchain.h"
#include "maemorunconfiguration.h"
@@ -68,6 +69,7 @@ MaemoManager::MaemoManager()
ExtensionSystem::PluginManager::instance()->addObject(m_runControlFactory);
ExtensionSystem::PluginManager::instance()->addObject(m_runConfigurationFactory);
ExtensionSystem::PluginManager::instance()->addObject(m_settingsPage);
MaemoDeviceConfigurations::instance(this);
}
MaemoManager::~MaemoManager()

View File

@@ -29,6 +29,7 @@
#include "maemorunconfiguration.h"
#include "maemodeviceconfigurations.h"
#include "maemomanager.h"
#include "maemotoolchain.h"
#include "profilereader.h"
@@ -48,6 +49,7 @@
#include <QtCore/QProcess>
#include <QtCore/QSharedPointer>
#include <QtGui/QComboBox>
#include <QtGui/QCheckBox>
#include <QtGui/QFormLayout>
#include <QtGui/QFrame>
@@ -66,21 +68,14 @@ class MaemoRunConfigurationWidget : public QWidget
{
Q_OBJECT
public:
MaemoRunConfigurationWidget(
MaemoRunConfiguration *runConfiguration, QWidget *parent = 0);
MaemoRunConfigurationWidget(MaemoRunConfiguration *runConfiguration,
QWidget *parent = 0);
private slots:
void configNameEdited(const QString &text);
void argumentsEdited(const QString &args);
void hostNameEdited(const QString &name);
void userNameEdited(const QString &name);
void portEdited(const QString &port);
void hostTypeChanged();
#if USE_SSL_PASSWORD
void passwordUseChanged();
void passwordEdited(const QString &password);
#endif
void deviceConfigurationChanged(const QString &name);
void resetDeviceConfigurations();
void updateTargetInformation();
@@ -88,22 +83,15 @@ private slots:
void updateVisibleSimulatorParameter();
private:
void setSimInfoVisible(const MaemoDeviceConfigurations::DeviceConfig &devConf);
QLineEdit *m_configNameLineEdit;
QLineEdit *m_argsLineEdit;
QLineEdit *m_hostNameLineEdit;
QLineEdit *m_userLineEdit;
QLineEdit *m_passwordLineEdit;
QLineEdit *m_portLineEdit;
QLabel *m_executableLabel;
QLabel *m_debuggerLabel;
QLabel *m_simParamsValueLabel;
QLabel *m_chooseSimPathLabel;
QLabel *m_simParamsNameLabel;
QCheckBox *m_passwordCheckBox;
QRadioButton *m_hwButton;
QRadioButton *m_simButton;
QToolButton *m_resetButton;
Utils::PathChooser *m_simPathChooser;
QComboBox *m_devConfBox;
QLabel *m_simPathNameLabel;
QLabel *m_simPathValueLabel;
MaemoRunConfiguration *m_runConfiguration;
};
@@ -124,9 +112,9 @@ protected:
const QString executableFileName() const;
const QString port() const;
const QString targetCmdLinePrefix() const;
const QString remoteDir() const;
virtual void deploymentFinished(bool success)=0;
virtual bool setProcessEnvironment(QProcess &process);
private slots:
void readStandardError();
void readStandardOutput();
@@ -140,6 +128,9 @@ private:
QProcess deployProcess;
bool deployingExecutable;
bool deployingDumperLib;
protected:
const MaemoDeviceConfigurations::DeviceConfig devConfig;
};
class MaemoRunControl : public AbstractMaemoRunControl
@@ -239,39 +230,19 @@ void ErrorDumper::printToStream(QProcess::ProcessError error)
// #pragma mark -- MaemoRunConfiguration
static const QLatin1String RemoteHostIsSimulatorKey("RemoteHostIsSimulator");
static const QLatin1String ArgumentsKeySim("ArgumentsSim");
static const QLatin1String RemoteHostNameKeySim("RemoteHostNameSim");
static const QLatin1String RemoteUserNameKeySim("RemoteUserNameSim");
static const QLatin1String RemotePortKeySim("RemotePortSim");
static const QLatin1String ArgumentsKeyDevice("ArgumentsDevice");
static const QLatin1String RemoteHostNameKeyDevice("RemoteHostNameDevice");
static const QLatin1String RemoteUserNameKeyDevice("RemoteUserNameDevice");
static const QLatin1String RemotePortKeyDevice("RemotePortDevice");
static const QLatin1String ArgumentsKey("Arguments");
static const QLatin1String SimulatorPathKey("Simulator");
static const QLatin1String DeviceIdKey("DeviceId");
static const QLatin1String LastDeployedKey("LastDeployed");
static const QLatin1String DebuggingHelpersLastDeployedKey(
"DebuggingHelpersLastDeployed");
static const QLatin1String SimulatorPath("SimulatorPath");
static const QLatin1String IsUserSetSimulator("IsUserSetSimulator");
#if USE_SSL_PASSWORD
static const QLatinString RemoteUserPasswordKey("RemoteUserPassword");
static const QLatinString RemoteHostRequiresPasswordKey(
"RemoteHostRequiresPassword");
#endif
MaemoRunConfiguration::MaemoRunConfiguration(Project *project,
const QString &proFilePath)
: RunConfiguration(project)
, m_proFilePath(proFilePath)
, m_cachedTargetInformationValid(false)
, m_cachedSimulatorInformationValid(false)
, m_isUserSetSimulator(false)
, m_remotePortSim(22)
, m_remotePortDevice(22)
, qemu(0)
{
if (!m_proFilePath.isEmpty()) {
@@ -281,6 +252,9 @@ MaemoRunConfiguration::MaemoRunConfiguration(Project *project,
setName(tr("MaemoRunConfiguration"));
}
connect(&MaemoDeviceConfigurations::instance(), SIGNAL(updated()),
this, SLOT(updateDeviceConfigurations()));
connect(project, SIGNAL(targetInformationChanged()), this,
SLOT(invalidateCachedTargetInformation()));
connect(project, SIGNAL(activeBuildConfigurationChanged()), this,
@@ -336,28 +310,14 @@ QWidget *MaemoRunConfiguration::configurationWidget()
void MaemoRunConfiguration::save(PersistentSettingsWriter &writer) const
{
writer.saveValue(RemoteHostIsSimulatorKey, m_remoteHostIsSimulator);
writer.saveValue(ArgumentsKeySim, m_argumentsSim);
writer.saveValue(RemoteHostNameKeySim, m_remoteHostNameSim);
writer.saveValue(RemoteUserNameKeySim, m_remoteUserNameSim);
writer.saveValue(RemotePortKeySim, m_remotePortSim);
writer.saveValue(ArgumentsKeyDevice, m_argumentsDevice);
writer.saveValue(RemoteHostNameKeyDevice, m_remoteHostNameDevice);
writer.saveValue(RemoteUserNameKeyDevice, m_remoteUserNameDevice);
writer.saveValue(RemotePortKeyDevice, m_remotePortDevice);
#if USE_SSL_PASSWORD
writer.saveValue(RemoteUserPasswordKey, m_remoteUserPassword);
writer.saveValue(RemoteHostRequiresPasswordKey, m_remoteHostRequiresPassword);
#endif
writer.saveValue(DeviceIdKey, m_devConfig.internalId);
writer.saveValue(ArgumentsKey, m_arguments);
writer.saveValue(LastDeployedKey, m_lastDeployed);
writer.saveValue(DebuggingHelpersLastDeployedKey,
m_debuggingHelpersLastDeployed);
writer.saveValue(SimulatorPath, m_simulatorPath);
writer.saveValue(IsUserSetSimulator, m_isUserSetSimulator);
writer.saveValue(SimulatorPathKey, m_simulatorPath);
const QDir &dir = QFileInfo(project()->file()->fileName()).absoluteDir();
writer.saveValue("ProFile", dir.relativeFilePath(m_proFilePath));
@@ -369,32 +329,15 @@ void MaemoRunConfiguration::restore(const PersistentSettingsReader &reader)
{
RunConfiguration::restore(reader);
m_remoteHostIsSimulator = reader.restoreValue(RemoteHostIsSimulatorKey)
.toBool();
m_argumentsSim = reader.restoreValue(ArgumentsKeySim).toStringList();
m_remoteHostNameSim = reader.restoreValue(RemoteHostNameKeySim).toString();
m_remoteUserNameSim = reader.restoreValue(RemoteUserNameKeySim).toString();
m_remotePortSim = reader.restoreValue(RemotePortKeySim).toInt();
m_argumentsDevice = reader.restoreValue(ArgumentsKeyDevice).toStringList();
m_remoteHostNameDevice = reader.restoreValue(RemoteHostNameKeyDevice)
.toString();
m_remoteUserNameDevice = reader.restoreValue(RemoteUserNameKeyDevice)
.toString();
m_remotePortDevice = reader.restoreValue(RemotePortKeyDevice).toInt();
#if USE_SSL_PASSWORD
m_remoteUserPassword = reader.restoreValue(RemoteUserPasswordKey).toString();
m_remoteHostRequiresPassword =
reader.restoreValue(RemoteHostRequiresPasswordKey).toBool();
#endif
setDeviceConfig(MaemoDeviceConfigurations::instance().
find(reader.restoreValue(DeviceIdKey).toInt()));
m_arguments = reader.restoreValue(ArgumentsKey).toStringList();
m_lastDeployed = reader.restoreValue(LastDeployedKey).toDateTime();
m_debuggingHelpersLastDeployed =
reader.restoreValue(DebuggingHelpersLastDeployedKey).toDateTime();
m_simulatorPath = reader.restoreValue(SimulatorPath).toString();
m_isUserSetSimulator = reader.restoreValue(IsUserSetSimulator).toBool();
m_simulatorPath = reader.restoreValue(SimulatorPathKey).toString();
const QDir &dir = QFileInfo(project()->file()->fileName()).absoluteDir();
m_proFilePath = dir.filePath(reader.restoreValue("ProFile").toString());
@@ -435,29 +378,15 @@ bool MaemoRunConfiguration::fileNeedsDeployment(const QString &path,
|| QFileInfo(path).lastModified() > lastDeployed;
}
const QString MaemoRunConfiguration::remoteHostName() const
void MaemoRunConfiguration::setDeviceConfig(
const MaemoDeviceConfigurations::DeviceConfig &devConf)
{
return m_remoteHostIsSimulator ? m_remoteHostNameSim
: m_remoteHostNameDevice;
m_devConfig = devConf;
}
const QString MaemoRunConfiguration::remoteUserName() const
MaemoDeviceConfigurations::DeviceConfig MaemoRunConfiguration::deviceConfig() const
{
return m_remoteHostIsSimulator ? m_remoteUserNameSim
: m_remoteUserNameDevice;
}
int MaemoRunConfiguration::remotePort() const
{
int port = m_remoteHostIsSimulator ? m_remotePortSim : m_remotePortDevice;
return port > 0 ? port : 22;
}
const QString MaemoRunConfiguration::remoteDir() const
{
return remoteUserName() == QString::fromLocal8Bit("root")
? QString::fromLocal8Bit("/root")
: QString::fromLocal8Bit("/home/") + remoteUserName();
return m_devConfig;
}
const QString MaemoRunConfiguration::sshCmd() const
@@ -507,13 +436,13 @@ QString MaemoRunConfiguration::maddeRoot() const
const QString MaemoRunConfiguration::sysRoot() const
{
if (const MaemoToolChain *tc = toolchain())
return toolchain()->sysrootRoot();
return tc->sysrootRoot();
return QString();
}
const QStringList MaemoRunConfiguration::arguments() const
{
return m_remoteHostIsSimulator ? m_argumentsSim : m_argumentsDevice;
return m_arguments;
}
const QString MaemoRunConfiguration::dumperLib() const
@@ -559,62 +488,9 @@ QString MaemoRunConfiguration::simulatorArgs() const
void MaemoRunConfiguration::setArguments(const QStringList &args)
{
if (m_remoteHostIsSimulator)
m_argumentsSim = args;
else
m_argumentsDevice = args;
m_arguments = args;
}
void MaemoRunConfiguration::setRemoteHostIsSimulator(bool isSimulator)
{
m_remoteHostIsSimulator = isSimulator;
}
void MaemoRunConfiguration::setRemoteHostName(const QString &hostName)
{
m_lastDeployed = QDateTime();
m_debuggingHelpersLastDeployed = QDateTime();
if (m_remoteHostIsSimulator)
m_remoteHostNameSim = hostName;
else
m_remoteHostNameDevice = hostName;
}
void MaemoRunConfiguration::setRemoteUserName(const QString &userName)
{
m_lastDeployed = QDateTime();
m_debuggingHelpersLastDeployed = QDateTime();
if (m_remoteHostIsSimulator)
m_remoteUserNameSim = userName;
else
m_remoteUserNameDevice = userName;
}
void MaemoRunConfiguration::setRemotePort(int port)
{
m_lastDeployed = QDateTime();
m_debuggingHelpersLastDeployed = QDateTime();
if (m_remoteHostIsSimulator)
m_remotePortSim = port;
else
m_remotePortDevice = port;
}
#if USE_SSL_PASSWORD
void MaemoRunConfiguration::setRemotePassword(const QString &password)
{
Q_ASSERT(remoteHostRequiresPassword());
m_remoteUserPassword = password;
}
void MaemoRunConfiguration::setRemoteHostRequiresPassword(bool requiresPassword)
{
m_remoteHostRequiresPassword = requiresPassword;
}
#endif
bool MaemoRunConfiguration::isQemuRunning() const
{
@@ -860,6 +736,15 @@ void MaemoRunConfiguration::enabledStateChanged()
MaemoManager::instance()->setQemuSimulatorStarterEnabled(isEnabled());
}
void MaemoRunConfiguration::updateDeviceConfigurations()
{
qDebug("%s: Current devid = %llu", Q_FUNC_INFO, m_devConfig.internalId);
m_devConfig =
MaemoDeviceConfigurations::instance().find(m_devConfig.internalId);
qDebug("%s: new devid = %llu", Q_FUNC_INFO, m_devConfig.internalId);
emit deviceConfigurationsUpdated();
}
// #pragma mark -- MaemoRunConfigurationWidget
@@ -874,6 +759,8 @@ MaemoRunConfigurationWidget::MaemoRunConfigurationWidget(
mainLayout->setFormAlignment(Qt::AlignLeft | Qt::AlignVCenter);
m_configNameLineEdit = new QLineEdit(m_runConfiguration->name());
mainLayout->addRow(tr("Run configuration name:"), m_configNameLineEdit);
m_devConfBox = new QComboBox;
mainLayout->addRow(new QLabel(tr("Device Configuration:")), m_devConfBox);
m_executableLabel = new QLabel(m_runConfiguration->executable());
mainLayout->addRow(tr("Executable:"), m_executableLabel);
m_argsLineEdit = new QLineEdit(m_runConfiguration->arguments().join(" "));
@@ -881,83 +768,24 @@ MaemoRunConfigurationWidget::MaemoRunConfigurationWidget(
m_debuggerLabel = new QLabel(m_runConfiguration->gdbCmd());
mainLayout->addRow(tr("Debugger:"), m_debuggerLabel);
mainLayout->addItem(new QSpacerItem(10, 10));
m_simPathNameLabel = new QLabel(tr("Simulator Path:"));
m_simPathValueLabel = new QLabel(m_runConfiguration->simulatorPath());
mainLayout->addRow(m_simPathNameLabel, m_simPathValueLabel);
resetDeviceConfigurations();
QHBoxLayout *hostTypeLayout = new QHBoxLayout;
m_hwButton = new QRadioButton(tr("Physical device"));
hostTypeLayout->addWidget(m_hwButton);
m_simButton = new QRadioButton(tr("Simulator"));
hostTypeLayout->addWidget(m_simButton);
hostTypeLayout->addStretch(1);
mainLayout->addRow(tr("Remote host type:"), hostTypeLayout);
m_chooseSimPathLabel = new QLabel(tr("Choose simulator:"));
m_simPathChooser = new Utils::PathChooser;
m_simPathChooser->setPath(m_runConfiguration->simulatorPath());
QHBoxLayout *pathLayout = new QHBoxLayout;
pathLayout->addWidget(m_simPathChooser);
m_resetButton = new QToolButton();
m_resetButton->setToolTip(tr("Reset to default"));
m_resetButton->setIcon(QIcon(":/core/images/reset.png"));
pathLayout->addWidget(m_resetButton);
mainLayout->addRow(m_chooseSimPathLabel, pathLayout);
m_simParamsNameLabel = new QLabel(tr("Simulator command line:"));
m_simParamsValueLabel= new QLabel(m_runConfiguration->visibleSimulatorParameter());
mainLayout->addRow(m_simParamsNameLabel, m_simParamsValueLabel);
connect(m_simPathChooser, SIGNAL(changed(QString)), m_runConfiguration,
SLOT(setUserSimulatorPath(QString)));
connect(m_runConfiguration, SIGNAL(cachedSimulatorInformationChanged()),
this, SLOT(updateSimulatorPath()));
connect(m_runConfiguration, SIGNAL(cachedSimulatorInformationChanged()),
this, SLOT(updateVisibleSimulatorParameter()));
connect(m_resetButton, SIGNAL(clicked()), m_runConfiguration,
SLOT(resetCachedSimulatorInformation()));
m_hostNameLineEdit = new QLineEdit(m_runConfiguration->remoteHostName());
mainLayout->addRow(tr("Remote host name:"), m_hostNameLineEdit);
m_userLineEdit = new QLineEdit(m_runConfiguration->remoteUserName());
mainLayout->addRow(tr("Remote user name:"), m_userLineEdit);
m_portLineEdit = new QLineEdit(QString::number(m_runConfiguration->remotePort()));
mainLayout->addRow(tr("Remote SSH port:"), m_portLineEdit);
// Unlikely to ever work: ssh uses /dev/tty directly instead of stdin/out
#if USE_SSL_PASSWORD
m_passwordCheckBox = new QCheckBox(tr("Remote password:"));
m_passwordCheckBox->setToolTip(tr("Uncheck for passwordless login"));
m_passwordCheckBox->setChecked(m_runConfiguration
->remoteHostRequiresPassword());
m_passwordLineEdit = new QLineEdit(m_runConfiguration->remoteUserPassword());
m_passwordLineEdit->setEchoMode(QLineEdit::Password);
m_passwordLineEdit->setEnabled(m_passwordCheckBox->isChecked());
mainLayout->addRow(m_passwordCheckBox, m_passwordLineEdit);
connect(m_passwordCheckBox, SIGNAL(stateChanged(int)), this,
SLOT(passwordUseChanged()));
connect(m_passwordLineEdit, SIGNAL(textEdited(QString)), this,
SLOT(passwordEdited(QString)));
#endif
connect(m_runConfiguration, SIGNAL(deviceConfigurationsUpdated()),
this, SLOT(resetDeviceConfigurations()));
connect(m_configNameLineEdit, SIGNAL(textEdited(QString)), this,
SLOT(configNameEdited(QString)));
connect(m_argsLineEdit, SIGNAL(textEdited(QString)), this,
SLOT(argumentsEdited(QString)));
connect(m_devConfBox, SIGNAL(activated(QString)), this,
SLOT(deviceConfigurationChanged(QString)));
connect(m_runConfiguration, SIGNAL(targetInformationChanged()), this,
SLOT(updateTargetInformation()));
connect(m_hwButton, SIGNAL(toggled(bool)), this, SLOT(hostTypeChanged()));
connect(m_simButton, SIGNAL(toggled(bool)), this, SLOT(hostTypeChanged()));
connect(m_hostNameLineEdit, SIGNAL(textEdited(QString)), this,
SLOT(hostNameEdited(QString)));
connect(m_userLineEdit, SIGNAL(textEdited(QString)), this,
SLOT(userNameEdited(QString)));
connect(m_portLineEdit, SIGNAL(textEdited(QString)), this,
SLOT(portEdited(QString)));
if (m_runConfiguration->remoteHostIsSimulator())
m_simButton->setChecked(true);
else
m_hwButton->setChecked(true);
}
void MaemoRunConfigurationWidget::configNameEdited(const QString &text)
@@ -977,66 +805,40 @@ void MaemoRunConfigurationWidget::updateTargetInformation()
void MaemoRunConfigurationWidget::updateSimulatorPath()
{
m_simPathChooser->setPath(m_runConfiguration->simulatorPath());
m_simPathValueLabel->setText(m_runConfiguration->simulatorPath());
}
void MaemoRunConfigurationWidget::updateVisibleSimulatorParameter()
void MaemoRunConfigurationWidget::deviceConfigurationChanged(const QString &name)
{
m_simParamsValueLabel->setText(m_runConfiguration->visibleSimulatorParameter());
const MaemoDeviceConfigurations::DeviceConfig &devConfig =
MaemoDeviceConfigurations::instance().find(name);
setSimInfoVisible(devConfig);
m_runConfiguration->setDeviceConfig(devConfig);
}
void MaemoRunConfigurationWidget::hostTypeChanged()
void MaemoRunConfigurationWidget::setSimInfoVisible(
const MaemoDeviceConfigurations::DeviceConfig &devConf)
{
const bool isSimulator = m_simButton->isChecked();
m_chooseSimPathLabel->setVisible(isSimulator);
m_simPathChooser->setVisible(isSimulator);
m_simParamsNameLabel->setVisible(isSimulator);
m_simParamsValueLabel->setVisible(isSimulator);
m_resetButton->setVisible(isSimulator);
m_runConfiguration->setRemoteHostIsSimulator(isSimulator);
m_argsLineEdit->setText(m_runConfiguration->arguments().join(" "));
m_hostNameLineEdit->setText(m_runConfiguration->remoteHostName());
m_userLineEdit->setText(m_runConfiguration->remoteUserName());
m_portLineEdit->setText(QString::number(m_runConfiguration->remotePort()));
const bool isSimulator =
devConf.type == MaemoDeviceConfigurations::DeviceConfig::Simulator;
m_simPathNameLabel->setVisible(isSimulator);
m_simPathValueLabel->setVisible(isSimulator);
}
void MaemoRunConfigurationWidget::hostNameEdited(const QString &hostName)
void MaemoRunConfigurationWidget::resetDeviceConfigurations()
{
m_runConfiguration->setRemoteHostName(hostName);
m_devConfBox->clear();
const QList<MaemoDeviceConfigurations::DeviceConfig> &devConfs =
MaemoDeviceConfigurations::instance().devConfigs();
foreach (const MaemoDeviceConfigurations::DeviceConfig &devConf, devConfs)
m_devConfBox->addItem(devConf.name);
m_devConfBox->addItem(MaemoDeviceConfigurations::DeviceConfig().name);
const MaemoDeviceConfigurations::DeviceConfig &devConf =
m_runConfiguration->deviceConfig();
m_devConfBox->setCurrentIndex(m_devConfBox->findText(devConf.name));
setSimInfoVisible(devConf);
}
void MaemoRunConfigurationWidget::userNameEdited(const QString &userName)
{
m_runConfiguration->setRemoteUserName(userName);
}
#if USE_SSL_PASSWORD
void MaemoRunConfigurationWidget::passwordUseChanged()
{
const bool usePassword = m_passwordCheckBox->checkState() == Qt::Checked;
m_passwordLineEdit->setEnabled(usePassword);
m_runConfiguration->setRemoteHostRequiresPassword(usePassword);
}
void MaemoRunConfigurationWidget::passwordEdited(const QString &password)
{
m_runConfiguration->setRemotePassword(password);
}
#endif
void MaemoRunConfigurationWidget::portEdited(const QString &portString)
{
bool isValidString;
int port = portString.toInt(&isValidString);
if (isValidString)
m_runConfiguration->setRemotePort(port);
else
m_portLineEdit->setText(QString::number(m_runConfiguration->remotePort()));
}
// #pragma mark -- MaemoRunConfigurationFactory
@@ -1219,6 +1021,8 @@ QWidget* MaemoRunControlFactory::configurationWidget(RunConfiguration *config)
AbstractMaemoRunControl::AbstractMaemoRunControl(RunConfiguration *rc)
: RunControl(rc)
, runConfig(qobject_cast<MaemoRunConfiguration *>(rc))
, devConfig(runConfig ? runConfig->deviceConfig()
: MaemoDeviceConfigurations::DeviceConfig())
{
setProcessEnvironment(deployProcess);
@@ -1235,6 +1039,8 @@ AbstractMaemoRunControl::AbstractMaemoRunControl(RunConfiguration *rc)
void AbstractMaemoRunControl::startDeployment(bool forDebugging)
{
QTC_ASSERT(runConfig, return);
if (!devConfig.isValid())
deploymentFinished(false);
QStringList deployables;
if (runConfig->currentlyNeedsDeployment()) {
deployingExecutable = true;
@@ -1252,8 +1058,8 @@ void AbstractMaemoRunControl::startDeployment(bool forDebugging)
emit addToOutputWindow(this, tr("Files to deploy: %1.")
.arg(deployables.join(" ")));
QStringList cmdArgs;
cmdArgs << "-P" << port() << deployables << (runConfig->remoteUserName()
+ "@" + runConfig->remoteHostName() + ":" + runConfig->remoteDir());
cmdArgs << "-P" << port() << deployables << (devConfig.uname
+ "@" + devConfig.host + ":" + remoteDir());
deployProcess.setWorkingDirectory(QFileInfo(executableOnHost()).absolutePath());
deployProcess.start(runConfig->scpCmd(), cmdArgs);
if (!deployProcess.waitForStarted()) {
@@ -1301,7 +1107,7 @@ const QString AbstractMaemoRunControl::executableOnHost() const
const QString AbstractMaemoRunControl::port() const
{
return QString::number(runConfig->remotePort());
return QString::number(devConfig.port);
}
const QString AbstractMaemoRunControl::executableFileName() const
@@ -1309,9 +1115,16 @@ const QString AbstractMaemoRunControl::executableFileName() const
return QFileInfo(executableOnHost()).fileName();
}
const QString AbstractMaemoRunControl::remoteDir() const
{
return devConfig.uname == QString::fromLocal8Bit("root")
? QString::fromLocal8Bit("/root")
: QString::fromLocal8Bit("/home/") + devConfig.uname;
}
const QString AbstractMaemoRunControl::executableOnTarget() const
{
return QString::fromLocal8Bit("%1/%2").arg(runConfig->remoteDir()).
return QString::fromLocal8Bit("%1/%2").arg(remoteDir()).
arg(executableFileName());
}
@@ -1397,8 +1210,8 @@ void MaemoRunControl::startExecution()
.arg(runConfig->arguments().join(" "));
QStringList cmdArgs;
cmdArgs << "-n" << "-p" << port() << "-l" << runConfig->remoteUserName()
<< runConfig->remoteHostName() << remoteCall;
cmdArgs << "-n" << "-p" << port() << "-l" << devConfig.uname
<< devConfig.host << remoteCall;
sshProcess.start(runConfig->sshCmd(), cmdArgs);
sshProcess.start(runConfig->sshCmd(), cmdArgs);
@@ -1432,8 +1245,8 @@ void MaemoRunControl::stop()
QStringList cmdArgs;
const QString remoteCall = QString::fromLocal8Bit("pkill -x %1; "
"sleep 1; pkill -x -9 %1").arg(executableFileName());
cmdArgs << "-n" << "-p" << port() << "-l" << runConfig->remoteUserName()
<< runConfig->remoteHostName() << remoteCall;
cmdArgs << "-n" << "-p" << port() << "-l" << devConfig.uname
<< devConfig.host << remoteCall;
stopProcess.start(runConfig->sshCmd(), cmdArgs);
}
}
@@ -1462,16 +1275,14 @@ MaemoDebugRunControl::MaemoDebugRunControl(RunConfiguration *runConfiguration)
QTC_ASSERT(debuggerManager != 0, return);
startParams->startMode = Debugger::StartRemote;
startParams->executable = executableOnHost();
startParams->remoteChannel = runConfig->remoteHostName() + ":"
+ gdbServerPort;
startParams->remoteChannel = devConfig.host + ":" + gdbServerPort;
startParams->remoteArchitecture = "arm";
startParams->sysRoot = runConfig->sysRoot();
startParams->toolChainType = ToolChain::GCC_MAEMO;
startParams->debuggerCommand = runConfig->gdbCmd();
startParams->dumperLibrary = runConfig->dumperLib();
startParams->remoteDumperLib = QString::fromLocal8Bit("%1/%2")
.arg(runConfig->remoteDir()).arg(QFileInfo(runConfig->dumperLib())
.fileName());
.arg(remoteDir()).arg(QFileInfo(runConfig->dumperLib()).fileName());
connect(this, SIGNAL(stopRequested()), debuggerManager, SLOT(exitDebugger()));
connect(debuggerManager, SIGNAL(debuggingFinished()), this,
@@ -1508,8 +1319,8 @@ void MaemoDebugRunControl::startGdbServer()
arg(targetCmdLinePrefix()).arg(gdbServerPort). arg(executableOnTarget())
.arg(runConfig->arguments().join(" ")));
QStringList sshArgs;
sshArgs << "-t" << "-n" << "-l" << runConfig->remoteUserName() << "-p"
<< port() << runConfig->remoteHostName() << remoteCall;
sshArgs << "-t" << "-n" << "-l" << devConfig.uname << "-p"
<< port() << devConfig.host << remoteCall;
inferiorPid = -1;
disconnect(&gdbServer, SIGNAL(readyReadStandardError()), 0, 0);
connect(&gdbServer, SIGNAL(readyReadStandardError()), this,
@@ -1591,8 +1402,8 @@ void MaemoDebugRunControl::debuggingFinished()
const QString remoteCall = QString::fromLocal8Bit("kill %1; sleep 1; "
"kill -9 %1; pkill -x -9 gdbserver").arg(inferiorPid);
QStringList sshArgs;
sshArgs << "-n" << "-l" << runConfig->remoteUserName() << "-p" << port()
<< runConfig->remoteHostName() << remoteCall;
sshArgs << "-n" << "-l" << devConfig.uname << "-p" << port()
<< devConfig.host << remoteCall;
stopProcess.start(runConfig->sshCmd(), sshArgs);
}
qDebug("ssh return code is %d", gdbServer.exitCode());

View File

@@ -30,6 +30,8 @@
#ifndef MAEMORUNCONFIGURATION_H
#define MAEMORUNCONFIGURATION_H
#include "maemodeviceconfigurations.h"
#include <QtCore/QDateTime>
#include <QtGui/QWidget>
@@ -87,28 +89,19 @@ public:
const QString sysRoot() const;
const QStringList arguments() const;
void setArguments(const QStringList &args);
void setDeviceConfig(const MaemoDeviceConfigurations::DeviceConfig &deviceConfig);
MaemoDeviceConfigurations::DeviceConfig deviceConfig() const;
QString simulator() const;
QString simulatorArgs() const;
QString simulatorPath() const;
QString visibleSimulatorParameter() const;
bool remoteHostIsSimulator() const { return m_remoteHostIsSimulator; }
const QString remoteHostName() const;
const QString remoteUserName() const;
int remotePort() const;
const QString remoteDir() const;
const QString sshCmd() const;
const QString scpCmd() const;
const QString gdbCmd() const;
const QString dumperLib() const;
void setRemoteHostIsSimulator(bool isSimulator);
void setRemoteHostName(const QString &hostName);
void setRemoteUserName(const QString &userName);
void setRemotePort(int port);
bool isQemuRunning() const;
#if USE_SSL_PASSWORD
@@ -121,11 +114,13 @@ public:
#endif
signals:
void deviceConfigurationsUpdated();
void targetInformationChanged();
void cachedSimulatorInformationChanged();
void qemuProcessStatus(bool running);
private slots:
void updateDeviceConfigurations();
void invalidateCachedTargetInformation();
void setUserSimulatorPath(const QString &path);
@@ -145,7 +140,6 @@ private:
bool fileNeedsDeployment(const QString &path, const QDateTime &lastDeployed) const;
private:
// Keys for saving/loading attributes.
QString m_executable;
QString m_proFilePath;
bool m_cachedTargetInformationValid;
@@ -161,18 +155,8 @@ private:
QString m_gdbPath;
// Information about the remote host.
bool m_remoteHostIsSimulator;
QStringList m_argumentsSim;
QString m_remoteHostNameSim;
QString m_remoteUserNameSim;
int m_remotePortSim;
QStringList m_argumentsDevice;
QString m_remoteHostNameDevice;
QString m_remoteUserNameDevice;
int m_remotePortDevice;
MaemoDeviceConfigurations::DeviceConfig m_devConfig;
QStringList m_arguments;
QDateTime m_lastDeployed;
QDateTime m_debuggingHelpersLastDeployed;

View File

@@ -60,7 +60,7 @@ bool configNameExists(const QList<MaemoDeviceConfigurations::DeviceConfig> &devC
const QString &name)
{
return std::find_if(devConfs.constBegin(), devConfs.constEnd(),
MaemoDeviceConfigurations::DevConfMatcher(name)) != devConfs.constEnd();
MaemoDeviceConfigurations::DevConfNameMatcher(name)) != devConfs.constEnd();
}
class PortAndTimeoutValidator : public QIntValidator
@@ -193,7 +193,7 @@ void MaemoSettingsPage::apply()
void MaemoSettingsPage::finish()
{
apply();
// apply();
}
MaemoSettingsWidget::MaemoSettingsWidget(QWidget *parent)
@@ -262,9 +262,9 @@ void MaemoSettingsWidget::display(const MaemoDeviceConfigurations::DeviceConfig
{
m_ui->nameLineEdit->setText(devConfig.name);
if (devConfig.type == MaemoDeviceConfigurations::DeviceConfig::Physical)
m_ui->deviceButton->setEnabled(true);
m_ui->deviceButton->setChecked(true);
else
m_ui->simulatorButton->setEnabled(true);
m_ui->simulatorButton->setChecked(true);
m_ui->hostLineEdit->setText(devConfig.host);
m_ui->portLineEdit->setText(QString::number(devConfig.port));
m_ui->timeoutLineEdit->setText(QString::number(devConfig.timeout));