Commit 1d85d8e7 authored by Christian Kandeler's avatar Christian Kandeler Committed by hjk

ProjectExplorer: Introduce generic application runner.

This class aims to be a flexible worker class for SSH-based
run controls. It supersedes AbstractRemoteLinuxApplicationRunner
as well as all of its derived classes, while having no
RemoteLinux dependencies itself.

Change-Id: If24f03a32126b36fc3d0b253a1615ad0af5f2b46
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent 93756975
......@@ -11,7 +11,6 @@ HEADERS += \
debianmanager.h \
maemoconstants.h \
maemorunconfigurationwidget.h \
maemoruncontrol.h \
maemorunfactories.h \
maemosettingspages.h \
maemopackagecreationstep.h \
......@@ -20,8 +19,6 @@ HEADERS += \
maemoqemumanager.h \
maemodeploystepfactory.h \
maemoglobal.h \
maemosshrunner.h \
maemodebugsupport.h \
maemoremotemountsmodel.h \
maemomountspecification.h \
maemoremotemounter.h \
......@@ -52,13 +49,13 @@ HEADERS += \
maddedevicetester.h \
maddedeviceconfigurationfactory.h \
maddedevice.h \
rpmmanager.h
rpmmanager.h \
maemoapplicationrunnerhelperactions.h
SOURCES += \
maddeplugin.cpp \
debianmanager.cpp \
maemorunconfigurationwidget.cpp \
maemoruncontrol.cpp \
maemorunfactories.cpp \
maemosettingspages.cpp \
maemopackagecreationstep.cpp \
......@@ -67,8 +64,6 @@ SOURCES += \
maemoqemumanager.cpp \
maemodeploystepfactory.cpp \
maemoglobal.cpp \
maemosshrunner.cpp \
maemodebugsupport.cpp \
maemoremotemountsmodel.cpp \
maemomountspecification.cpp \
maemoremotemounter.cpp \
......@@ -98,7 +93,8 @@ SOURCES += \
maddedevicetester.cpp \
maemorunconfiguration.cpp \
maddedevice.cpp \
rpmmanager.cpp
rpmmanager.cpp \
maemoapplicationrunnerhelperactions.cpp
FORMS += \
maemopackagecreationwidget.ui \
......
......@@ -31,8 +31,6 @@ QtcPlugin {
"maddeuploadandinstallpackagesteps.cpp",
"maddeuploadandinstallpackagesteps.h",
"maemoconstants.h",
"maemodebugsupport.cpp",
"maemodebugsupport.h",
"maemodeploybymountsteps.cpp",
"maemodeploybymountsteps.h",
"maemodeployconfigurationwidget.cpp",
......@@ -108,14 +106,10 @@ QtcPlugin {
"maemorunconfiguration.h",
"maemorunconfigurationwidget.cpp",
"maemorunconfigurationwidget.h",
"maemoruncontrol.cpp",
"maemoruncontrol.h",
"maemorunfactories.cpp",
"maemorunfactories.h",
"maemosettingspages.cpp",
"maemosettingspages.h",
"maemosshrunner.cpp",
"maemosshrunner.h",
"qt-maemo.qrc",
"qt4maemodeployconfiguration.cpp",
"qt4maemodeployconfiguration.h",
......@@ -124,6 +118,8 @@ QtcPlugin {
"debianmanager.h",
"debianmanager.cpp",
"rpmmanager.h",
"rpmmanager.cpp"
"rpmmanager.cpp",
"maemoapplicationrunnerhelperactions.h",
"maemoapplicationrunnerhelperactions.cpp"
]
}
......@@ -6,6 +6,7 @@
**
** Contact: http://www.qt-project.org/
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
......@@ -26,41 +27,122 @@
**
**
**************************************************************************/
#include "maemoapplicationrunnerhelperactions.h"
#include "maemomountspecification.h"
#include "maemoremotemounter.h"
#include "maemoruncontrol.h"
#include <utils/qtcassert.h>
#include "maemoglobal.h"
#include "maemorunconfiguration.h"
#include "maemosshrunner.h"
using namespace ProjectExplorer;
using namespace Utils;
namespace Madde {
namespace Internal {
using namespace RemoteLinux;
using ProjectExplorer::RunConfiguration;
MaemoPreRunAction::MaemoPreRunAction(const IDevice::ConstPtr &device, const FileName &maddeRoot,
const QList<MaemoMountSpecification> &mountSpecs, QObject *parent)
: DeviceApplicationHelperAction(parent), m_mounter(new MaemoRemoteMounter(this))
{
m_mounter->setParameters(device, maddeRoot);
foreach (const MaemoMountSpecification &m, mountSpecs)
m_mounter->addMountSpecification(m, false);
}
void MaemoPreRunAction::handleMounted()
{
QTC_ASSERT(m_isRunning, return);
setFinished(true);
}
void MaemoPreRunAction::handleError(const QString &message)
{
if (!m_isRunning)
return;
emit reportError(message);
setFinished(false);
}
void MaemoPreRunAction::start()
{
QTC_ASSERT(!m_isRunning, return);
connect(m_mounter, SIGNAL(debugOutput(QString)), SIGNAL(reportProgress(QString)));
connect(m_mounter, SIGNAL(reportProgress(QString)), SIGNAL(reportProgress(QString)));
connect(m_mounter, SIGNAL(mounted()), SLOT(handleMounted()));
connect(m_mounter, SIGNAL(error(QString)), SLOT(handleError(QString)));
m_isRunning = true;
m_mounter->mount();
}
void MaemoPreRunAction::stop()
{
QTC_ASSERT(m_isRunning, return);
m_mounter->stop();
setFinished(false);
}
MaemoRunControl::MaemoRunControl(RunConfiguration *rc)
: AbstractRemoteLinuxRunControl(rc)
, m_runner(new MaemoSshRunner(this, qobject_cast<MaemoRunConfiguration *>(rc)))
void MaemoPreRunAction::setFinished(bool success)
{
QTC_ASSERT(m_isRunning, return);
m_mounter->disconnect(this);
m_isRunning = false;
emit finished(success);
}
MaemoRunControl::~MaemoRunControl()
MaemoPostRunAction::MaemoPostRunAction(MaemoRemoteMounter *mounter, QObject *parent)
: DeviceApplicationHelperAction(parent), m_mounter(mounter)
{
}
void MaemoRunControl::start()
void MaemoPostRunAction::handleUnmounted()
{
AbstractRemoteLinuxRunControl::start();
connect(m_runner, SIGNAL(mountDebugOutput(QString)), SLOT(handleMountDebugOutput(QString)));
QTC_ASSERT(m_isRunning, return);
setFinished(true);
}
void MaemoRunControl::handleMountDebugOutput(const QString &output)
void MaemoPostRunAction::handleError(const QString &message)
{
appendMessage(output, Utils::StdErrFormatSameLine);
if (!m_isRunning)
return;
emit reportError(message);
setFinished(false);
}
AbstractRemoteLinuxApplicationRunner *MaemoRunControl::runner() const { return m_runner; }
void MaemoPostRunAction::start()
{
QTC_ASSERT(!m_isRunning, return);
connect(m_mounter, SIGNAL(debugOutput(QString)), SIGNAL(reportProgress(QString)));
connect(m_mounter, SIGNAL(reportProgress(QString)), SIGNAL(reportProgress(QString)));
connect(m_mounter, SIGNAL(unmounted()), SLOT(handleUnmounted()));
connect(m_mounter, SIGNAL(error(QString)), SLOT(handleError(QString)));
m_isRunning = true;
m_mounter->unmount();
}
void MaemoPostRunAction::stop()
{
QTC_ASSERT(m_isRunning, return);
m_mounter->stop();
setFinished(false);
}
void MaemoPostRunAction::setFinished(bool success)
{
QTC_ASSERT(m_isRunning, return);
m_mounter->disconnect(this);
m_isRunning = false;
emit finished(success);
}
} // namespace Internal
} // namespace Madde
......@@ -6,6 +6,7 @@
**
** Contact: http://www.qt-project.org/
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
......@@ -26,54 +27,65 @@
**
**
**************************************************************************/
#ifndef MAEMOAPPLICATIONRUNNERHELPERACTIONS_H
#define MAEMOAPPLICATIONRUNNERHELPERACTIONS_H
#ifndef MAEMOSSHRUNNER_H
#define MAEMOSSHRUNNER_H
#include <projectexplorer/devicesupport/deviceapplicationrunner.h>
#include "maemomountspecification.h"
#include <QList>
#include <remotelinux/remotelinuxapplicationrunner.h>
namespace Utils { class FileName; }
namespace Madde {
namespace Internal {
class MaemoMountSpecification;
class MaemoRemoteMounter;
class MaemoRunConfiguration;
class MaemoSshRunner : public RemoteLinux::AbstractRemoteLinuxApplicationRunner
class MaemoPreRunAction : public ProjectExplorer::DeviceApplicationHelperAction
{
Q_OBJECT
public:
MaemoSshRunner(QObject *parent, MaemoRunConfiguration *runConfig);
MaemoPreRunAction(const ProjectExplorer::IDevice::ConstPtr &device,
const Utils::FileName &maddeRoot, const QList<MaemoMountSpecification> &mountSpecs,
QObject *parent = 0);
signals:
void mountDebugOutput(const QString &output);
MaemoRemoteMounter *mounter() const { return m_mounter; }
private slots:
void handleMounted();
void handleUnmounted();
void handleMounterError(const QString &errorMsg);
void handleError(const QString &message);
private:
enum MountState { InactiveMountState, InitialUnmounting, Mounting, Mounted, PostRunUnmounting };
void start();
void stop();
void setFinished(bool success);
bool canRun(QString &whyNot) const;
void doDeviceSetup();
void doAdditionalInitialCleanup();
void doAdditionalInitializations();
void doPostRunCleanup();
void doAdditionalConnectionErrorHandling();
MaemoRemoteMounter * const m_mounter;
bool m_isRunning;
};
class MaemoPostRunAction : public ProjectExplorer::DeviceApplicationHelperAction
{
Q_OBJECT
public:
MaemoPostRunAction(MaemoRemoteMounter *mounter, QObject *parent = 0);
private slots:
void handleUnmounted();
void handleError(const QString &message);
private:
void start();
void stop();
void mount();
void unmount();
void setFinished(bool success);
MaemoRemoteMounter * const m_mounter;
QList<MaemoMountSpecification> m_mountSpecs;
MountState m_mountState;
int m_qtId;
bool m_isRunning;
};
} // namespace Internal
} // namespace Madde
#endif // MAEMOSSHRUNNER_H
#endif // MAEMOAPPLICATIONRUNNERHELPERACTIONS_H
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: http://www.qt-project.org/
**
** 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.
**
**
**************************************************************************/
#include "maemodebugsupport.h"
#include "maemorunconfiguration.h"
#include "maemosshrunner.h"
#include <remotelinux/linuxdeviceconfiguration.h>
using namespace RemoteLinux;
namespace Madde {
namespace Internal {
MaemoDebugSupport::MaemoDebugSupport(MaemoRunConfiguration *runConfig, Debugger::DebuggerEngine *engine)
: AbstractRemoteLinuxDebugSupport(runConfig, engine),
m_runner(new MaemoSshRunner(this, runConfig))
{
}
MaemoDebugSupport::~MaemoDebugSupport()
{
}
AbstractRemoteLinuxApplicationRunner *MaemoDebugSupport::runner() const { return m_runner; }
} // namespace Internal
} // namespace Madde
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: http://www.qt-project.org/
**
** 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.
**
**
**************************************************************************/
#ifndef MAEMODEBUGSUPPORT_H
#define MAEMODEBUGSUPPORT_H
#include <remotelinux/remotelinuxdebugsupport.h>
namespace Madde {
namespace Internal {
class MaemoRunConfiguration;
class MaemoSshRunner;
class MaemoDebugSupport : public RemoteLinux::AbstractRemoteLinuxDebugSupport
{
Q_OBJECT
public:
MaemoDebugSupport(MaemoRunConfiguration *runConfig, Debugger::DebuggerEngine *engine);
~MaemoDebugSupport();
private:
RemoteLinux::AbstractRemoteLinuxApplicationRunner *runner() const;
MaemoSshRunner * const m_runner;
};
} // namespace Internal
} // namespace Madde
#endif // MAEMODEBUGSUPPORT_H
......@@ -59,7 +59,7 @@ public:
~MaemoRemoteMounter();
void setParameters(const ProjectExplorer::IDevice::ConstPtr &devConf,
const Utils::FileName &fileName);
const Utils::FileName &maddeRoot);
void addMountSpecification(const MaemoMountSpecification &mountSpec,
bool mountAsRoot);
bool hasValidMountSpecifications() const;
......
......@@ -135,32 +135,6 @@ Utils::PortList MaemoRunConfiguration::freePorts() const
return MaemoGlobal::freePorts(target()->profile());
}
QString MaemoRunConfiguration::localDirToMountForRemoteGdb() const
{
const QString projectDir
= QDir::fromNativeSeparators(QDir::cleanPath(activeBuildConfiguration()
->target()->project()->projectDirectory()));
const QString execDir
= QDir::fromNativeSeparators(QFileInfo(localExecutableFilePath()).path());
const int length = qMin(projectDir.length(), execDir.length());
int lastSeparatorPos = 0;
for (int i = 0; i < length; ++i) {
if (projectDir.at(i) != execDir.at(i))
return projectDir.left(lastSeparatorPos);
if (projectDir.at(i) == QLatin1Char('/'))
lastSeparatorPos = i;
}
return projectDir.length() == execDir.length()
? projectDir : projectDir.left(lastSeparatorPos);
}
QString MaemoRunConfiguration::remoteProjectSourcesMountPoint() const
{
return MaemoGlobal::homeDirOnDevice(DeviceProfileInformation::device(target()->profile())->sshParameters().userName)
+ QLatin1String("/gdbSourcesDir_")
+ QFileInfo(localExecutableFilePath()).fileName();
}
bool MaemoRunConfiguration::hasEnoughFreePorts(RunMode mode) const
{
const int freePortCount = freePorts().count();
......
......@@ -53,8 +53,6 @@ public:
Internal::MaemoRemoteMountsModel *remoteMounts() const { return m_remoteMounts; }
bool hasEnoughFreePorts(ProjectExplorer::RunMode mode) const;
QString localDirToMountForRemoteGdb() const;
QString remoteProjectSourcesMountPoint() const;
signals:
void remoteMountsChanged();
......
......@@ -28,11 +28,11 @@
**************************************************************************/
#include "maemorunfactories.h"
#include "maemoapplicationrunnerhelperactions.h"
#include "maemoconstants.h"
#include "maemodebugsupport.h"
#include "maemoglobal.h"
#include "maemoremotemountsmodel.h"
#include "maemorunconfiguration.h"
#include "maemoruncontrol.h"
#include <debugger/debuggerconstants.h>
#include <debugger/debuggerstartparameters.h>
......@@ -44,6 +44,8 @@
#include <qt4projectmanager/qt4nodes.h>
#include <qt4projectmanager/qt4project.h>
#include <qtsupport/customexecutablerunconfiguration.h>
#include <remotelinux/remotelinuxdebugsupport.h>
#include <remotelinux/remotelinuxruncontrol.h>
using namespace Debugger;
using namespace ProjectExplorer;
......@@ -169,7 +171,6 @@ QList<RunConfiguration *> MaemoRunConfigurationFactory::runConfigurationsForNode
return result;
}
// #pragma mark -- MaemoRunControlFactory
MaemoRunControlFactory::MaemoRunControlFactory(QObject *parent)
: IRunControlFactory(parent)
......@@ -197,14 +198,21 @@ RunControl* MaemoRunControlFactory::create(RunConfiguration *runConfig, RunMode
Q_ASSERT(rc);
if (mode == NormalRunMode)
return new MaemoRunControl(rc);
return new RemoteLinuxRunControl(rc);
const DebuggerStartParameters params
= AbstractRemoteLinuxDebugSupport::startParameters(rc);
const DebuggerStartParameters params = LinuxDeviceDebugSupport::startParameters(rc);
DebuggerRunControl * const runControl = DebuggerPlugin::createDebugger(params, rc);
if (!runControl)
return 0;
MaemoDebugSupport *debugSupport = new MaemoDebugSupport(rc, runControl->engine());
LinuxDeviceDebugSupport * const debugSupport
= new LinuxDeviceDebugSupport(rc, runControl->engine());
const Profile * const profile = runConfig->target()->profile();
MaemoPreRunAction * const preRunAction = new MaemoPreRunAction(
DeviceProfileInformation::device(profile), MaemoGlobal::maddeRoot(profile),
rc->remoteMounts()->mountSpecs(), rc);
MaemoPostRunAction * const postRunAction = new MaemoPostRunAction(preRunAction->mounter(), rc);
debugSupport->setApplicationRunnerPreRunAction(preRunAction);
debugSupport->setApplicationRunnerPostRunAction(postRunAction);
connect(runControl, SIGNAL(finished()), debugSupport, SLOT(handleDebuggingFinished()));
return runControl;
}
......
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: http://www.qt-project.org/
**
** 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.
**
**
**************************************************************************/
#include "maemosshrunner.h"
#include "maemoglobal.h"
#include "maemoqemumanager.h"
#include "maemoremotemounter.h"
#include "maemoremotemountsmodel.h"
#include "maemorunconfiguration.h"
#include <projectexplorer/buildconfiguration.h>
#include <projectexplorer/target.h>
#include <qtsupport/qtprofileinformation.h>
#include <utils/qtcassert.h>
#include <ssh/sshconnection.h>
using namespace ProjectExplorer;
using namespace QSsh;
using namespace RemoteLinux;
namespace Madde {
namespace Internal {
MaemoSshRunner::MaemoSshRunner(<