Get rid of IDevice::createProcess()

And most of QtcProcess subclasses.

Change-Id: Ic891defbf49736442243f9ee0f9d28d140e0ba9d
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Jarek Kobus
2022-05-02 16:02:53 +02:00
parent a6940abc29
commit 85cb7d2b71
26 changed files with 3 additions and 845 deletions

View File

@@ -35,7 +35,6 @@
#include <projectexplorer/devicesupport/idevice.h> #include <projectexplorer/devicesupport/idevice.h>
#include <projectexplorer/runcontrol.h> #include <projectexplorer/runcontrol.h>
#include <remotelinux/linuxdeviceprocess.h>
#include <remotelinux/linuxprocessinterface.h> #include <remotelinux/linuxprocessinterface.h>
#include <ssh/sshconnection.h> #include <ssh/sshconnection.h>
@@ -56,26 +55,6 @@ using namespace Utils;
namespace Qdb { namespace Qdb {
namespace Internal { namespace Internal {
class QdbDeviceProcess : public RemoteLinux::LinuxDeviceProcess
{
public:
QdbDeviceProcess(const QSharedPointer<const IDevice> &device, QObject *parent)
: RemoteLinux::LinuxDeviceProcess(device, parent)
{
}
void terminate() override
{
ProjectExplorer::Runnable r;
r.command = {Constants::AppcontrollerFilepath, {"--stop"}};
r.device = device();
auto launcher = new ApplicationLauncher(this);
launcher->setRunnable(r);
launcher->start();
}
};
class QdbProcessImpl : public LinuxProcessInterface class QdbProcessImpl : public LinuxProcessInterface
{ {
public: public:
@@ -183,11 +162,6 @@ ProjectExplorer::IDeviceWidget *QdbDevice::createWidget()
return w; return w;
} }
QtcProcess *QdbDevice::createProcess(QObject *parent) const
{
return new QdbDeviceProcess(sharedFromThis(), parent);
}
ProcessInterface *QdbDevice::createProcessInterface() const ProcessInterface *QdbDevice::createProcessInterface() const
{ {
return new QdbProcessImpl(this); return new QdbProcessImpl(this);

View File

@@ -44,7 +44,6 @@ public:
ProjectExplorer::IDeviceWidget *createWidget() final; ProjectExplorer::IDeviceWidget *createWidget() final;
Utils::QtcProcess *createProcess(QObject *parent) const final;
Utils::ProcessInterface *createProcessInterface() const override; Utils::ProcessInterface *createProcessInterface() const override;
void setSerialNumber(const QString &serial); void setSerialNumber(const QString &serial);

View File

@@ -104,52 +104,6 @@ const QString s_pidMarker = "__qtc$$qtc__";
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 Utils::QtcProcess
{
public:
DockerDeviceProcess(const QSharedPointer<const IDevice> &device, QObject *parent = nullptr);
~DockerDeviceProcess() {}
void startImpl() override;
void interrupt() override;
const QSharedPointer<const IDevice> m_device;
};
DockerDeviceProcess::DockerDeviceProcess(const QSharedPointer<const IDevice> &device,
QObject *parent)
: QtcProcess(parent), m_device(device)
{
setProcessMode(ProcessMode::Writer);
}
void DockerDeviceProcess::startImpl()
{
QTC_ASSERT(state() == QProcess::NotRunning, return);
DockerDevice::ConstPtr dockerDevice = qSharedPointerCast<const DockerDevice>(m_device);
QTC_ASSERT(dockerDevice, return);
connect(this, &QtcProcess::readyReadStandardOutput, this, [this] {
MessageManager::writeSilently(QString::fromLocal8Bit(readAllStandardError()));
});
connect(this, &QtcProcess::readyReadStandardError, this, [this] {
MessageManager::writeDisrupting(QString::fromLocal8Bit(readAllStandardError()));
});
CommandLine command = commandLine();
command.setExecutable(
command.executable().withNewPath(dockerDevice->mapToDevicePath(command.executable())));
setCommand(command);
LOG("Running process:" << command.toUserOutput() << "in" << workingDirectory().toUserOutput());
QtcProcess::startImpl();
}
void DockerDeviceProcess::interrupt()
{
m_device->signalOperation()->interruptProcess(processId());
}
class DockerPortsGatheringMethod : public PortsGatheringMethod class DockerPortsGatheringMethod : public PortsGatheringMethod
{ {
CommandLine commandLine(QAbstractSocket::NetworkLayerProtocol protocol) const override CommandLine commandLine(QAbstractSocket::NetworkLayerProtocol protocol) const override
@@ -655,11 +609,6 @@ QVariantMap DockerDevice::toMap() const
return map; return map;
} }
QtcProcess *DockerDevice::createProcess(QObject *parent) const
{
return new DockerDeviceProcess(sharedFromThis(), parent);
}
ProcessInterface *DockerDevice::createProcessInterface() const ProcessInterface *DockerDevice::createProcessInterface() const
{ {
return new DockerProcessImpl(d); return new DockerProcessImpl(d);

View File

@@ -63,8 +63,6 @@ public:
ProjectExplorer::IDeviceWidget *createWidget() override; ProjectExplorer::IDeviceWidget *createWidget() override;
QList<ProjectExplorer::Task> validate() const override; QList<ProjectExplorer::Task> validate() const override;
bool canCreateProcess() const override { return true; }
Utils::QtcProcess *createProcess(QObject *parent) const override;
Utils::ProcessInterface *createProcessInterface() const override; Utils::ProcessInterface *createProcessInterface() const override;
bool canAutoDetectPorts() const override; bool canAutoDetectPorts() const override;

View File

@@ -25,12 +25,12 @@
#include "dockerdevicewidget.h" #include "dockerdevicewidget.h"
#include <utils/environment.h>
#include <utils/utilsicons.h>
#include <utils/hostosinfo.h>
#include <utils/algorithm.h> #include <utils/algorithm.h>
#include <utils/environment.h>
#include <utils/hostosinfo.h>
#include <utils/layoutbuilder.h> #include <utils/layoutbuilder.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <utils/utilsicons.h>
#include <QCoreApplication> #include <QCoreApplication>
#include <QToolButton> #include <QToolButton>

View File

@@ -66,8 +66,6 @@ add_qtc_plugin(ProjectExplorer
devicesupport/idevicefwd.h devicesupport/idevicefwd.h
devicesupport/idevicewidget.h devicesupport/idevicewidget.h
devicesupport/localprocesslist.cpp devicesupport/localprocesslist.h devicesupport/localprocesslist.cpp devicesupport/localprocesslist.h
devicesupport/sshdeviceprocess.cpp devicesupport/sshdeviceprocess.h
devicesupport/sshdeviceprocess.cpp devicesupport/sshdeviceprocess.h
devicesupport/sshdeviceprocesslist.cpp devicesupport/sshdeviceprocesslist.h devicesupport/sshdeviceprocesslist.cpp devicesupport/sshdeviceprocesslist.h
devicesupport/sshsettingspage.cpp devicesupport/sshsettingspage.h devicesupport/sshsettingspage.cpp devicesupport/sshsettingspage.h
editorconfiguration.cpp editorconfiguration.h editorconfiguration.cpp editorconfiguration.h

View File

@@ -377,15 +377,6 @@ void ApplicationLauncherPrivate::start()
return; return;
} }
if (!m_runnable.device->canCreateProcess()) {
m_resultData.m_errorString =ApplicationLauncher::tr("Cannot run: Device is not able to create processes.");
m_resultData.m_error = QProcess::FailedToStart;
m_resultData.m_exitStatus = QProcess::CrashExit;
emit q->errorOccurred(QProcess::FailedToStart);
emit q->finished();
return;
}
if (!m_runnable.device->isEmptyCommandAllowed() && m_runnable.command.isEmpty()) { if (!m_runnable.device->isEmptyCommandAllowed() && m_runnable.command.isEmpty()) {
m_resultData.m_errorString = ApplicationLauncher::tr("Cannot run: No command given."); m_resultData.m_errorString = ApplicationLauncher::tr("Cannot run: No command given.");
m_resultData.m_error = QProcess::FailedToStart; m_resultData.m_error = QProcess::FailedToStart;

View File

@@ -97,11 +97,6 @@ DeviceProcessList *DesktopDevice::createProcessListModel(QObject *parent) const
return new Internal::LocalProcessList(sharedFromThis(), parent); return new Internal::LocalProcessList(sharedFromThis(), parent);
} }
QtcProcess *DesktopDevice::createProcess(QObject *parent) const
{
return new QtcProcess(parent);
}
DeviceProcessSignalOperation::Ptr DesktopDevice::signalOperation() const DeviceProcessSignalOperation::Ptr DesktopDevice::signalOperation() const
{ {
return DeviceProcessSignalOperation::Ptr(new DesktopProcessSignalOperation()); return DeviceProcessSignalOperation::Ptr(new DesktopProcessSignalOperation());

View File

@@ -48,9 +48,7 @@ public:
bool canAutoDetectPorts() const override; bool canAutoDetectPorts() const override;
bool canCreateProcessModel() const override; bool canCreateProcessModel() const override;
DeviceProcessList *createProcessListModel(QObject *parent) const override; DeviceProcessList *createProcessListModel(QObject *parent) const override;
bool canCreateProcess() const override { return true; }
ProjectExplorer::PortsGatheringMethod::Ptr portsGatheringMethod() const override; ProjectExplorer::PortsGatheringMethod::Ptr portsGatheringMethod() const override;
Utils::QtcProcess *createProcess(QObject *parent) const override;
DeviceProcessSignalOperation::Ptr signalOperation() const override; DeviceProcessSignalOperation::Ptr signalOperation() const override;
DeviceEnvironmentFetcher::Ptr environmentFetcher() const override; DeviceEnvironmentFetcher::Ptr environmentFetcher() const override;
QUrl toolControlChannel(const ControlChannelHint &) const override; QUrl toolControlChannel(const ControlChannelHint &) const override;

View File

@@ -583,12 +583,6 @@ OsType IDevice::osType() const
return d->osType; return d->osType;
} }
QtcProcess *IDevice::createProcess(QObject * /* parent */) const
{
QTC_CHECK(false);
return nullptr;
}
DeviceEnvironmentFetcher::Ptr IDevice::environmentFetcher() const DeviceEnvironmentFetcher::Ptr IDevice::environmentFetcher() const
{ {
return DeviceEnvironmentFetcher::Ptr(); return DeviceEnvironmentFetcher::Ptr();

View File

@@ -181,8 +181,6 @@ public:
virtual bool hasDeviceTester() const { return false; } virtual bool hasDeviceTester() const { return false; }
virtual DeviceTester *createDeviceTester() const; virtual DeviceTester *createDeviceTester() const;
virtual bool canCreateProcess() const { return false; }
virtual Utils::QtcProcess *createProcess(QObject *parent) const;
virtual DeviceProcessSignalOperation::Ptr signalOperation() const = 0; virtual DeviceProcessSignalOperation::Ptr signalOperation() const = 0;
virtual DeviceEnvironmentFetcher::Ptr environmentFetcher() const; virtual DeviceEnvironmentFetcher::Ptr environmentFetcher() const;

View File

@@ -1,335 +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 "sshdeviceprocess.h"
#include "idevice.h"
#include <coreplugin/icore.h>
#include <ssh/sshconnection.h>
#include <ssh/sshconnectionmanager.h>
#include <ssh/sshremoteprocess.h>
#include <utils/environment.h>
#include <utils/processinterface.h>
#include <utils/qtcassert.h>
#include <utils/qtcprocess.h>
#include <QString>
#include <QTimer>
using namespace Utils;
namespace ProjectExplorer {
enum class Signal { Interrupt, Terminate, Kill };
class SshDeviceProcess::SshDeviceProcessPrivate
{
public:
SshDeviceProcessPrivate(SshDeviceProcess *q) : q(q) {}
SshDeviceProcess * const q;
QSharedPointer<const IDevice> m_device;
QSsh::SshConnection *connection = nullptr;
QSsh::SshRemoteProcessPtr remoteProcess;
QString processName;
QString displayName;
QString errorMessage;
QProcess::ExitStatus exitStatus = QProcess::NormalExit;
DeviceProcessSignalOperation::Ptr killOperation;
QTimer killTimer;
enum State { Inactive, Connecting, Connected, ProcessRunning } state = Inactive;
void setState(State newState);
void doSignal(Signal signal);
};
SshDeviceProcess::SshDeviceProcess(const IDevice::ConstPtr &device, QObject *parent)
: QtcProcess(parent),
d(std::make_unique<SshDeviceProcessPrivate>(this))
{
d->m_device = device;
connect(&d->killTimer, &QTimer::timeout, this, &SshDeviceProcess::handleKillOperationTimeout);
}
void SshDeviceProcess::emitStarted()
{
handleProcessStarted();
}
void SshDeviceProcess::emitFinished()
{
handleProcessFinished(QtcProcess::errorString());
}
const QSharedPointer<const IDevice> &SshDeviceProcess::device() const
{
return d->m_device;
}
SshDeviceProcess::~SshDeviceProcess()
{
d->setState(SshDeviceProcessPrivate::Inactive);
}
void SshDeviceProcess::startImpl()
{
QTC_ASSERT(d->state == SshDeviceProcessPrivate::Inactive, return);
QTC_ASSERT(usesTerminal() || !commandLine().isEmpty(), return);
d->setState(SshDeviceProcessPrivate::Connecting);
d->errorMessage.clear();
d->exitStatus = QProcess::NormalExit;
d->processName = commandLine().executable().toString();
d->displayName = extraData("Ssh.X11ForwardToDisplay").toString();
QSsh::SshConnectionParameters params = d->m_device->sshParameters();
params.x11DisplayName = d->displayName;
d->connection = QSsh::SshConnectionManager::acquireConnection(params);
connect(d->connection, &QSsh::SshConnection::errorOccurred,
this, &SshDeviceProcess::handleConnectionError);
connect(d->connection, &QSsh::SshConnection::disconnected,
this, &SshDeviceProcess::handleDisconnected);
if (d->connection->state() == QSsh::SshConnection::Connected) {
handleConnected();
} else {
connect(d->connection, &QSsh::SshConnection::connected,
this, &SshDeviceProcess::handleConnected);
if (d->connection->state() == QSsh::SshConnection::Unconnected)
d->connection->connectToHost();
}
}
void SshDeviceProcess::interrupt()
{
QTC_ASSERT(d->state == SshDeviceProcessPrivate::ProcessRunning, return);
d->doSignal(Signal::Interrupt);
}
void SshDeviceProcess::terminate()
{
QTC_ASSERT(d->state == SshDeviceProcessPrivate::ProcessRunning, return);
d->doSignal(Signal::Terminate);
}
void SshDeviceProcess::kill()
{
QTC_ASSERT(d->state == SshDeviceProcessPrivate::ProcessRunning, return);
d->doSignal(Signal::Kill);
}
ProcessResultData SshDeviceProcess::resultData() const
{
const ProcessResultData result = QtcProcess::resultData();
return { usesTerminal() ? result.m_exitCode : d->remoteProcess->exitCode(),
d->exitStatus == QProcess::NormalExit && result.m_exitCode != 255
? QProcess::NormalExit : QProcess::CrashExit,
result.m_error,
d->errorMessage };
}
QByteArray SshDeviceProcess::readAllStandardOutput()
{
return d->remoteProcess.get() ? d->remoteProcess->readAllStandardOutput() : QByteArray();
}
QByteArray SshDeviceProcess::readAllStandardError()
{
return d->remoteProcess.get() ? d->remoteProcess->readAllStandardError() : QByteArray();
}
void SshDeviceProcess::handleConnected()
{
QTC_ASSERT(d->state == SshDeviceProcessPrivate::Connecting, return);
d->setState(SshDeviceProcessPrivate::Connected);
d->remoteProcess = usesTerminal() && d->processName.isEmpty()
? d->connection->createRemoteShell()
: d->connection->createRemoteProcess(fullCommandLine());
const QString display = d->displayName;
if (!display.isEmpty())
d->remoteProcess->requestX11Forwarding(display);
if (usesTerminal()) {
setAbortOnMetaChars(false);
setCommand(d->remoteProcess->fullLocalCommandLine(true));
QtcProcess::startImpl();
} else {
connect(d->remoteProcess.get(), &QtcProcess::started,
this, &SshDeviceProcess::handleProcessStarted);
connect(d->remoteProcess.get(), &QtcProcess::done, this, [this] {
handleProcessFinished(d->remoteProcess->errorString());
emit done();
});
connect(d->remoteProcess.get(), &QtcProcess::readyReadStandardOutput,
this, &QtcProcess::readyReadStandardOutput);
connect(d->remoteProcess.get(), &QtcProcess::readyReadStandardError,
this, &QtcProcess::readyReadStandardError);
d->remoteProcess->start();
}
}
void SshDeviceProcess::handleConnectionError()
{
QTC_ASSERT(d->state != SshDeviceProcessPrivate::Inactive, return);
d->errorMessage = d->connection->errorString();
handleDisconnected();
}
void SshDeviceProcess::handleDisconnected()
{
QTC_ASSERT(d->state != SshDeviceProcessPrivate::Inactive, return);
const SshDeviceProcessPrivate::State oldState = d->state;
d->setState(SshDeviceProcessPrivate::Inactive);
switch (oldState) {
case SshDeviceProcessPrivate::Connecting:
case SshDeviceProcessPrivate::Connected:
emit errorOccurred(QProcess::FailedToStart);
emit done();
break;
case SshDeviceProcessPrivate::ProcessRunning:
d->exitStatus = QProcess::CrashExit;
emit finished();
emit done();
default:
break;
}
}
void SshDeviceProcess::handleProcessStarted()
{
QTC_ASSERT(d->state == SshDeviceProcessPrivate::Connected, return);
d->setState(SshDeviceProcessPrivate::ProcessRunning);
emit started();
}
void SshDeviceProcess::handleProcessFinished(const QString &error)
{
d->errorMessage = error;
if (d->killOperation && error.isEmpty())
d->errorMessage = tr("The process was ended forcefully.");
d->setState(SshDeviceProcessPrivate::Inactive);
emit finished();
}
void SshDeviceProcess::handleKillOperationFinished(const QString &errorMessage)
{
QTC_ASSERT(d->state == SshDeviceProcessPrivate::ProcessRunning, return);
if (errorMessage.isEmpty()) // Process will finish as expected; nothing to do here.
return;
d->exitStatus = QProcess::CrashExit; // Not entirely true, but it will get the message across.
d->errorMessage = tr("Failed to kill remote process: %1").arg(errorMessage);
d->setState(SshDeviceProcessPrivate::Inactive);
emit finished();
emit done();
}
void SshDeviceProcess::handleKillOperationTimeout()
{
d->exitStatus = QProcess::CrashExit; // Not entirely true, but it will get the message across.
d->errorMessage = tr("Timeout waiting for remote process to finish.");
d->setState(SshDeviceProcessPrivate::Inactive);
emit finished();
emit done();
}
QString SshDeviceProcess::fullCommandLine() const
{
return commandLine().toUserOutput();
}
void SshDeviceProcess::SshDeviceProcessPrivate::doSignal(Signal signal)
{
if (processName.isEmpty())
return;
switch (state) {
case SshDeviceProcessPrivate::Inactive:
QTC_ASSERT(false, return);
break;
case SshDeviceProcessPrivate::Connecting:
errorMessage = tr("Terminated by request.");
setState(SshDeviceProcessPrivate::Inactive);
emit q->errorOccurred(QProcess::FailedToStart);
emit q->done();
break;
case SshDeviceProcessPrivate::Connected:
case SshDeviceProcessPrivate::ProcessRunning:
DeviceProcessSignalOperation::Ptr signalOperation = m_device->signalOperation();
const qint64 processId = q->processId();
if (signal == Signal::Interrupt) {
if (processId != 0)
signalOperation->interruptProcess(processId);
else
signalOperation->interruptProcess(processName);
} else {
if (killOperation) // We are already in the process of killing the app.
return;
killOperation = signalOperation;
connect(signalOperation.data(), &DeviceProcessSignalOperation::finished, q,
&SshDeviceProcess::handleKillOperationFinished);
killTimer.start(5000);
if (processId != 0)
signalOperation->killProcess(processId);
else
signalOperation->killProcess(processName);
}
break;
}
}
void SshDeviceProcess::SshDeviceProcessPrivate::setState(SshDeviceProcess::SshDeviceProcessPrivate::State newState)
{
if (state == newState)
return;
state = newState;
if (state != Inactive)
return;
if (killOperation) {
killOperation->disconnect(q);
killOperation.clear();
if (q->usesTerminal())
QMetaObject::invokeMethod(q, &QtcProcess::stopProcess, Qt::QueuedConnection);
}
killTimer.stop();
if (remoteProcess)
remoteProcess->disconnect(q);
if (connection) {
connection->disconnect(q);
QSsh::SshConnectionManager::releaseConnection(connection);
connection = nullptr;
}
}
qint64 SshDeviceProcess::write(const QString &data)
{
QTC_ASSERT(!usesTerminal(), return -1);
return d->remoteProcess->write(data);
}
} // namespace ProjectExplorer

View File

@@ -1,79 +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 <memory>
namespace ProjectExplorer {
class IDevice;
class PROJECTEXPLORER_EXPORT SshDeviceProcess : public Utils::QtcProcess
{
Q_OBJECT
public:
explicit SshDeviceProcess(const QSharedPointer<const IDevice> &device, QObject *parent = nullptr);
~SshDeviceProcess() override;
void startImpl() override;
void interrupt() override;
void terminate() override;
void kill() override;
Utils::ProcessResultData resultData() const override;
QByteArray readAllStandardOutput() override;
QByteArray readAllStandardError() override;
qint64 write(const QString &data) override;
protected:
void emitStarted() override;
void emitFinished() override;
const QSharedPointer<const IDevice> &device() const;
private:
void handleConnected();
void handleConnectionError();
void handleDisconnected();
void handleProcessStarted();
void handleProcessFinished(const QString &error);
void handleKillOperationFinished(const QString &errorMessage);
void handleKillOperationTimeout();
virtual QString fullCommandLine() const;
class SshDeviceProcessPrivate;
friend class SshDeviceProcessPrivate;
const std::unique_ptr<SshDeviceProcessPrivate> d;
};
} // namespace ProjectExplorer

View File

@@ -224,7 +224,6 @@ Project {
"idevicefwd.h", "idevicefwd.h",
"idevicewidget.h", "idevicewidget.h",
"localprocesslist.cpp", "localprocesslist.h", "localprocesslist.cpp", "localprocesslist.h",
"sshdeviceprocess.cpp", "sshdeviceprocess.h",
"sshdeviceprocesslist.cpp", "sshdeviceprocesslist.h", "sshdeviceprocesslist.cpp", "sshdeviceprocesslist.h",
"sshsettingspage.cpp", "sshsettingspage.h", "sshsettingspage.cpp", "sshsettingspage.h",
"desktopprocesssignaloperation.cpp", "desktopprocesssignaloperation.h" "desktopprocesssignaloperation.cpp", "desktopprocesssignaloperation.h"

View File

@@ -11,7 +11,6 @@ add_qtc_plugin(Qnx
qnxdebugsupport.cpp qnxdebugsupport.h qnxdebugsupport.cpp qnxdebugsupport.h
qnxdeployqtlibrariesdialog.cpp qnxdeployqtlibrariesdialog.h qnxdeployqtlibrariesdialog.ui qnxdeployqtlibrariesdialog.cpp qnxdeployqtlibrariesdialog.h qnxdeployqtlibrariesdialog.ui
qnxdevice.cpp qnxdevice.h qnxdevice.cpp qnxdevice.h
qnxdeviceprocess.cpp qnxdeviceprocess.h
qnxdeviceprocesslist.cpp qnxdeviceprocesslist.h qnxdeviceprocesslist.cpp qnxdeviceprocesslist.h
qnxdeviceprocesssignaloperation.cpp qnxdeviceprocesssignaloperation.h qnxdeviceprocesssignaloperation.cpp qnxdeviceprocesssignaloperation.h
qnxdevicetester.cpp qnxdevicetester.h qnxdevicetester.cpp qnxdevicetester.h

View File

@@ -36,8 +36,6 @@ QtcPlugin {
"qnxdeviceprocesslist.h", "qnxdeviceprocesslist.h",
"qnxdeviceprocesssignaloperation.cpp", "qnxdeviceprocesssignaloperation.cpp",
"qnxdeviceprocesssignaloperation.h", "qnxdeviceprocesssignaloperation.h",
"qnxdeviceprocess.cpp",
"qnxdeviceprocess.h",
"qnxdevicetester.cpp", "qnxdevicetester.cpp",
"qnxdevicetester.h", "qnxdevicetester.h",
"qnxsettingswidget.ui", "qnxsettingswidget.ui",

View File

@@ -30,7 +30,6 @@
#include "qnxdeviceprocesslist.h" #include "qnxdeviceprocesslist.h"
#include "qnxdeviceprocesssignaloperation.h" #include "qnxdeviceprocesssignaloperation.h"
#include "qnxdeployqtlibrariesdialog.h" #include "qnxdeployqtlibrariesdialog.h"
#include "qnxdeviceprocess.h"
#include "qnxdevicewizard.h" #include "qnxdevicewizard.h"
#include <remotelinux/sshprocessinterface.h> #include <remotelinux/sshprocessinterface.h>
@@ -197,11 +196,6 @@ DeviceTester *QnxDevice::createDeviceTester() const
return new QnxDeviceTester; return new QnxDeviceTester;
} }
QtcProcess *QnxDevice::createProcess(QObject *parent) const
{
return new QnxDeviceProcess(sharedFromThis(), parent);
}
Utils::ProcessInterface *QnxDevice::createProcessInterface() const Utils::ProcessInterface *QnxDevice::createProcessInterface() const
{ {
return new QnxProcessImpl(this); return new QnxProcessImpl(this);

View File

@@ -47,7 +47,6 @@ public:
ProjectExplorer::DeviceProcessSignalOperation::Ptr signalOperation() const override; ProjectExplorer::DeviceProcessSignalOperation::Ptr signalOperation() const override;
ProjectExplorer::DeviceTester *createDeviceTester() const override; ProjectExplorer::DeviceTester *createDeviceTester() const override;
Utils::QtcProcess *createProcess(QObject *parent) const override;
Utils::ProcessInterface *createProcessInterface() const override; Utils::ProcessInterface *createProcessInterface() const override;
int qnxVersion() const; int qnxVersion() const;

View File

@@ -1,83 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 BlackBerry Limited. All rights reserved.
** Contact: KDAB (info@kdab.com)
**
** 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 "qnxdeviceprocess.h"
#include <projectexplorer/devicesupport/sshdeviceprocess.h>
#include <projectexplorer/runcontrol.h>
#include <utils/qtcprocess.h>
using namespace ProjectExplorer;
using namespace Utils;
namespace Qnx {
namespace Internal {
static int pidFileCounter = 0;
QnxDeviceProcess::QnxDeviceProcess(const QSharedPointer<const IDevice> &device, QObject *parent)
: SshDeviceProcess(device, parent)
{
m_pidFile = QString::fromLatin1("/var/run/qtc.%1.pid").arg(++pidFileCounter);
}
QString QnxDeviceProcess::fullCommandLine() const
{
const CommandLine command = commandLine();
QStringList args = ProcessArgs::splitArgs(command.arguments());
args.prepend(command.executable().toString());
QString cmd = ProcessArgs::createUnixArgs(args).toString();
QString fullCommandLine =
"test -f /etc/profile && . /etc/profile ; "
"test -f $HOME/profile && . $HOME/profile ; ";
if (!workingDirectory().isEmpty())
fullCommandLine += QString::fromLatin1("cd %1 ; ").arg(
ProcessArgs::quoteArg(workingDirectory().toString()));
const Environment env = remoteEnvironment();
for (auto it = env.constBegin(); it != env.constEnd(); ++it) {
fullCommandLine += QString::fromLatin1("%1='%2' ")
.arg(env.key(it)).arg(env.expandedValueForKey(env.key(it)));
}
fullCommandLine += QString::fromLatin1("%1 & echo $! > %2").arg(cmd).arg(m_pidFile);
return fullCommandLine;
}
void QnxDeviceProcess::doSignal(int sig)
{
auto signaler = new SshDeviceProcess(device(), this);
const QString args = QString("-%2 `cat %1`").arg(m_pidFile).arg(sig);
signaler->setCommand({"kill", args, CommandLine::Raw});
connect(signaler, &SshDeviceProcess::finished, signaler, &QObject::deleteLater);
signaler->start();
}
} // namespace Internal
} // namespace Qnx

View File

@@ -1,51 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 BlackBerry Limited. All rights reserved.
** Contact: KDAB (info@kdab.com)
**
** 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 "qnx_export.h"
#include <projectexplorer/devicesupport/sshdeviceprocess.h>
namespace Qnx {
namespace Internal {
class QnxDeviceProcess : public ProjectExplorer::SshDeviceProcess
{
public:
QnxDeviceProcess(const QSharedPointer<const ProjectExplorer::IDevice> &device, QObject *parent);
void interrupt() override { doSignal(2); }
void terminate() override { doSignal(15); }
void kill() override { doSignal(9); }
QString fullCommandLine() const override;
private:
void doSignal(int sig);
QString m_pidFile;
};
} // namespace Internal
} // namespace Qnx

View File

@@ -14,7 +14,6 @@ add_qtc_plugin(RemoteLinux
genericlinuxdeviceconfigurationwizardpages.cpp genericlinuxdeviceconfigurationwizardpages.h genericlinuxdeviceconfigurationwizardpages.cpp genericlinuxdeviceconfigurationwizardpages.h
genericlinuxdeviceconfigurationwizardsetuppage.ui genericlinuxdeviceconfigurationwizardsetuppage.ui
linuxdevice.cpp linuxdevice.h linuxdevice.cpp linuxdevice.h
linuxdeviceprocess.cpp linuxdeviceprocess.h
linuxdevicetester.cpp linuxdevicetester.h linuxdevicetester.cpp linuxdevicetester.h
linuxprocessinterface.h linuxprocessinterface.h
makeinstallstep.cpp makeinstallstep.h makeinstallstep.cpp makeinstallstep.h

View File

@@ -27,7 +27,6 @@
#include "genericlinuxdeviceconfigurationwidget.h" #include "genericlinuxdeviceconfigurationwidget.h"
#include "genericlinuxdeviceconfigurationwizard.h" #include "genericlinuxdeviceconfigurationwizard.h"
#include "linuxdeviceprocess.h"
#include "linuxdevicetester.h" #include "linuxdevicetester.h"
#include "linuxprocessinterface.h" #include "linuxprocessinterface.h"
#include "publickeydeploymentdialog.h" #include "publickeydeploymentdialog.h"
@@ -1034,11 +1033,6 @@ IDeviceWidget *LinuxDevice::createWidget()
return new GenericLinuxDeviceConfigurationWidget(sharedFromThis()); return new GenericLinuxDeviceConfigurationWidget(sharedFromThis());
} }
QtcProcess *LinuxDevice::createProcess(QObject *parent) const
{
return new LinuxDeviceProcess(sharedFromThis(), parent);
}
bool LinuxDevice::canAutoDetectPorts() const bool LinuxDevice::canAutoDetectPorts() const
{ {
return true; return true;

View File

@@ -46,8 +46,6 @@ public:
ProjectExplorer::IDeviceWidget *createWidget() override; ProjectExplorer::IDeviceWidget *createWidget() override;
bool canCreateProcess() const override { return true; }
Utils::QtcProcess *createProcess(QObject *parent) const override;
bool canAutoDetectPorts() const override; bool canAutoDetectPorts() const override;
ProjectExplorer::PortsGatheringMethod::Ptr portsGatheringMethod() const override; ProjectExplorer::PortsGatheringMethod::Ptr portsGatheringMethod() const override;
bool canCreateProcessModel() const override { return true; } bool canCreateProcessModel() const override { return true; }

View File

@@ -1,114 +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 "linuxdeviceprocess.h"
#include <projectexplorer/runcontrol.h>
#include <utils/environment.h>
using namespace ProjectExplorer;
using namespace Utils;
namespace RemoteLinux {
const QByteArray pidMarker = "__qtc";
LinuxDeviceProcess::LinuxDeviceProcess(const QSharedPointer<const ProjectExplorer::IDevice> &device,
QObject *parent)
: ProjectExplorer::SshDeviceProcess(device, parent)
{
connect(this, &QtcProcess::finished, this, [this]() {
m_processId = 0;
});
connect(this, &QtcProcess::started, this, [this]() {
m_pidParsed = false;
m_output.clear();
});
}
QByteArray LinuxDeviceProcess::readAllStandardOutput()
{
QByteArray output = SshDeviceProcess::readAllStandardOutput();
if (m_pidParsed || usesTerminal())
return output;
m_output.append(output);
static const QByteArray endMarker = pidMarker + '\n';
const int endMarkerOffset = m_output.indexOf(endMarker);
if (endMarkerOffset == -1)
return {};
const int startMarkerOffset = m_output.indexOf(pidMarker);
if (startMarkerOffset == endMarkerOffset) // Only theoretically possible.
return {};
const int pidStart = startMarkerOffset + pidMarker.length();
const QByteArray pidString = m_output.mid(pidStart, endMarkerOffset - pidStart);
m_pidParsed = true;
m_processId = pidString.toLongLong();
// We don't want to show output from e.g. /etc/profile.
const QByteArray actualOutput = m_output.mid(endMarkerOffset + endMarker.length());
m_output.clear();
return actualOutput;
}
qint64 LinuxDeviceProcess::processId() const
{
return m_processId < 0 ? 0 : m_processId;
}
QString LinuxDeviceProcess::fullCommandLine() const
{
CommandLine cmd;
const QStringList rcFilesToSource = {"/etc/profile", "$HOME/.profile"};
for (const QString &filePath : rcFilesToSource) {
cmd.addArgs({"test", "-f", filePath});
cmd.addArgs("&&", CommandLine::Raw);
cmd.addArgs({".", filePath});
cmd.addArgs(";", CommandLine::Raw);
}
if (!workingDirectory().isEmpty()) {
cmd.addArgs({"cd", workingDirectory().path()});
cmd.addArgs("&&", CommandLine::Raw);
}
if (!usesTerminal())
cmd.addArgs(QString("echo ") + pidMarker + "$$" + pidMarker + " && ", CommandLine::Raw);
const Environment &env = remoteEnvironment();
for (auto it = env.constBegin(); it != env.constEnd(); ++it)
cmd.addArgs(env.key(it) + "='" + env.expandedValueForKey(env.key(it)) + '\'', CommandLine::Raw);
if (!usesTerminal())
cmd.addArg("exec");
cmd.addCommandLineAsArgs(commandLine(), CommandLine::Raw);
return cmd.arguments();
}
} // namespace RemoteLinux

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 "remotelinux_export.h"
#include <projectexplorer/devicesupport/sshdeviceprocess.h>
namespace RemoteLinux {
class REMOTELINUX_EXPORT LinuxDeviceProcess : public ProjectExplorer::SshDeviceProcess
{
Q_OBJECT
public:
explicit LinuxDeviceProcess(const QSharedPointer<const ProjectExplorer::IDevice> &device,
QObject *parent = nullptr);
QByteArray readAllStandardOutput() override;
private:
QString fullCommandLine() const override;
qint64 processId() const override;
QByteArray m_output;
qint64 m_processId = 0;
bool m_pidParsed = false;
};
} // namespace RemoteLinux

View File

@@ -38,8 +38,6 @@ Project {
"genericlinuxdeviceconfigurationwizardsetuppage.ui", "genericlinuxdeviceconfigurationwizardsetuppage.ui",
"linuxdevice.cpp", "linuxdevice.cpp",
"linuxdevice.h", "linuxdevice.h",
"linuxdeviceprocess.cpp",
"linuxdeviceprocess.h",
"linuxdevicetester.cpp", "linuxdevicetester.cpp",
"linuxdevicetester.h", "linuxdevicetester.h",
"linuxprocessinterface.h", "linuxprocessinterface.h",