2011-07-07 10:43:59 +02:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2012-01-26 18:33:46 +01:00
|
|
|
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
2011-07-07 10:43:59 +02:00
|
|
|
**
|
2011-11-02 15:59:12 +01:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2011-07-07 10:43:59 +02:00
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
** 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
|
2011-11-02 15:59:12 +01:00
|
|
|
** Nokia at qt-info@nokia.com.
|
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>
|
2011-10-21 13:06:26 +00:00
|
|
|
#include <projectexplorer/target.h>
|
2011-07-07 10:43:59 +02:00
|
|
|
#include <qt4projectmanager/qt4buildconfiguration.h>
|
|
|
|
|
|
|
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
|
|
|
|
|
namespace RemoteLinux {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
class AbstractRemoteLinuxDeployStepPrivate
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
bool hasError;
|
|
|
|
|
QFutureInterface<bool> future;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
|
|
|
|
|
AbstractRemoteLinuxDeployStep::AbstractRemoteLinuxDeployStep(BuildStepList *bsl, const QString &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
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
2011-11-22 18:17:07 +01:00
|
|
|
deployService()->setDeviceConfiguration(deployConfiguration()->deviceConfiguration());
|
|
|
|
|
deployService()->setBuildConfiguration(qobject_cast<Qt4ProjectManager::Qt4BuildConfiguration *>(target()->activeBuildConfiguration()));
|
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);
|
2011-07-07 10:43:59 +02:00
|
|
|
emit addTask(Task(Task::Error, message, QString(), -1,
|
|
|
|
|
ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM));
|
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);
|
|
|
|
|
emit addTask(Task(Task::Warning, message, QString(), -1,
|
|
|
|
|
ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM));
|
|
|
|
|
}
|
|
|
|
|
|
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
|