RemoteLinux: Make device configurations settings page generic.

The list of per-device actions now comes from a factory and can
be different for different OS types.
This is a step towards moving knowledge about devices from the
RemoteLinux plugin into specialized plugins.

Change-Id: Ia46e0199d8d8c1a3891c73a4936ac53fb1063313
Reviewed-on: http://codereview.qt.nokia.com/439
Reviewed-by: Tobias Hunger <tobias.hunger@nokia.com>
This commit is contained in:
Christian Kandeler
2011-06-09 17:17:01 +02:00
parent 2b31dbadcf
commit 140eaaab0b
17 changed files with 619 additions and 207 deletions

View File

@@ -0,0 +1,96 @@
/**************************************************************************
**
** 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

View File

@@ -0,0 +1,59 @@
/**************************************************************************
**
** 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

View File

@@ -203,20 +203,18 @@ LinuxDeviceConfiguration::Ptr LinuxDeviceConfiguration::create(const ConstPtr &o
} }
LinuxDeviceConfiguration::Ptr LinuxDeviceConfiguration::createHardwareConfig(const QString &name, LinuxDeviceConfiguration::Ptr LinuxDeviceConfiguration::createHardwareConfig(const QString &name,
const QString &osType, const QString &hostName, const QString &osType, const QString &hostName, const QString &privateKeyFilePath)
const QString &privateKeyFilePath, Id &nextId)
{ {
Utils::SshConnectionParameters sshParams(Utils::SshConnectionParameters::NoProxy); Utils::SshConnectionParameters sshParams(Utils::SshConnectionParameters::NoProxy);
sshParams.authenticationType = Utils::SshConnectionParameters::AuthenticationByKey; sshParams.authenticationType = Utils::SshConnectionParameters::AuthenticationByKey;
sshParams.host = hostName; sshParams.host = hostName;
sshParams.userName = defaultUser(osType); sshParams.userName = defaultUser(osType);
sshParams.privateKeyFile = privateKeyFilePath; sshParams.privateKeyFile = privateKeyFilePath;
return Ptr(new LinuxDeviceConfiguration(name, osType, Physical, sshParams, nextId)); return Ptr(new LinuxDeviceConfiguration(name, osType, Physical, sshParams));
} }
LinuxDeviceConfiguration::Ptr LinuxDeviceConfiguration::createGenericLinuxConfigUsingPassword(const QString &name, LinuxDeviceConfiguration::Ptr LinuxDeviceConfiguration::createGenericLinuxConfigUsingPassword(const QString &name,
const QString &hostName, const QString &userName, const QString &password, const QString &hostName, const QString &userName, const QString &password)
Id &nextId)
{ {
Utils::SshConnectionParameters sshParams(Utils::SshConnectionParameters::NoProxy); Utils::SshConnectionParameters sshParams(Utils::SshConnectionParameters::NoProxy);
sshParams.authenticationType sshParams.authenticationType
@@ -225,12 +223,11 @@ LinuxDeviceConfiguration::Ptr LinuxDeviceConfiguration::createGenericLinuxConfig
sshParams.userName = userName; sshParams.userName = userName;
sshParams.password = password; sshParams.password = password;
return Ptr(new LinuxDeviceConfiguration(name, LinuxDeviceConfiguration::GenericLinuxOsType, Physical, return Ptr(new LinuxDeviceConfiguration(name, LinuxDeviceConfiguration::GenericLinuxOsType, Physical,
sshParams, nextId)); sshParams));
} }
LinuxDeviceConfiguration::Ptr LinuxDeviceConfiguration::createGenericLinuxConfigUsingKey(const QString &name, LinuxDeviceConfiguration::Ptr LinuxDeviceConfiguration::createGenericLinuxConfigUsingKey(const QString &name,
const QString &hostName, const QString &userName, const QString &privateKeyFile, const QString &hostName, const QString &userName, const QString &privateKeyFile)
Id &nextId)
{ {
Utils::SshConnectionParameters sshParams(Utils::SshConnectionParameters::NoProxy); Utils::SshConnectionParameters sshParams(Utils::SshConnectionParameters::NoProxy);
sshParams.authenticationType sshParams.authenticationType
@@ -238,31 +235,29 @@ LinuxDeviceConfiguration::Ptr LinuxDeviceConfiguration::createGenericLinuxConfig
sshParams.host = hostName; sshParams.host = hostName;
sshParams.userName = userName; sshParams.userName = userName;
sshParams.privateKeyFile = privateKeyFile; sshParams.privateKeyFile = privateKeyFile;
return Ptr(new LinuxDeviceConfiguration(name, LinuxDeviceConfiguration::GenericLinuxOsType, Physical, return Ptr(new LinuxDeviceConfiguration(name, LinuxDeviceConfiguration::GenericLinuxOsType,
sshParams, nextId)); Physical, sshParams));
} }
LinuxDeviceConfiguration::Ptr LinuxDeviceConfiguration::createEmulatorConfig(const QString &name, LinuxDeviceConfiguration::Ptr LinuxDeviceConfiguration::createEmulatorConfig(const QString &name,
const QString &osType, Id &nextId) const QString &osType)
{ {
Utils::SshConnectionParameters sshParams(Utils::SshConnectionParameters::NoProxy); Utils::SshConnectionParameters sshParams(Utils::SshConnectionParameters::NoProxy);
sshParams.authenticationType = Utils::SshConnectionParameters::AuthenticationByPassword; sshParams.authenticationType = Utils::SshConnectionParameters::AuthenticationByPassword;
sshParams.host = defaultHost(Emulator, osType); sshParams.host = defaultHost(Emulator, osType);
sshParams.userName = defaultUser(osType); sshParams.userName = defaultUser(osType);
sshParams.password = defaultQemuPassword(osType); sshParams.password = defaultQemuPassword(osType);
return Ptr(new LinuxDeviceConfiguration(name, osType, Emulator, sshParams, nextId)); return Ptr(new LinuxDeviceConfiguration(name, osType, Emulator, sshParams));
} }
LinuxDeviceConfiguration::LinuxDeviceConfiguration(const QString &name, LinuxDeviceConfiguration::LinuxDeviceConfiguration(const QString &name,
const QString &osType, DeviceType devType, const QString &osType, DeviceType devType, const Utils::SshConnectionParameters &sshParams)
const Utils::SshConnectionParameters &sshParams, Id &nextId)
: m_sshParameters(sshParams), : m_sshParameters(sshParams),
m_name(name), m_name(name),
m_osType(osType), m_osType(osType),
m_type(devType), m_type(devType),
m_portsSpec(defaultPortsSpec(m_type)), m_portsSpec(defaultPortsSpec(m_type)),
m_isDefault(false), m_isDefault(false)
m_internalId(nextId++)
{ {
m_sshParameters.port = defaultSshPort(m_type); m_sshParameters.port = defaultSshPort(m_type);
m_sshParameters.timeout = DefaultTimeout; m_sshParameters.timeout = DefaultTimeout;

View File

@@ -39,8 +39,11 @@
#include <QtCore/QPair> #include <QtCore/QPair>
#include <QtCore/QSharedPointer> #include <QtCore/QSharedPointer>
#include <QtCore/QString> #include <QtCore/QString>
#include <QtCore/QStringList>
#include <QtGui/QWizard>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QDialog;
class QSettings; class QSettings;
QT_END_NAMESPACE QT_END_NAMESPACE
@@ -70,7 +73,9 @@ class REMOTELINUX_EXPORT LinuxDeviceConfiguration
{ {
friend class Internal::LinuxDeviceConfigurations; friend class Internal::LinuxDeviceConfigurations;
public: public:
typedef QSharedPointer<LinuxDeviceConfiguration> Ptr;
typedef QSharedPointer<const LinuxDeviceConfiguration> ConstPtr; typedef QSharedPointer<const LinuxDeviceConfiguration> ConstPtr;
typedef quint64 Id; typedef quint64 Id;
static const QString Maemo5OsType; static const QString Maemo5OsType;
@@ -83,11 +88,14 @@ public:
PortList freePorts() const; PortList freePorts() const;
Utils::SshConnectionParameters sshParameters() const { return m_sshParameters; } Utils::SshConnectionParameters sshParameters() const { return m_sshParameters; }
QString name() const { return m_name; } QString name() const { return m_name; }
void setName(const QString &name) { m_name = name; }
QString osType() const { return m_osType; } QString osType() const { return m_osType; }
DeviceType type() const { return m_type; } DeviceType type() const { return m_type; }
QString portsSpec() const { return m_portsSpec; } QString portsSpec() const { return m_portsSpec; }
Id internalId() const { return m_internalId; } Id internalId() const { return m_internalId; }
bool isDefault() const { return m_isDefault; } bool isDefault() const { return m_isDefault; }
QString displayName() const { return m_displayName; }
static QString portsRegExpr(); static QString portsRegExpr();
static QString defaultHost(DeviceType type, const QString &osType); static QString defaultHost(DeviceType type, const QString &osType);
static QString defaultPrivateKeyFilePath(); static QString defaultPrivateKeyFilePath();
@@ -98,28 +106,23 @@ public:
static const Id InvalidId; static const Id InvalidId;
private: static Ptr createHardwareConfig(const QString &name, const QString &osType,
typedef QSharedPointer<LinuxDeviceConfiguration> Ptr; 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);
private:
LinuxDeviceConfiguration(const QString &name, const QString &osType, LinuxDeviceConfiguration(const QString &name, const QString &osType,
DeviceType type, const Utils::SshConnectionParameters &sshParams, DeviceType type, const Utils::SshConnectionParameters &sshParams);
Id &nextId);
LinuxDeviceConfiguration(const QSettings &settings, Id &nextId); LinuxDeviceConfiguration(const QSettings &settings, Id &nextId);
LinuxDeviceConfiguration(const ConstPtr &other); LinuxDeviceConfiguration(const ConstPtr &other);
LinuxDeviceConfiguration(const LinuxDeviceConfiguration &); LinuxDeviceConfiguration(const LinuxDeviceConfiguration &);
LinuxDeviceConfiguration &operator=(const LinuxDeviceConfiguration &); LinuxDeviceConfiguration &operator=(const LinuxDeviceConfiguration &);
static Ptr createHardwareConfig(const QString &name, const QString &osType,
const QString &hostName, const QString &privateKeyFilePath, Id &nextId);
static Ptr createGenericLinuxConfigUsingPassword(const QString &name,
const QString &hostName, const QString &userName,
const QString &password, Id &nextId);
static Ptr createGenericLinuxConfigUsingKey(const QString &name,
const QString &hostName, const QString &userName,
const QString &privateKeyFilePath, Id &nextId);
static Ptr createEmulatorConfig(const QString &name, const QString &osType,
Id &nextId);
static Ptr create(const QSettings &settings, Id &nextId); static Ptr create(const QSettings &settings, Id &nextId);
static Ptr create(const ConstPtr &other); static Ptr create(const ConstPtr &other);
@@ -132,10 +135,90 @@ private:
DeviceType m_type; DeviceType m_type;
QString m_portsSpec; QString m_portsSpec;
bool m_isDefault; bool m_isDefault;
QString m_displayName;
Id m_internalId; Id m_internalId;
}; };
/*!
\class RemoteLinux::ILinuxDeviceConfigurationWizard
\brief Provides an interface for wizards creating a LinuxDeviceConfiguration
A class implementing this interface is a wizard whose final result is
a LinuxDeviceConfiguration object. The wizard will be started when the user chooses the
"Add..." action from the "Linux devices" options page.
*/
class REMOTELINUX_EXPORT ILinuxDeviceConfigurationWizard : public QWizard
{
Q_OBJECT
Q_DISABLE_COPY(ILinuxDeviceConfigurationWizard)
public:
virtual LinuxDeviceConfiguration::Ptr deviceConfiguration()=0;
protected:
ILinuxDeviceConfigurationWizard(QWidget *parent) : QWizard(parent) {}
};
/*!
\class ProjectExplorer::ILinuxDeviceConfiguration factory.
\brief Provides an interface for classes providing services related to certain type of Linux devices.
The main service is a wizard providing the device configuration itself.
The factory objects have to be added to the global object pool via
\c ExtensionSystem::PluginManager::addObject().
\sa ExtensionSystem::PluginManager::addObject()
*/
class REMOTELINUX_EXPORT ILinuxDeviceConfigurationFactory : public QObject
{
Q_OBJECT
Q_DISABLE_COPY(ILinuxDeviceConfigurationFactory)
public:
/*!
A short, one-line description of what kind of device this factory supports.
*/
virtual QString displayName() const=0;
/*!
A wizard that can create the types of device configuration this factory supports.
*/
virtual ILinuxDeviceConfigurationWizard *createWizard(QWidget *parent = 0) const=0;
/*!
Returns true iff this factory supports the given device type.
*/
virtual bool supportsOsType(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"
options page.
*/
virtual QStringList supportedDeviceActionIds() const=0;
/*!
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;
/*!
Produces a dialog implementing the respective action. The dialog is supposed to be
modal, so implementers must make sure to make it interruptible as to not needlessly
block the UI.
*/
virtual QDialog *createDeviceAction(const QString &actionId,
const LinuxDeviceConfiguration::ConstPtr &deviceConfig, QWidget *parent = 0) const=0;
protected:
ILinuxDeviceConfigurationFactory(QObject *parent) : QObject(parent) {}
};
} // namespace RemoteLinux } // namespace RemoteLinux
#endif // LINUXDEVICECONFIGURATION_H #endif // LINUXDEVICECONFIGURATION_H

