Refactor deployment for Symbian OS

* Add buildstep to handle the deployment
 * Remove deployment code from the runconfiguration
 * Update .user files to add new deployment step into existing setups

Reviewed-by: Tobias Hunger
This commit is contained in:
Pawel Polanski
2010-07-15 13:58:18 +02:00
parent cd09e24cef
commit 647b91c78f
9 changed files with 750 additions and 149 deletions

View File

@@ -167,6 +167,23 @@ public:
QVariantMap update(Project *project, const QVariantMap &map);
};
// Version 5 reflects the introduction of new deploy steps for Symbian/Maemo
class Version5Handler : public UserFileVersionHandler
{
public:
int userFileVersion() const
{
return 5;
}
QString displayUserFileVersion() const
{
return QLatin1String("2.2pre2");
}
QVariantMap update(Project *project, const QVariantMap &map);
};
//
// Helper functions:
//
@@ -238,6 +255,7 @@ UserFileAccessor::UserFileAccessor() :
addVersionHandler(new Version2Handler);
addVersionHandler(new Version3Handler);
addVersionHandler(new Version4Handler);
addVersionHandler(new Version5Handler);
}
UserFileAccessor::~UserFileAccessor()
@@ -1108,3 +1126,65 @@ QVariantMap Version4Handler::update(Project *, const QVariantMap &map)
}
return result;
}
// -------------------------------------------------------------------------
// Version5Handler
// -------------------------------------------------------------------------
// Move packaging steps from build steps into deploy steps
QVariantMap Version5Handler::update(Project *, const QVariantMap &map)
{
QVariantMap result;
QMapIterator<QString, QVariant> it(map);
while (it.hasNext()) {
it.next();
const QString &globalKey = it.key();
// check for target info
if (!globalKey.startsWith(QLatin1String("ProjectExplorer.Project.Target."))) {
result.insert(globalKey, it.value());
continue;
}
const QVariantMap &originalTarget = it.value().toMap();
// check for symbian and maemo device target
if (originalTarget.value(QLatin1String("ProjectExplorer.ProjectConfiguration.Id"))
!= QLatin1String("Qt4ProjectManager.Target.S60DeviceTarget")
&& originalTarget.value(QLatin1String("ProjectExplorer.ProjectConfiguration.Id"))
!= QLatin1String("Qt4ProjectManager.Target.MaemoDeviceTarget")) {
result.insert(globalKey, originalTarget);
continue;
}
QVariantMap newTarget;
QMapIterator<QString, QVariant> targetIt(originalTarget);
while (targetIt.hasNext()) {
targetIt.next();
const QString &targetKey = targetIt.key();
if (!targetKey.startsWith(QLatin1String("ProjectExplorer.Target.BuildConfiguration."))) {
newTarget.insert(targetKey, targetIt.value());
continue;
}
const QVariantMap &originalBc = targetIt.value().toMap();
QVariantMap newBc = originalBc;
QVariantMap newDeployStep;
if (originalTarget.value(QLatin1String("ProjectExplorer.ProjectConfiguration.Id"))
== QLatin1String("Qt4ProjectManager.Target.S60DeviceTarget")) {
newDeployStep.insert(QLatin1String("ProjectExplorer.ProjectConfiguration.Id"),
QLatin1String("Qt4ProjectManager.S60DeployStep"));
} else {
newDeployStep.insert(QLatin1String("ProjectExplorer.ProjectConfiguration.Id"),
QLatin1String("Qt4ProjectManager.MaemoDeployStep"));
}
int deployCount = newBc.value(QLatin1String("ProjectExplorer.BuildConfiguration.DeployStepsCount"), 0).toInt();
newBc.insert(QString::fromLatin1("ProjectExplorer.BuildConfiguration.DeployStep.") + QString::number(deployCount),
newDeployStep);
newBc.insert(QLatin1String("ProjectExplorer.BuildConfiguration.DeployStepsCount"), deployCount + 1);
newTarget.insert(targetKey, newBc);
}
result.insert(globalKey, newTarget);
}
return result;
}

View File

