forked from qt-creator/qt-creator
RemoteLinux: Add support for auto-detected devices.
We assume them to be transient, which means they do not get saved. Change-Id: Ia9016172737d6e2547e3db5faf35d81c5c8cb91a Reviewed-on: http://codereview.qt.nokia.com/2943 Reviewed-by: Christian Kandeler <christian.kandeler@nokia.com>
This commit is contained in:
@@ -79,6 +79,7 @@ public:
|
||||
LinuxDeviceConfiguration::DeviceType deviceType;
|
||||
PortList freePorts;
|
||||
bool isDefault;
|
||||
LinuxDeviceConfiguration::Origin origin;
|
||||
LinuxDeviceConfiguration::Id internalId;
|
||||
};
|
||||
|
||||
@@ -104,13 +105,14 @@ LinuxDeviceConfiguration::Ptr LinuxDeviceConfiguration::create(const ConstPtr &o
|
||||
|
||||
LinuxDeviceConfiguration::Ptr LinuxDeviceConfiguration::create(const QString &name,
|
||||
const QString &osType, DeviceType deviceType, const PortList &freePorts,
|
||||
const SshConnectionParameters &sshParams)
|
||||
const SshConnectionParameters &sshParams, Origin origin)
|
||||
{
|
||||
return Ptr(new LinuxDeviceConfiguration(name, osType, deviceType, freePorts, sshParams));
|
||||
return Ptr(new LinuxDeviceConfiguration(name, osType, deviceType, freePorts, sshParams, origin));
|
||||
}
|
||||
|
||||
LinuxDeviceConfiguration::LinuxDeviceConfiguration(const QString &name, const QString &osType,
|
||||
DeviceType deviceType, const PortList &freePorts, const SshConnectionParameters &sshParams)
|
||||
DeviceType deviceType, const PortList &freePorts, const SshConnectionParameters &sshParams,
|
||||
Origin origin)
|
||||
: m_d(new LinuxDeviceConfigurationPrivate(sshParams))
|
||||
{
|
||||
m_d->name = name;
|
||||
@@ -118,11 +120,13 @@ LinuxDeviceConfiguration::LinuxDeviceConfiguration(const QString &name, const QS
|
||||
m_d->deviceType = deviceType;
|
||||
m_d->freePorts = freePorts;
|
||||
m_d->isDefault = false;
|
||||
m_d->origin = origin;
|
||||
}
|
||||
|
||||
LinuxDeviceConfiguration::LinuxDeviceConfiguration(const QSettings &settings, Id &nextId)
|
||||
: m_d(new LinuxDeviceConfigurationPrivate(SshConnectionParameters::NoProxy))
|
||||
{
|
||||
m_d->origin = ManuallyAdded;
|
||||
m_d->name = settings.value(NameKey).toString();
|
||||
m_d->osType = settings.value(OsTypeKey).toString();
|
||||
m_d->deviceType = static_cast<DeviceType>(settings.value(TypeKey, DefaultDeviceType).toInt());
|
||||
@@ -163,6 +167,7 @@ LinuxDeviceConfiguration::LinuxDeviceConfiguration(const LinuxDeviceConfiguratio
|
||||
m_d->deviceType = other->deviceType();
|
||||
m_d->freePorts = other->freePorts();
|
||||
m_d->isDefault = other->m_d->isDefault;
|
||||
m_d->origin = other->m_d->origin;
|
||||
m_d->internalId = other->m_d->internalId;
|
||||
}
|
||||
|
||||
@@ -219,6 +224,11 @@ void LinuxDeviceConfiguration::setFreePorts(const PortList &freePorts)
|
||||
m_d->freePorts = freePorts;
|
||||
}
|
||||
|
||||
bool LinuxDeviceConfiguration::isAutoDetected() const
|
||||
{
|
||||
return m_d->origin == AutoDetected;
|
||||
}
|
||||
|
||||
PortList LinuxDeviceConfiguration::freePorts() const { return m_d->freePorts; }
|
||||
QString LinuxDeviceConfiguration::name() const { return m_d->name; }
|
||||
QString LinuxDeviceConfiguration::osType() const { return m_d->osType; }
|
||||
|
||||
@@ -66,6 +66,7 @@ public:
|
||||
typedef quint64 Id;
|
||||
|
||||
enum DeviceType { Hardware, Emulator };
|
||||
enum Origin { ManuallyAdded, AutoDetected };
|
||||
|
||||
~LinuxDeviceConfiguration();
|
||||
|
||||
@@ -76,6 +77,7 @@ public:
|
||||
DeviceType deviceType() const;
|
||||
Id internalId() const;
|
||||
bool isDefault() const;
|
||||
bool isAutoDetected() const;
|
||||
|
||||
static QString defaultPrivateKeyFilePath();
|
||||
static QString defaultPublicKeyFilePath();
|
||||
@@ -83,11 +85,12 @@ public:
|
||||
static const Id InvalidId;
|
||||
|
||||
static Ptr create(const QString &name, const QString &osType, DeviceType deviceType,
|
||||
const PortList &freePorts, const Utils::SshConnectionParameters &sshParams);
|
||||
const PortList &freePorts, const Utils::SshConnectionParameters &sshParams,
|
||||
Origin origin = ManuallyAdded);
|
||||
private:
|
||||
LinuxDeviceConfiguration(const QString &name, const QString &osType, DeviceType deviceType,
|
||||
const PortList &freePorts, const Utils::SshConnectionParameters &sshParams);
|
||||
|
||||
const PortList &freePorts, const Utils::SshConnectionParameters &sshParams,
|
||||
Origin origin);
|
||||
LinuxDeviceConfiguration(const QSettings &settings, Id &nextId);
|
||||
LinuxDeviceConfiguration(const ConstPtr &other);
|
||||
|
||||
|
||||
@@ -110,9 +110,15 @@ void LinuxDeviceConfigurations::save()
|
||||
settings->setValue(IdCounterKey, m_nextId);
|
||||
settings->setValue(DefaultKeyFilePathKey, m_defaultSshKeyFilePath);
|
||||
settings->beginWriteArray(ConfigListKey, m_devConfigs.count());
|
||||
int skippedCount = 0;
|
||||
for (int i = 0; i < m_devConfigs.count(); ++i) {
|
||||
settings->setArrayIndex(i);
|
||||
m_devConfigs.at(i)->save(*settings);
|
||||
const LinuxDeviceConfiguration::ConstPtr &devConf = m_devConfigs.at(i);
|
||||
if (devConf->isAutoDetected()) {
|
||||
++skippedCount;
|
||||
} else {
|
||||
settings->setArrayIndex(i-skippedCount);
|
||||
devConf->save(*settings);
|
||||
}
|
||||
}
|
||||
settings->endArray();
|
||||
settings->endGroup();
|
||||
|
||||
Reference in New Issue
Block a user