Commit f74e1675 authored by Christian Kandeler's avatar Christian Kandeler

RemoteLinux: More untangling of generic and Maemo-specific stuff.

- Make key deployment a device type dependent action.
- Split up monolithic device configuration wizard.
- Split up run configurations, run controls and the associated
  factories.

Change-Id: Ib2ef9d405e6b7eaae89fc27c56e3c327829a88f7
Reviewed-on: http://codereview.qt.nokia.com/486Reviewed-by: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarTobias Hunger <tobias.hunger@nokia.com>
parent dfa7995b
/**************************************************************************
**
** 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 "genericlinuxdeviceconfigurationfactory.h"
#include "genericlinuxdeviceconfigurationwizard.h"
#include "maemoconfigtestdialog.h"
#include "maemoremoteprocessesdialog.h"
#include "publickeydeploymentdialog.h"
namespace RemoteLinux {
namespace Internal {
namespace {
const char * const TestDeviceActionId = "TestDeviceAction";
const char * const DeployKeyToDeviceActionId = "DeployKeyToDeviceAction";
const char * const RemoteProcessesActionId = "RemoteProcessesAction";
} // anonymous namespace;
GenericLinuxDeviceConfigurationFactory::GenericLinuxDeviceConfigurationFactory(QObject *parent)
: ILinuxDeviceConfigurationFactory(parent)
{
}
QString GenericLinuxDeviceConfigurationFactory::displayName() const
{
return tr("Generic Linux Devices");
}
ILinuxDeviceConfigurationWizard *GenericLinuxDeviceConfigurationFactory::createWizard(QWidget *parent) const
{
return new GenericLinuxDeviceConfigurationWizard(parent);
}
bool GenericLinuxDeviceConfigurationFactory::supportsOsType(const QString &osType) const
{
return osType == LinuxDeviceConfiguration::GenericLinuxOsType;
}
QStringList GenericLinuxDeviceConfigurationFactory::supportedDeviceActionIds() const
{
return QStringList() << QLatin1String(TestDeviceActionId)
<< QLatin1String(DeployKeyToDeviceActionId) << QLatin1String(RemoteProcessesActionId);
}
QString GenericLinuxDeviceConfigurationFactory::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");
if (actionId == QLatin1String(DeployKeyToDeviceActionId))
return tr("Deploy Public Key");
return QString(); // Can't happen.
}
QDialog *GenericLinuxDeviceConfigurationFactory::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);
if (actionId == QLatin1String(DeployKeyToDeviceActionId))
return new PublicKeyDeploymentDialog(deviceConfig, parent);
return 0; // Can't happen.
}
} // namespace Internal
} // namespace RemoteLinux
/**************************************************************************
**
** 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 GENERICLINUXDEVICECONFIGURATIONFACTORY_H
#define GENERICLINUXDEVICECONFIGURATIONFACTORY_H
#include "linuxdeviceconfiguration.h"
namespace RemoteLinux {
namespace Internal {
class GenericLinuxDeviceConfigurationFactory : public ILinuxDeviceConfigurationFactory
{
Q_OBJECT
Q_DISABLE_COPY(GenericLinuxDeviceConfigurationFactory)
public:
GenericLinuxDeviceConfigurationFactory(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 // GENERICLINUXDEVICECONFIGURATIONFACTORY_H
/**************************************************************************
**
** 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 "genericlinuxdeviceconfigurationwizard.h"
#include "genericlinuxdeviceconfigurationwizardsetuppage.h"
#include "maemoconfigtestdialog.h"
#include <QtGui/QLabel>
#include <QtGui/QVBoxLayout>
using namespace Utils;
namespace RemoteLinux {
namespace Internal {
namespace {
enum PageId { SetupPageId, FinalPageId };
class GenericLinuxDeviceConfigurationWizardFinalPage : public QWizardPage
{
Q_OBJECT
public:
GenericLinuxDeviceConfigurationWizardFinalPage(QWidget *parent)
: QWizardPage(parent), m_infoLabel(new QLabel(this))
{
setTitle(tr("Setup Finished"));
setSubTitle(QLatin1String(" ")); // For Qt bug (background color)
m_infoLabel->setWordWrap(true);
QVBoxLayout * const layout = new QVBoxLayout(this);
layout->addWidget(m_infoLabel);
}
virtual void initializePage()
{
const QString infoText = tr("The new device configuration will now be "
"created. In addition, a test procedure will be run to check whether "
"Qt Creator can connect to the device and to provide some information about it.");
m_infoLabel->setText(infoText);
}
private:
QLabel * const m_infoLabel;
};
} // anonymous namespace
class GenericLinuxDeviceConfigurationWizardPrivate
{
public:
GenericLinuxDeviceConfigurationWizardPrivate(QWidget *parent)
: setupPage(parent), finalPage(parent)
{
}
GenericLinuxDeviceConfigurationWizardSetupPage setupPage;
GenericLinuxDeviceConfigurationWizardFinalPage finalPage;
};
} // namespace Internal
GenericLinuxDeviceConfigurationWizard::GenericLinuxDeviceConfigurationWizard(QWidget *parent)
: ILinuxDeviceConfigurationWizard(parent),
m_d(new Internal::GenericLinuxDeviceConfigurationWizardPrivate(this))
{
setWindowTitle(tr("New Generic Linux Device Configuration Setup"));
setPage(Internal::SetupPageId, &m_d->setupPage);
setPage(Internal::FinalPageId, &m_d->finalPage);
m_d->finalPage.setCommitPage(true);
}
GenericLinuxDeviceConfigurationWizard::~GenericLinuxDeviceConfigurationWizard()
{
delete m_d;
}
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());
}
Internal::MaemoConfigTestDialog dlg(devConf, this);
dlg.exec();
return devConf;
}
} // namespace RemoteLinux
#include "genericlinuxdeviceconfigurationwizard.moc"
/**************************************************************************
**
** 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 GENERICLINUXDEVICECONFIGURATIONWIZARD_H
#define GENERICLINUXDEVICECONFIGURATIONWIZARD_H
#include "linuxdeviceconfiguration.h"
namespace RemoteLinux {
namespace Internal {
class GenericLinuxDeviceConfigurationWizardPrivate;
} // namespace Internal
class REMOTELINUX_EXPORT GenericLinuxDeviceConfigurationWizard
: public ILinuxDeviceConfigurationWizard
{
Q_OBJECT
Q_DISABLE_COPY(GenericLinuxDeviceConfigurationWizard)
public:
GenericLinuxDeviceConfigurationWizard(QWidget *parent = 0);
~GenericLinuxDeviceConfigurationWizard();
LinuxDeviceConfiguration::Ptr deviceConfiguration();
private:
Internal::GenericLinuxDeviceConfigurationWizardPrivate * const m_d;
};
} // namespace RemoteLinux
#endif // GENERICLINUXDEVICECONFIGURATIONWIZARD_H
/**************************************************************************
**
** 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 "genericlinuxdeviceconfigurationwizardsetuppage.h"
#include "ui_genericlinuxdeviceconfigurationwizardsetuppage.h"
#include "linuxdeviceconfiguration.h"
namespace RemoteLinux {
namespace Internal {
class GenericLinuxDeviceConfigurationWizardSetupPagePrivate
{
public:
Ui::GenericLinuxDeviceConfigurationWizardSetupPage ui;
};
} // namespace Internal
using namespace Utils;
GenericLinuxDeviceConfigurationWizardSetupPage::GenericLinuxDeviceConfigurationWizardSetupPage(QWidget *parent) :
QWizardPage(parent), m_d(new Internal::GenericLinuxDeviceConfigurationWizardSetupPagePrivate)
{
m_d->ui.setupUi(this);
setTitle(tr("Connection Data"));
setSubTitle(QLatin1String(" ")); // For Qt bug (background color)
m_d->ui.privateKeyPathChooser->setExpectedKind(PathChooser::File);
connect(m_d->ui.nameLineEdit, SIGNAL(textChanged(QString)), SIGNAL(completeChanged()));
connect(m_d->ui.hostNameLineEdit, SIGNAL(textChanged(QString)), SIGNAL(completeChanged()));
connect(m_d->ui.userNameLineEdit, SIGNAL(textChanged(QString)), SIGNAL(completeChanged()));
connect(m_d->ui.privateKeyPathChooser, SIGNAL(validChanged()), SIGNAL(completeChanged()));
connect(m_d->ui.passwordButton, SIGNAL(toggled(bool)), SLOT(handleAuthTypeChanged()));
}
GenericLinuxDeviceConfigurationWizardSetupPage::~GenericLinuxDeviceConfigurationWizardSetupPage()
{
delete m_d;
}
void GenericLinuxDeviceConfigurationWizardSetupPage::initializePage()
{
m_d->ui.nameLineEdit->setText(QLatin1String("(New Configuration)"));
m_d->ui.hostNameLineEdit->setText(defaultHostName());
m_d->ui.userNameLineEdit->setText(defaultUserName());
m_d->ui.passwordButton->setChecked(true);
m_d->ui.passwordLineEdit->clear();
m_d->ui.privateKeyPathChooser->setPath(LinuxDeviceConfiguration::defaultPrivateKeyFilePath());
handleAuthTypeChanged();
}
bool GenericLinuxDeviceConfigurationWizardSetupPage::isComplete() const
{
return !configurationName().isEmpty() && !hostName().isEmpty() && !userName().isEmpty()
&& (authenticationType() == SshConnectionParameters::AuthenticationByPassword
|| !m_d->ui.privateKeyPathChooser->isValid());
}
QString GenericLinuxDeviceConfigurationWizardSetupPage::configurationName() const
{
return m_d->ui.nameLineEdit->text().trimmed();
}
QString GenericLinuxDeviceConfigurationWizardSetupPage::hostName() const
{
return m_d->ui.hostNameLineEdit->text().trimmed();
}
QString GenericLinuxDeviceConfigurationWizardSetupPage::userName() const
{
return m_d->ui.userNameLineEdit->text().trimmed();
}
SshConnectionParameters::AuthenticationType GenericLinuxDeviceConfigurationWizardSetupPage::authenticationType() const
{
return m_d->ui.passwordButton->isChecked()
? SshConnectionParameters::AuthenticationByPassword
: SshConnectionParameters::AuthenticationByKey;
}
QString GenericLinuxDeviceConfigurationWizardSetupPage::password() const
{
return m_d->ui.passwordLineEdit->text();
}
QString GenericLinuxDeviceConfigurationWizardSetupPage::privateKeyFilePath() const
{
return m_d->ui.privateKeyPathChooser->path();
}
QString GenericLinuxDeviceConfigurationWizardSetupPage::defaultHostName() const
{
return QString();
}
QString GenericLinuxDeviceConfigurationWizardSetupPage::defaultUserName() const
{
return QString();
}
void GenericLinuxDeviceConfigurationWizardSetupPage::handleAuthTypeChanged()
{
m_d->ui.passwordLineEdit->setEnabled(authenticationType() == SshConnectionParameters::AuthenticationByPassword);
m_d->ui.privateKeyPathChooser->setEnabled(authenticationType() == SshConnectionParameters::AuthenticationByKey);
emit completeChanged();
}
} // namespace RemoteLinux
/**************************************************************************
**
** 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 GENERICLINUXDEVICECONFIGURATIONWIZARDSETUPPAGE_H
#define GENERICLINUXDEVICECONFIGURATIONWIZARDSETUPPAGE_H
#include "remotelinux_export.h"
#include <utils/ssh/sshconnection.h>
#include <QtGui/QWizardPage>
namespace RemoteLinux {
namespace Internal {
class GenericLinuxDeviceConfigurationWizardSetupPagePrivate;
} // namespace Internal
class REMOTELINUX_EXPORT GenericLinuxDeviceConfigurationWizardSetupPage : public QWizardPage
{
Q_OBJECT
Q_DISABLE_COPY(GenericLinuxDeviceConfigurationWizardSetupPage)
public:
explicit GenericLinuxDeviceConfigurationWizardSetupPage(QWidget *parent = 0);
~GenericLinuxDeviceConfigurationWizardSetupPage();
void initializePage();
bool isComplete() const;
QString configurationName() const;
QString hostName() const;
QString userName() const;
Utils::SshConnectionParameters::AuthenticationType authenticationType() const;
QString password() const;
QString privateKeyFilePath() const;
virtual QString defaultHostName() const;
virtual QString defaultUserName() const;
private:
Q_SLOT void handleAuthTypeChanged();
Internal::GenericLinuxDeviceConfigurationWizardSetupPagePrivate * const m_d;
};
} // namespace RemoteLinux
#endif // GENERICLINUXDEVICECONFIGURATIONWIZARDSETUPPAGE_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GenericLinuxDeviceConfigurationWizardSetupPage</class>
<widget class="QWizardPage" name="GenericLinuxDeviceConfigurationWizardSetupPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>542</width>
<height>201</height>
</rect>
</property>
<property name="windowTitle">
<string>WizardPage</string>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">