@@ -58,7 +58,6 @@ namespace Internal {
const QLatin1String MaemoDeployStep::Id("Qt4ProjectManager.MaemoDeployStep");
MaemoDeployStep::MaemoDeployStep(ProjectExplorer::BuildConfiguration *bc)
: BuildStep(bc, Id), m_deployables(new MaemoDeployables(this))
{

View File

@@ -15,7 +15,8 @@ SOURCES += $$PWD/s60devices.cpp \
$$PWD/abldparser.cpp \
$$PWD/rvctparser.cpp \
$$PWD/winscwparser.cpp \
qt-s60/s60createpackagestep.cpp
qt-s60/s60createpackagestep.cpp \
qt-s60/s60deploystep.cpp
HEADERS += $$PWD/s60devices.h \
$$PWD/s60devicespreferencepane.h \
$$PWD/s60manager.h \
@@ -30,6 +31,7 @@ HEADERS += $$PWD/s60devices.h \
$$PWD/abldparser.h \
$$PWD/rvctparser.h \
$$PWD/winscwparser.h \
qt-s60/s60createpackagestep.h
qt-s60/s60createpackagestep.h \
qt-s60/s60deploystep.h
FORMS += $$PWD/s60devicespreferencepane.ui \
qt-s60/s60createpackagestep.ui

View File

@@ -0,0 +1,489 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** 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.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#include "S60deployStep.h"
#include "qt4buildconfiguration.h"
#include "s60devicerunconfiguration.h"
#include "symbiandevicemanager.h"
#include "s60runconfigbluetoothstarter.h"
#include <QtGui/QMessageBox>
#include <QtGui/QMainWindow>
#include <QtCore/QCoreApplication>
#include <QtCore/QTimer>
#include <QDateTime>
#include <QFile>
#include <QFileInfo>
#include <QDir>
#include <coreplugin/icore.h>
#include <projectexplorer/buildconfiguration.h>
#include <projectexplorer/target.h>
#include <projectexplorer/ioutputparser.h>
#include <qt4projectmanagerconstants.h>
using namespace ProjectExplorer;
using namespace Qt4ProjectManager::Internal;
namespace {
const char * const S60_DEPLOY_STEP_ID = "Qt4ProjectManager.S60DeployStep";
}
static inline bool ensureDeleteFile(const QString &fileName, QString *errorMessage)
{
QFile file(fileName);
if (file.exists() && !file.remove()) {
*errorMessage = S60DeployStep::tr("Unable to remove existing file '%1': %2").arg(fileName, file.errorString());
return false;
}
return true;
}
static inline bool renameFile(const QString &sourceName, const QString &targetName,
QString *errorMessage)
{
if (sourceName == targetName)
return true;
if (!ensureDeleteFile(targetName, errorMessage))
return false;
QFile source(sourceName);
if (!source.rename(targetName)) {
*errorMessage = S60DeployStep::tr("Unable to rename file '%1' to '%2': %3")
.arg(sourceName, targetName, source.errorString());
return false;
}
return true;
}
// #pragma mark -- S60DeployStep
S60DeployStep::S60DeployStep(ProjectExplorer::BuildConfiguration *bc, const QString &id) :
BuildStep(bc, id), m_timer(0), m_launcher(0),
m_releaseDeviceAfterLauncherFinish(true), m_handleDeviceRemoval(true),
m_eventLoop(0)
{
}
S60DeployStep::S60DeployStep(ProjectExplorer::BuildConfiguration *bc,
S60DeployStep *bs):
BuildStep(bc, bs), m_timer(0), m_launcher(0),
m_releaseDeviceAfterLauncherFinish(bs->m_releaseDeviceAfterLauncherFinish),
m_handleDeviceRemoval(bs->m_handleDeviceRemoval),
m_eventLoop(0)
{
}
S60DeployStep::S60DeployStep(ProjectExplorer::BuildConfiguration *bc):
BuildStep(bc, QLatin1String(S60_DEPLOY_STEP_ID)), m_timer(0),
m_launcher(0), m_releaseDeviceAfterLauncherFinish(true),
m_handleDeviceRemoval(true), m_eventLoop(0)
{
}
S60DeployStep::~S60DeployStep()
{
delete m_timer;
delete m_launcher;
delete m_eventLoop;
}
bool S60DeployStep::init()
{
Qt4BuildConfiguration *bc = static_cast<Qt4BuildConfiguration *>(buildConfiguration());
S60DeviceRunConfiguration* runConfiguration = static_cast<S60DeviceRunConfiguration *>(bc->target()->activeRunConfiguration());
if(!runConfiguration) {
return false;
}
m_serialPortName = runConfiguration->serialPortName();
m_serialPortFriendlyName = SymbianUtils::SymbianDeviceManager::instance()->friendlyNameForPort(m_serialPortName);
m_packageFileNameWithTarget = runConfiguration->packageFileNameWithTargetInfo();
m_signedPackage = runConfiguration->signedPackage();
setDisplayName(tr("Deploy", "Qt4 DeployStep display name."));
QString message;
m_launcher = trk::Launcher::acquireFromDeviceManager(m_serialPortName, this, &message);
if (!message.isEmpty()) {
trk::Launcher::releaseToDeviceManager(m_launcher);
delete m_launcher;
m_launcher = 0;
appendMessage(message, true);
return false;
}
return true;
}
QVariantMap S60DeployStep::toMap() const
{
return BuildStep::toMap();
}
bool S60DeployStep::fromMap(const QVariantMap &map)
{
return BuildStep::fromMap(map);
}
void S60DeployStep::appendMessage(const QString &error, bool isError)
{
emit addOutput(error, isError?ProjectExplorer::BuildStep::ErrorMessageOutput:
ProjectExplorer::BuildStep::MessageOutput);
}
bool S60DeployStep::processPackageName(QString &errorMessage)
{
QFileInfo packageInfo(m_signedPackage);
{
// support for 4.6.1 and pre, where make sis creates 'targetname_armX_udeb.sis' instead of 'targetname.sis'
QFileInfo packageWithTargetInfo(m_packageFileNameWithTarget);
// does the 4.6.1 version exist?
if (packageWithTargetInfo.exists() && packageWithTargetInfo.isFile()) {
// is the 4.6.1 version newer? (to guard against behavior change Qt Creator 1.3 --> 2.0)
if (!packageInfo.exists() || packageInfo.lastModified() < packageWithTargetInfo.lastModified()) { //TODO change the QtCore
// the 'targetname_armX_udeb.sis' crap exists and is new, rename it
appendMessage(tr("Renaming new package '%1' to '%2'")
.arg(QDir::toNativeSeparators(m_packageFileNameWithTarget),
QDir::toNativeSeparators(m_signedPackage)), false);
return renameFile(m_packageFileNameWithTarget, m_signedPackage, &errorMessage);
} else {
// the 'targetname_armX_udeb.sis' crap exists but is old, remove it
appendMessage(tr("Removing old package '%1'")
.arg(QDir::toNativeSeparators(m_packageFileNameWithTarget)),
false);
ensureDeleteFile(m_packageFileNameWithTarget, &errorMessage);
}
}
}
if (!packageInfo.exists() || !packageInfo.isFile()) {
errorMessage = tr("Package file not found");
return false;
}
return true;
}
void S60DeployStep::start()
{
if (m_serialPortName.isEmpty()) {
appendMessage(tr("There is no device plugged in."), true);
emit finished();
return;
}
QString errorMessage;
// make sure we have the right name of the sis package
if (processPackageName(errorMessage)) {
startDeployment();
} else {
errorMessage = tr("Failed to find package '%1': %2").arg(m_signedPackage, errorMessage);
appendMessage(errorMessage, true);
stop();
emit finished();
}
}
void S60DeployStep::stop()
{
if (m_launcher)
m_launcher->terminate();
emit finished();
}
void S60DeployStep::setupConnections()
{
connect(SymbianUtils::SymbianDeviceManager::instance(), SIGNAL(deviceRemoved(SymbianUtils::SymbianDevice)),
this, SLOT(deviceRemoved(SymbianUtils::SymbianDevice)));
connect(m_launcher, SIGNAL(finished()), this, SLOT(launcherFinished()));
connect(m_launcher, SIGNAL(canNotConnect(QString)), this, SLOT(printConnectFailed(QString)));
connect(m_launcher, SIGNAL(copyingStarted()), this, SLOT(printCopyingNotice()));
connect(m_launcher, SIGNAL(canNotCreateFile(QString,QString)), this, SLOT(printCreateFileFailed(QString,QString)));
connect(m_launcher, SIGNAL(canNotWriteFile(QString,QString)), this, SLOT(printWriteFileFailed(QString,QString)));
connect(m_launcher, SIGNAL(canNotCloseFile(QString,QString)), this, SLOT(printCloseFileFailed(QString,QString)));
connect(m_launcher, SIGNAL(installingStarted()), this, SLOT(printInstallingNotice()));
connect(m_launcher, SIGNAL(canNotInstall(QString,QString)), this, SLOT(printInstallFailed(QString,QString)));
connect(m_launcher, SIGNAL(installingFinished()), this, SLOT(printInstallingFinished()));
connect(m_launcher, SIGNAL(stateChanged(int)), this, SLOT(slotLauncherStateChanged(int)));
}
void S60DeployStep::startDeployment()
{
Q_ASSERT(m_launcher);
QString errorMessage;
bool success = false;
do {
setupConnections();
//TODO sisx destination and file path user definable
const QString copyDst = QString::fromLatin1("C:\\Data\\%1").arg(QFileInfo(m_signedPackage).fileName());
m_launcher->setCopyFileName(m_signedPackage, copyDst);
m_launcher->setInstallFileName(copyDst);
m_launcher->addStartupActions(trk::Launcher::ActionCopyInstall);
appendMessage(tr("Package: %1\nDeploying application to '%2'...").arg(m_signedPackage, m_serialPortFriendlyName), false);
// Prompt the user to start up the Blue tooth connection
const trk::PromptStartCommunicationResult src =
S60RunConfigBluetoothStarter::startCommunication(m_launcher->trkDevice(),
0, &errorMessage);
if (src != trk::PromptStartCommunicationConnected)
break;
if (!m_launcher->startServer(&errorMessage)) {
errorMessage = tr("Could not connect to phone on port '%1': %2\n"
"Check if the phone is connected and App TRK is running.").arg(m_serialPortName, errorMessage);
break;
}
success = true;
} while (false);
if (!success) {
if (!errorMessage.isEmpty())
appendMessage(errorMessage, true);
stop();
emit finished();
}
}
void S60DeployStep::run(QFutureInterface<bool> &fi)
{
m_futureInterface = &fi;
m_deployResult = false;
connect(this, SIGNAL(finished()),
this, SLOT(launcherFinished()));
connect(this, SIGNAL(finishNow()),
this, SLOT(launcherFinished()), Qt::DirectConnection);
start();
m_timer = new QTimer();
connect(m_timer, SIGNAL(timeout()), this, SLOT(checkForCancel()), Qt::DirectConnection);
m_timer->start(500);
m_eventLoop = new QEventLoop();
m_eventLoop->exec();
m_timer->stop();
delete m_timer;
m_timer = 0;
delete m_eventLoop;
m_eventLoop = 0;
fi.reportResult(m_deployResult);
m_futureInterface = 0;
}
void S60DeployStep::setReleaseDeviceAfterLauncherFinish(bool v)
{
m_releaseDeviceAfterLauncherFinish = v;
}
void S60DeployStep::slotLauncherStateChanged(int s)
{
if (s == trk::Launcher::WaitingForTrk) {
QMessageBox *mb = S60DeviceRunControlBase::createTrkWaitingMessageBox(m_launcher->trkServerName(),
Core::ICore::instance()->mainWindow());
connect(m_launcher, SIGNAL(stateChanged(int)), mb, SLOT(close()));
connect(mb, SIGNAL(finished(int)), this, SLOT(slotWaitingForTrkClosed()));
mb->open();
}
}
void S60DeployStep::slotWaitingForTrkClosed()
{
if (m_launcher && m_launcher->state() == trk::Launcher::WaitingForTrk) {
stop();
appendMessage(tr("Canceled."), true);
emit finished();
}
}
void S60DeployStep::printCreateFileFailed(const QString &filename, const QString &errorMessage)
{
appendMessage(tr("Could not create file %1 on device: %2").arg(filename, errorMessage), true);
}
void S60DeployStep::printWriteFileFailed(const QString &filename, const QString &errorMessage)
{
appendMessage(tr("Could not write to file %1 on device: %2").arg(filename, errorMessage), true);
}
void S60DeployStep::printCloseFileFailed(const QString &filename, const QString &errorMessage)
{
const QString msg = tr("Could not close file %1 on device: %2. It will be closed when App TRK is closed.");
appendMessage( msg.arg(filename, errorMessage), true);
}
void S60DeployStep::printConnectFailed(const QString &errorMessage)
{
appendMessage(tr("Could not connect to App TRK on device: %1. Restarting App TRK might help.").arg(errorMessage), true);
}
void S60DeployStep::printCopyingNotice()
{
appendMessage(tr("Copying installation file..."), false);
}
void S60DeployStep::printInstallingNotice()
{
appendMessage(tr("Installing application..."), false);
}
void S60DeployStep::printInstallingFinished()
{
appendMessage(tr("Installation has finished"), false);
}
void S60DeployStep::printInstallFailed(const QString &filename, const QString &errorMessage)
{
appendMessage(tr("Could not install from package %1 on device: %2").arg(filename, errorMessage), true);
}
void S60DeployStep::checkForCancel()
{
if (m_futureInterface->isCanceled() && m_timer->isActive()) {
m_timer->stop();
stop();
appendMessage(tr("Canceled."), true);
emit finishNow();
}
}
void S60DeployStep::launcherFinished()
{
if (m_releaseDeviceAfterLauncherFinish && m_launcher) {
m_handleDeviceRemoval = false;
trk::Launcher::releaseToDeviceManager(m_launcher);
}
m_deployResult = true;
if(m_launcher)
m_launcher->deleteLater();
m_launcher = 0;
if(m_eventLoop)
m_eventLoop->exit(0);
}
void S60DeployStep::deviceRemoved(const SymbianUtils::SymbianDevice &d)
{
if (m_handleDeviceRemoval && d.portName() == m_serialPortName) {
appendMessage(tr("The device '%1' has been disconnected").arg(d.friendlyName()), true);
emit finished();
}
}
// #pragma mark -- S60DeployStepWidget
BuildStepConfigWidget *S60DeployStep::createConfigWidget()
{
return new S60DeployStepWidget();
}
void S60DeployStepWidget::init()
{
}
QString S60DeployStepWidget::summaryText() const
{
return tr("<b>Deploy SIS Package</b>");
}
QString S60DeployStepWidget::displayName() const
{
return QString("S60DeployStepWidget::displayName");
}
// #pragma mark -- S60DeployStepFactory
S60DeployStepFactory::S60DeployStepFactory(QObject *parent) :
ProjectExplorer::IBuildStepFactory(parent)
{
}
S60DeployStepFactory::~S60DeployStepFactory()
{
}
bool S60DeployStepFactory::canCreate(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, const QString &id) const
{
if (type != ProjectExplorer::BuildStep::Deploy)
return false;
if (parent->target()->id() != QLatin1String(Constants::S60_DEVICE_TARGET_ID))
return false;
return (id == QLatin1String(S60_DEPLOY_STEP_ID));
}
ProjectExplorer::BuildStep *S60DeployStepFactory::create(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, const QString &id)
{
if (!canCreate(parent, type, id))
return 0;
return new S60DeployStep(parent, id);
}
bool S60DeployStepFactory::canClone(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, ProjectExplorer::BuildStep *source) const
{
return canCreate(parent, type, source->id());
}
ProjectExplorer::BuildStep *S60DeployStepFactory::clone(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, ProjectExplorer::BuildStep *source)
{
if (!canClone(parent, type, source))
return 0;
return new S60DeployStep(parent, static_cast<S60DeployStep *>(source));
}
bool S60DeployStepFactory::canRestore(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, const QVariantMap &map) const
{
QString id(ProjectExplorer::idFromMap(map));
return canCreate(parent, type, id);
}
ProjectExplorer::BuildStep *S60DeployStepFactory::restore(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, const QVariantMap &map)
{
if (!canRestore(parent, type, map))
return 0;
S60DeployStep *bs = new S60DeployStep(parent);
if (bs->fromMap(map))
return bs;
delete bs;
return 0;
}
QStringList S60DeployStepFactory::availableCreationIds(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type) const
{
if (type != ProjectExplorer::BuildStep::Deploy)
return QStringList();
if (parent->target()->id() == QLatin1String(Constants::S60_DEVICE_TARGET_ID))
return QStringList() << QLatin1String(S60_DEPLOY_STEP_ID);
return QStringList();
}
QString S60DeployStepFactory::displayNameForId(const QString &id) const
{
if (id == QLatin1String(S60_DEPLOY_STEP_ID))
return tr("Deploy SIS Package");
return QString();
}

View File

@@ -0,0 +1,165 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** 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.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#ifndef S60DeployStep_H
#define S60DeployStep_H
#include <projectexplorer/buildstep.h>
#include "launcher.h"
#include <QtCore/QString>
#include <QtCore/QEventLoop>
namespace SymbianUtils {
class SymbianDevice;
}
namespace ProjectExplorer {
class IOutputParser;
}
namespace Qt4ProjectManager {
namespace Internal {
class BuildConfiguration;
class S60DeviceRunConfiguration;
class S60DeployStepFactory : public ProjectExplorer::IBuildStepFactory
{
Q_OBJECT
public:
explicit S60DeployStepFactory(QObject *parent = 0);
~S60DeployStepFactory();
// used to show the list of possible additons to a target, returns a list of types
QStringList availableCreationIds(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type) const;
// used to translate the types to names to display to the user
QString displayNameForId(const QString &id) const;
bool canCreate(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, const QString &id) const;
ProjectExplorer::BuildStep *create(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, const QString &id);
// used to recreate the runConfigurations when restoring settings
bool canRestore(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, const QVariantMap &map) const;
ProjectExplorer::BuildStep *restore(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, const QVariantMap &map);
bool canClone(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, ProjectExplorer::BuildStep *product) const;
ProjectExplorer::BuildStep *clone(ProjectExplorer::BuildConfiguration *parent, ProjectExplorer::BuildStep::Type type, ProjectExplorer::BuildStep *product);
};
class S60DeployStep : public ProjectExplorer::BuildStep
{
Q_OBJECT
public:
friend class S60DeployStepFactory;
S60DeployStep(ProjectExplorer::BuildConfiguration *bc, const QString &id);
S60DeployStep(ProjectExplorer::BuildConfiguration *bc,
S60DeployStep *bs);
explicit S60DeployStep(ProjectExplorer::BuildConfiguration *bc);
virtual ~S60DeployStep();
virtual bool init();
virtual void run(QFutureInterface<bool> &fi);
virtual ProjectExplorer::BuildStepConfigWidget *createConfigWidget();
void setReleaseDeviceAfterLauncherFinish(bool);
virtual QVariantMap toMap() const;
protected:
virtual bool fromMap(const QVariantMap &map);
private:
void start();
void stop();
void startDeployment();
bool processPackageName(QString &errorMessage);
void setupConnections();
void appendMessage(const QString &error, bool isError);
protected slots:
void deviceRemoved(const SymbianUtils::SymbianDevice &);
private slots:
void printConnectFailed(const QString &errorMessage);
void printCopyingNotice();
void printCreateFileFailed(const QString &filename, const QString &errorMessage);
void printWriteFileFailed(const QString &filename, const QString &errorMessage);
void printCloseFileFailed(const QString &filename, const QString &errorMessage);
void printInstallingNotice();
void printInstallFailed(const QString &filename, const QString &errorMessage);
void printInstallingFinished();
void launcherFinished();
void slotLauncherStateChanged(int);
void slotWaitingForTrkClosed();
void checkForCancel();
signals:
void finished();
void finishNow();
private:
QString m_serialPortName;
QString m_serialPortFriendlyName;
QString m_packageFileNameWithTarget; // Support for 4.6.1
QString m_signedPackage;
QTimer *m_timer;
bool m_releaseDeviceAfterLauncherFinish;
bool m_handleDeviceRemoval;
QFutureInterface<bool> *m_futureInterface; //not owned
trk::Launcher *m_launcher;
QEventLoop *m_eventLoop;
bool m_deployResult;
};
class S60DeployStepWidget : public ProjectExplorer::BuildStepConfigWidget
{
Q_OBJECT
public:
S60DeployStepWidget()
: ProjectExplorer::BuildStepConfigWidget()
{}
void init();
QString summaryText() const;
QString displayName() const;
};
} // Internal
} // Qt4ProjectManager
#endif // S60DeployStep_H

View File

@@ -509,10 +509,7 @@ S60DeviceRunControlBase::S60DeviceRunControlBase(RunConfiguration *runConfigurat
m_serialPortName = s60runConfig->serialPortName();
m_serialPortFriendlyName = SymbianUtils::SymbianDeviceManager::instance()->friendlyNameForPort(m_serialPortName);
m_targetName = s60runConfig->targetName();
m_packageFileNameWithTarget = s60runConfig->packageFileNameWithTargetInfo();
m_signedPackage = s60runConfig->signedPackage();
m_commandLineArguments = s60runConfig->commandLineArguments();
m_workingDirectory = QFileInfo(m_signedPackage).absolutePath();
m_qtDir = activeBuildConf->qtVersion()->versionInfo().value("QT_INSTALL_DATA");
if (const QtVersion *qtv = s60runConfig->qtVersion())
m_qtBinPath = qtv->versionInfo().value(QLatin1String("QT_INSTALL_BINS"));
@@ -520,7 +517,7 @@ S60DeviceRunControlBase::S60DeviceRunControlBase(RunConfiguration *runConfigurat
m_executableFileName = s60runConfig->localExecutableFileName();
if (debug)
qDebug() << "S60DeviceRunControlBase::CT" << m_targetName << ProjectExplorer::ToolChain::toolChainName(m_toolChain)
<< m_serialPortName << m_workingDirectory;
<< m_serialPortName;
}
S60DeviceRunControlBase::~S60DeviceRunControlBase()
@@ -536,32 +533,6 @@ void S60DeviceRunControlBase::setReleaseDeviceAfterLauncherFinish(bool v)
m_releaseDeviceAfterLauncherFinish = v;
}
static inline bool ensureDeleteFile(const QString &fileName, QString *errorMessage)
{
QFile file(fileName);
if (file.exists() && !file.remove()) {
*errorMessage = S60DeviceRunControlBase::tr("Unable to remove existing file '%1': %2").arg(fileName, file.errorString());
return false;
}
return true;
}
static inline bool renameFile(const QString &sourceName, const QString &targetName,
QString *errorMessage)
{
if (sourceName == targetName)
return true;
if (!ensureDeleteFile(targetName, errorMessage))
return false;
QFile source(sourceName);
if (!source.rename(targetName)) {
*errorMessage = S60DeviceRunControlBase::tr("Unable to rename file '%1' to '%2': %3")
.arg(sourceName, targetName, source.errorString());
return false;
}
return true;
}
void S60DeviceRunControlBase::start()
{
m_deployProgress = new QFutureInterface<void>;
@@ -594,46 +565,7 @@ void S60DeviceRunControlBase::start()
return;
}
// make sure we have the right name of the sis package
bool ok = true;
QFileInfo packageInfo(m_signedPackage);
{
// support for 4.6.1 and pre, where make sis creates 'targetname_armX_udeb.sis' instead of 'targetname.sis'
QFileInfo packageWithTargetInfo(m_packageFileNameWithTarget);
// does the 4.6.1 version exist?
if (packageWithTargetInfo.exists() && packageWithTargetInfo.isFile()) {
// is the 4.6.1 version newer? (to guard against behavior change Qt Creator 1.3 --> 2.0)
if (!packageInfo.exists()
|| packageInfo.lastModified() < packageWithTargetInfo.lastModified()) {
// the 'targetname_armX_udeb.sis' crap exists and is new, rename it
emit appendMessage(this, tr("Renaming new package '%1' to '%2'")
.arg(QDir::toNativeSeparators(m_packageFileNameWithTarget),
QDir::toNativeSeparators(m_signedPackage)), false);
ok = renameFile(m_packageFileNameWithTarget, m_signedPackage, &errorMessage);
} else {
// the 'targetname_armX_udeb.sis' crap exists but is old, remove it
emit appendMessage(this, tr("Removing old package '%1'")
.arg(QDir::toNativeSeparators(m_packageFileNameWithTarget)),
false);
QFile::remove(m_packageFileNameWithTarget);
}
}
}
if (ok) {
if (!packageInfo.exists() || !packageInfo.isFile()) {
errorMessage = tr("Package file not found");
ok = false;
}
}
if (ok) {
startDeployment();
} else {
m_deployProgress->reportCanceled();
errorMessage = tr("Failed to find package '%1': %2").arg(m_signedPackage, errorMessage);
appendMessage(this, errorMessage, true);
stop();
emit finished();
}
}
static inline void stopProcess(QProcess *p)
@@ -672,14 +604,6 @@ void S60DeviceRunControlBase::startDeployment()
connect(m_launcher, SIGNAL(finished()), this, SLOT(launcherFinished()));
connect(m_launcher, SIGNAL(canNotConnect(QString)), this, SLOT(printConnectFailed(QString)));
connect(m_launcher, SIGNAL(copyingStarted()), this, SLOT(printCopyingNotice()));
connect(m_launcher, SIGNAL(canNotCreateFile(QString,QString)), this, SLOT(printCreateFileFailed(QString,QString)));
connect(m_launcher, SIGNAL(canNotWriteFile(QString,QString)), this, SLOT(printWriteFileFailed(QString,QString)));
connect(m_launcher, SIGNAL(canNotCloseFile(QString,QString)), this, SLOT(printCloseFileFailed(QString,QString)));
connect(m_launcher, SIGNAL(installingStarted()), this, SLOT(printInstallingNotice()));
connect(m_launcher, SIGNAL(canNotInstall(QString,QString)), this, SLOT(printInstallFailed(QString,QString)));
connect(m_launcher, SIGNAL(installingFinished()), this, SLOT(printInstallingFinished()));
connect(m_launcher, SIGNAL(copyProgress(int)), this, SLOT(printCopyProgress(int)));
connect(m_launcher, SIGNAL(stateChanged(int)), this, SLOT(slotLauncherStateChanged(int)));
connect(m_launcher, SIGNAL(processStopped(uint,uint,uint,QString)),
this, SLOT(processStopped(uint,uint,uint,QString)));
@@ -687,13 +611,8 @@ void S60DeviceRunControlBase::startDeployment()
//TODO sisx destination and file path user definable
if (!m_commandLineArguments.isEmpty())
m_launcher->setCommandLineArgs(m_commandLineArguments);
const QString copyDst = QString::fromLatin1("C:\\Data\\%1").arg(QFileInfo(m_signedPackage).fileName());
const QString runFileName = QString::fromLatin1("C:\\sys\\bin\\%1.exe").arg(m_targetName);
m_launcher->setCopyFileName(m_signedPackage, copyDst);
m_launcher->setInstallFileName(copyDst);
initLauncher(runFileName, m_launcher);
emit appendMessage(this, tr("Package: %1\nDeploying application to '%2'...").arg(msgListFile(m_signedPackage), m_serialPortFriendlyName), false);
// Prompt the user to start up the Blue tooth connection
const trk::PromptStartCommunicationResult src =
S60RunConfigBluetoothStarter::startCommunication(m_launcher->trkDevice(),
0, &errorMessage);
@@ -715,59 +634,11 @@ void S60DeviceRunControlBase::startDeployment()
}
}
void S60DeviceRunControlBase::printCreateFileFailed(const QString &filename, const QString &errorMessage)
{
emit appendMessage(this, tr("Could not create file %1 on device: %2").arg(filename, errorMessage), true);
}
void S60DeviceRunControlBase::printWriteFileFailed(const QString &filename, const QString &errorMessage)
{
emit appendMessage(this, tr("Could not write to file %1 on device: %2").arg(filename, errorMessage), true);
}
void S60DeviceRunControlBase::printCloseFileFailed(const QString &filename, const QString &errorMessage)
{
const QString msg = tr("Could not close file %1 on device: %2. It will be closed when App TRK is closed.");
emit appendMessage(this, msg.arg(filename, errorMessage), true);
}
void S60DeviceRunControlBase::printConnectFailed(const QString &errorMessage)
{
emit appendMessage(this, tr("Could not connect to App TRK on device: %1. Restarting App TRK might help.").arg(errorMessage), true);
}
void S60DeviceRunControlBase::printCopyingNotice()
{
emit appendMessage(this, tr("Copying installation file..."), false);
}
void S60DeviceRunControlBase::printCopyProgress(int progress)
{
m_deployProgress->setProgressValue(PROGRESS_DEPLOYBASE + progress);
}
void S60DeviceRunControlBase::printInstallingNotice()
{
m_deployProgress->setProgressValue(PROGRESS_PACKAGEDEPLOYED);
emit appendMessage(this, tr("Installing application..."), false);
}
void S60DeviceRunControlBase::printInstallingFinished()
{
m_deployProgress->setProgressValue(PROGRESS_PACKAGEINSTALLED);
m_deployProgress->reportFinished();
delete m_deployProgress;
m_deployProgress = 0;
}
void S60DeviceRunControlBase::printInstallFailed(const QString &filename, const QString &errorMessage)
{
QTC_ASSERT(m_deployProgress, ;)
if (m_deployProgress)
m_deployProgress->reportCanceled();
emit appendMessage(this, tr("Could not install from package %1 on device: %2").arg(filename, errorMessage), true);
}
void S60DeviceRunControlBase::launcherFinished()
{
if (m_releaseDeviceAfterLauncherFinish) {
@@ -866,7 +737,7 @@ void S60DeviceRunControl::initLauncher(const QString &executable, trk::Launcher
connect(launcher, SIGNAL(applicationRunning(uint)), this, SLOT(printRunNotice(uint)));
connect(launcher, SIGNAL(canNotRun(QString)), this, SLOT(printRunFailNotice(QString)));
connect(launcher, SIGNAL(applicationOutputReceived(QString)), this, SLOT(printApplicationOutput(QString)));
launcher->addStartupActions(trk::Launcher::ActionCopyInstallRun);
launcher->addStartupActions(trk::Launcher::ActionRun);
launcher->setFileName(executable);
}
@@ -936,10 +807,10 @@ void S60DeviceDebugRunControl::initLauncher(const QString &executable, trk::Laun
m_startParams->symbolFileName.clear();
emit appendMessage(this, tr("Warning: Cannot locate the symbol file belonging to %1.").arg(m_localExecutableFileName), true);
}
launcher->addStartupActions(trk::Launcher::ActionCopyInstall);
// Avoid close/open sequence in quick succession, which may cause crashs
launcher->setCloseDevice(false);
// The S60DeviceDebugRunControl does not deploy anything anymore
emit finished();
}
void S60DeviceDebugRunControl::handleLauncherFinished()

View File

@@ -175,14 +175,6 @@ protected slots:
private slots:
void processStopped(uint pc, uint pid, uint tid, const QString& reason);
void printConnectFailed(const QString &errorMessage);
void printCopyingNotice();
void printCreateFileFailed(const QString &filename, const QString &errorMessage);
void printWriteFileFailed(const QString &filename, const QString &errorMessage);
void printCloseFileFailed(const QString &filename, const QString &errorMessage);
void printCopyProgress(int progress);
void printInstallingNotice();
void printInstallFailed(const QString &filename, const QString &errorMessage);
void printInstallingFinished();
void launcherFinished();
void slotLauncherStateChanged(int);
void slotWaitingForTrkClosed();
@@ -199,8 +191,6 @@ private:
QString m_workingDirectory;
QString m_executableFileName;
QString m_qtDir;
QString m_packageFileNameWithTarget; // Support for 4.6.1
QString m_signedPackage;
QString m_qtBinPath;
bool m_releaseDeviceAfterLauncherFinish;
bool m_handleDeviceRemoval;

View File

@@ -38,6 +38,7 @@
#include "s60emulatorrunconfiguration.h"
#include "s60devicerunconfiguration.h"
#include "s60createpackagestep.h"
#include "s60deploystep.h"
#include <coreplugin/icore.h>
#include <extensionsystem/pluginmanager.h>
@@ -120,6 +121,7 @@ S60Manager::S60Manager(QObject *parent)
(QLatin1String(ProjectExplorer::Constants::RUNMODE),
tr("Run on Device"), parent));
addAutoReleasedObject(new S60CreatePackageStepFactory);
addAutoReleasedObject(new S60DeployStepFactory);
if (Debugger::DebuggerPlugin::instance())
addAutoReleasedObject(new RunControlFactory<S60DeviceDebugRunControl,

View File

@@ -41,6 +41,7 @@
#include "qt-s60/s60devicerunconfiguration.h"
#include "qt-s60/s60emulatorrunconfiguration.h"
#include "qt-s60/s60createpackagestep.h"
#include "qt-s60/s60deploystep.h"
#include <projectexplorer/customexecutablerunconfiguration.h>
#include <projectexplorer/toolchain.h>
@@ -285,6 +286,8 @@ Qt4BuildConfiguration *Qt4Target::addQt4BuildConfiguration(QString displayName,
if (id() == Constants::S60_DEVICE_TARGET_ID) {
S60CreatePackageStep *packageStep = new S60CreatePackageStep(bc);
bc->insertStep(ProjectExplorer::BuildStep::Deploy, 2, packageStep);
S60DeployStep *deployStep = new S60DeployStep(bc);
bc->insertStep(ProjectExplorer::BuildStep::Deploy, 3, deployStep);
} else if (id() == Constants::MAEMO_DEVICE_TARGET_ID) {
bc->insertStep(ProjectExplorer::BuildStep::Deploy, 2,
new MaemoPackageCreationStep(bc));