Commit ba6bd103 authored by hjk's avatar hjk Committed by Christian Kandeler
Browse files

device handling: move LinuxDeviceConfiguration::MachineType to IDevice



Change-Id: I1619f8ca7751acfe3379b6486949b65c1f9b42fd
Reviewed-by: default avatarChristian Kandeler <christian.kandeler@nokia.com>
parent 047973c3
......@@ -37,7 +37,9 @@ namespace Android {
namespace Internal {
AndroidDevice::AndroidDevice():
ProjectExplorer::IDevice(Core::Id(Constants::ANDROID_DEVICE_TYPE), IDevice::AutoDetected,
ProjectExplorer::IDevice(Core::Id(Constants::ANDROID_DEVICE_TYPE),
IDevice::AutoDetected,
IDevice::Hardware,
Core::Id(Constants::ANDROID_DEVICE_ID))
{
setDisplayName(QCoreApplication::translate("ProjectExplorer::AndroidDevice", "Run on Android"));
......
......@@ -71,7 +71,9 @@ IDevice::Ptr DesktopDevice::clone() const
return Ptr(new DesktopDevice(*this));
}
DesktopDevice::DesktopDevice() : IDevice(Core::Id(Constants::DESKTOP_DEVICE_TYPE), IDevice::AutoDetected,
DesktopDevice::DesktopDevice() : IDevice(Core::Id(Constants::DESKTOP_DEVICE_TYPE),
IDevice::AutoDetected,
IDevice::Hardware,
Core::Id(Constants::DESKTOP_DEVICE_ID))
{
setDisplayName(QCoreApplication::translate("ProjectExplorer::DesktopDevice", "Run locally"));
......
......@@ -150,6 +150,7 @@ const char DisplayNameKey[] = "Name";
const char TypeKey[] = "OsType";
const char IdKey[] = "InternalId";
const char OriginKey[] = "Origin";
const char MachineTypeKey[] = "Type";
// Connection
const char HostKey[] = "Host";
......@@ -163,6 +164,7 @@ const char TimeoutKey[] = "Timeout";
typedef QSsh::SshConnectionParameters::AuthenticationType AuthType;
const AuthType DefaultAuthType = QSsh::SshConnectionParameters::AuthenticationByKey;
const IDevice::MachineType DefaultMachineType = IDevice::Hardware;
const int DefaultTimeout = 10;
......@@ -172,7 +174,8 @@ class IDevicePrivate
public:
IDevicePrivate() :
origin(IDevice::AutoDetected),
deviceState(IDevice::DeviceStateUnknown)
deviceState(IDevice::DeviceStateUnknown),
machineType(IDevice::Hardware)
{ }
QString displayName;
......@@ -180,6 +183,7 @@ public:
IDevice::Origin origin;
Core::Id id;
IDevice::DeviceState deviceState;
IDevice::MachineType machineType;
QSsh::SshConnectionParameters sshParameters;
Utils::PortList freePorts;
......@@ -189,10 +193,12 @@ public:
IDevice::IDevice() : d(new Internal::IDevicePrivate)
{ }
IDevice::IDevice(Core::Id type, Origin origin, Core::Id id) : d(new Internal::IDevicePrivate)
IDevice::IDevice(Core::Id type, Origin origin, MachineType machineType, Core::Id id)
: d(new Internal::IDevicePrivate)
{
d->type = type;
d->origin = origin;
d->machineType = machineType;
QTC_CHECK(origin == ManuallyAdded || id.isValid());
d->id = id.isValid() ? id : newId();
}
......@@ -288,6 +294,7 @@ void IDevice::fromMap(const QVariantMap &map)
d->freePorts = Utils::PortList::fromString(map.value(PortsSpecKey,
QLatin1String("10000-10100")).toString());
d->machineType = static_cast<MachineType>(map.value(MachineTypeKey, DefaultMachineType).toInt());
}
QVariantMap IDevice::toMap() const
......@@ -298,6 +305,7 @@ QVariantMap IDevice::toMap() const
map.insert(QLatin1String(IdKey), d->id.name());
map.insert(QLatin1String(OriginKey), d->origin);
map.insert(MachineTypeKey, d->machineType);
map.insert(HostKey, d->sshParameters.host);
map.insert(SshPortKey, d->sshParameters.port);
map.insert(UserNameKey, d->sshParameters.userName);
......@@ -353,6 +361,11 @@ Utils::PortList IDevice::freePorts() const
return d->freePorts;
}
IDevice::MachineType IDevice::machineType() const
{
return d->machineType;
}
QString IDevice::defaultPrivateKeyFilePath()
{
return QDesktopServices::storageLocation(QDesktopServices::HomeLocation)
......
......@@ -57,6 +57,7 @@ public:
typedef QSharedPointer<const IDevice> ConstPtr;
enum Origin { ManuallyAdded, AutoDetected };
enum MachineType { Hardware, Emulator };
virtual ~IDevice();
......@@ -108,9 +109,11 @@ public:
Utils::PortList freePorts() const;
void setFreePorts(const Utils::PortList &freePorts);
MachineType machineType() const;
protected:
IDevice();
IDevice(Core::Id type, Origin origin, Core::Id id = Core::Id());
IDevice(Core::Id type, Origin origin, MachineType machineType, Core::Id id = Core::Id());
IDevice(const IDevice &other);
Ptr sharedFromThis();
......
......@@ -51,6 +51,7 @@ namespace Qt4ProjectManager {
SymbianIDevice::SymbianIDevice() :
ProjectExplorer::IDevice(Internal::SymbianIDeviceFactory::deviceType(),
ProjectExplorer::IDevice::AutoDetected,
ProjectExplorer::IDevice::Hardware,
Core::Id("Symbian Device")),
m_port(QLatin1String(DEFAULT_CODA_TCP_PORT)),
m_communicationChannel(CommunicationCodaSerialConnection)
......
......@@ -45,9 +45,6 @@
namespace RemoteLinux {
const QLatin1String MachineTypeKey("Type");
const LinuxDeviceConfiguration::MachineType DefaultMachineType = LinuxDeviceConfiguration::Hardware;
LinuxDeviceConfiguration::Ptr LinuxDeviceConfiguration::create(const QString &name,
Core::Id type, MachineType machineType, Origin origin, Core::Id id)
{
......@@ -102,18 +99,16 @@ void LinuxDeviceConfiguration::executeAction(Core::Id actionId, QWidget *parent)
d->exec();
}
LinuxDeviceConfiguration::LinuxDeviceConfiguration(const QString &name, Core::Id type,
MachineType machineType, Origin origin, Core::Id id)
: IDevice(type, origin, id)
LinuxDeviceConfiguration::LinuxDeviceConfiguration(const QString &name, Core::Id type, MachineType machineType,
Origin origin, Core::Id id)
: IDevice(type, origin, machineType, id)
{
setDisplayName(name);
m_machineType = machineType;
}
LinuxDeviceConfiguration::LinuxDeviceConfiguration(const LinuxDeviceConfiguration &other)
: IDevice(other)
{
m_machineType = other.machineType();
}
LinuxDeviceConfiguration::Ptr LinuxDeviceConfiguration::create()
......@@ -121,27 +116,9 @@ LinuxDeviceConfiguration::Ptr LinuxDeviceConfiguration::create()
return Ptr(new LinuxDeviceConfiguration);
}
void LinuxDeviceConfiguration::fromMap(const QVariantMap &map)
{
IDevice::fromMap(map);
m_machineType = static_cast<MachineType>(map.value(MachineTypeKey, DefaultMachineType).toInt());
}
QVariantMap LinuxDeviceConfiguration::toMap() const
{
QVariantMap map = IDevice::toMap();
map.insert(MachineTypeKey, m_machineType);
return map;
}
ProjectExplorer::IDevice::Ptr LinuxDeviceConfiguration::clone() const
{
return Ptr(new LinuxDeviceConfiguration(*this));
}
LinuxDeviceConfiguration::MachineType LinuxDeviceConfiguration::machineType() const
{
return m_machineType;
}
} // namespace RemoteLinux
......@@ -51,10 +51,6 @@ public:
typedef QSharedPointer<LinuxDeviceConfiguration> Ptr;
typedef QSharedPointer<const LinuxDeviceConfiguration> ConstPtr;
enum MachineType { Hardware, Emulator };
MachineType machineType() const;
static Ptr create();
static Ptr create(const QString &name, Core::Id type, MachineType machineType,
Origin origin = ManuallyAdded, Core::Id id = Core::Id());
......@@ -64,20 +60,16 @@ public:
QList<Core::Id> actionIds() const;
QString displayNameForActionId(Core::Id actionId) const;
void executeAction(Core::Id actionId, QWidget *parent) const;
void fromMap(const QVariantMap &map);
ProjectExplorer::IDevice::Ptr clone() const;
protected:
LinuxDeviceConfiguration() {}
LinuxDeviceConfiguration(const QString &name, Core::Id type, MachineType machineType,
Origin origin, Core::Id id);
LinuxDeviceConfiguration(const QString &name, Core::Id type,
MachineType machineType, Origin origin, Core::Id id);
LinuxDeviceConfiguration(const LinuxDeviceConfiguration &other);
QVariantMap toMap() const;
private:
LinuxDeviceConfiguration &operator=(const LinuxDeviceConfiguration &);
LinuxDeviceConfiguration::MachineType m_machineType;
};
} // namespace RemoteLinux
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment