2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2022 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2022-05-26 15:10:06 +02:00
|
|
|
|
|
|
|
|
#include "killappstep.h"
|
|
|
|
|
|
2022-07-01 15:59:17 +02:00
|
|
|
#include "abstractremotelinuxdeploystep.h"
|
2022-05-26 15:10:06 +02:00
|
|
|
#include "remotelinux_constants.h"
|
2022-07-01 15:59:17 +02:00
|
|
|
#include "remotelinuxtr.h"
|
2022-05-26 15:10:06 +02:00
|
|
|
|
|
|
|
|
#include <projectexplorer/devicesupport/idevice.h>
|
2022-07-01 15:59:17 +02:00
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
2022-05-26 15:10:06 +02:00
|
|
|
#include <projectexplorer/runcontrol.h>
|
|
|
|
|
#include <projectexplorer/target.h>
|
2022-07-01 15:59:17 +02:00
|
|
|
|
2022-05-26 15:10:06 +02:00
|
|
|
#include <utils/qtcassert.h>
|
|
|
|
|
|
|
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
using namespace Utils;
|
2022-11-24 16:09:29 +01:00
|
|
|
using namespace Utils::Tasking;
|
2022-05-26 15:10:06 +02:00
|
|
|
|
2022-07-01 15:59:17 +02:00
|
|
|
namespace RemoteLinux::Internal {
|
2022-05-26 15:10:06 +02:00
|
|
|
|
|
|
|
|
class KillAppService : public AbstractRemoteLinuxDeployService
|
|
|
|
|
{
|
|
|
|
|
public:
|
2022-11-24 16:09:29 +01:00
|
|
|
void setRemoteExecutable(const FilePath &filePath) { m_remoteExecutable = filePath; }
|
2022-05-26 15:10:06 +02:00
|
|
|
|
|
|
|
|
private:
|
2022-11-24 21:45:00 +01:00
|
|
|
bool isDeploymentNecessary() const final { return !m_remoteExecutable.isEmpty(); }
|
|
|
|
|
Group deployRecipe() final;
|
2022-05-26 15:10:06 +02:00
|
|
|
|
2022-09-01 08:00:21 +02:00
|
|
|
FilePath m_remoteExecutable;
|
2022-05-26 15:10:06 +02:00
|
|
|
};
|
|
|
|
|
|
2022-11-24 21:45:00 +01:00
|
|
|
Group KillAppService::deployRecipe()
|
2022-05-26 15:10:06 +02:00
|
|
|
{
|
2022-11-24 16:09:29 +01:00
|
|
|
const auto setupHandler = [this](DeviceProcessKiller &killer) {
|
|
|
|
|
killer.setProcessPath(m_remoteExecutable);
|
|
|
|
|
emit progressMessage(Tr::tr("Trying to kill \"%1\" on remote device...")
|
|
|
|
|
.arg(m_remoteExecutable.path()));
|
|
|
|
|
};
|
|
|
|
|
const auto doneHandler = [this](const DeviceProcessKiller &) {
|
|
|
|
|
emit progressMessage(Tr::tr("Remote application killed."));
|
|
|
|
|
};
|
|
|
|
|
const auto errorHandler = [this](const DeviceProcessKiller &) {
|
|
|
|
|
emit progressMessage(Tr::tr("Failed to kill remote application. "
|
|
|
|
|
"Assuming it was not running."));
|
|
|
|
|
};
|
2022-11-24 21:45:00 +01:00
|
|
|
return Group { Killer(setupHandler, doneHandler, errorHandler) };
|
2022-05-26 15:10:06 +02:00
|
|
|
}
|
|
|
|
|
|
2022-07-01 15:59:17 +02:00
|
|
|
class KillAppStep : public AbstractRemoteLinuxDeployStep
|
2022-05-26 15:10:06 +02:00
|
|
|
{
|
2022-07-01 15:59:17 +02:00
|
|
|
public:
|
|
|
|
|
KillAppStep(BuildStepList *bsl, Id id) : AbstractRemoteLinuxDeployStep(bsl, id)
|
|
|
|
|
{
|
2022-10-13 14:35:25 +02:00
|
|
|
auto service = new Internal::KillAppService;
|
|
|
|
|
setDeployService(service);
|
2022-07-01 15:59:17 +02:00
|
|
|
|
|
|
|
|
setWidgetExpandedByDefault(false);
|
|
|
|
|
|
|
|
|
|
setInternalInitializer([this, service] {
|
|
|
|
|
Target * const theTarget = target();
|
|
|
|
|
QTC_ASSERT(theTarget, return CheckResult::failure());
|
|
|
|
|
RunConfiguration * const rc = theTarget->activeRunConfiguration();
|
2022-09-01 08:00:21 +02:00
|
|
|
const FilePath remoteExe = rc ? rc->runnable().command.executable() : FilePath();
|
2022-07-01 15:59:17 +02:00
|
|
|
service->setRemoteExecutable(remoteExe);
|
|
|
|
|
return CheckResult::success();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
};
|
2022-05-26 15:10:06 +02:00
|
|
|
|
2022-07-01 15:59:17 +02:00
|
|
|
KillAppStepFactory::KillAppStepFactory()
|
2022-05-26 15:10:06 +02:00
|
|
|
{
|
2022-07-01 15:59:17 +02:00
|
|
|
registerStep<KillAppStep>(Constants::KillAppStepId);
|
|
|
|
|
setDisplayName(Tr::tr("Kill current application instance"));
|
|
|
|
|
setSupportedConfiguration(RemoteLinux::Constants::DeployToGenericLinux);
|
|
|
|
|
setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_DEPLOY);
|
2022-05-26 15:10:06 +02:00
|
|
|
}
|
|
|
|
|
|
2022-07-01 15:59:17 +02:00
|
|
|
} // RemoteLinux::Internal
|