forked from qt-creator/qt-creator
Qnx: Compactify QnxDevice creation infrastructure
Change-Id: I939a435859c494f8750d62d2ca393775e01ad214 Reviewed-by: David Schulz <david.schulz@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -11,7 +11,6 @@ add_qtc_plugin(Qnx
|
||||
qnxdeployqtlibrariesdialog.cpp qnxdeployqtlibrariesdialog.h
|
||||
qnxdevice.cpp qnxdevice.h
|
||||
qnxdevicetester.cpp qnxdevicetester.h
|
||||
qnxdevicewizard.cpp qnxdevicewizard.h
|
||||
qnxplugin.cpp
|
||||
qnxqtversion.cpp qnxqtversion.h
|
||||
qnxrunconfiguration.cpp qnxrunconfiguration.h
|
||||
|
||||
@@ -28,8 +28,6 @@ QtcPlugin {
|
||||
"qnxdebugsupport.h",
|
||||
"qnxdevice.cpp",
|
||||
"qnxdevice.h",
|
||||
"qnxdevicewizard.cpp",
|
||||
"qnxdevicewizard.h",
|
||||
"qnxdevicetester.cpp",
|
||||
"qnxdevicetester.h",
|
||||
"qnxconfigurationmanager.cpp",
|
||||
|
||||
@@ -6,19 +6,21 @@
|
||||
#include "qnxconstants.h"
|
||||
#include "qnxdeployqtlibrariesdialog.h"
|
||||
#include "qnxdevicetester.h"
|
||||
#include "qnxdevicewizard.h"
|
||||
#include "qnxtr.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <projectexplorer/devicesupport/sshparameters.h>
|
||||
|
||||
#include <remotelinux/genericlinuxdeviceconfigurationwizardpages.h>
|
||||
#include <remotelinux/remotelinuxsignaloperation.h>
|
||||
#include <remotelinux/linuxdevice.h>
|
||||
|
||||
#include <utils/port.h>
|
||||
#include <utils/portlist.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/qtcprocess.h>
|
||||
|
||||
#include <QRegularExpression>
|
||||
#include <utils/wizard.h>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
using namespace RemoteLinux;
|
||||
@@ -54,7 +56,10 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
QnxDevice::QnxDevice()
|
||||
class QnxDevice final : public LinuxDevice
|
||||
{
|
||||
public:
|
||||
QnxDevice()
|
||||
{
|
||||
setDisplayType(Tr::tr("QNX"));
|
||||
setDefaultDisplayName(Tr::tr("QNX Device"));
|
||||
@@ -73,30 +78,52 @@ QnxDevice::QnxDevice()
|
||||
}});
|
||||
}
|
||||
|
||||
PortsGatheringMethod QnxDevice::portsGatheringMethod() const
|
||||
PortsGatheringMethod portsGatheringMethod() const final
|
||||
{
|
||||
return {
|
||||
// TODO: The command is probably needlessly complicated because the parsing method
|
||||
// used to be fixed. These two can now be matched to each other.
|
||||
[this](QAbstractSocket::NetworkLayerProtocol protocol) -> CommandLine {
|
||||
Q_UNUSED(protocol)
|
||||
return {filePath("netstat"), {"-na"}};
|
||||
[this](QAbstractSocket::NetworkLayerProtocol) {
|
||||
return CommandLine(filePath("netstat"), {"-na"});
|
||||
},
|
||||
|
||||
&Port::parseFromNetstatOutput
|
||||
};
|
||||
}
|
||||
|
||||
DeviceTester *QnxDevice::createDeviceTester() const
|
||||
{
|
||||
return new QnxDeviceTester;
|
||||
}
|
||||
|
||||
DeviceProcessSignalOperation::Ptr QnxDevice::signalOperation() const
|
||||
DeviceProcessSignalOperation::Ptr signalOperation() const final
|
||||
{
|
||||
return DeviceProcessSignalOperation::Ptr(new QnxDeviceProcessSignalOperation(sharedFromThis()));
|
||||
}
|
||||
|
||||
DeviceTester *createDeviceTester() const final { return new QnxDeviceTester; }
|
||||
};
|
||||
|
||||
class QnxDeviceWizard : public Wizard
|
||||
{
|
||||
public:
|
||||
QnxDeviceWizard() : Wizard(Core::ICore::dialogParent())
|
||||
{
|
||||
setWindowTitle(Tr::tr("New QNX Device Configuration Setup"));
|
||||
|
||||
addPage(&m_setupPage);
|
||||
addPage(&m_keyDeploymentPage);
|
||||
addPage(&m_finalPage);
|
||||
m_finalPage.setCommitPage(true);
|
||||
|
||||
m_device.reset(new QnxDevice);
|
||||
|
||||
m_setupPage.setDevice(m_device);
|
||||
m_keyDeploymentPage.setDevice(m_device);
|
||||
}
|
||||
|
||||
IDevice::Ptr device() const { return m_device; }
|
||||
|
||||
private:
|
||||
GenericLinuxDeviceConfigurationWizardSetupPage m_setupPage;
|
||||
GenericLinuxDeviceConfigurationWizardKeyDeploymentPage m_keyDeploymentPage;
|
||||
GenericLinuxDeviceConfigurationWizardFinalPage m_finalPage;
|
||||
|
||||
LinuxDevice::Ptr m_device;
|
||||
};
|
||||
|
||||
// Factory
|
||||
|
||||
QnxDeviceFactory::QnxDeviceFactory() : IDeviceFactory(Constants::QNX_QNX_OS_TYPE)
|
||||
@@ -105,8 +132,13 @@ QnxDeviceFactory::QnxDeviceFactory() : IDeviceFactory(Constants::QNX_QNX_OS_TYPE
|
||||
setCombinedIcon(":/qnx/images/qnxdevicesmall.png",
|
||||
":/qnx/images/qnxdevice.png");
|
||||
setQuickCreationAllowed(true);
|
||||
setConstructionFunction(&QnxDevice::create);
|
||||
setCreator(&runDeviceWizard);
|
||||
setConstructionFunction([] { return IDevice::Ptr(new QnxDevice); });
|
||||
setCreator([] {
|
||||
QnxDeviceWizard wizard;
|
||||
if (wizard.exec() != QDialog::Accepted)
|
||||
return IDevice::Ptr();
|
||||
return wizard.device();
|
||||
});
|
||||
}
|
||||
|
||||
} // Qnx::Internal
|
||||
|
||||
@@ -3,30 +3,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <remotelinux/linuxdevice.h>
|
||||
#include <projectexplorer/devicesupport/idevicefactory.h>
|
||||
|
||||
namespace Qnx::Internal {
|
||||
|
||||
class QnxDevice final : public RemoteLinux::LinuxDevice
|
||||
{
|
||||
public:
|
||||
using Ptr = QSharedPointer<QnxDevice>;
|
||||
using ConstPtr = QSharedPointer<const QnxDevice>;
|
||||
|
||||
static Ptr create() { return Ptr(new QnxDevice); }
|
||||
|
||||
ProjectExplorer::PortsGatheringMethod portsGatheringMethod() const override;
|
||||
ProjectExplorer::DeviceProcessSignalOperation::Ptr signalOperation() const override;
|
||||
|
||||
ProjectExplorer::DeviceTester *createDeviceTester() const override;
|
||||
|
||||
private:
|
||||
QnxDevice();
|
||||
|
||||
QString interruptProcessByNameCommandLine(const QString &filePath) const;
|
||||
QString killProcessByNameCommandLine(const QString &filePath) const;
|
||||
};
|
||||
|
||||
class QnxDeviceFactory final : public ProjectExplorer::IDeviceFactory
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
// Copyright (C) 2016 BlackBerry Limited. All rights reserved.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "qnxdevicewizard.h"
|
||||
|
||||
#include "qnxconstants.h"
|
||||
#include "qnxdevice.h"
|
||||
#include "qnxtr.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <projectexplorer/devicesupport/sshparameters.h>
|
||||
|
||||
#include <remotelinux/genericlinuxdeviceconfigurationwizardpages.h>
|
||||
|
||||
#include <utils/portlist.h>
|
||||
#include <utils/wizard.h>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
using namespace RemoteLinux;
|
||||
using namespace Utils;
|
||||
|
||||
namespace Qnx::Internal {
|
||||
|
||||
class QnxDeviceWizard : public Wizard
|
||||
{
|
||||
public:
|
||||
QnxDeviceWizard() : Wizard(Core::ICore::dialogParent())
|
||||
{
|
||||
setWindowTitle(Tr::tr("New QNX Device Configuration Setup"));
|
||||
|
||||
addPage(&m_setupPage);
|
||||
addPage(&m_keyDeploymentPage);
|
||||
addPage(&m_finalPage);
|
||||
m_finalPage.setCommitPage(true);
|
||||
|
||||
SshParameters sshParams;
|
||||
sshParams.timeout = 10;
|
||||
m_device = QnxDevice::create();
|
||||
m_device->setupId(IDevice::ManuallyAdded);
|
||||
m_device->setType(Constants::QNX_QNX_OS_TYPE);
|
||||
m_device->setMachineType(IDevice::Hardware);
|
||||
m_device->setSshParameters(sshParams);
|
||||
m_device->setFreePorts(PortList::fromString("10000-10100"));
|
||||
|
||||
m_setupPage.setDevice(m_device);
|
||||
m_keyDeploymentPage.setDevice(m_device);
|
||||
}
|
||||
|
||||
IDevice::Ptr device() const { return m_device; }
|
||||
|
||||
private:
|
||||
GenericLinuxDeviceConfigurationWizardSetupPage m_setupPage;
|
||||
GenericLinuxDeviceConfigurationWizardKeyDeploymentPage m_keyDeploymentPage;
|
||||
GenericLinuxDeviceConfigurationWizardFinalPage m_finalPage;
|
||||
|
||||
LinuxDevice::Ptr m_device;
|
||||
};
|
||||
|
||||
|
||||
IDevice::Ptr runDeviceWizard()
|
||||
{
|
||||
QnxDeviceWizard wizard;
|
||||
if (wizard.exec() != QDialog::Accepted)
|
||||
return IDevice::Ptr();
|
||||
return wizard.device();
|
||||
}
|
||||
|
||||
} // Qnx::Internal
|
||||
@@ -1,12 +0,0 @@
|
||||
// Copyright (C) 2016 BlackBerry Limited. All rights reserved.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <projectexplorer/devicesupport/idevice.h>
|
||||
|
||||
namespace Qnx::Internal {
|
||||
|
||||
ProjectExplorer::IDevice::Ptr runDeviceWizard();
|
||||
|
||||
} // Qnx::Internal
|
||||
Reference in New Issue
Block a user