RemoteLinux: Make custom command deployment step extensible.

Also fix typo in service class name.

Change-Id: Icd664d77b43fc63a59a94575529b1a1c272b500c
Reviewed-on: http://codereview.qt-project.org/5549
Reviewed-by: Christian Kandeler <christian.kandeler@nokia.com>
This commit is contained in:
Christian Kandeler
2011-09-26 16:03:07 +02:00
parent 5c746546f5
commit eb6cee45e1
5 changed files with 112 additions and 58 deletions

View File

@@ -57,7 +57,8 @@ QStringList GenericRemoteLinuxDeployStepFactory::availableCreationIds(BuildStepL
if (!dc || dc->id() != RemoteLinuxDeployConfigurationFactory::genericDeployConfigurationId()) if (!dc || dc->id() != RemoteLinuxDeployConfigurationFactory::genericDeployConfigurationId())
return ids; return ids;
ids << TarPackageCreationStep::stepId() << UploadAndInstallTarPackageStep::stepId() ids << TarPackageCreationStep::stepId() << UploadAndInstallTarPackageStep::stepId()
<< GenericDirectUploadStep::stepId() << RemoteLinuxCustomCommandDeploymentStep::stepId(); << GenericDirectUploadStep::stepId()
<< GenericRemoteLinuxCustomCommandDeploymentStep::stepId();
return ids; return ids;
} }
@@ -69,8 +70,8 @@ QString GenericRemoteLinuxDeployStepFactory::displayNameForId(const QString &id)
return UploadAndInstallTarPackageStep::displayName(); return UploadAndInstallTarPackageStep::displayName();
if (id == GenericDirectUploadStep::stepId()) if (id == GenericDirectUploadStep::stepId())
return GenericDirectUploadStep::displayName(); return GenericDirectUploadStep::displayName();
if (id == RemoteLinuxCustomCommandDeploymentStep::stepId()) if (id == GenericRemoteLinuxCustomCommandDeploymentStep::stepId())
return RemoteLinuxCustomCommandDeploymentStep::stepDisplayName(); return GenericRemoteLinuxCustomCommandDeploymentStep::stepDisplayName();
return QString(); return QString();
} }
@@ -89,8 +90,8 @@ BuildStep *GenericRemoteLinuxDeployStepFactory::create(BuildStepList *parent, co
return new UploadAndInstallTarPackageStep(parent); return new UploadAndInstallTarPackageStep(parent);
if (id == GenericDirectUploadStep::stepId()) if (id == GenericDirectUploadStep::stepId())
return new GenericDirectUploadStep(parent, GenericDirectUploadStep::stepId()); return new GenericDirectUploadStep(parent, GenericDirectUploadStep::stepId());
if (id == RemoteLinuxCustomCommandDeploymentStep::stepId()) if (id == GenericRemoteLinuxCustomCommandDeploymentStep::stepId())
return new RemoteLinuxCustomCommandDeploymentStep(parent); return new GenericRemoteLinuxCustomCommandDeploymentStep(parent);
return 0; return 0;
} }
@@ -126,8 +127,8 @@ BuildStep *GenericRemoteLinuxDeployStepFactory::clone(BuildStepList *parent, Bui
return new UploadAndInstallTarPackageStep(parent, other); return new UploadAndInstallTarPackageStep(parent, other);
if (GenericDirectUploadStep * const other = qobject_cast<GenericDirectUploadStep *>(product)) if (GenericDirectUploadStep * const other = qobject_cast<GenericDirectUploadStep *>(product))
return new GenericDirectUploadStep(parent, other); return new GenericDirectUploadStep(parent, other);
if (RemoteLinuxCustomCommandDeploymentStep * const other = qobject_cast<RemoteLinuxCustomCommandDeploymentStep *>(product)) if (GenericRemoteLinuxCustomCommandDeploymentStep * const other = qobject_cast<GenericRemoteLinuxCustomCommandDeploymentStep *>(product))
return new RemoteLinuxCustomCommandDeploymentStep(parent, other); return new GenericRemoteLinuxCustomCommandDeploymentStep(parent, other);
return 0; return 0;
} }

