diff --git a/src/plugins/boot2qt/CMakeLists.txt b/src/plugins/boot2qt/CMakeLists.txt index d644dedbe0b..a2a32346696 100644 --- a/src/plugins/boot2qt/CMakeLists.txt +++ b/src/plugins/boot2qt/CMakeLists.txt @@ -13,7 +13,6 @@ add_qtc_plugin(Boot2Qt qdbplugin.cpp qdbplugin.h qdbqtversion.cpp qdbqtversion.h qdbrunconfiguration.cpp qdbrunconfiguration.h - qdbstopapplicationservice.cpp qdbstopapplicationservice.h qdbstopapplicationstep.cpp qdbstopapplicationstep.h qdbutils.cpp qdbutils.h ) diff --git a/src/plugins/boot2qt/boot2qt.qbs b/src/plugins/boot2qt/boot2qt.qbs index 209ea96cc77..448659b47b3 100644 --- a/src/plugins/boot2qt/boot2qt.qbs +++ b/src/plugins/boot2qt/boot2qt.qbs @@ -31,8 +31,6 @@ QtcPlugin { "qdbmakedefaultappstep.h", "qdbplugin.cpp", "qdbplugin.h", - "qdbstopapplicationservice.cpp", - "qdbstopapplicationservice.h", "qdbstopapplicationstep.cpp", "qdbstopapplicationstep.h", "qdbqtversion.cpp", diff --git a/src/plugins/boot2qt/qdbstopapplicationservice.cpp b/src/plugins/boot2qt/qdbstopapplicationservice.cpp deleted file mode 100644 index ce9a22308cc..00000000000 --- a/src/plugins/boot2qt/qdbstopapplicationservice.cpp +++ /dev/null @@ -1,119 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2019 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#include "qdbstopapplicationservice.h" - -#include "qdbconstants.h" - -#include -#include -#include -#include - -using namespace Utils; - -namespace Qdb { -namespace Internal { - -class QdbStopApplicationServicePrivate -{ -public: - ProjectExplorer::ApplicationLauncher applicationLauncher; - QString errorOutput; -}; - -QdbStopApplicationService::QdbStopApplicationService(QObject *parent) - : AbstractRemoteLinuxDeployService(parent), - d(new QdbStopApplicationServicePrivate) -{ - -} - -QdbStopApplicationService::~QdbStopApplicationService() -{ - cleanup(); - delete d; -} - -void QdbStopApplicationService::handleProcessFinished() -{ - const QString failureMessage = tr("Could not check and possibly stop running application."); - if (d->applicationLauncher.exitStatus() == QProcess::CrashExit) { - emit errorMessage(failureMessage); - stopDeployment(); - return; - } - - if (d->errorOutput.contains("Could not connect: Connection refused")) { - emit progressMessage(tr("Checked that there is no running application.")); - } else if (!d->errorOutput.isEmpty()) { - emit stdErrData(d->errorOutput); - emit errorMessage(failureMessage); - } else { - emit progressMessage(tr("Stopped the running application.")); - } - - stopDeployment(); -} - -void QdbStopApplicationService::handleAppendMessage(const QString &message, Utils::OutputFormat format) -{ - if (format == Utils::StdErrFormat) - d->errorOutput.append(message); - else - emit stdOutData(message); -} - -void QdbStopApplicationService::doDeploy() -{ - connect(&d->applicationLauncher, &ProjectExplorer::ApplicationLauncher::errorOccurred, - this, [this] { emit stdErrData(d->applicationLauncher.errorString()); }); - connect(&d->applicationLauncher, &ProjectExplorer::ApplicationLauncher::finished, - this, &QdbStopApplicationService::handleProcessFinished); - connect(&d->applicationLauncher, &ProjectExplorer::ApplicationLauncher::appendMessage, - this, &QdbStopApplicationService::handleAppendMessage); - - ProjectExplorer::Runnable runnable; - runnable.command = {Constants::AppcontrollerFilepath, {"--stop"}}; - runnable.workingDirectory = "/usr/bin"; - runnable.device = ProjectExplorer::DeviceKitAspect::device(target()->kit()); - - d->applicationLauncher.setRunnable(runnable); - d->applicationLauncher.start(); -} - -void QdbStopApplicationService::stopDeployment() -{ - cleanup(); - handleDeploymentDone(); -} - -void QdbStopApplicationService::cleanup() -{ - d->applicationLauncher.disconnect(this); -} - -} // namespace Internal -} // namespace Qdb diff --git a/src/plugins/boot2qt/qdbstopapplicationservice.h b/src/plugins/boot2qt/qdbstopapplicationservice.h deleted file mode 100644 index 3db114a3188..00000000000 --- a/src/plugins/boot2qt/qdbstopapplicationservice.h +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2019 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#pragma once - -#include -#include - -namespace Qdb { -namespace Internal { - -class QdbStopApplicationServicePrivate; - -class QdbStopApplicationService : public RemoteLinux::AbstractRemoteLinuxDeployService -{ - Q_OBJECT -public: - QdbStopApplicationService(QObject *parent = 0); - ~QdbStopApplicationService(); - -private: - void handleProcessFinished(); - void handleAppendMessage(const QString &message, Utils::OutputFormat format); - - bool isDeploymentNecessary() const final { return true; } - - void doDeploy() final; - void stopDeployment() final; - - void cleanup(); - - QdbStopApplicationServicePrivate * const d; -}; - -} // namespace Internal -} // namespace Qdb diff --git a/src/plugins/boot2qt/qdbstopapplicationstep.cpp b/src/plugins/boot2qt/qdbstopapplicationstep.cpp index c5a847c1195..d5650243df8 100644 --- a/src/plugins/boot2qt/qdbstopapplicationstep.cpp +++ b/src/plugins/boot2qt/qdbstopapplicationstep.cpp @@ -26,34 +26,123 @@ #include "qdbstopapplicationstep.h" #include "qdbconstants.h" -#include "qdbstopapplicationservice.h" +#include +#include #include +#include +#include #include using namespace ProjectExplorer; +using namespace Utils; namespace Qdb { namespace Internal { +// QdbStopApplicationService + +class QdbStopApplicationService : public RemoteLinux::AbstractRemoteLinuxDeployService +{ + Q_DECLARE_TR_FUNCTIONS(Qdb::Internal::QdbStopApplicationService) + +public: + QdbStopApplicationService() {} + ~QdbStopApplicationService() { cleanup(); } + +private: + void handleProcessFinished(); + void handleAppendMessage(const QString &message, OutputFormat format); + + bool isDeploymentNecessary() const final { return true; } + + void doDeploy() final; + void stopDeployment() final; + + void cleanup(); + + ApplicationLauncher m_applicationLauncher; + QString m_errorOutput; +}; + +void QdbStopApplicationService::handleProcessFinished() +{ + const QString failureMessage = tr("Could not check and possibly stop running application."); + if (m_applicationLauncher.exitStatus() == QProcess::CrashExit) { + emit errorMessage(failureMessage); + stopDeployment(); + return; + } + + if (m_errorOutput.contains("Could not connect: Connection refused")) { + emit progressMessage(tr("Checked that there is no running application.")); + } else if (!m_errorOutput.isEmpty()) { + emit stdErrData(m_errorOutput); + emit errorMessage(failureMessage); + } else { + emit progressMessage(tr("Stopped the running application.")); + } + + stopDeployment(); +} + +void QdbStopApplicationService::handleAppendMessage(const QString &message, OutputFormat format) +{ + if (format == StdErrFormat) + m_errorOutput.append(message); + else + emit stdOutData(message); +} + +void QdbStopApplicationService::doDeploy() +{ + connect(&m_applicationLauncher, &ApplicationLauncher::errorOccurred, + this, [this] { emit stdErrData(m_applicationLauncher.errorString()); }); + connect(&m_applicationLauncher, &ApplicationLauncher::finished, + this, &QdbStopApplicationService::handleProcessFinished); + connect(&m_applicationLauncher, &ApplicationLauncher::appendMessage, + this, &QdbStopApplicationService::handleAppendMessage); + + Runnable runnable; + runnable.command = {Constants::AppcontrollerFilepath, {"--stop"}}; + runnable.workingDirectory = "/usr/bin"; + runnable.device = DeviceKitAspect::device(target()->kit()); + + m_applicationLauncher.setRunnable(runnable); + m_applicationLauncher.start(); +} + +void QdbStopApplicationService::stopDeployment() +{ + cleanup(); + handleDeploymentDone(); +} + +void QdbStopApplicationService::cleanup() +{ + m_applicationLauncher.disconnect(this); +} + + +// QdbStopApplicationStep + class QdbStopApplicationStep final : public RemoteLinux::AbstractRemoteLinuxDeployStep { Q_DECLARE_TR_FUNCTIONS(Qdb::Internal::QdbStopApplicationStep) public: - QdbStopApplicationStep(BuildStepList *bsl, Utils::Id id); + QdbStopApplicationStep(BuildStepList *bsl, Id id) + : AbstractRemoteLinuxDeployStep(bsl, id) + { + auto service = createDeployService(); + + setWidgetExpandedByDefault(false); + + setInternalInitializer([service] { return service->isDeploymentPossible(); }); + } }; -QdbStopApplicationStep::QdbStopApplicationStep(BuildStepList *bsl, Utils::Id id) - : AbstractRemoteLinuxDeployStep(bsl, id) -{ - auto service = createDeployService(); - - setWidgetExpandedByDefault(false); - - setInternalInitializer([service] { return service->isDeploymentPossible(); }); -} // QdbStopApplicationStepFactory