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