Commit bb5c7366 authored by Christian Kandeler's avatar Christian Kandeler
Browse files

RemoteLinux: Factor out generic deploy step factory.

Change-Id: I66d09f0e14a604429852c6cd72003f31ce5c7eb5
Reviewed-on: http://codereview.qt.nokia.com/1676

Reviewed-by: default avatarChristian Kandeler <christian.kandeler@nokia.com>
parent 51d83e4c
/**************************************************************************
**
** 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 "genericremotelinuxdeploystepfactory.h"
#include "genericdirectuploadstep.h"
#include "maemopackagecreationstep.h"
#include "remotelinuxdeployconfigurationfactory.h"
#include "uploadandinstalltarpackagestep.h"
#include <projectexplorer/buildsteplist.h>
#include <projectexplorer/deployconfiguration.h>
using namespace ProjectExplorer;
namespace RemoteLinux {
namespace Internal {
GenericRemoteLinuxDeployStepFactory::GenericRemoteLinuxDeployStepFactory(QObject *parent)
: IBuildStepFactory(parent)
{
}
QStringList GenericRemoteLinuxDeployStepFactory::availableCreationIds(BuildStepList *parent) const
{
QStringList ids;
if (qobject_cast<DeployConfiguration *>(parent->parent())->id()
!= RemoteLinuxDeployConfigurationFactory::genericDeployConfigurationId()) {
return ids;
}
ids << MaemoTarPackageCreationStep::CreatePackageId << UploadAndInstallTarPackageStep::stepId()
<< GenericDirectUploadStep::stepId();
return ids;
}
QString GenericRemoteLinuxDeployStepFactory::displayNameForId(const QString &id) const
{
if (id == MaemoTarPackageCreationStep::CreatePackageId)
return tr("Create tarball");
if (id == UploadAndInstallTarPackageStep::stepId())
return UploadAndInstallTarPackageStep::displayName();
if (id == GenericDirectUploadStep::stepId())
return GenericDirectUploadStep::displayName();
return QString();
}
bool GenericRemoteLinuxDeployStepFactory::canCreate(BuildStepList *parent, const QString &id) const
{
return availableCreationIds(parent).contains(id);
}
BuildStep *GenericRemoteLinuxDeployStepFactory::create(BuildStepList *parent, const QString &id)
{
Q_ASSERT(canCreate(parent, id));
if (id == MaemoTarPackageCreationStep::CreatePackageId)
return new MaemoTarPackageCreationStep(parent);
if (id == UploadAndInstallTarPackageStep::stepId())
return new UploadAndInstallTarPackageStep(parent);
if (id == GenericDirectUploadStep::stepId())
return new GenericDirectUploadStep(parent, GenericDirectUploadStep::stepId());
return 0;
}
bool GenericRemoteLinuxDeployStepFactory::canRestore(BuildStepList *parent,
const QVariantMap &map) const
{
return canCreate(parent, idFromMap(map));
}
BuildStep *GenericRemoteLinuxDeployStepFactory::restore(BuildStepList *parent,
const QVariantMap &map)
{
Q_ASSERT(canRestore(parent, map));
BuildStep * const step = create(parent, idFromMap(map));
if (!step->fromMap(map)) {
delete step;
return 0;
}
return step;
}
bool GenericRemoteLinuxDeployStepFactory::canClone(BuildStepList *parent, BuildStep *product) const
{
return canCreate(parent, product->id());
}
BuildStep *GenericRemoteLinuxDeployStepFactory::clone(BuildStepList *parent, BuildStep *product)
{
if (MaemoTarPackageCreationStep * const other = qobject_cast<MaemoTarPackageCreationStep *>(product))
return new MaemoTarPackageCreationStep(parent, other);
if (UploadAndInstallTarPackageStep * const other = qobject_cast<UploadAndInstallTarPackageStep*>(product))
return new UploadAndInstallTarPackageStep(parent, other);
if (GenericDirectUploadStep * const other = qobject_cast<GenericDirectUploadStep *>(product))
return new GenericDirectUploadStep(parent, other);
return 0;
}
} // 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 GENERICREMOTELINUXDEPLOYSTEPFACTORY_H
#define GENERICREMOTELINUXDEPLOYSTEPFACTORY_H
#include <projectexplorer/buildstep.h>
namespace RemoteLinux {
namespace Internal {
class GenericRemoteLinuxDeployStepFactory : public ProjectExplorer::IBuildStepFactory
{
Q_OBJECT
public:
GenericRemoteLinuxDeployStepFactory(QObject *parent = 0);
QStringList availableCreationIds(ProjectExplorer::BuildStepList *parent) const;
QString displayNameForId(const QString &id) const;
bool canCreate(ProjectExplorer::BuildStepList *parent, const QString &id) const;
ProjectExplorer::BuildStep *create(ProjectExplorer::BuildStepList *parent, const QString &id);
bool canRestore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map) const;
ProjectExplorer::BuildStep *restore(ProjectExplorer::BuildStepList *parent,
const QVariantMap &map);
bool canClone(ProjectExplorer::BuildStepList *parent,
ProjectExplorer::BuildStep *product) const;
ProjectExplorer::BuildStep *clone(ProjectExplorer::BuildStepList *parent,
ProjectExplorer::BuildStep *product);
};
} // namespace Internal
} // namespace RemoteLinux
#endif // GENERICREMOTELINUXDEPLOYSTEPFACTORY_H
......@@ -35,10 +35,9 @@
#include "genericdirectuploadstep.h"
#include "maddeuploadandinstallpackagesteps.h"
#include "maemodeploybymountsteps.h"
#include "maemoglobal.h"
#include "maemoinstalltosysrootstep.h"
#include "qt4maemotarget.h"
#include "remotelinuxdeployconfiguration.h"
#include "qt4maemodeployconfiguration.h"
#include "uploadandinstalltarpackagestep.h"
#include <projectexplorer/buildconfiguration.h>
......@@ -64,18 +63,13 @@ MaemoDeployStepFactory::MaemoDeployStepFactory(QObject *parent)
QStringList MaemoDeployStepFactory::availableCreationIds(BuildStepList *parent) const
{
QStringList ids;
if (!qobject_cast<RemoteLinuxDeployConfiguration *>(parent->parent()))
if (!qobject_cast<Qt4MaemoDeployConfiguration *>(parent->parent()))
return ids;
AbstractQt4MaemoTarget * const maemoTarget
= qobject_cast<AbstractQt4MaemoTarget *>(parent->target());
if (maemoTarget) {
if (maemoTarget)
ids << MaemoMakeInstallToSysrootStep::Id;
} else if (MaemoGlobal::hasLinuxQt(parent->target())) {
ids << UploadAndInstallTarPackageStep::stepId() << GenericDirectUploadStep::stepId();
}
if (maemoTarget && !qobject_cast<Qt4HarmattanTarget *>(parent->target()))
ids << UploadAndInstallTarPackageStep::stepId();
if (qobject_cast<AbstractDebBasedQt4MaemoTarget *>(parent->target())) {
ids << MaemoInstallDebianPackageToSysrootStep::Id;
ids << MaemoUploadAndInstallPackageStep::stepId();
......@@ -99,8 +93,6 @@ QString MaemoDeployStepFactory::displayNameForId(const QString &id) const
return MaemoUploadAndInstallPackageStep::displayName();
else if (id == MeegoUploadAndInstallPackageStep::stepId())
return MeegoUploadAndInstallPackageStep::displayName();
else if (id == UploadAndInstallTarPackageStep::stepId())
return UploadAndInstallTarPackageStep::displayName();
else if (id == MaemoInstallDebianPackageToSysrootStep::Id)
return MaemoInstallDebianPackageToSysrootStep::displayName();
else if (id == MaemoInstallRpmPackageToSysrootStep::Id)
......@@ -109,8 +101,6 @@ QString MaemoDeployStepFactory::displayNameForId(const QString &id) const
return MaemoCopyToSysrootStep::displayName();
else if (id == MaemoMakeInstallToSysrootStep::Id)
return MaemoMakeInstallToSysrootStep::displayName();
else if (id == GenericDirectUploadStep::stepId())
return GenericDirectUploadStep::displayName();
return QString();
}
......@@ -142,10 +132,6 @@ BuildStep *MaemoDeployStepFactory::create(BuildStepList *parent, const QString &
} else if (id == MeegoUploadAndInstallPackageStep::stepId()
|| (id == OldMaemoDeployStepId && (qobject_cast<const Qt4MeegoTarget *>(t)))) {
return new MeegoUploadAndInstallPackageStep(parent);
} else if (id == UploadAndInstallTarPackageStep::stepId()) {
return new UploadAndInstallTarPackageStep(parent);
} else if (id == GenericDirectUploadStep::stepId()) {
return new GenericDirectUploadStep(parent, GenericDirectUploadStep::stepId());
}
return 0;
......@@ -188,9 +174,6 @@ BuildStep *MaemoDeployStepFactory::clone(BuildStepList *parent, BuildStep *produ
} else if (product->id() == MeegoUploadAndInstallPackageStep::stepId()) {
return new MeegoUploadAndInstallPackageStep(parent,
qobject_cast<MeegoUploadAndInstallPackageStep*>(product));
} else if (product->id() == UploadAndInstallTarPackageStep::stepId()) {
return new UploadAndInstallTarPackageStep(parent,
qobject_cast<UploadAndInstallTarPackageStep*>(product));
} else if (product->id() == MaemoInstallDebianPackageToSysrootStep::Id) {
return new MaemoInstallDebianPackageToSysrootStep(parent,
qobject_cast<MaemoInstallDebianPackageToSysrootStep *>(product));
......@@ -203,8 +186,6 @@ BuildStep *MaemoDeployStepFactory::clone(BuildStepList *parent, BuildStep *produ
} else if (product->id() == MaemoMakeInstallToSysrootStep::Id) {
return new MaemoMakeInstallToSysrootStep(parent,
qobject_cast<MaemoMakeInstallToSysrootStep *>(product));
} else if (product->id() == GenericDirectUploadStep::stepId()) {
return new GenericDirectUploadStep(parent, qobject_cast<GenericDirectUploadStep *>(product));
}
return 0;
}
......
......@@ -31,10 +31,9 @@
#include "maemopackagecreationfactory.h"
#include "maemoglobal.h"
#include "maemopackagecreationstep.h"
#include "qt4maemotarget.h"
#include "remotelinuxdeployconfiguration.h"
#include "qt4maemodeployconfiguration.h"
#include <projectexplorer/buildconfiguration.h>
#include <projectexplorer/buildsteplist.h>
......@@ -61,9 +60,7 @@ MaemoPackageCreationFactory::MaemoPackageCreationFactory(QObject *parent)
QStringList MaemoPackageCreationFactory::availableCreationIds(ProjectExplorer::BuildStepList *parent) const
{
QStringList ids;
if (!MaemoGlobal::hasLinuxQt(parent->target()))
return ids;
if (!qobject_cast<RemoteLinuxDeployConfiguration *>(parent->parent()))
if (!qobject_cast<Qt4MaemoDeployConfiguration *>(parent->parent()))
return ids;
if (qobject_cast<AbstractDebBasedQt4MaemoTarget *>(parent->target())
&& !parent->contains(MaemoDebianPackageCreationStep::CreatePackageId)) {
......@@ -72,10 +69,6 @@ QStringList MaemoPackageCreationFactory::availableCreationIds(ProjectExplorer::B
&& !parent->contains(MaemoRpmPackageCreationStep::CreatePackageId)) {
ids << MaemoRpmPackageCreationStep::CreatePackageId;
}
if (!qobject_cast<Qt4HarmattanTarget *>(parent->target())
&& !parent->contains(MaemoTarPackageCreationStep::CreatePackageId)) {
ids << MaemoTarPackageCreationStep::CreatePackageId;
}
return ids;
}
......@@ -87,9 +80,6 @@ QString MaemoPackageCreationFactory::displayNameForId(const QString &id) const
} else if (id == MaemoRpmPackageCreationStep::CreatePackageId) {
return QCoreApplication::translate("RemoteLinux::Internal::MaemoPackageCreationFactory",
"Create RPM Package");
} else if (id == MaemoTarPackageCreationStep::CreatePackageId) {
return QCoreApplication::translate("RemoteLinux::Internal::MaemoPackageCreationFactory",
"Create tarball");
}
return QString();
}
......@@ -106,8 +96,6 @@ BuildStep *MaemoPackageCreationFactory::create(ProjectExplorer::BuildStepList *p
return new MaemoDebianPackageCreationStep(parent);
else if (id == MaemoRpmPackageCreationStep::CreatePackageId)
return new MaemoRpmPackageCreationStep(parent);
else if (id == MaemoTarPackageCreationStep::CreatePackageId)
return new MaemoTarPackageCreationStep(parent);
return 0;
}
......@@ -132,9 +120,7 @@ BuildStep *MaemoPackageCreationFactory::restore(ProjectExplorer::BuildStepList *
|| (id == OldCreatePackageId
&& qobject_cast<AbstractRpmBasedQt4MaemoTarget *>(parent->target()))) {
step = new MaemoRpmPackageCreationStep(parent);
} else if (id == MaemoTarPackageCreationStep::CreatePackageId) {
step = new MaemoTarPackageCreationStep(parent);
}
}
Q_ASSERT(step);
if (!step->fromMap(map)) {
......@@ -154,20 +140,15 @@ BuildStep *MaemoPackageCreationFactory::clone(ProjectExplorer::BuildStepList *pa
ProjectExplorer::BuildStep *product)
{
Q_ASSERT(canClone(parent, product));
MaemoDebianPackageCreationStep * const debianStep
= qobject_cast<MaemoDebianPackageCreationStep *>(product);
if (debianStep) {
if (MaemoDebianPackageCreationStep * const debianStep
= qobject_cast<MaemoDebianPackageCreationStep *>(product)) {
return new MaemoDebianPackageCreationStep(parent, debianStep);
} else {
MaemoRpmPackageCreationStep * const rpmStep
= qobject_cast<MaemoRpmPackageCreationStep *>(product);
if (rpmStep) {
return new MaemoRpmPackageCreationStep(parent, rpmStep);
} else {
return new MaemoTarPackageCreationStep(parent,
qobject_cast<MaemoTarPackageCreationStep *>(product));
}
}
if (MaemoRpmPackageCreationStep * const rpmStep
= qobject_cast<MaemoRpmPackageCreationStep *>(product)) {
return new MaemoRpmPackageCreationStep(parent, rpmStep);
}
return 0;
}
} // namespace Internal
......
......@@ -160,26 +160,24 @@ private:
class MaemoTarPackageCreationStep : public AbstractMaemoPackageCreationStep
{
Q_OBJECT
friend class MaemoPackageCreationFactory;
public:
MaemoTarPackageCreationStep(ProjectExplorer::BuildStepList *bsl);
MaemoTarPackageCreationStep(ProjectExplorer::BuildStepList *buildConfig,
MaemoTarPackageCreationStep *other);
virtual QString packageFilePath() const;
static const QString CreatePackageId;
private:
virtual bool createPackage(QProcess *buildProc, const QFutureInterface<bool> &fi);
virtual bool isMetaDataNewerThan(const QDateTime &packageDate) const;
virtual ProjectExplorer::BuildStepConfigWidget *createConfigWidget();
MaemoTarPackageCreationStep(ProjectExplorer::BuildStepList *buildConfig,
MaemoTarPackageCreationStep *other);
void ctor();
bool appendFile(QFile &tarFile, const QFileInfo &fileInfo,
const QString &remoteFilePath, const QFutureInterface<bool> &fi);
bool writeHeader(QFile &tarFile, const QFileInfo &fileInfo,
const QString &remoteFilePath);
static const QString CreatePackageId;
};
} // namespace Internal
......
......@@ -88,7 +88,8 @@ HEADERS += \
abstractuploadandinstallpackageservice.h \
genericdirectuploadservice.h \
remotelinuxdeployconfiguration.h \
remotelinuxdeployconfigurationfactory.h
remotelinuxdeployconfigurationfactory.h \
genericremotelinuxdeploystepfactory.h
SOURCES += \
remotelinuxplugin.cpp \
......@@ -170,7 +171,8 @@ SOURCES += \
abstractuploadandinstallpackageservice.cpp \
genericdirectuploadservice.cpp \
remotelinuxdeployconfiguration.cpp \
remotelinuxdeployconfigurationfactory.cpp
remotelinuxdeployconfigurationfactory.cpp \
genericremotelinuxdeploystepfactory.cpp
FORMS += \
maemoconfigtestdialog.ui \
......
......@@ -37,15 +37,11 @@
#include "remotelinuxdeployconfiguration.h"
#include "uploadandinstalltarpackagestep.h"
#include <QtCore/QCoreApplication>
using namespace ProjectExplorer;
namespace RemoteLinux {
namespace Internal {
namespace {
const char GenericLinuxId[] = "DeployToGenericLinux";
QString genericLinuxDisplayName() {
return QCoreApplication::translate("RemoteLinux", "Build Tarball and Install to Linux Host");
}
......@@ -59,13 +55,13 @@ QStringList RemoteLinuxDeployConfigurationFactory::availableCreationIds(Target *
{
QStringList ids;
if (MaemoGlobal::hasLinuxQt(parent))
ids << QLatin1String(GenericLinuxId);
ids << genericDeployConfigurationId();
return ids;
}
QString RemoteLinuxDeployConfigurationFactory::displayNameForId(const QString &id) const
{
if (id == QLatin1String(GenericLinuxId))
if (id == genericDeployConfigurationId())
return genericLinuxDisplayName();
return QString();
}
......@@ -116,5 +112,10 @@ DeployConfiguration *RemoteLinuxDeployConfigurationFactory::clone(Target *parent
qobject_cast<RemoteLinuxDeployConfiguration *>(product));
}
QString RemoteLinuxDeployConfigurationFactory::genericDeployConfigurationId()
{
return QLatin1String("DeployToGenericLinux");
}
} // namespace Internal
} // namespace RemoteLinux
......@@ -54,6 +54,8 @@ public:
const QVariantMap &map);
virtual ProjectExplorer::DeployConfiguration *clone(ProjectExplorer::Target *parent,
ProjectExplorer::DeployConfiguration *product);
static QString genericDeployConfigurationId();
};
} // namespace Internal
......
......@@ -34,6 +34,7 @@
#include "deployablefile.h"
#include "genericlinuxdeviceconfigurationfactory.h"
#include "genericremotelinuxdeploystepfactory.h"
#include "maddedeviceconfigurationfactory.h"
#include "maemoconstants.h"
#include "maemodeploystepfactory.h"
......@@ -91,6 +92,7 @@ bool RemoteLinuxPlugin::initialize(const QStringList &arguments,
addAutoReleasedObject(new RemoteLinuxRunConfigurationFactory);
addAutoReleasedObject(new RemoteLinuxRunControlFactory);
addAutoReleasedObject(new RemoteLinuxDeployConfigurationFactory);
addAutoReleasedObject(new GenericRemoteLinuxDeployStepFactory);
qRegisterMetaType<DeployableFile>("DeployableFile");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment