1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
10 ** GNU Lesser General Public License Usage
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
15 ** Please review the following information to ensure the GNU Lesser General
16 ** Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
25 ** Alternatively, this file may be used in accordance with the terms and
26 ** conditions contained in a signed written agreement between you and Nokia.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at info@qt.nokia.com.
31 **************************************************************************/
32 #include "abstractremotelinuxdeploystep.h"
34 #include "abstractremotelinuxdeployservice.h"
35 #include "maemodeploystepwidget.h"
36 #include "remotelinuxdeployconfiguration.h"
38 #include <projectexplorer/projectexplorerconstants.h>
39 #include <qt4projectmanager/qt4buildconfiguration.h>
41 using namespace ProjectExplorer;
43 namespace RemoteLinux {
46 class AbstractRemoteLinuxDeployStepPrivate
50 QFutureInterface<bool> future;
53 } // namespace Internal
55 AbstractRemoteLinuxDeployStep::AbstractRemoteLinuxDeployStep(BuildStepList *bsl, const QString &id)
56 : BuildStep(bsl, id), m_d(new Internal::AbstractRemoteLinuxDeployStepPrivate)
60 AbstractRemoteLinuxDeployStep::AbstractRemoteLinuxDeployStep(BuildStepList *bsl,
61 AbstractRemoteLinuxDeployStep *other)
62 : BuildStep(bsl, other), m_d(new Internal::AbstractRemoteLinuxDeployStepPrivate)
66 bool AbstractRemoteLinuxDeployStep::fromMap(const QVariantMap &map)
68 if (!BuildStep::fromMap(map))
70 deployService()->importDeployTimes(map);
74 QVariantMap AbstractRemoteLinuxDeployStep::toMap() const
76 return BuildStep::toMap().unite(deployService()->exportDeployTimes());
79 bool AbstractRemoteLinuxDeployStep::init()
81 return isDeploymentPossible();
84 bool AbstractRemoteLinuxDeployStep::isDeploymentPossible(QString *whyNot) const
86 deployService()->setDeviceConfiguration(deployConfiguration()->deviceConfiguration());
87 deployService()->setBuildConfiguration(qobject_cast<Qt4ProjectManager::Qt4BuildConfiguration *>(buildConfiguration()));
88 return deployService()->isDeploymentPossible(whyNot);
91 void AbstractRemoteLinuxDeployStep::run(QFutureInterface<bool> &fi)
93 connect(deployService(), SIGNAL(errorMessage(QString)), SLOT(handleErrorMessage(QString)));
94 connect(deployService(), SIGNAL(progressMessage(QString)), SLOT(handleProgressMessage(QString)));
95 connect(deployService(), SIGNAL(stdOutData(QString)), SLOT(handleStdOutData(QString)));
96 connect(deployService(), SIGNAL(stdErrData(QString)), SLOT(handleStdErrData(QString)));
97 connect(deployService(), SIGNAL(finished()), SLOT(handleFinished()));
99 m_d->hasError = false;
101 deployService()->start();
104 void AbstractRemoteLinuxDeployStep::cancel()
109 emit addOutput(tr("User requests deployment to stop; cleaning up."), MessageOutput);
110 m_d->hasError = true;
111 deployService()->stop();
114 BuildStepConfigWidget *AbstractRemoteLinuxDeployStep::createConfigWidget()
116 return new Internal::MaemoDeployStepBaseWidget(this);
119 RemoteLinuxDeployConfiguration *AbstractRemoteLinuxDeployStep::deployConfiguration() const
121 return qobject_cast<RemoteLinuxDeployConfiguration *>(BuildStep::deployConfiguration());
124 void AbstractRemoteLinuxDeployStep::handleProgressMessage(const QString &message)
126 emit addOutput(message, MessageOutput);
129 void AbstractRemoteLinuxDeployStep::handleErrorMessage(const QString &message)
131 emit addTask(Task(Task::Error, message, QString(), -1,
132 ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM));
133 m_d->hasError = true;
136 void AbstractRemoteLinuxDeployStep::handleFinished()
139 emit addOutput(tr("Deployment failed."), ErrorMessageOutput);
141 emit addOutput(tr("Deployment finished."), MessageOutput);
142 disconnect(deployService(), 0, this, 0);
143 m_d->future.reportResult(!m_d->hasError);
147 void AbstractRemoteLinuxDeployStep::handleStdOutData(const QString &data)
149 emit addOutput(data, NormalOutput, DontAppendNewline);
152 void AbstractRemoteLinuxDeployStep::handleStdErrData(const QString &data)
154 emit addOutput(data, ErrorOutput, DontAppendNewline);
157 } // namespace RemoteLinux