diff --git a/src/plugins/remotelinux/deviceconfigurationfactory.cpp b/src/plugins/remotelinux/deviceconfigurationfactory.cpp deleted file mode 100644 index a7fb155e29e170dc785ac9c4aed84dca2316e2e4..0000000000000000000000000000000000000000 --- a/src/plugins/remotelinux/deviceconfigurationfactory.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ -#include "deviceconfigurationfactory.h" - -#include "maemoconfigtestdialog.h" -#include "maemodeviceconfigwizard.h" -#include "maemoremoteprocessesdialog.h" - -namespace RemoteLinux { -namespace Internal { -namespace { -const char * const TestDeviceActionId = "TestDeviceAction"; -const char * const RemoteProcessesActionId = "RemoteProcessesAction"; -} // anonymous namespace; - -DeviceConfigurationFactory::DeviceConfigurationFactory(QObject *parent) - : ILinuxDeviceConfigurationFactory(parent) -{ -} - -QString DeviceConfigurationFactory::displayName() const -{ - return tr("Fremantle, Harmattan, MeeGo, GenericLinux"); -} - -ILinuxDeviceConfigurationWizard *DeviceConfigurationFactory::createWizard(QWidget *parent) const -{ - return new MaemoDeviceConfigWizard(parent); -} - -bool DeviceConfigurationFactory::supportsOsType(const QString &osType) const -{ - return osType == LinuxDeviceConfiguration::Maemo5OsType - || osType == LinuxDeviceConfiguration::HarmattanOsType - || osType == LinuxDeviceConfiguration::MeeGoOsType - || osType == LinuxDeviceConfiguration::GenericLinuxOsType; -} - -QStringList DeviceConfigurationFactory::supportedDeviceActionIds() const -{ - return QStringList() << QLatin1String(TestDeviceActionId) - << QLatin1String(RemoteProcessesActionId); -} - -QString DeviceConfigurationFactory::displayNameForId(const QString &actionId) const -{ - Q_ASSERT(supportedDeviceActionIds().contains(actionId)); - if (actionId == QLatin1String(TestDeviceActionId)) - return tr("Test"); - if (actionId == QLatin1String(RemoteProcessesActionId)) - return tr("Remote processes"); - return QString(); // Can't happen. -} - -QDialog *DeviceConfigurationFactory::createDeviceAction(const QString &actionId, - const LinuxDeviceConfiguration::ConstPtr &deviceConfig, QWidget *parent) const -{ - Q_ASSERT(supportedDeviceActionIds().contains(actionId)); - if (actionId == QLatin1String(TestDeviceActionId)) - return new MaemoConfigTestDialog(deviceConfig, parent); - if (actionId == QLatin1String(RemoteProcessesActionId)) - return new MaemoRemoteProcessesDialog(deviceConfig, parent); - return 0; // Can't happen. -} - -} // namespace Internal -} // namespace RemoteLinux diff --git a/src/plugins/remotelinux/deviceconfigurationfactory.h b/src/plugins/remotelinux/deviceconfigurationfactory.h deleted file mode 100644 index 2b41799955d5bfbbedf4282b60071735b63d7943..0000000000000000000000000000000000000000 --- a/src/plugins/remotelinux/deviceconfigurationfactory.h +++ /dev/null @@ -1,59 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (info@qt.nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at info@qt.nokia.com. -** -**************************************************************************/ -#ifndef DEVICECONFIGURATIONFACTORY_H -#define DEVICECONFIGURATIONFACTORY_H - -#include "linuxdeviceconfiguration.h" - -namespace RemoteLinux { -namespace Internal { - -class DeviceConfigurationFactory : public ILinuxDeviceConfigurationFactory -{ - Q_OBJECT - Q_DISABLE_COPY(DeviceConfigurationFactory) -public: - DeviceConfigurationFactory(QObject *parent = 0); - - QString displayName() const; - ILinuxDeviceConfigurationWizard *createWizard(QWidget *parent) const; - bool supportsOsType(const QString &osType) const; - QStringList supportedDeviceActionIds() const; - QString displayNameForId(const QString &actionId) const; - QDialog *createDeviceAction(const QString &actionId, - const LinuxDeviceConfiguration::ConstPtr &deviceConfig, QWidget *parent) const; -}; - -} // namespace Internal -} // namespace RemoteLinux - -#endif // DEVICECONFIGURATIONFACTORY_H diff --git a/src/plugins/remotelinux/genericlinuxdeviceconfigurationfactory.cpp b/src/plugins/remotelinux/genericlinuxdeviceconfigurationfactory.cpp index b0d7f94fbd6b112302760a8978f724980c6434e1..9c5de08a67b4bc325eebca4dd231dd992b008cdd 100644 --- a/src/plugins/remotelinux/genericlinuxdeviceconfigurationfactory.cpp +++ b/src/plugins/remotelinux/genericlinuxdeviceconfigurationfactory.cpp @@ -36,6 +36,8 @@ #include "maemoremoteprocessesdialog.h" #include "publickeydeploymentdialog.h" +#include <utils/qtcassert.h> + namespace RemoteLinux { namespace Internal { namespace { @@ -64,13 +66,19 @@ bool GenericLinuxDeviceConfigurationFactory::supportsOsType(const QString &osTyp return osType == LinuxDeviceConfiguration::GenericLinuxOsType; } +QString GenericLinuxDeviceConfigurationFactory::displayNameForOsType(const QString &osType) const +{ + QTC_ASSERT(supportsOsType(osType), return QString()); + return tr("Generic Linux"); +} + QStringList GenericLinuxDeviceConfigurationFactory::supportedDeviceActionIds() const { return QStringList() << QLatin1String(TestDeviceActionId) << QLatin1String(DeployKeyToDeviceActionId) << QLatin1String(RemoteProcessesActionId); } -QString GenericLinuxDeviceConfigurationFactory::displayNameForId(const QString &actionId) const +QString GenericLinuxDeviceConfigurationFactory::displayNameForActionId(const QString &actionId) const { Q_ASSERT(supportedDeviceActionIds().contains(actionId)); if (actionId == QLatin1String(TestDeviceActionId)) diff --git a/src/plugins/remotelinux/genericlinuxdeviceconfigurationfactory.h b/src/plugins/remotelinux/genericlinuxdeviceconfigurationfactory.h index f04e610cd6c4824d04c8f7c53ccee7dd791de4d0..1633977133080e5e336258f80a91c024dc4b5072 100644 --- a/src/plugins/remotelinux/genericlinuxdeviceconfigurationfactory.h +++ b/src/plugins/remotelinux/genericlinuxdeviceconfigurationfactory.h @@ -47,8 +47,9 @@ public: QString displayName() const; ILinuxDeviceConfigurationWizard *createWizard(QWidget *parent) const; bool supportsOsType(const QString &osType) const; + QString displayNameForOsType(const QString &osType) const; QStringList supportedDeviceActionIds() const; - QString displayNameForId(const QString &actionId) const; + QString displayNameForActionId(const QString &actionId) const; QDialog *createDeviceAction(const QString &actionId, const LinuxDeviceConfiguration::ConstPtr &deviceConfig, QWidget *parent) const; }; diff --git a/src/plugins/remotelinux/genericlinuxdeviceconfigurationwizard.cpp b/src/plugins/remotelinux/genericlinuxdeviceconfigurationwizard.cpp index 07b12a3ad68a722b0767d98c46e12f1f6db0666e..54b5bbb671bb2c68b5a58ede10ced5ba437a6484 100644 --- a/src/plugins/remotelinux/genericlinuxdeviceconfigurationwizard.cpp +++ b/src/plugins/remotelinux/genericlinuxdeviceconfigurationwizard.cpp @@ -71,15 +71,19 @@ GenericLinuxDeviceConfigurationWizard::~GenericLinuxDeviceConfigurationWizard() LinuxDeviceConfiguration::Ptr GenericLinuxDeviceConfigurationWizard::deviceConfiguration() { - LinuxDeviceConfiguration::Ptr devConf; - if (m_d->setupPage.authenticationType() == SshConnectionParameters::AuthenticationByPassword) { - devConf = LinuxDeviceConfiguration::createGenericLinuxConfigUsingPassword(m_d->setupPage.configurationName(), - m_d->setupPage.hostName(), m_d->setupPage.userName(), m_d->setupPage.password()); - } else { - devConf = LinuxDeviceConfiguration::createGenericLinuxConfigUsingKey(m_d->setupPage.configurationName(), - m_d->setupPage.hostName(), m_d->setupPage.userName(), m_d->setupPage.privateKeyFilePath()); - } - + Utils::SshConnectionParameters sshParams(SshConnectionParameters::NoProxy); + sshParams.host = m_d->setupPage.hostName(); + sshParams.userName = m_d->setupPage.userName(); + sshParams.port = 22; + sshParams.timeout = 10; + sshParams.authenticationType = m_d->setupPage.authenticationType(); + if (sshParams.authenticationType == SshConnectionParameters::AuthenticationByPassword) + sshParams.password = m_d->setupPage.password(); + else + sshParams.privateKeyFile = m_d->setupPage.privateKeyFilePath(); + LinuxDeviceConfiguration::Ptr devConf = LinuxDeviceConfiguration::create(m_d->setupPage.configurationName(), + LinuxDeviceConfiguration::GenericLinuxOsType, LinuxDeviceConfiguration::Physical, + QLatin1String("10000-10100"), sshParams); Internal::MaemoConfigTestDialog dlg(devConf, this); dlg.exec(); return devConf; diff --git a/src/plugins/remotelinux/linuxdeviceconfiguration.cpp b/src/plugins/remotelinux/linuxdeviceconfiguration.cpp index 633fc9dfb0010c8c12773f6063f1b5ef7af7e12b..12bf5ba6c19d18104944903f02e5c90cee3927fe 100644 --- a/src/plugins/remotelinux/linuxdeviceconfiguration.cpp +++ b/src/plugins/remotelinux/linuxdeviceconfiguration.cpp @@ -55,12 +55,8 @@ const QLatin1String TimeoutKey("Timeout"); const QLatin1String IsDefaultKey("IsDefault"); const QLatin1String InternalIdKey("InternalId"); -const int DefaultSshPortHW(22); -const int DefaultSshPortSim(6666); -const int DefaultGdbServerPortHW(10000); -const int DefaultGdbServerPortSim(13219); const AuthType DefaultAuthType(Utils::SshConnectionParameters::AuthenticationByKey); -const int DefaultTimeout(30); +const int DefaultTimeout(10); const LinuxDeviceConfiguration::DeviceType DefaultDeviceType(LinuxDeviceConfiguration::Physical); @@ -190,6 +186,13 @@ QString PortList::toString() const return stringRep; } +QString PortList::regularExpression() +{ + const QLatin1String portExpr("(\\d)+"); + const QString listElemExpr = QString::fromLatin1("%1(-%1)?").arg(portExpr); + return QString::fromLatin1("((%1)(,%1)*)?").arg(listElemExpr); +} + LinuxDeviceConfiguration::Ptr LinuxDeviceConfiguration::create(const QSettings &settings, Id &nextId) @@ -202,65 +205,19 @@ LinuxDeviceConfiguration::Ptr LinuxDeviceConfiguration::create(const ConstPtr &o return Ptr(new LinuxDeviceConfiguration(other)); } -LinuxDeviceConfiguration::Ptr LinuxDeviceConfiguration::createHardwareConfig(const QString &name, - const QString &osType, const QString &hostName, const QString &privateKeyFilePath) -{ - Utils::SshConnectionParameters sshParams(Utils::SshConnectionParameters::NoProxy); - sshParams.authenticationType = Utils::SshConnectionParameters::AuthenticationByKey; - sshParams.host = hostName; - sshParams.userName = defaultUser(osType); - sshParams.privateKeyFile = privateKeyFilePath; - return Ptr(new LinuxDeviceConfiguration(name, osType, Physical, sshParams)); -} - -LinuxDeviceConfiguration::Ptr LinuxDeviceConfiguration::createGenericLinuxConfigUsingPassword(const QString &name, - const QString &hostName, const QString &userName, const QString &password) +LinuxDeviceConfiguration::Ptr LinuxDeviceConfiguration::create(const QString &name, + const QString &osType, DeviceType deviceType, const QString &freePortsSpec, + const Utils::SshConnectionParameters &sshParams) { - Utils::SshConnectionParameters sshParams(Utils::SshConnectionParameters::NoProxy); - sshParams.authenticationType - = Utils::SshConnectionParameters::AuthenticationByPassword; - sshParams.host = hostName; - sshParams.userName = userName; - sshParams.password = password; - return Ptr(new LinuxDeviceConfiguration(name, LinuxDeviceConfiguration::GenericLinuxOsType, Physical, - sshParams)); + return Ptr(new LinuxDeviceConfiguration(name, osType, deviceType, freePortsSpec, sshParams)); } -LinuxDeviceConfiguration::Ptr LinuxDeviceConfiguration::createGenericLinuxConfigUsingKey(const QString &name, - const QString &hostName, const QString &userName, const QString &privateKeyFile) +LinuxDeviceConfiguration::LinuxDeviceConfiguration(const QString &name, const QString &osType, + DeviceType deviceType, const QString &freePortsSpec, + const Utils::SshConnectionParameters &sshParams) + : m_sshParameters(sshParams), m_name(name), m_osType(osType), m_type(deviceType), + m_portsSpec(freePortsSpec), m_isDefault(false) { - Utils::SshConnectionParameters sshParams(Utils::SshConnectionParameters::NoProxy); - sshParams.authenticationType - = Utils::SshConnectionParameters::AuthenticationByKey; - sshParams.host = hostName; - sshParams.userName = userName; - sshParams.privateKeyFile = privateKeyFile; - return Ptr(new LinuxDeviceConfiguration(name, LinuxDeviceConfiguration::GenericLinuxOsType, - Physical, sshParams)); -} - -LinuxDeviceConfiguration::Ptr LinuxDeviceConfiguration::createEmulatorConfig(const QString &name, - const QString &osType) -{ - Utils::SshConnectionParameters sshParams(Utils::SshConnectionParameters::NoProxy); - sshParams.authenticationType = Utils::SshConnectionParameters::AuthenticationByPassword; - sshParams.host = defaultHost(Emulator, osType); - sshParams.userName = defaultUser(osType); - sshParams.password = defaultQemuPassword(osType); - return Ptr(new LinuxDeviceConfiguration(name, osType, Emulator, sshParams)); -} - -LinuxDeviceConfiguration::LinuxDeviceConfiguration(const QString &name, - const QString &osType, DeviceType devType, const Utils::SshConnectionParameters &sshParams) - : m_sshParameters(sshParams), - m_name(name), - m_osType(osType), - m_type(devType), - m_portsSpec(defaultPortsSpec(m_type)), - m_isDefault(false) -{ - m_sshParameters.port = defaultSshPort(m_type); - m_sshParameters.timeout = DefaultTimeout; } LinuxDeviceConfiguration::LinuxDeviceConfiguration(const QSettings &settings, @@ -287,9 +244,9 @@ LinuxDeviceConfiguration::LinuxDeviceConfiguration(const QSettings &settings, } m_portsSpec = settings.value(PortsSpecKey, defaultPortsSpec(m_type)).toString(); - m_sshParameters.host = settings.value(HostKey, defaultHost(m_type, m_osType)).toString(); - m_sshParameters.port = settings.value(SshPortKey, defaultSshPort(m_type)).toInt(); - m_sshParameters.userName = settings.value(UserNameKey, defaultUser(m_osType)).toString(); + m_sshParameters.host = settings.value(HostKey).toString(); + m_sshParameters.port = settings.value(SshPortKey, 22).toInt(); + m_sshParameters.userName = settings.value(UserNameKey).toString(); m_sshParameters.authenticationType = static_cast<AuthType>(settings.value(AuthKey, DefaultAuthType).toInt()); m_sshParameters.password = settings.value(PasswordKey).toString(); @@ -309,30 +266,11 @@ LinuxDeviceConfiguration::LinuxDeviceConfiguration(const LinuxDeviceConfiguratio { } -QString LinuxDeviceConfiguration::portsRegExpr() -{ - const QLatin1String portExpr("(\\d)+"); - const QString listElemExpr = QString::fromLatin1("%1(-%1)?").arg(portExpr); - return QString::fromLatin1("((%1)(,%1)*)?").arg(listElemExpr); -} - -int LinuxDeviceConfiguration::defaultSshPort(DeviceType type) -{ - return type == Physical ? DefaultSshPortHW : DefaultSshPortSim; -} - QString LinuxDeviceConfiguration::defaultPortsSpec(DeviceType type) const { return QLatin1String(type == Physical ? "10000-10100" : "13219,14168"); } -QString LinuxDeviceConfiguration::defaultHost(DeviceType type, const QString &osType) -{ - if (osType == Maemo5OsType || osType == HarmattanOsType || osType == MeeGoOsType) - return QLatin1String(type == Physical ? "192.168.2.15" : "localhost"); - return QString(); -} - QString LinuxDeviceConfiguration::defaultPrivateKeyFilePath() { return QDesktopServices::storageLocation(QDesktopServices::HomeLocation) @@ -344,22 +282,6 @@ QString LinuxDeviceConfiguration::defaultPublicKeyFilePath() return defaultPrivateKeyFilePath() + QLatin1String(".pub"); } -QString LinuxDeviceConfiguration::defaultUser(const QString &osType) -{ - if (osType == Maemo5OsType || osType == HarmattanOsType) - return QLatin1String("developer"); - if (osType == MeeGoOsType) - return QLatin1String("meego"); - return QString(); -} - -QString LinuxDeviceConfiguration::defaultQemuPassword(const QString &osType) -{ - if (osType == MeeGoOsType) - return QLatin1String("meego"); - return QString(); -} - PortList LinuxDeviceConfiguration::freePorts() const { return PortsSpecParser(m_portsSpec).parse(); diff --git a/src/plugins/remotelinux/linuxdeviceconfiguration.h b/src/plugins/remotelinux/linuxdeviceconfiguration.h index 68615fec4fafb69f6e59283fc24b8728a55f2c8a..5f35947b184e6f9af94fd207acb3f6d85bd543e4 100644 --- a/src/plugins/remotelinux/linuxdeviceconfiguration.h +++ b/src/plugins/remotelinux/linuxdeviceconfiguration.h @@ -63,6 +63,8 @@ public: int getNext(); QString toString() const; + static QString regularExpression(); + private: typedef QPair<int, int> Range; QList<Range> m_ranges; @@ -90,33 +92,22 @@ public: QString name() const { return m_name; } void setName(const QString &name) { m_name = name; } QString osType() const { return m_osType; } - QString osTypeDisplayName() const { return m_osTypeDisplayName; } DeviceType type() const { return m_type; } QString portsSpec() const { return m_portsSpec; } Id internalId() const { return m_internalId; } bool isDefault() const { return m_isDefault; } - static QString portsRegExpr(); - static QString defaultHost(DeviceType type, const QString &osType); static QString defaultPrivateKeyFilePath(); static QString defaultPublicKeyFilePath(); - static QString defaultUser(const QString &osType); - static int defaultSshPort(DeviceType type); - static QString defaultQemuPassword(const QString &osType); static const Id InvalidId; - static Ptr createHardwareConfig(const QString &name, const QString &osType, - const QString &hostName, const QString &privateKeyFilePath); - static Ptr createGenericLinuxConfigUsingPassword(const QString &name, const QString &hostName, - const QString &userName, const QString &password); - static Ptr createGenericLinuxConfigUsingKey(const QString &name, const QString &hostName, - const QString &userName, const QString &privateKeyFilePath); - static Ptr createEmulatorConfig(const QString &name, const QString &osType); - + static Ptr create(const QString &name, const QString &osType, DeviceType deviceType, + const QString &freePortsSpec, const Utils::SshConnectionParameters &sshParams); private: - LinuxDeviceConfiguration(const QString &name, const QString &osType, - DeviceType type, const Utils::SshConnectionParameters &sshParams); + LinuxDeviceConfiguration(const QString &name, const QString &osType, DeviceType deviceType, + const QString &freePortsSpec, const Utils::SshConnectionParameters &sshParams); + LinuxDeviceConfiguration(const QSettings &settings, Id &nextId); LinuxDeviceConfiguration(const ConstPtr &other); @@ -135,7 +126,6 @@ private: DeviceType m_type; QString m_portsSpec; bool m_isDefault; - QString m_osTypeDisplayName; Id m_internalId; }; @@ -193,6 +183,11 @@ public: */ virtual bool supportsOsType(const QString &osType) const=0; + /*! + Returns a human-readable string for the given OS type, if this factory supports that type. + */ + virtual QString displayNameForOsType(const QString &osType) const=0; + /*! Returns a list of ids representing actions that can be run on device configurations that this factory supports. These actions will be available in the "Linux Devices" @@ -204,7 +199,7 @@ public: A human-readable string for the given id. Will be displayed on a button which, when clicked, will start the respective action. */ - virtual QString displayNameForId(const QString &actionId) const=0; + virtual QString displayNameForActionId(const QString &actionId) const=0; /*! diff --git a/src/plugins/remotelinux/maddedeviceconfigurationfactory.cpp b/src/plugins/remotelinux/maddedeviceconfigurationfactory.cpp index a160da28b844669a74926f314b7b11cdc7610ed8..01ebb4ca2077c4a2eea50db9e4325f025551ab11 100644 --- a/src/plugins/remotelinux/maddedeviceconfigurationfactory.cpp +++ b/src/plugins/remotelinux/maddedeviceconfigurationfactory.cpp @@ -33,6 +33,8 @@ #include "maemodeviceconfigwizard.h" +#include <utils/qtcassert.h> + namespace RemoteLinux { namespace Internal { @@ -58,5 +60,15 @@ bool MaddeDeviceConfigurationFactory::supportsOsType(const QString &osType) cons || osType == LinuxDeviceConfiguration::MeeGoOsType; } +QString MaddeDeviceConfigurationFactory::displayNameForOsType(const QString &osType) const +{ + QTC_ASSERT(supportsOsType(osType), return QString()); + if (osType == LinuxDeviceConfiguration::Maemo5OsType) + return tr("Maemo5/Fremantle"); + if (osType == LinuxDeviceConfiguration::HarmattanOsType) + return tr("Harmattan"); + return tr("MeeGo"); +} + } // namespace Internal } // namespace RemoteLinux diff --git a/src/plugins/remotelinux/maddedeviceconfigurationfactory.h b/src/plugins/remotelinux/maddedeviceconfigurationfactory.h index 1bc1f5b93a6b5caa4b7baa3d57a5aba717ac2f2b..59cadcebfafa2d31bf603fbd6519cfa46b732b94 100644 --- a/src/plugins/remotelinux/maddedeviceconfigurationfactory.h +++ b/src/plugins/remotelinux/maddedeviceconfigurationfactory.h @@ -46,6 +46,7 @@ public: QString displayName() const; ILinuxDeviceConfigurationWizard *createWizard(QWidget *parent) const; bool supportsOsType(const QString &osType) const; + QString displayNameForOsType(const QString &osType) const; }; } // namespace Internal diff --git a/src/plugins/remotelinux/maemodeviceconfigurationssettingswidget.cpp b/src/plugins/remotelinux/maemodeviceconfigurationssettingswidget.cpp index 05c6e5435d235215061b7e0ec247d5711bcadcad..f6a5447aab07221a85f77c03b1b818eec39bec26 100644 --- a/src/plugins/remotelinux/maemodeviceconfigurationssettingswidget.cpp +++ b/src/plugins/remotelinux/maemodeviceconfigurationssettingswidget.cpp @@ -152,7 +152,7 @@ void MaemoDeviceConfigurationsSettingsWidget::initGui() m_ui->nameLineEdit->setValidator(m_nameValidator); m_ui->keyFileLineEdit->setExpectedKind(Utils::PathChooser::File); QRegExpValidator * const portsValidator - = new QRegExpValidator(QRegExp(LinuxDeviceConfiguration::portsRegExpr()), this); + = new QRegExpValidator(QRegExp(PortList::regularExpression()), this); m_ui->portsLineEdit->setValidator(portsValidator); connect(m_ui->makeKeyFileDefaultButton, SIGNAL(clicked()), SLOT(setDefaultKeyFilePath())); @@ -375,7 +375,7 @@ void MaemoDeviceConfigurationsSettingsWidget::currentConfigChanged(int index) if (factory) { const QStringList &actionIds = factory->supportedDeviceActionIds(); foreach (const QString &actionId, actionIds) { - QPushButton * const button = new QPushButton(factory->displayNameForId(actionId)); + QPushButton * const button = new QPushButton(factory->displayNameForActionId(actionId)); m_additionalActionButtons << button; connect(button, SIGNAL(clicked()), m_additionalActionsMapper, SLOT(map())); m_additionalActionsMapper->setMapping(button, actionId); diff --git a/src/plugins/remotelinux/maemodeviceconfigwizard.cpp b/src/plugins/remotelinux/maemodeviceconfigwizard.cpp index b122f5bfb14ef96248f62d87a9e8eb40ebefa175..c49bdce8f372c7026ec8574b3b894e644f3eacb7 100644 --- a/src/plugins/remotelinux/maemodeviceconfigwizard.cpp +++ b/src/plugins/remotelinux/maemodeviceconfigwizard.cpp @@ -59,6 +59,18 @@ namespace RemoteLinux { namespace Internal { namespace { +QString defaultUser(const QString &osType) +{ + if (osType == LinuxDeviceConfiguration::MeeGoOsType) + return QLatin1String("meego"); + return QLatin1String("developer"); +} + +QString defaultHost(LinuxDeviceConfiguration::DeviceType type) +{ + return QLatin1String(type == LinuxDeviceConfiguration::Physical ? "192.168.2.15" : "localhost"); +} + struct WizardData { QString configName; @@ -108,8 +120,7 @@ public: m_ui->harmattanButton->setChecked(true); m_ui->hwButton->setChecked(true); handleDeviceTypeChanged(); - m_ui->hostNameLineEdit->setText(LinuxDeviceConfiguration::defaultHost(deviceType(), - osType())); + m_ui->hostNameLineEdit->setText(defaultHost(deviceType())); connect(m_ui->nameLineEdit, SIGNAL(textChanged(QString)), this, SIGNAL(completeChanged())); connect(m_ui->hostNameLineEdit, SIGNAL(textChanged(QString)), this, @@ -126,7 +137,7 @@ public: QString hostName() const { return deviceType() == LinuxDeviceConfiguration::Emulator - ? LinuxDeviceConfiguration::defaultHost(LinuxDeviceConfiguration::Emulator, osType()) + ? defaultHost(LinuxDeviceConfiguration::Emulator) : m_ui->hostNameLineEdit->text().trimmed(); } @@ -186,7 +197,7 @@ public: virtual void initializePage() { - m_ui->userNameLineEdit->setText(LinuxDeviceConfiguration::defaultUser(m_wizardData.osType)); + m_ui->userNameLineEdit->setText(defaultUser(m_wizardData.osType)); m_ui->passwordButton->setChecked(true); m_ui->passwordLineEdit->clear(); m_ui->privateKeyPathChooser->setPath(LinuxDeviceConfiguration::defaultPrivateKeyFilePath()); @@ -488,10 +499,10 @@ private: SshConnectionParameters sshParams(SshConnectionParameters::NoProxy); sshParams.authenticationType = SshConnectionParameters::AuthenticationByPassword; sshParams.host = hostAddress(); - sshParams.port = LinuxDeviceConfiguration::defaultSshPort(LinuxDeviceConfiguration::Physical); + sshParams.port = 22; sshParams.password = password(); sshParams.timeout = 30; - sshParams.userName = LinuxDeviceConfiguration::defaultUser(m_wizardData.osType); + sshParams.userName = defaultUser(m_wizardData.osType); m_ui->statusLabel->setText(tr("Deploying... ")); m_keyDeployer->deployPublicKey(sshParams, m_wizardData.publicKeyFilePath); } @@ -597,16 +608,33 @@ MaemoDeviceConfigWizard::~MaemoDeviceConfigWizard() {} LinuxDeviceConfiguration::Ptr MaemoDeviceConfigWizard::deviceConfiguration() { + bool doTest; + QString freePortsSpec; + Utils::SshConnectionParameters sshParams(Utils::SshConnectionParameters::NoProxy); + sshParams.userName = defaultUser(d->wizardData.osType); + sshParams.host = d->wizardData.hostName; if (d->wizardData.deviceType == LinuxDeviceConfiguration::Emulator) { - return LinuxDeviceConfiguration::createEmulatorConfig(d->wizardData.configName, - d->wizardData.osType); + sshParams.authenticationType = Utils::SshConnectionParameters::AuthenticationByPassword; + sshParams.password = d->wizardData.osType == LinuxDeviceConfiguration::MeeGoOsType + ? QLatin1String("meego") : QString(); + sshParams.port = 6666; + sshParams.timeout = 30; + freePortsSpec = QLatin1String("13219,14168"); + doTest = false; + } else { + sshParams.authenticationType = Utils::SshConnectionParameters::AuthenticationByKey; + sshParams.privateKeyFile = d->wizardData.privateKeyFilePath; + sshParams.port = 22; + sshParams.timeout = 10; + freePortsSpec = QLatin1String("10000-10100"); + doTest = true; + } + const LinuxDeviceConfiguration::Ptr devConf = LinuxDeviceConfiguration::create(d->wizardData.configName, + d->wizardData.osType, LinuxDeviceConfiguration::Physical, freePortsSpec, sshParams); + if (doTest) { + MaemoConfigTestDialog dlg(devConf, this); + dlg.exec(); } - - const LinuxDeviceConfiguration::Ptr devConf - = LinuxDeviceConfiguration::createHardwareConfig(d->wizardData.configName, - d->wizardData.osType, d->wizardData.hostName, d->wizardData.privateKeyFilePath); - MaemoConfigTestDialog dlg(devConf, this); - dlg.exec(); return devConf; } diff --git a/src/plugins/remotelinux/maemoglobal.cpp b/src/plugins/remotelinux/maemoglobal.cpp index 32200e6204643727629dfe84c4b8941f6efb70b7..6d22c179ee35fcbfaacd866d5e5b4f37e6bd405d 100644 --- a/src/plugins/remotelinux/maemoglobal.cpp +++ b/src/plugins/remotelinux/maemoglobal.cpp @@ -37,6 +37,7 @@ #include <projectexplorer/projectexplorerconstants.h> #include <coreplugin/filemanager.h> +#include <extensionsystem/pluginmanager.h> #include <utils/ssh/sshconnection.h> #include <qt4projectmanager/qt4projectmanagerconstants.h> #include <qtsupport/qtversionmanager.h> @@ -441,13 +442,13 @@ QStringList MaemoGlobal::targetArgs(const QString &qmakePath, bool useTarget) QString MaemoGlobal::osTypeToString(const QString &osType) { - if (osType == LinuxDeviceConfiguration::Maemo5OsType) - return QLatin1String("Maemo5/Fremantle"); - if (osType == LinuxDeviceConfiguration::HarmattanOsType) - return QLatin1String("Harmattan"); - if (osType == LinuxDeviceConfiguration::MeeGoOsType) - return QLatin1String("MeeGo"); - return QLatin1String("Other Linux"); + const QList<ILinuxDeviceConfigurationFactory *> &factories + = ExtensionSystem::PluginManager::instance()->getObjects<ILinuxDeviceConfigurationFactory>(); + foreach (const ILinuxDeviceConfigurationFactory * const factory, factories) { + if (factory->supportsOsType(osType)) + return factory->displayNameForOsType(osType); + } + return tr("Unknown OS"); } MaemoGlobal::PackagingSystem MaemoGlobal::packagingSystem(const QString &osType)