View File

@@ -31,7 +31,6 @@
**************************************************************************/ **************************************************************************/
#include "remotelinuxcustomcommanddeploymentstep.h" #include "remotelinuxcustomcommanddeploymentstep.h"
#include "remotelinuxcustomcommanddeployservice.h"
#include "remotelinuxdeploystepwidget.h" #include "remotelinuxdeploystepwidget.h"
#include <QtCore/QString> #include <QtCore/QString>
@@ -52,7 +51,8 @@ class ConfigWidget : public BuildStepConfigWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
ConfigWidget(RemoteLinuxCustomCommandDeploymentStep *step) : m_step(step), m_widget(step) ConfigWidget(AbstractRemoteLinuxCustomCommandDeploymentStep *step)
: m_step(step), m_widget(step)
{ {
QVBoxLayout * const mainLayout = new QVBoxLayout(this); QVBoxLayout * const mainLayout = new QVBoxLayout(this);
mainLayout->setMargin(0); mainLayout->setMargin(0);
@@ -78,50 +78,55 @@ private:
m_step->setCommandLine(m_commandLineEdit.text().trimmed()); m_step->setCommandLine(m_commandLineEdit.text().trimmed());
} }
RemoteLinuxCustomCommandDeploymentStep * const m_step; AbstractRemoteLinuxCustomCommandDeploymentStep * const m_step;
QLineEdit m_commandLineEdit; QLineEdit m_commandLineEdit;
RemoteLinuxDeployStepWidget m_widget; RemoteLinuxDeployStepWidget m_widget;
}; };
} // anonymous namespace } // anonymous namespace
class RemoteLinuxCustomCommandDeploymentStepPrivate class AbstractRemoteLinuxCustomCommandDeploymentStepPrivate
{ {
public: public:
RemoteLinuxCustomCommandDeployservice service;
QString commandLine; QString commandLine;
}; };
class GenericRemoteLinuxCustomCommandDeploymentStepPrivate
{
public:
RemoteLinuxCustomCommandDeployService service;
};
} // namespace Internal } // namespace Internal
using namespace Internal; using namespace Internal;
RemoteLinuxCustomCommandDeploymentStep::RemoteLinuxCustomCommandDeploymentStep(BuildStepList *bsl) AbstractRemoteLinuxCustomCommandDeploymentStep::AbstractRemoteLinuxCustomCommandDeploymentStep(BuildStepList *bsl,
: AbstractRemoteLinuxDeployStep(bsl, stepId()) const QString &id)
: AbstractRemoteLinuxDeployStep(bsl, id)
{ {
ctor(); ctor();
} }
RemoteLinuxCustomCommandDeploymentStep::RemoteLinuxCustomCommandDeploymentStep(BuildStepList *bsl, AbstractRemoteLinuxCustomCommandDeploymentStep::AbstractRemoteLinuxCustomCommandDeploymentStep(BuildStepList *bsl,
RemoteLinuxCustomCommandDeploymentStep *other) AbstractRemoteLinuxCustomCommandDeploymentStep *other)
: AbstractRemoteLinuxDeployStep(bsl, other) : AbstractRemoteLinuxDeployStep(bsl, other)
{ {
ctor(); ctor();
} }
RemoteLinuxCustomCommandDeploymentStep::~RemoteLinuxCustomCommandDeploymentStep() AbstractRemoteLinuxCustomCommandDeploymentStep::~AbstractRemoteLinuxCustomCommandDeploymentStep()
{ {
delete d; delete d;
} }
void RemoteLinuxCustomCommandDeploymentStep::ctor() void AbstractRemoteLinuxCustomCommandDeploymentStep::ctor()
{ {
d = new RemoteLinuxCustomCommandDeploymentStepPrivate; d = new AbstractRemoteLinuxCustomCommandDeploymentStepPrivate;
setDisplayName(stepDisplayName());
} }
bool RemoteLinuxCustomCommandDeploymentStep::fromMap(const QVariantMap &map) bool AbstractRemoteLinuxCustomCommandDeploymentStep::fromMap(const QVariantMap &map)
{ {
if (!AbstractRemoteLinuxDeployStep::fromMap(map)) if (!AbstractRemoteLinuxDeployStep::fromMap(map))
return false; return false;
@@ -129,45 +134,70 @@ bool RemoteLinuxCustomCommandDeploymentStep::fromMap(const QVariantMap &map)
return true; return true;
} }
QVariantMap RemoteLinuxCustomCommandDeploymentStep::toMap() const QVariantMap AbstractRemoteLinuxCustomCommandDeploymentStep::toMap() const
{ {
QVariantMap map = AbstractRemoteLinuxDeployStep::toMap(); QVariantMap map = AbstractRemoteLinuxDeployStep::toMap();
map.insert(QLatin1String(CommandLineKey), d->commandLine); map.insert(QLatin1String(CommandLineKey), d->commandLine);
return map; return map;
} }
void RemoteLinuxCustomCommandDeploymentStep::setCommandLine(const QString &commandLine) void AbstractRemoteLinuxCustomCommandDeploymentStep::setCommandLine(const QString &commandLine)
{ {
d->commandLine = commandLine; d->commandLine = commandLine;
} }
QString RemoteLinuxCustomCommandDeploymentStep::commandLine() const QString AbstractRemoteLinuxCustomCommandDeploymentStep::commandLine() const
{ {
return d->commandLine; return d->commandLine;
} }
bool RemoteLinuxCustomCommandDeploymentStep::isDeploymentPossible(QString *whyNot) const bool AbstractRemoteLinuxCustomCommandDeploymentStep::isDeploymentPossible(QString *whyNot) const
{ {
d->service.setCommandLine(d->commandLine); deployService()->setCommandLine(d->commandLine);
return AbstractRemoteLinuxDeployStep::isDeploymentPossible(whyNot); return AbstractRemoteLinuxDeployStep::isDeploymentPossible(whyNot);
} }
AbstractRemoteLinuxDeployService *RemoteLinuxCustomCommandDeploymentStep::deployService() const BuildStepConfigWidget *AbstractRemoteLinuxCustomCommandDeploymentStep::createConfigWidget()
{
return &d->service;
}
BuildStepConfigWidget *RemoteLinuxCustomCommandDeploymentStep::createConfigWidget()
{ {
return new ConfigWidget(this); return new ConfigWidget(this);
} }
QString RemoteLinuxCustomCommandDeploymentStep::stepId()
GenericRemoteLinuxCustomCommandDeploymentStep::GenericRemoteLinuxCustomCommandDeploymentStep(BuildStepList *bsl)
: AbstractRemoteLinuxCustomCommandDeploymentStep(bsl, stepId())
{ {
return QLatin1String("RemoteLinuxCustomCommandDeploymentStep"); ctor();
} }
QString RemoteLinuxCustomCommandDeploymentStep::stepDisplayName() GenericRemoteLinuxCustomCommandDeploymentStep::GenericRemoteLinuxCustomCommandDeploymentStep(BuildStepList *bsl,
GenericRemoteLinuxCustomCommandDeploymentStep *other)
: AbstractRemoteLinuxCustomCommandDeploymentStep(bsl, other)
{
ctor();
}
GenericRemoteLinuxCustomCommandDeploymentStep::~GenericRemoteLinuxCustomCommandDeploymentStep()
{
delete d;
}
void GenericRemoteLinuxCustomCommandDeploymentStep::ctor()
{
d = new GenericRemoteLinuxCustomCommandDeploymentStepPrivate;
setDefaultDisplayName(stepDisplayName());
}
RemoteLinuxCustomCommandDeployService *GenericRemoteLinuxCustomCommandDeploymentStep::deployService() const
{
return &d->service;
}
QString GenericRemoteLinuxCustomCommandDeploymentStep::stepId()
{
return QLatin1String("RemoteLinux.GenericRemoteLinuxCustomCommandDeploymentStep");
}
QString GenericRemoteLinuxCustomCommandDeploymentStep::stepDisplayName()
{ {
return tr("Run custom remote command"); return tr("Run custom remote command");
} }

