ProjectExplorer: Dissolve DeviceProcess

Move remaining device member to subclasses where needed.

Change-Id: I1a872315579c7f6529e8937d57511a9e99e06926
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
hjk
2022-03-02 15:00:31 +01:00
parent a17374778a
commit d439a7a25f
7 changed files with 23 additions and 111 deletions

View File

@@ -98,7 +98,7 @@ namespace Internal {
static Q_LOGGING_CATEGORY(dockerDeviceLog, "qtc.docker.device", QtWarningMsg); static Q_LOGGING_CATEGORY(dockerDeviceLog, "qtc.docker.device", QtWarningMsg);
#define LOG(x) qCDebug(dockerDeviceLog) << this << x << '\n' #define LOG(x) qCDebug(dockerDeviceLog) << this << x << '\n'
class DockerDeviceProcess : public ProjectExplorer::DeviceProcess class DockerDeviceProcess : public Utils::QtcProcess
{ {
public: public:
DockerDeviceProcess(const QSharedPointer<const IDevice> &device, QObject *parent = nullptr); DockerDeviceProcess(const QSharedPointer<const IDevice> &device, QObject *parent = nullptr);
@@ -106,11 +106,13 @@ public:
void start() override; void start() override;
void interrupt() override; void interrupt() override;
const QSharedPointer<const IDevice> m_device;
}; };
DockerDeviceProcess::DockerDeviceProcess(const QSharedPointer<const IDevice> &device, DockerDeviceProcess::DockerDeviceProcess(const QSharedPointer<const IDevice> &device,
QObject *parent) QObject *parent)
: DeviceProcess(device, parent) : QtcProcess(parent), m_device(device)
{ {
setProcessMode(ProcessMode::Writer); setProcessMode(ProcessMode::Writer);
} }
@@ -118,7 +120,7 @@ DockerDeviceProcess::DockerDeviceProcess(const QSharedPointer<const IDevice> &de
void DockerDeviceProcess::start() void DockerDeviceProcess::start()
{ {
QTC_ASSERT(state() == QProcess::NotRunning, return); QTC_ASSERT(state() == QProcess::NotRunning, return);
DockerDevice::ConstPtr dockerDevice = qSharedPointerCast<const DockerDevice>(device()); DockerDevice::ConstPtr dockerDevice = qSharedPointerCast<const DockerDevice>(m_device);
QTC_ASSERT(dockerDevice, return); QTC_ASSERT(dockerDevice, return);
connect(this, &QtcProcess::readyReadStandardOutput, this, [this] { connect(this, &QtcProcess::readyReadStandardOutput, this, [this] {
@@ -139,7 +141,7 @@ void DockerDeviceProcess::start()
void DockerDeviceProcess::interrupt() void DockerDeviceProcess::interrupt()
{ {
device()->signalOperation()->interruptProcess(processId()); m_device->signalOperation()->interruptProcess(processId());
} }
class DockerPortsGatheringMethod : public PortsGatheringMethod class DockerPortsGatheringMethod : public PortsGatheringMethod

View File

@@ -54,7 +54,6 @@ add_qtc_plugin(ProjectExplorer
devicesupport/devicefactoryselectiondialog.cpp devicesupport/devicefactoryselectiondialog.h devicesupport/devicefactoryselectiondialog.ui devicesupport/devicefactoryselectiondialog.cpp devicesupport/devicefactoryselectiondialog.h devicesupport/devicefactoryselectiondialog.ui
devicesupport/devicemanager.cpp devicesupport/devicemanager.h devicesupport/devicemanager.cpp devicesupport/devicemanager.h
devicesupport/devicemanagermodel.cpp devicesupport/devicemanagermodel.h devicesupport/devicemanagermodel.cpp devicesupport/devicemanagermodel.h
devicesupport/deviceprocess.cpp devicesupport/deviceprocess.h
devicesupport/deviceprocessesdialog.cpp devicesupport/deviceprocessesdialog.h devicesupport/deviceprocessesdialog.cpp devicesupport/deviceprocessesdialog.h
devicesupport/deviceprocesslist.cpp devicesupport/deviceprocesslist.h devicesupport/deviceprocesslist.cpp devicesupport/deviceprocesslist.h
devicesupport/devicesettingspage.cpp devicesupport/devicesettingspage.h devicesupport/devicesettingspage.cpp devicesupport/devicesettingspage.h

View File

@@ -1,47 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 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 "deviceprocess.h"
#include "idevice.h"
#include <utils/qtcassert.h>
#include <utils/fileutils.h>
using namespace Utils;
namespace ProjectExplorer {
DeviceProcess::DeviceProcess(const IDevice::ConstPtr &device, QObject *parent)
: QtcProcess(parent), m_device(device)
{
}
IDevice::ConstPtr DeviceProcess::device() const
{
return m_device;
}
} // namespace ProjectExplorer

View File

@@ -1,52 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 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 "../projectexplorer_export.h"
#include <utils/qtcprocess.h>
#include <QSharedPointer>
namespace ProjectExplorer {
class IDevice;
class PROJECTEXPLORER_EXPORT DeviceProcess : public Utils::QtcProcess
{
Q_OBJECT
protected:
explicit DeviceProcess(const QSharedPointer<const IDevice> &device,
QObject *parent = nullptr);
QSharedPointer<const IDevice> device() const;
private:
const QSharedPointer<const IDevice> m_device;
};
} // namespace ProjectExplorer

View File

@@ -51,6 +51,7 @@ public:
SshDeviceProcessPrivate(SshDeviceProcess *q) : q(q) {} SshDeviceProcessPrivate(SshDeviceProcess *q) : q(q) {}
SshDeviceProcess * const q; SshDeviceProcess * const q;
QSharedPointer<const IDevice> m_device;
QSsh::SshConnection *connection = nullptr; QSsh::SshConnection *connection = nullptr;
QSsh::SshRemoteProcessPtr remoteProcess; QSsh::SshRemoteProcessPtr remoteProcess;
QString processName; QString processName;
@@ -66,9 +67,10 @@ public:
}; };
SshDeviceProcess::SshDeviceProcess(const IDevice::ConstPtr &device, QObject *parent) SshDeviceProcess::SshDeviceProcess(const IDevice::ConstPtr &device, QObject *parent)
: DeviceProcess(device, parent), : QtcProcess(parent),
d(std::make_unique<SshDeviceProcessPrivate>(this)) d(std::make_unique<SshDeviceProcessPrivate>(this))
{ {
d->m_device = device;
connect(&d->killTimer, &QTimer::timeout, this, &SshDeviceProcess::handleKillOperationTimeout); connect(&d->killTimer, &QTimer::timeout, this, &SshDeviceProcess::handleKillOperationTimeout);
} }
@@ -82,6 +84,11 @@ void SshDeviceProcess::emitFinished()
handleProcessFinished(QtcProcess::errorString()); handleProcessFinished(QtcProcess::errorString());
} }
const QSharedPointer<const IDevice> &SshDeviceProcess::device() const
{
return d->m_device;
}
SshDeviceProcess::~SshDeviceProcess() SshDeviceProcess::~SshDeviceProcess()
{ {
d->setState(SshDeviceProcessPrivate::Inactive); d->setState(SshDeviceProcessPrivate::Inactive);
@@ -98,7 +105,7 @@ void SshDeviceProcess::start()
d->processName = commandLine().executable().toString(); d->processName = commandLine().executable().toString();
d->displayName = extraData("Ssh.X11ForwardToDisplay").toString(); d->displayName = extraData("Ssh.X11ForwardToDisplay").toString();
QSsh::SshConnectionParameters params = device()->sshParameters(); QSsh::SshConnectionParameters params = d->m_device->sshParameters();
params.x11DisplayName = d->displayName; params.x11DisplayName = d->displayName;
d->connection = QSsh::SshConnectionManager::acquireConnection(params); d->connection = QSsh::SshConnectionManager::acquireConnection(params);
connect(d->connection, &QSsh::SshConnection::errorOccurred, connect(d->connection, &QSsh::SshConnection::errorOccurred,
@@ -287,7 +294,7 @@ void SshDeviceProcess::SshDeviceProcessPrivate::doSignal(Signal signal)
break; break;
case SshDeviceProcessPrivate::Connected: case SshDeviceProcessPrivate::Connected:
case SshDeviceProcessPrivate::ProcessRunning: case SshDeviceProcessPrivate::ProcessRunning:
DeviceProcessSignalOperation::Ptr signalOperation = q->device()->signalOperation(); DeviceProcessSignalOperation::Ptr signalOperation = m_device->signalOperation();
const qint64 processId = q->processId(); const qint64 processId = q->processId();
if (signal == Signal::Interrupt) { if (signal == Signal::Interrupt) {
if (processId != 0) if (processId != 0)

View File

@@ -25,13 +25,15 @@
#pragma once #pragma once
#include "deviceprocess.h" #include "idevice.h"
#include <utils/qtcprocess.h>
#include <memory> #include <memory>
namespace ProjectExplorer { namespace ProjectExplorer {
class PROJECTEXPLORER_EXPORT SshDeviceProcess : public DeviceProcess class PROJECTEXPLORER_EXPORT SshDeviceProcess : public Utils::QtcProcess
{ {
Q_OBJECT Q_OBJECT
public: public:
@@ -57,6 +59,8 @@ protected:
void emitStarted() override; void emitStarted() override;
void emitFinished() override; void emitFinished() override;
const QSharedPointer<const IDevice> &device() const;
private: private:
void handleConnected(); void handleConnected();
void handleConnectionError(); void handleConnectionError();

View File

@@ -211,7 +211,6 @@ Project {
"devicefactoryselectiondialog.cpp", "devicefactoryselectiondialog.h", "devicefactoryselectiondialog.ui", "devicefactoryselectiondialog.cpp", "devicefactoryselectiondialog.h", "devicefactoryselectiondialog.ui",
"devicemanager.cpp", "devicemanager.h", "devicemanager.cpp", "devicemanager.h",
"devicemanagermodel.cpp", "devicemanagermodel.h", "devicemanagermodel.cpp", "devicemanagermodel.h",
"deviceprocess.cpp", "deviceprocess.h",
"deviceprocessesdialog.cpp", "deviceprocessesdialog.h", "deviceprocessesdialog.cpp", "deviceprocessesdialog.h",
"deviceprocesslist.cpp", "deviceprocesslist.h", "deviceprocesslist.cpp", "deviceprocesslist.h",
"devicesettingspage.cpp", "devicesettingspage.h", "devicesettingspage.cpp", "devicesettingspage.h",