2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2011-07-07 10:43:59 +02:00
|
|
|
**
|
2014-01-07 13:27:11 +01:00
|
|
|
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
2011-07-07 10:43:59 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2011-07-07 10:43:59 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Digia. For licensing terms and
|
|
|
|
|
** conditions see http://qt.digia.com/licensing. For further information
|
|
|
|
|
** use the contact form at http://qt.digia.com/contact-us.
|
2011-07-07 10:43:59 +02:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, 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, Digia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
2011-07-07 10:43:59 +02:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2012-07-25 17:41:01 +02:00
|
|
|
|
2011-07-07 10:43:59 +02:00
|
|
|
#include "abstractremotelinuxdeploystep.h"
|
|
|
|
|
|
|
|
|
|
#include "abstractremotelinuxdeployservice.h"
|
2011-07-15 16:57:25 +02:00
|
|
|
#include "remotelinuxdeployconfiguration.h"
|
2011-07-07 10:43:59 +02:00
|
|
|
|
|
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
2012-09-03 18:31:44 +02:00
|
|
|
#include <projectexplorer/kitinformation.h>
|
2011-07-07 10:43:59 +02:00
|
|
|
|
|
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
|
|
|
|
|
namespace RemoteLinux {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
class AbstractRemoteLinuxDeployStepPrivate
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
bool hasError;
|
|
|
|
|
QFutureInterface<bool> future;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
|
2012-03-15 17:17:40 +01:00
|
|
|
AbstractRemoteLinuxDeployStep::AbstractRemoteLinuxDeployStep(BuildStepList *bsl, const Core::Id id)
|
2011-09-16 11:33:48 +02:00
|
|
|
: BuildStep(bsl, id), d(new Internal::AbstractRemoteLinuxDeployStepPrivate)
|
2011-07-07 10:43:59 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AbstractRemoteLinuxDeployStep::AbstractRemoteLinuxDeployStep(BuildStepList *bsl,
|
|
|
|
|
AbstractRemoteLinuxDeployStep *other)
|
2011-09-16 11:33:48 +02:00
|
|
|
: BuildStep(bsl, other), d(new Internal::AbstractRemoteLinuxDeployStepPrivate)
|
2011-07-07 10:43:59 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2012-07-13 12:44:01 +02:00
|
|
|
AbstractRemoteLinuxDeployStep::~AbstractRemoteLinuxDeployStep()
|
|
|
|
|
{
|
|
|
|
|
delete d;
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-07 10:43:59 +02:00
|
|
|
bool AbstractRemoteLinuxDeployStep::fromMap(const QVariantMap &map)
|
|
|
|
|
{
|
|
|
|
|
if (!BuildStep::fromMap(map))
|
|
|
|
|
return false;
|
|
|
|
|
deployService()->importDeployTimes(map);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariantMap AbstractRemoteLinuxDeployStep::toMap() const
|
|
|
|
|
{
|
|
|
|
|
return BuildStep::toMap().unite(deployService()->exportDeployTimes());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool AbstractRemoteLinuxDeployStep::init()
|
|
|
|
|
{
|
2011-09-22 17:37:05 +02:00
|
|
|
QString error;
|
2012-12-06 19:21:19 +01:00
|
|
|
deployService()->setTarget(target());
|
2011-11-23 11:55:38 +01:00
|
|
|
const bool canDeploy = initInternal(&error);
|
2011-09-22 17:37:05 +02:00
|
|
|
if (!canDeploy)
|
2012-01-24 15:40:45 +01:00
|
|
|
emit addOutput(tr("Cannot deploy: %1").arg(error), ErrorMessageOutput);
|
2011-09-22 17:37:05 +02:00
|
|
|
return canDeploy;
|
2011-07-07 10:43:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AbstractRemoteLinuxDeployStep::run(QFutureInterface<bool> &fi)
|
|
|
|
|
{
|
|
|
|
|
connect(deployService(), SIGNAL(errorMessage(QString)), SLOT(handleErrorMessage(QString)));
|
2011-09-29 15:00:15 +02:00
|
|
|
connect(deployService(), SIGNAL(progressMessage(QString)),
|
|
|
|
|
SLOT(handleProgressMessage(QString)));
|
|
|
|
|
connect(deployService(), SIGNAL(warningMessage(QString)), SLOT(handleWarningMessage(QString)));
|
2011-07-07 10:43:59 +02:00
|
|
|
connect(deployService(), SIGNAL(stdOutData(QString)), SLOT(handleStdOutData(QString)));
|
|
|
|
|
connect(deployService(), SIGNAL(stdErrData(QString)), SLOT(handleStdErrData(QString)));
|
|
|
|
|
connect(deployService(), SIGNAL(finished()), SLOT(handleFinished()));
|
|
|
|
|
|
2011-09-16 11:33:48 +02:00
|
|
|
d->hasError = false;
|
|
|
|
|
d->future = fi;
|
2011-07-07 10:43:59 +02:00
|
|
|
deployService()->start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AbstractRemoteLinuxDeployStep::cancel()
|
|
|
|
|
{
|
2011-09-16 11:33:48 +02:00
|
|
|
if (d->hasError)
|
2011-07-07 10:43:59 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
emit addOutput(tr("User requests deployment to stop; cleaning up."), MessageOutput);
|
2011-09-16 11:33:48 +02:00
|
|
|
d->hasError = true;
|
2011-07-07 10:43:59 +02:00
|
|
|
deployService()->stop();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BuildStepConfigWidget *AbstractRemoteLinuxDeployStep::createConfigWidget()
|
|
|
|
|
{
|
2012-01-09 16:23:40 +01:00
|
|
|
return new SimpleBuildStepConfigWidget(this);
|
2011-07-07 10:43:59 +02:00
|
|
|
}
|
|
|
|
|
|
2011-07-14 15:38:16 +02:00
|
|
|
RemoteLinuxDeployConfiguration *AbstractRemoteLinuxDeployStep::deployConfiguration() const
|
2011-07-07 10:43:59 +02:00
|
|
|
{
|
2011-07-14 15:38:16 +02:00
|
|
|
return qobject_cast<RemoteLinuxDeployConfiguration *>(BuildStep::deployConfiguration());
|
2011-07-07 10:43:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AbstractRemoteLinuxDeployStep::handleProgressMessage(const QString &message)
|
|
|
|
|
{
|
|
|
|
|
emit addOutput(message, MessageOutput);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AbstractRemoteLinuxDeployStep::handleErrorMessage(const QString &message)
|
|
|
|
|
{
|
2011-09-29 15:00:15 +02:00
|
|
|
emit addOutput(message, ErrorMessageOutput);
|
2012-01-26 13:38:25 +01:00
|
|
|
emit addTask(Task(Task::Error, message, Utils::FileName(), -1,
|
2013-08-19 15:35:14 +02:00
|
|
|
Constants::TASK_CATEGORY_DEPLOYMENT));
|
2011-09-16 11:33:48 +02:00
|
|
|
d->hasError = true;
|
2011-07-07 10:43:59 +02:00
|
|
|
}
|
|
|
|
|
|
2011-09-29 15:00:15 +02:00
|
|
|
void AbstractRemoteLinuxDeployStep::handleWarningMessage(const QString &message)
|
|
|
|
|
{
|
|
|
|
|
emit addOutput(message, ErrorMessageOutput);
|
2012-01-26 13:38:25 +01:00
|
|
|
emit addTask(Task(Task::Warning, message, Utils::FileName(), -1,
|
2013-08-19 15:35:14 +02:00
|
|
|
Constants::TASK_CATEGORY_DEPLOYMENT));
|
2011-09-29 15:00:15 +02:00
|
|
|
}
|
|
|
|
|
|
2011-07-07 10:43:59 +02:00
|
|
|
void AbstractRemoteLinuxDeployStep::handleFinished()
|
|
|
|
|
{
|
2011-09-16 11:33:48 +02:00
|
|
|
if (d->hasError)
|
2011-09-09 17:06:15 +02:00
|
|
|
emit addOutput(tr("Deploy step failed."), ErrorMessageOutput);
|
2011-07-07 10:43:59 +02:00
|
|
|
else
|
2011-09-09 17:06:15 +02:00
|
|
|
emit addOutput(tr("Deploy step finished."), MessageOutput);
|
2011-07-07 10:43:59 +02:00
|
|
|
disconnect(deployService(), 0, this, 0);
|
2011-09-16 11:33:48 +02:00
|
|
|
d->future.reportResult(!d->hasError);
|
2011-07-07 10:43:59 +02:00
|
|
|
emit finished();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AbstractRemoteLinuxDeployStep::handleStdOutData(const QString &data)
|
|
|
|
|
{
|
|
|
|
|
emit addOutput(data, NormalOutput, DontAppendNewline);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AbstractRemoteLinuxDeployStep::handleStdErrData(const QString &data)
|
|
|
|
|
{
|
|
|
|
|
emit addOutput(data, ErrorOutput, DontAppendNewline);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace RemoteLinux
|