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 qt-info@nokia.com.
31 **************************************************************************/
33 #include "s60runcontrolbase.h"
35 #include "s60deployconfiguration.h"
36 #include "s60devicerunconfiguration.h"
38 #include "qt4buildconfiguration.h"
39 #include "qt4symbiantarget.h"
40 #include "qt4target.h"
41 #include "qtoutputformatter.h"
43 #include <utils/qtcassert.h>
45 #include <coreplugin/icore.h>
46 #include <coreplugin/progressmanager/progressmanager.h>
48 #include <QtCore/QDateTime>
49 #include <QtCore/QDir>
50 #include <QtCore/QFileInfo>
52 using namespace ProjectExplorer;
53 using namespace Qt4ProjectManager;
54 using namespace Qt4ProjectManager::Internal;
56 const int PROGRESS_MIN = 0;
57 const int PROGRESS_MAX = 200;
61 // Format information about a file
62 QString S60RunControlBase::msgListFile(const QString &file)
65 const QFileInfo fi(file);
68 str << fi.size() << ' ' << fi.lastModified().toString(Qt::ISODate) << ' ' << QDir::toNativeSeparators(fi.absoluteFilePath());
70 str << "<non-existent> " << QDir::toNativeSeparators(fi.absoluteFilePath());
74 S60RunControlBase::S60RunControlBase(RunConfiguration *runConfiguration, const QString &mode) :
75 RunControl(runConfiguration, mode),
78 connect(this, SIGNAL(finished()), this, SLOT(reportLaunchFinished()));
79 connect(this, SIGNAL(finished()), this, SLOT(handleFinished()));
81 const S60DeviceRunConfiguration *s60runConfig = qobject_cast<S60DeviceRunConfiguration *>(runConfiguration);
82 QTC_ASSERT(s60runConfig, return);
83 const Qt4BuildConfiguration *activeBuildConf = s60runConfig->qt4Target()->activeBuildConfiguration();
84 QTC_ASSERT(activeBuildConf, return);
85 const S60DeployConfiguration *activeDeployConf = qobject_cast<S60DeployConfiguration *>(s60runConfig->qt4Target()->activeDeployConfiguration());
86 QTC_ASSERT(activeDeployConf, return);
88 m_executableUid = s60runConfig->executableUid();
89 m_targetName = s60runConfig->targetName();
90 m_commandLineArguments = s60runConfig->commandLineArguments();
91 m_qtDir = activeBuildConf->qtVersion()->versionInfo().value("QT_INSTALL_DATA");
92 m_installationDrive = activeDeployConf->installationDrive();
93 if (const QtVersion *qtv = activeDeployConf->qtVersion())
94 m_qtBinPath = qtv->versionInfo().value(QLatin1String("QT_INSTALL_BINS"));
95 QTC_ASSERT(!m_qtBinPath.isEmpty(), return);
96 m_executableFileName = s60runConfig->localExecutableFileName();
97 m_runSmartInstaller = activeDeployConf->runSmartInstaller();
100 qDebug() << "S60RunControlBase::CT" << m_targetName;
103 void S60RunControlBase::start()
105 QTC_ASSERT(!m_launchProgress, return);
107 m_launchProgress = new QFutureInterface<void>;
108 Core::ICore::instance()->progressManager()->addTask(m_launchProgress->future(),
110 QLatin1String("Symbian.Launch"));
111 m_launchProgress->setProgressRange(PROGRESS_MIN, PROGRESS_MAX);
112 m_launchProgress->setProgressValue(PROGRESS_MIN);
113 m_launchProgress->reportStarted();
115 if (m_runSmartInstaller) { //Smart Installer does the running by itself
117 appendMessage(tr("Please finalise the installation on your device."), NormalMessageFormat);
130 S60RunControlBase::~S60RunControlBase()
132 if (m_launchProgress) {
133 m_launchProgress->reportFinished();
134 delete m_launchProgress;
135 m_launchProgress = 0;
139 RunControl::StopResult S60RunControlBase::stop()
142 return AsynchronousStop;
145 bool S60RunControlBase::promptToStop(bool *optionalPrompt) const
147 Q_UNUSED(optionalPrompt)
148 // We override the settings prompt
149 QTC_ASSERT(isRunning(), return true;)
151 const QString question = tr("<html><head/><body><center><i>%1</i> is still running on the device.</center>"
152 "<center>Terminating it can leave the target in an inconsistent state.</center>"
153 "<center>Would you still like to terminate it?</center></body></html>").arg(displayName());
154 return showPromptToStopDialog(tr("Application Still Running"), question,
155 tr("Force Quit"), tr("Keep Running"));
158 void S60RunControlBase::startLaunching()
161 setProgress(maxProgress()*0.30);
168 void S60RunControlBase::handleFinished()
170 appendMessage(tr("Finished."), NormalMessageFormat);
173 void S60RunControlBase::setProgress(int value)
175 if (m_launchProgress) {
176 if (value < PROGRESS_MAX) {
177 if (value < PROGRESS_MIN)
178 m_launchProgress->setProgressValue(PROGRESS_MIN);
180 m_launchProgress->setProgressValue(value);
182 m_launchProgress->setProgressValue(PROGRESS_MAX);
183 m_launchProgress->reportFinished();
184 delete m_launchProgress;
185 m_launchProgress = 0;
190 void S60RunControlBase::cancelProgress()
192 if (m_launchProgress) {
193 m_launchProgress->reportCanceled();
194 m_launchProgress->reportFinished();
196 delete m_launchProgress;
197 m_launchProgress = 0;
200 int S60RunControlBase::maxProgress() const
205 void S60RunControlBase::reportLaunchFinished()
207 setProgress(maxProgress());
210 quint32 S60RunControlBase::executableUid() const
212 return m_executableUid;
215 QString S60RunControlBase::executableName() const
217 return QString::fromLatin1("%1.exe").arg(targetName());
220 const QString &S60RunControlBase::targetName() const
225 const QString &S60RunControlBase::commandLineArguments() const
227 return m_commandLineArguments;
230 const QString &S60RunControlBase::executableFileName() const
232 return m_executableFileName;
235 const QString &S60RunControlBase::qtDir() const
240 const QString &S60RunControlBase::qtBinPath() const
245 bool S60RunControlBase::runSmartInstaller() const
247 return m_runSmartInstaller;
250 char S60RunControlBase::installationDrive() const
252 return m_installationDrive;