View File

@@ -33,21 +33,21 @@
#define REMOTELINUXCUSTOMCOMMANDDEPLOYMENTSTEP_H #define REMOTELINUXCUSTOMCOMMANDDEPLOYMENTSTEP_H
#include "abstractremotelinuxdeploystep.h" #include "abstractremotelinuxdeploystep.h"
#include "remotelinuxcustomcommanddeployservice.h"
namespace RemoteLinux { namespace RemoteLinux {
namespace Internal { namespace Internal {
class RemoteLinuxCustomCommandDeploymentStepPrivate; class AbstractRemoteLinuxCustomCommandDeploymentStepPrivate;
class GenericRemoteLinuxCustomCommandDeploymentStepPrivate;
} // namespace Internal } // namespace Internal
class REMOTELINUX_EXPORT RemoteLinuxCustomCommandDeploymentStep
class REMOTELINUX_EXPORT AbstractRemoteLinuxCustomCommandDeploymentStep
: public AbstractRemoteLinuxDeployStep : public AbstractRemoteLinuxDeployStep
{ {
Q_OBJECT Q_OBJECT
public: public:
RemoteLinuxCustomCommandDeploymentStep(ProjectExplorer::BuildStepList *bsl); ~AbstractRemoteLinuxCustomCommandDeploymentStep();
RemoteLinuxCustomCommandDeploymentStep(ProjectExplorer::BuildStepList *bsl,
RemoteLinuxCustomCommandDeploymentStep *other);
~RemoteLinuxCustomCommandDeploymentStep();
bool fromMap(const QVariantMap &map); bool fromMap(const QVariantMap &map);
QVariantMap toMap() const; QVariantMap toMap() const;
@@ -55,19 +55,42 @@ public:
void setCommandLine(const QString &commandLine); void setCommandLine(const QString &commandLine);
QString commandLine() const; QString commandLine() const;
static QString stepId();
static QString stepDisplayName();
protected: protected:
AbstractRemoteLinuxCustomCommandDeploymentStep(ProjectExplorer::BuildStepList *bsl,
const QString &id);
AbstractRemoteLinuxCustomCommandDeploymentStep(ProjectExplorer::BuildStepList *bsl,
AbstractRemoteLinuxCustomCommandDeploymentStep *other);
bool isDeploymentPossible(QString *whyNot = 0) const; bool isDeploymentPossible(QString *whyNot = 0) const;
private: private:
void ctor(); void ctor();
AbstractRemoteLinuxDeployService *deployService() const; RemoteLinuxCustomCommandDeployService *deployService() const = 0;
ProjectExplorer::BuildStepConfigWidget *createConfigWidget(); ProjectExplorer::BuildStepConfigWidget *createConfigWidget();
Internal::RemoteLinuxCustomCommandDeploymentStepPrivate *d; Internal::AbstractRemoteLinuxCustomCommandDeploymentStepPrivate *d;
};
class REMOTELINUX_EXPORT GenericRemoteLinuxCustomCommandDeploymentStep
: public AbstractRemoteLinuxCustomCommandDeploymentStep
{
Q_OBJECT
public:
GenericRemoteLinuxCustomCommandDeploymentStep(ProjectExplorer::BuildStepList *bsl);
GenericRemoteLinuxCustomCommandDeploymentStep(ProjectExplorer::BuildStepList *bsl,
GenericRemoteLinuxCustomCommandDeploymentStep *other);
~GenericRemoteLinuxCustomCommandDeploymentStep();
static QString stepId();
static QString stepDisplayName();
private:
RemoteLinuxCustomCommandDeployService *deployService() const;
void ctor();
Internal::GenericRemoteLinuxCustomCommandDeploymentStepPrivate *d;
}; };
} // namespace RemoteLinux } // namespace RemoteLinux

View File

@@ -59,24 +59,24 @@ public:
using namespace Internal; using namespace Internal;
RemoteLinuxCustomCommandDeployservice::RemoteLinuxCustomCommandDeployservice(QObject *parent) RemoteLinuxCustomCommandDeployService::RemoteLinuxCustomCommandDeployService(QObject *parent)
: AbstractRemoteLinuxDeployService(parent), d(new RemoteLinuxCustomCommandDeployservicePrivate) : AbstractRemoteLinuxDeployService(parent), d(new RemoteLinuxCustomCommandDeployservicePrivate)
{ {
} }
RemoteLinuxCustomCommandDeployservice::~RemoteLinuxCustomCommandDeployservice() RemoteLinuxCustomCommandDeployService::~RemoteLinuxCustomCommandDeployService()
{ {
delete d; delete d;
} }
void RemoteLinuxCustomCommandDeployservice::setCommandLine(const QString &commandLine) void RemoteLinuxCustomCommandDeployService::setCommandLine(const QString &commandLine)
{ {
QTC_ASSERT(d->state == Inactive, return); QTC_ASSERT(d->state == Inactive, return);
d->commandLine = commandLine; d->commandLine = commandLine;
} }
bool RemoteLinuxCustomCommandDeployservice::isDeploymentPossible(QString *whyNot) const bool RemoteLinuxCustomCommandDeployService::isDeploymentPossible(QString *whyNot) const
{ {
QTC_ASSERT(d->state == Inactive, return false); QTC_ASSERT(d->state == Inactive, return false);
@@ -91,7 +91,7 @@ bool RemoteLinuxCustomCommandDeployservice::isDeploymentPossible(QString *whyNot
return true; return true;
} }
void RemoteLinuxCustomCommandDeployservice::doDeploy() void RemoteLinuxCustomCommandDeployService::doDeploy()
{ {
QTC_ASSERT(d->state == Inactive, handleDeploymentDone()); QTC_ASSERT(d->state == Inactive, handleDeploymentDone());
@@ -107,7 +107,7 @@ void RemoteLinuxCustomCommandDeployservice::doDeploy()
d->runner->run(d->commandLine.toUtf8()); d->runner->run(d->commandLine.toUtf8());
} }
void RemoteLinuxCustomCommandDeployservice::stopDeployment() void RemoteLinuxCustomCommandDeployService::stopDeployment()
{ {
QTC_ASSERT(d->state == Running, return); QTC_ASSERT(d->state == Running, return);
@@ -118,17 +118,17 @@ void RemoteLinuxCustomCommandDeployservice::stopDeployment()
handleDeploymentDone(); handleDeploymentDone();
} }
void RemoteLinuxCustomCommandDeployservice::handleStdout(const QByteArray &output) void RemoteLinuxCustomCommandDeployService::handleStdout(const QByteArray &output)
{ {
emit stdOutData(QString::fromUtf8(output)); emit stdOutData(QString::fromUtf8(output));
} }
void RemoteLinuxCustomCommandDeployservice::handleStderr(const QByteArray &output) void RemoteLinuxCustomCommandDeployService::handleStderr(const QByteArray &output)
{ {
emit stdErrData(QString::fromUtf8(output)); emit stdErrData(QString::fromUtf8(output));
} }
void RemoteLinuxCustomCommandDeployservice::handleProcessClosed(int exitStatus) void RemoteLinuxCustomCommandDeployService::handleProcessClosed(int exitStatus)
{ {
QTC_ASSERT(d->state == Running, return); QTC_ASSERT(d->state == Running, return);

View File

@@ -39,13 +39,13 @@ namespace Internal {
class RemoteLinuxCustomCommandDeployservicePrivate; class RemoteLinuxCustomCommandDeployservicePrivate;
} // namespace Internal } // namespace Internal
class REMOTELINUX_EXPORT RemoteLinuxCustomCommandDeployservice class REMOTELINUX_EXPORT RemoteLinuxCustomCommandDeployService
: public AbstractRemoteLinuxDeployService : public AbstractRemoteLinuxDeployService
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit RemoteLinuxCustomCommandDeployservice(QObject *parent = 0); explicit RemoteLinuxCustomCommandDeployService(QObject *parent = 0);
~RemoteLinuxCustomCommandDeployservice(); ~RemoteLinuxCustomCommandDeployService();
void setCommandLine(const QString &commandLine); void setCommandLine(const QString &commandLine);