Devices: Unify Port Gathering method

All devices that support it use the same mechanism to gather ports
so this patch removes the individual implementations in favor
of a single one in IDevice.cpp.

This patch also removes:
* canAutodetectPorts() as it was not used.
* Port::parseFrom...Output as they are not used anymore.

Change-Id: I8ecedec2d71e60985402387982c64311c5a651e6
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Marcus Tillmanns
2023-04-05 11:15:02 +02:00
parent f5c41a7f83
commit 522de9bfd7
17 changed files with 23 additions and 182 deletions

View File

@@ -419,7 +419,7 @@ DockerDevice::DockerDevice(DockerSettings *settings, const DockerDeviceData &dat
{
setFileAccess(&d->m_fileAccess);
setDisplayType(Tr::tr("Docker"));
setOsType(OsTypeOtherUnix);
setOsType(OsTypeLinux);
setDefaultDisplayName(Tr::tr("Docker Image"));
setupId(IDevice::ManuallyAdded);
setType(Constants::DOCKER_DEVICE_TYPE);
@@ -832,33 +832,6 @@ ProcessInterface *DockerDevice::createProcessInterface() const
return new DockerProcessImpl(this->sharedFromThis(), d);
}
bool DockerDevice::canAutoDetectPorts() const
{
return true;
}
PortsGatheringMethod DockerDevice::portsGatheringMethod() const
{
return {[this](QAbstractSocket::NetworkLayerProtocol protocol) -> CommandLine {
// We might encounter the situation that protocol is given IPv6
// but the consumer of the free port information decides to open
// an IPv4(only) port. As a result the next IPv6 scan will
// report the port again as open (in IPv6 namespace), while the
// same port in IPv4 namespace might still be blocked, and
// re-use of this port fails.
// GDBserver behaves exactly like this.
Q_UNUSED(protocol)
// /proc/net/tcp* covers /proc/net/tcp and /proc/net/tcp6
return {filePath("sed"),
"-e 's/.*: [[:xdigit:]]*:\\([[:xdigit:]]\\{4\\}\\).*/\\1/g' /proc/net/tcp*",
CommandLine::Raw};
},
&Port::parseFromSedOutput};
};
DeviceProcessList *DockerDevice::createProcessListModel(QObject *parent) const
{
return new ProcessList(sharedFromThis(), parent);

View File

@@ -73,8 +73,6 @@ public:
Utils::ProcessInterface *createProcessInterface() const override;
bool canAutoDetectPorts() const override;
ProjectExplorer::PortsGatheringMethod portsGatheringMethod() const override;
bool canCreateProcessModel() const override { return true; }
ProjectExplorer::DeviceProcessList *createProcessListModel(QObject *parent) const override;
bool hasDeviceTester() const override { return false; }