diff --git a/src/plugins/remotelinux/genericremotelinuxdeploystepfactory.cpp b/src/plugins/remotelinux/genericremotelinuxdeploystepfactory.cpp new file mode 100644 index 0000000000000000000000000000000000000000..80a134fd60a0c7b4908ddcf2f71f7d15b075c4e9 --- /dev/null +++ b/src/plugins/remotelinux/genericremotelinuxdeploystepfactory.cpp @@ -0,0 +1,129 @@ +/************************************************************************** +** +** 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 diff --git a/src/plugins/remotelinux/genericremotelinuxdeploystepfactory.h b/src/plugins/remotelinux/genericremotelinuxdeploystepfactory.h new file mode 100644 index 0000000000000000000000000000000000000000..aec111afee6e41e31f892163b9fb3335ab3704b3 --- /dev/null +++ b/src/plugins/remotelinux/genericremotelinuxdeploystepfactory.h @@ -0,0 +1,62 @@ +/************************************************************************** +** +** 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 diff --git a/src/plugins/remotelinux/maemodeploystepfactory.cpp b/src/plugins/remotelinux/maemodeploystepfactory.cpp index 844a3ba1873281d728169b2fa97258f34d3b0db4..f588dedbb2cabd02c75ef05cf571fa01dffee98b 100644 --- a/src/plugins/remotelinux/maemodeploystepfactory.cpp +++ b/src/plugins/remotelinux/maemodeploystepfactory.cpp @@ -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; } diff --git a/src/plugins/remotelinux/maemopackagecreationfactory.cpp b/src/plugins/remotelinux/maemopackagecreationfactory.cpp index a898bfd9fc0cf8e54fe7c6c4a99b57731a1239fa..64d9883fddc90ec55a1291be41a29b432539dbf1 100644 --- a/src/plugins/remotelinux/maemopackagecreationfactory.cpp +++ b/src/plugins/remotelinux/maemopackagecreationfactory.cpp @@ -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 diff --git a/src/plugins/remotelinux/maemopackagecreationstep.h b/src/plugins/remotelinux/maemopackagecreationstep.h index 6ea7e61def614e9b3c8f3a8bcec69219b1f8a5c5..c9451883b43282461ffde2afa61e9170ae9b8451 100644 --- a/src/plugins/remotelinux/maemopackagecreationstep.h +++ b/src/plugins/remotelinux/maemopackagecreationstep.h @@ -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 diff --git a/src/plugins/remotelinux/remotelinux.pro b/src/plugins/remotelinux/remotelinux.pro index 4f88f70788041c888b3293e373d914871d060e0c..f6b668216f8c699a37a700957687806bde08cd36 100644 --- a/src/plugins/remotelinux/remotelinux.pro +++ b/src/plugins/remotelinux/remotelinux.pro @@ -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 \ diff --git a/src/plugins/remotelinux/remotelinuxdeployconfigurationfactory.cpp b/src/plugins/remotelinux/remotelinuxdeployconfigurationfactory.cpp index 4bb3b9fe6980402a15a3e1b64d32619cc5c1c4eb..18b4a1656104fdb1183024602af2d21d7a4e73be 100644 --- a/src/plugins/remotelinux/remotelinuxdeployconfigurationfactory.cpp +++ b/src/plugins/remotelinux/remotelinuxdeployconfigurationfactory.cpp @@ -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 diff --git a/src/plugins/remotelinux/remotelinuxdeployconfigurationfactory.h b/src/plugins/remotelinux/remotelinuxdeployconfigurationfactory.h index abcb2d7d3e0c76aa18e6c99968f35115d8ff9f1d..c06f97148a90ac04c8637934ab5f58d69c36b338 100644 --- a/src/plugins/remotelinux/remotelinuxdeployconfigurationfactory.h +++ b/src/plugins/remotelinux/remotelinuxdeployconfigurationfactory.h @@ -54,6 +54,8 @@ public: const QVariantMap &map); virtual ProjectExplorer::DeployConfiguration *clone(ProjectExplorer::Target *parent, ProjectExplorer::DeployConfiguration *product); + + static QString genericDeployConfigurationId(); }; } // namespace Internal diff --git a/src/plugins/remotelinux/remotelinuxplugin.cpp b/src/plugins/remotelinux/remotelinuxplugin.cpp index be8b7a4446260a94781df18b484f5df55fc2e649..22577f434e5fa6205130575290144cc6ace22e00 100644 --- a/src/plugins/remotelinux/remotelinuxplugin.cpp +++ b/src/plugins/remotelinux/remotelinuxplugin.cpp @@ -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");