View File

@@ -118,41 +118,9 @@ void LinuxDeviceConfigurations::save()
settings->endGroup(); settings->endGroup();
} }
void LinuxDeviceConfigurations::addHardwareDeviceConfiguration(const QString &name,
const QString &osType, const QString &hostName, const QString &privateKeyFilePath)
{
const LinuxDeviceConfiguration::Ptr &devConf = LinuxDeviceConfiguration::createHardwareConfig(name,
osType, hostName, privateKeyFilePath, m_nextId);
addConfiguration(devConf);
}
void LinuxDeviceConfigurations::addGenericLinuxConfigurationUsingPassword(const QString &name,
const QString &hostName, const QString &userName, const QString &password)
{
const LinuxDeviceConfiguration::Ptr &devConf
= LinuxDeviceConfiguration::createGenericLinuxConfigUsingPassword(name,
hostName, userName, password, m_nextId);
addConfiguration(devConf);
}
void LinuxDeviceConfigurations::addGenericLinuxConfigurationUsingKey(const QString &name,
const QString &hostName, const QString &userName, const QString &privateKeyFilePath)
{
const LinuxDeviceConfiguration::Ptr &devConf = LinuxDeviceConfiguration::createGenericLinuxConfigUsingKey(name,
hostName, userName, privateKeyFilePath, m_nextId);
addConfiguration(devConf);
}
void LinuxDeviceConfigurations::addEmulatorDeviceConfiguration(const QString &name,
const QString &osType)
{
const LinuxDeviceConfiguration::Ptr &devConf
= LinuxDeviceConfiguration::createEmulatorConfig(name, osType, m_nextId);
addConfiguration(devConf);
}
void LinuxDeviceConfigurations::addConfiguration(const LinuxDeviceConfiguration::Ptr &devConfig) void LinuxDeviceConfigurations::addConfiguration(const LinuxDeviceConfiguration::Ptr &devConfig)
{ {
devConfig->m_internalId = m_nextId++;
beginInsertRows(QModelIndex(), rowCount(), rowCount()); beginInsertRows(QModelIndex(), rowCount(), rowCount());
if (!defaultDeviceConfig(devConfig->osType())) if (!defaultDeviceConfig(devConfig->osType()))
devConfig->m_isDefault = true; devConfig->m_isDefault = true;

View File

@@ -48,6 +48,7 @@ class LinuxDeviceConfigurations : public QAbstractListModel
{ {
Q_OBJECT Q_OBJECT
Q_DISABLE_COPY(LinuxDeviceConfigurations) Q_DISABLE_COPY(LinuxDeviceConfigurations)
friend class MaemoDeviceConfigurationsSettingsWidget;
public: public:
static LinuxDeviceConfigurations *instance(QObject *parent = 0); static LinuxDeviceConfigurations *instance(QObject *parent = 0);
@@ -64,15 +65,6 @@ public:
void setDefaultSshKeyFilePath(const QString &path) { m_defaultSshKeyFilePath = path; } void setDefaultSshKeyFilePath(const QString &path) { m_defaultSshKeyFilePath = path; }
QString defaultSshKeyFilePath() const { return m_defaultSshKeyFilePath; } QString defaultSshKeyFilePath() const { return m_defaultSshKeyFilePath; }
void addHardwareDeviceConfiguration(const QString &name, const QString &osType,
const QString &hostName, const QString &privateKeyFilePath);
void addGenericLinuxConfigurationUsingPassword(const QString &name,
const QString &hostName, const QString &userName,
const QString &password);
void addGenericLinuxConfigurationUsingKey(const QString &name,
const QString &hostName, const QString &userName,
const QString &privateKeyFilePath);
void addEmulatorDeviceConfiguration(const QString &name, const QString &osType);
void removeConfiguration(int index); void removeConfiguration(int index);
void setConfigurationName(int i, const QString &name); void setConfigurationName(int i, const QString &name);
void setSshParameters(int i, const Utils::SshConnectionParameters &params); void setSshParameters(int i, const Utils::SshConnectionParameters &params);

View File

@@ -0,0 +1,79 @@
/**************************************************************************
**
** 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 "linuxdevicefactoryselectiondialog.h"
#include "ui_linuxdevicefactoryselectiondialog.h"
#include "linuxdeviceconfiguration.h"
#include <extensionsystem/pluginmanager.h>
#include <utils/qtcassert.h>
#include <QtGui/QPushButton>
namespace RemoteLinux {
namespace Internal {
LinuxDeviceFactorySelectionDialog::LinuxDeviceFactorySelectionDialog(QWidget *parent) :
QDialog(parent), ui(new Ui::LinuxDeviceFactorySelectionDialog)
{
ui->setupUi(this);
ui->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Start Wizard"));
const QList<ILinuxDeviceConfigurationFactory *> &factories
= ExtensionSystem::PluginManager::instance()->getObjects<ILinuxDeviceConfigurationFactory>();
foreach (const ILinuxDeviceConfigurationFactory * const factory, factories) {
m_factories << factory;
ui->listWidget->addItem(factory->displayName());
}
connect(ui->listWidget, SIGNAL(itemSelectionChanged()), SLOT(handleItemSelectionChanged()));
handleItemSelectionChanged();
}
LinuxDeviceFactorySelectionDialog::~LinuxDeviceFactorySelectionDialog()
{
delete ui;
}
void LinuxDeviceFactorySelectionDialog::handleItemSelectionChanged()
{
ui->buttonBox->button(QDialogButtonBox::Ok)
->setEnabled(!ui->listWidget->selectedItems().isEmpty());
}
const ILinuxDeviceConfigurationFactory *LinuxDeviceFactorySelectionDialog::selectedFactory() const
{
return m_factories.at(ui->listWidget->row(ui->listWidget->selectedItems().first()));
}
} // namespace Internal
} // namespace RemoteLinux

View File

@@ -0,0 +1,68 @@
/**************************************************************************
**
** 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 LINUXDEVICEFACTORYSELECTIONDIALOG_H
#define LINUXDEVICEFACTORYSELECTIONDIALOG_H
#include <QtCore/QList>
#include <QtGui/QDialog>
QT_BEGIN_NAMESPACE
namespace Ui {
class LinuxDeviceFactorySelectionDialog;
} // namespace Ui
QT_END_NAMESPACE
namespace RemoteLinux {
class ILinuxDeviceConfigurationFactory;
namespace Internal {
class LinuxDeviceFactorySelectionDialog : public QDialog
{
Q_OBJECT
public:
explicit LinuxDeviceFactorySelectionDialog(QWidget *parent = 0);
~LinuxDeviceFactorySelectionDialog();
const ILinuxDeviceConfigurationFactory *selectedFactory() const;
private:
Q_SLOT void handleItemSelectionChanged();
Ui::LinuxDeviceFactorySelectionDialog *ui;
QList<const ILinuxDeviceConfigurationFactory *> m_factories;
};
} // namespace Internal
} // namespace RemoteLinux
#endif // LINUXDEVICEFACTORYSELECTIONDIALOG_H

View File

@@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>LinuxDeviceFactorySelectionDialog</class>
<widget class="QDialog" name="LinuxDeviceFactorySelectionDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>276</width>
<height>324</height>
</rect>
</property>
<property name="windowTitle">
<string>Publishing Wizard Selection</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Available wizards:</string>
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="listWidget"/>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>LinuxDeviceFactorySelectionDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>LinuxDeviceFactorySelectionDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@@ -53,8 +53,6 @@ MaemoConfigTestDialog::MaemoConfigTestDialog(const LinuxDeviceConfiguration::Con
, m_config(config) , m_config(config)
, m_portsGatherer(new MaemoUsedPortsGatherer(this)) , m_portsGatherer(new MaemoUsedPortsGatherer(this))
{ {
setAttribute(Qt::WA_DeleteOnClose);
m_ui->setupUi(this); m_ui->setupUi(this);
m_closeButton = m_ui->buttonBox->button(QDialogButtonBox::Close); m_closeButton = m_ui->buttonBox->button(QDialogButtonBox::Close);

View File

@@ -34,19 +34,19 @@
#include "ui_maemodeviceconfigurationssettingswidget.h" #include "ui_maemodeviceconfigurationssettingswidget.h"
#include "linuxdeviceconfigurations.h" #include "linuxdeviceconfigurations.h"
#include "maemoconfigtestdialog.h" #include "linuxdevicefactoryselectiondialog.h"
#include "maemodeviceconfigwizard.h"
#include "maemoglobal.h" #include "maemoglobal.h"
#include "maemokeydeployer.h" #include "maemokeydeployer.h"
#include "maemoremoteprocessesdialog.h"
#include "maemosshconfigdialog.h" #include "maemosshconfigdialog.h"
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <extensionsystem/pluginmanager.h>
#include <utils/ssh/sshremoteprocessrunner.h> #include <utils/ssh/sshremoteprocessrunner.h>
#include <QtCore/QFileInfo> #include <QtCore/QFileInfo>
#include <QtCore/QRegExp> #include <QtCore/QRegExp>
#include <QtCore/QSettings> #include <QtCore/QSettings>
#include <QtCore/QSignalMapper>
#include <QtCore/QTextStream> #include <QtCore/QTextStream>
#include <QtGui/QFileDialog> #include <QtGui/QFileDialog>
@@ -103,13 +103,16 @@ MaemoDeviceConfigurationsSettingsWidget::MaemoDeviceConfigurationsSettingsWidget
m_devConfigs(LinuxDeviceConfigurations::cloneInstance()), m_devConfigs(LinuxDeviceConfigurations::cloneInstance()),
m_nameValidator(new NameValidator(m_devConfigs.data(), this)), m_nameValidator(new NameValidator(m_devConfigs.data(), this)),
m_keyDeployer(new MaemoKeyDeployer(this)), m_keyDeployer(new MaemoKeyDeployer(this)),
m_saveSettingsRequested(false) m_saveSettingsRequested(false),
m_additionalActionsMapper(new QSignalMapper(this))
{ {
initGui(); initGui();
connect(m_keyDeployer, SIGNAL(error(QString)), this, connect(m_keyDeployer, SIGNAL(error(QString)), this,
SLOT(handleDeploymentError(QString)), Qt::QueuedConnection); SLOT(handleDeploymentError(QString)), Qt::QueuedConnection);
connect(m_keyDeployer, SIGNAL(finishedSuccessfully()), connect(m_keyDeployer, SIGNAL(finishedSuccessfully()),
SLOT(handleDeploymentSuccess())); SLOT(handleDeploymentSuccess()));
connect(m_additionalActionsMapper, SIGNAL(mapped(QString)),
SLOT(handleAdditionalActionRequest(QString)));
} }
MaemoDeviceConfigurationsSettingsWidget::~MaemoDeviceConfigurationsSettingsWidget() MaemoDeviceConfigurationsSettingsWidget::~MaemoDeviceConfigurationsSettingsWidget()
@@ -174,14 +177,44 @@ void MaemoDeviceConfigurationsSettingsWidget::initGui()
void MaemoDeviceConfigurationsSettingsWidget::addConfig() void MaemoDeviceConfigurationsSettingsWidget::addConfig()
{ {
MaemoDeviceConfigWizard wizard(m_devConfigs.data(), this); const QList<ILinuxDeviceConfigurationFactory *> &factories
if (wizard.exec() == QDialog::Accepted) { = ExtensionSystem::PluginManager::instance()->getObjects<ILinuxDeviceConfigurationFactory>();
wizard.createDeviceConfig();
m_ui->removeConfigButton->setEnabled(true); if (factories.isEmpty()) // Can't happen, because this plugin provides the generic one.
m_ui->configurationComboBox->setCurrentIndex(m_ui->configurationComboBox->count()-1); return;
if (currentConfig()->type() != LinuxDeviceConfiguration::Emulator)
testConfig(); const ILinuxDeviceConfigurationFactory *factory;
if (factories.count() == 1) {
// Don't show dialog when there's nothing to choose from.
// TODO: This is transitional. Remove it once the MADDE plugin exists.
factory = factories.first();
} else {
LinuxDeviceFactorySelectionDialog d;
if (d.exec() != QDialog::Accepted)
return;
factory = d.selectedFactory();
} }
ILinuxDeviceConfigurationWizard *wizard = factory->createWizard();
if (wizard->exec() != QDialog::Accepted)
return;
LinuxDeviceConfiguration::Ptr devConf = wizard->deviceConfiguration();
QString name = devConf->name();
if (m_devConfigs->hasConfig(name)) {
const QString nameTemplate = name + QLatin1String(" (%1)");
int suffix = 2;
do
name = nameTemplate.arg(QString::number(suffix++));
while (m_devConfigs->hasConfig(name));
}
devConf->setName(name);
m_devConfigs->addConfiguration(devConf);
m_ui->removeConfigButton->setEnabled(true);
m_ui->configurationComboBox->setCurrentIndex(m_ui->configurationComboBox->count()-1);
delete wizard;
} }
void MaemoDeviceConfigurationsSettingsWidget::deleteConfig() void MaemoDeviceConfigurationsSettingsWidget::deleteConfig()
@@ -329,24 +362,12 @@ void MaemoDeviceConfigurationsSettingsWidget::showPassword(bool showClearText)
? QLineEdit::Normal : QLineEdit::Password); ? QLineEdit::Normal : QLineEdit::Password);
} }
void MaemoDeviceConfigurationsSettingsWidget::testConfig()
{
QDialog *dialog = new MaemoConfigTestDialog(currentConfig(), this);
dialog->open();
}
void MaemoDeviceConfigurationsSettingsWidget::showGenerateSshKeyDialog() void MaemoDeviceConfigurationsSettingsWidget::showGenerateSshKeyDialog()
{ {
MaemoSshConfigDialog dialog(this); MaemoSshConfigDialog dialog(this);
dialog.exec(); dialog.exec();
} }
void MaemoDeviceConfigurationsSettingsWidget::showRemoteProcesses()
{
MaemoRemoteProcessesDialog dlg(currentConfig(), this);
dlg.exec();
}
void MaemoDeviceConfigurationsSettingsWidget::setDefaultKeyFilePath() void MaemoDeviceConfigurationsSettingsWidget::setDefaultKeyFilePath()
{ {
m_devConfigs->setDefaultSshKeyFilePath(m_ui->keyFileLineEdit->path()); m_devConfigs->setDefaultSshKeyFilePath(m_ui->keyFileLineEdit->path());
@@ -405,21 +426,30 @@ void MaemoDeviceConfigurationsSettingsWidget::finishDeployment()
void MaemoDeviceConfigurationsSettingsWidget::currentConfigChanged(int index) void MaemoDeviceConfigurationsSettingsWidget::currentConfigChanged(int index)
{ {
finishDeployment(); finishDeployment();
qDeleteAll(m_additionalActionButtons);
m_additionalActionButtons.clear();
if (index == -1) { if (index == -1) {
m_ui->removeConfigButton->setEnabled(false); m_ui->removeConfigButton->setEnabled(false);
m_ui->testConfigButton->setEnabled(false);
m_ui->generateKeyButton->setEnabled(false); m_ui->generateKeyButton->setEnabled(false);
m_ui->deployKeyButton->setEnabled(false); m_ui->deployKeyButton->setEnabled(false);
m_ui->remoteProcessesButton->setEnabled(false);
clearDetails(); clearDetails();
m_ui->detailsWidget->setEnabled(false); m_ui->detailsWidget->setEnabled(false);
m_ui->defaultDeviceButton->setEnabled(false); m_ui->defaultDeviceButton->setEnabled(false);
} else { } else {
m_ui->removeConfigButton->setEnabled(true); m_ui->removeConfigButton->setEnabled(true);
m_ui->testConfigButton->setEnabled(true);
m_ui->generateKeyButton->setEnabled(true); m_ui->generateKeyButton->setEnabled(true);
m_ui->deployKeyButton->setEnabled(true); m_ui->deployKeyButton->setEnabled(true);
m_ui->remoteProcessesButton->setEnabled(true); const ILinuxDeviceConfigurationFactory * const factory = factoryForCurrentConfig();
if (factory) {
const QStringList &actionIds = factory->supportedDeviceActionIds();
foreach (const QString &actionId, actionIds) {
QPushButton * const button = new QPushButton(factory->displayNameForId(actionId));
m_additionalActionButtons << button;
connect(button, SIGNAL(clicked()), m_additionalActionsMapper, SLOT(map()));
m_additionalActionsMapper->setMapping(button, actionId);
m_ui->buttonsLayout->insertWidget(m_ui->buttonsLayout->count() - 1, button);
}
}
m_ui->configurationComboBox->setCurrentIndex(index); m_ui->configurationComboBox->setCurrentIndex(index);
displayCurrent(); displayCurrent();
} }
@@ -450,5 +480,27 @@ void MaemoDeviceConfigurationsSettingsWidget::updatePortsWarningLabel()
} }
} }
const ILinuxDeviceConfigurationFactory *MaemoDeviceConfigurationsSettingsWidget::factoryForCurrentConfig() const
{
Q_ASSERT(currentConfig());
const QList<ILinuxDeviceConfigurationFactory *> &factories
= ExtensionSystem::PluginManager::instance()->getObjects<ILinuxDeviceConfigurationFactory>();
foreach (const ILinuxDeviceConfigurationFactory * const factory, factories) {
if (factory->supportsOsType(currentConfig()->osType()))
return factory;
}
return 0;
}
void MaemoDeviceConfigurationsSettingsWidget::handleAdditionalActionRequest(const QString &actionId)
{
const ILinuxDeviceConfigurationFactory * const factory = factoryForCurrentConfig();
Q_ASSERT(factory);
QDialog * const action = factory->createDeviceAction(actionId, currentConfig(), this);
Q_ASSERT(action);
action->exec();
delete action;
}
} // namespace Internal } // namespace Internal
} // namespace RemoteLinux } // namespace RemoteLinux

View File

@@ -35,10 +35,12 @@
#include <QtCore/QList> #include <QtCore/QList>
#include <QtCore/QScopedPointer> #include <QtCore/QScopedPointer>
#include <QtCore/QString> #include <QtCore/QString>
#include <QtGui/QPushButton>
#include <QtGui/QWidget> #include <QtGui/QWidget>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QLineEdit; class QLineEdit;
class QSignalMapper;
class Ui_MaemoDeviceConfigurationsSettingsWidget; class Ui_MaemoDeviceConfigurationsSettingsWidget;
QT_END_NAMESPACE QT_END_NAMESPACE
@@ -48,6 +50,7 @@ class SshRemoteProcessRunner;
} }
namespace RemoteLinux { namespace RemoteLinux {
class ILinuxDeviceConfigurationFactory;
class LinuxDeviceConfiguration; class LinuxDeviceConfiguration;
namespace Internal { namespace Internal {
@@ -80,16 +83,14 @@ private slots:
void keyFileEditingFinished(); void keyFileEditingFinished();
void showPassword(bool showClearText); void showPassword(bool showClearText);
void handleFreePortsChanged(); void handleFreePortsChanged();
void showRemoteProcesses();
void setDefaultKeyFilePath(); void setDefaultKeyFilePath();
void setDefaultDevice(); void setDefaultDevice();
// For configuration testing.
void testConfig();
void showGenerateSshKeyDialog(); void showGenerateSshKeyDialog();
void setPrivateKey(const QString &path); void setPrivateKey(const QString &path);
void handleAdditionalActionRequest(const QString &actionId);
// For key deploying. // For key deploying.
void deployKey(); void deployKey();
void finishDeployment(); void finishDeployment();
@@ -105,12 +106,15 @@ private:
QString parseTestOutput(); QString parseTestOutput();
void fillInValues(); void fillInValues();
void updatePortsWarningLabel(); void updatePortsWarningLabel();
const ILinuxDeviceConfigurationFactory *factoryForCurrentConfig() const;
Ui_MaemoDeviceConfigurationsSettingsWidget *m_ui; Ui_MaemoDeviceConfigurationsSettingsWidget *m_ui;
const QScopedPointer<LinuxDeviceConfigurations> m_devConfigs; const QScopedPointer<LinuxDeviceConfigurations> m_devConfigs;
NameValidator * const m_nameValidator; NameValidator * const m_nameValidator;
MaemoKeyDeployer *const m_keyDeployer; MaemoKeyDeployer *const m_keyDeployer;
bool m_saveSettingsRequested; bool m_saveSettingsRequested;
QList<QPushButton *> m_additionalActionButtons;
QSignalMapper * const m_additionalActionsMapper;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -322,7 +322,7 @@
<item row="10" column="1"> <item row="10" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_8"> <layout class="QHBoxLayout" name="horizontalLayout_8">
<item> <item>
<widget class="Utils::PathChooser" name="keyFileLineEdit" native="true"/> <widget class="Utils::PathChooser" name="keyFileLineEdit"/>
</item> </item>
<item> <item>
<widget class="QPushButton" name="makeKeyFileDefaultButton"> <widget class="QPushButton" name="makeKeyFileDefaultButton">
@@ -363,7 +363,7 @@
</layout> </layout>
</item> </item>
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="buttonsLayout">
<item> <item>
<widget class="QPushButton" name="addConfigButton"> <widget class="QPushButton" name="addConfigButton">
<property name="focusPolicy"> <property name="focusPolicy">
@@ -387,22 +387,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QPushButton" name="testConfigButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="toolTip">
<string>Click here to check whether this device is properly set up to run Maemo projects.</string>
</property>
<property name="text">
<string>&amp;Test</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QPushButton" name="generateKeyButton"> <widget class="QPushButton" name="generateKeyButton">
<property name="enabled"> <property name="enabled">
@@ -435,22 +419,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QPushButton" name="remoteProcessesButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="toolTip">
<string>Click here to see which processes are running on the device.</string>
</property>
<property name="text">
<string>Remote Processes...</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QPushButton" name="defaultDeviceButton"> <widget class="QPushButton" name="defaultDeviceButton">
<property name="enabled"> <property name="enabled">
@@ -464,6 +432,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item> <item>
<spacer name="verticalSpacer"> <spacer name="verticalSpacer">
<property name="orientation"> <property name="orientation">
@@ -607,22 +582,6 @@
</hint> </hint>
</hints> </hints>
</connection> </connection>
<connection>
<sender>testConfigButton</sender>
<signal>clicked()</signal>
<receiver>MaemoDeviceConfigurationsSettingsWidget</receiver>
<slot>testConfig()</slot>
<hints>
<hint type="sourcelabel">
<x>697</x>
<y>99</y>
</hint>
<hint type="destinationlabel">
<x>428</x>
<y>351</y>
</hint>
</hints>
</connection>
<connection> <connection>
<sender>deployKeyButton</sender> <sender>deployKeyButton</sender>
<signal>clicked()</signal> <signal>clicked()</signal>
@@ -783,22 +742,6 @@
</hint> </hint>
</hints> </hints>
</connection> </connection>
<connection>
<sender>remoteProcessesButton</sender>
<signal>clicked()</signal>
<receiver>MaemoDeviceConfigurationsSettingsWidget</receiver>
<slot>showRemoteProcesses()</slot>
<hints>
<hint type="sourcelabel">
<x>697</x>
<y>195</y>
</hint>
<hint type="destinationlabel">
<x>598</x>
<y>378</y>
</hint>
</hints>
</connection>
<connection> <connection>
<sender>removeConfigButton</sender> <sender>removeConfigButton</sender>
<signal>clicked()</signal> <signal>clicked()</signal>

View File

@@ -38,6 +38,7 @@
#include "ui_maemodeviceconfigwizardstartpage.h" #include "ui_maemodeviceconfigwizardstartpage.h"
#include "linuxdeviceconfigurations.h" #include "linuxdeviceconfigurations.h"
#include "maemoconfigtestdialog.h"
#include "maemoglobal.h" #include "maemoglobal.h"
#include "maemokeydeployer.h" #include "maemokeydeployer.h"
@@ -589,10 +590,8 @@ private:
struct MaemoDeviceConfigWizardPrivate struct MaemoDeviceConfigWizardPrivate
{ {
MaemoDeviceConfigWizardPrivate(LinuxDeviceConfigurations *devConfigs, MaemoDeviceConfigWizardPrivate(QWidget *parent)
QWidget *parent) : startPage(parent),
: devConfigs(devConfigs),
startPage(parent),
loginDataPage(wizardData, parent), loginDataPage(wizardData, parent),
previousKeySetupPage(parent), previousKeySetupPage(parent),
reuseKeysCheckPage(parent), reuseKeysCheckPage(parent),
@@ -603,7 +602,6 @@ struct MaemoDeviceConfigWizardPrivate
} }
WizardData wizardData; WizardData wizardData;
LinuxDeviceConfigurations * const devConfigs;
MaemoDeviceConfigWizardStartPage startPage; MaemoDeviceConfigWizardStartPage startPage;
MaemoDeviceConfigWizardLoginDataPage loginDataPage; MaemoDeviceConfigWizardLoginDataPage loginDataPage;
MaemoDeviceConfigWizardPreviousKeySetupCheckPage previousKeySetupPage; MaemoDeviceConfigWizardPreviousKeySetupCheckPage previousKeySetupPage;
@@ -614,10 +612,8 @@ struct MaemoDeviceConfigWizardPrivate
}; };
MaemoDeviceConfigWizard::MaemoDeviceConfigWizard(LinuxDeviceConfigurations *devConfigs, MaemoDeviceConfigWizard::MaemoDeviceConfigWizard(QWidget *parent)
QWidget *parent) : ILinuxDeviceConfigurationWizard(parent), d(new MaemoDeviceConfigWizardPrivate(this))
: QWizard(parent),
d(new MaemoDeviceConfigWizardPrivate(devConfigs, this))
{ {
setWindowTitle(tr("New Device Configuration Setup")); setWindowTitle(tr("New Device Configuration Setup"));
setPage(StartPageId, &d->startPage); setPage(StartPageId, &d->startPage);
@@ -632,35 +628,31 @@ MaemoDeviceConfigWizard::MaemoDeviceConfigWizard(LinuxDeviceConfigurations *devC
MaemoDeviceConfigWizard::~MaemoDeviceConfigWizard() {} MaemoDeviceConfigWizard::~MaemoDeviceConfigWizard() {}
void MaemoDeviceConfigWizard::createDeviceConfig() LinuxDeviceConfiguration::Ptr MaemoDeviceConfigWizard::deviceConfiguration()
{ {
QString name = d->wizardData.configName; LinuxDeviceConfiguration::Ptr devConf;
if (d->devConfigs->hasConfig(name)) {
const QString nameTemplate = name + QLatin1String(" (%1)");
int suffix = 2;
do
name = nameTemplate.arg(QString::number(suffix++));
while (d->devConfigs->hasConfig(name));
}
if (d->wizardData.osType == LinuxDeviceConfiguration::GenericLinuxOsType) { if (d->wizardData.osType == LinuxDeviceConfiguration::GenericLinuxOsType) {
if (d->wizardData.authType == SshConnectionParameters::AuthenticationByPassword) { if (d->wizardData.authType == SshConnectionParameters::AuthenticationByPassword) {
d->devConfigs->addGenericLinuxConfigurationUsingPassword(name, devConf = LinuxDeviceConfiguration::createGenericLinuxConfigUsingPassword(d->wizardData.configName,
d->wizardData.hostName, d->wizardData.userName, d->wizardData.hostName, d->wizardData.userName, d->wizardData.password);
d->wizardData.password);
} else { } else {
d->devConfigs->addGenericLinuxConfigurationUsingKey(name, devConf = LinuxDeviceConfiguration::createGenericLinuxConfigUsingKey(d->wizardData.configName,
d->wizardData.hostName, d->wizardData.userName, d->wizardData.hostName, d->wizardData.userName, d->wizardData.privateKeyFilePath);
d->wizardData.privateKeyFilePath);
} }
} else if (d->wizardData.deviceType == LinuxDeviceConfiguration::Physical) { } else if (d->wizardData.deviceType == LinuxDeviceConfiguration::Physical) {
d->devConfigs->addHardwareDeviceConfiguration(name, devConf = LinuxDeviceConfiguration::createHardwareConfig(d->wizardData.configName,
d->wizardData.osType, d->wizardData.hostName, d->wizardData.osType, d->wizardData.hostName, d->wizardData.privateKeyFilePath);
d->wizardData.privateKeyFilePath);
} else { } else {
d->devConfigs->addEmulatorDeviceConfiguration(name, devConf = LinuxDeviceConfiguration::createEmulatorConfig(d->wizardData.configName,
d->wizardData.osType); d->wizardData.osType);
} }
if (devConf->type() != LinuxDeviceConfiguration::Emulator) {
MaemoConfigTestDialog dlg(devConf, this);
dlg.exec();
}
return devConf;
} }
int MaemoDeviceConfigWizard::nextId() const int MaemoDeviceConfigWizard::nextId() const

View File

@@ -32,22 +32,24 @@
#ifndef MAEMODEVICECONFIGWIZARD_H #ifndef MAEMODEVICECONFIGWIZARD_H
#define MAEMODEVICECONFIGWIZARD_H #define MAEMODEVICECONFIGWIZARD_H
#include "linuxdeviceconfiguration.h"
#include <QtCore/QScopedPointer> #include <QtCore/QScopedPointer>
#include <QtGui/QWizard>
namespace RemoteLinux { namespace RemoteLinux {
namespace Internal { namespace Internal {
class LinuxDeviceConfigurations; class LinuxDeviceConfigurations;
struct MaemoDeviceConfigWizardPrivate; struct MaemoDeviceConfigWizardPrivate;
class MaemoDeviceConfigWizard : public QWizard class MaemoDeviceConfigWizard : public ILinuxDeviceConfigurationWizard
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit MaemoDeviceConfigWizard(LinuxDeviceConfigurations *devConfigs, explicit MaemoDeviceConfigWizard(QWidget *parent = 0);
QWidget *parent = 0);
~MaemoDeviceConfigWizard(); ~MaemoDeviceConfigWizard();
void createDeviceConfig();
LinuxDeviceConfiguration::Ptr deviceConfiguration();
virtual int nextId() const; virtual int nextId() const;
private: private:

View File

@@ -71,7 +71,9 @@ HEADERS += \
maemoqtversion.h \ maemoqtversion.h \
linuxdeviceconfiguration.h \ linuxdeviceconfiguration.h \
linuxdeviceconfigurations.h \ linuxdeviceconfigurations.h \
remotelinuxrunconfiguration.h remotelinuxrunconfiguration.h \
linuxdevicefactoryselectiondialog.h \
deviceconfigurationfactory.h
SOURCES += \ SOURCES += \
remotelinuxplugin.cpp \ remotelinuxplugin.cpp \
@@ -134,7 +136,9 @@ SOURCES += \
maemoqtversion.cpp \ maemoqtversion.cpp \
linuxdeviceconfiguration.cpp \ linuxdeviceconfiguration.cpp \
linuxdeviceconfigurations.cpp \ linuxdeviceconfigurations.cpp \
remotelinuxrunconfiguration.cpp remotelinuxrunconfiguration.cpp \
linuxdevicefactoryselectiondialog.cpp \
deviceconfigurationfactory.cpp
FORMS += \ FORMS += \
maemoconfigtestdialog.ui \ maemoconfigtestdialog.ui \
@@ -155,7 +159,8 @@ FORMS += \
maemodeviceconfigwizardkeycreationpage.ui \ maemodeviceconfigwizardkeycreationpage.ui \
maemodeviceconfigwizardkeydeploymentpage.ui \ maemodeviceconfigwizardkeydeploymentpage.ui \
maemodeployconfigurationwidget.ui \ maemodeployconfigurationwidget.ui \
maemodeviceconfigwizardlogindatapage.ui maemodeviceconfigwizardlogindatapage.ui \
linuxdevicefactoryselectiondialog.ui
RESOURCES += qt-maemo.qrc RESOURCES += qt-maemo.qrc
DEFINES += QT_NO_CAST_TO_ASCII DEFINES += QT_NO_CAST_TO_ASCII

View File

@@ -36,6 +36,7 @@
#include "maemodeployable.h" #include "maemodeployable.h"
#include "maemodeploystepfactory.h" #include "maemodeploystepfactory.h"
#include "linuxdeviceconfigurations.h" #include "linuxdeviceconfigurations.h"
#include "deviceconfigurationfactory.h"
#include "maemoglobal.h" #include "maemoglobal.h"
#include "maemopackagecreationfactory.h" #include "maemopackagecreationfactory.h"
#include "maemopublishingwizardfactories.h" #include "maemopublishingwizardfactories.h"
@@ -81,6 +82,7 @@ bool RemoteLinuxPlugin::initialize(const QStringList &arguments,
addAutoReleasedObject(new MaemoPublishingWizardFactoryFremantleFree); addAutoReleasedObject(new MaemoPublishingWizardFactoryFremantleFree);
addAutoReleasedObject(new Qt4MaemoTargetFactory); addAutoReleasedObject(new Qt4MaemoTargetFactory);
addAutoReleasedObject(new MaemoQtVersionFactory); addAutoReleasedObject(new MaemoQtVersionFactory);
addAutoReleasedObject(new DeviceConfigurationFactory);
qRegisterMetaType<MaemoDeployable>("MaemoDeployable"); qRegisterMetaType<MaemoDeployable>("MaemoDeployable");