DeviceSupport: Implement DesktopDevice::portsGatheringMethod()

The feature is useful in a QtApplicationManager debugging context.

Internally, DeviceUsedPortsGatherer uses a DeviceProcess now,
not an SshRemoteProcess, to cover cases where the (Windows Desktop)
device not have ssh available.

Change-Id: I9d33ceac65a135123a376ebd2727dcb540563179
Reviewed-by: Wolfgang Bremer <wolfgang.bremer@pelagicore.com>
Reviewed-by: Dan Cape <dcape@qnx.com>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2017-08-07 18:54:01 +02:00
parent 4048629d1a
commit 7f87e2af3c
7 changed files with 152 additions and 60 deletions

View File

@@ -55,19 +55,25 @@ class QnxPortsGatheringMethod : public PortsGatheringMethod
{
// TODO: The command is probably needlessly complicated because the parsing method
// used to be fixed. These two can now be matched to each other.
QByteArray commandLine(QAbstractSocket::NetworkLayerProtocol protocol) const
Runnable runnable(QAbstractSocket::NetworkLayerProtocol protocol) const override
{
Q_UNUSED(protocol);
return "netstat -na "
StandardRunnable runnable;
// FIXME: Is this extra shell needed?
runnable.executable = "/bin/sh";
runnable.commandLineArguments = "-c \""
"netstat -na "
"| sed 's/[a-z]\\+\\s\\+[0-9]\\+\\s\\+[0-9]\\+\\s\\+\\(\\*\\|[0-9\\.]\\+\\)\\.\\([0-9]\\+\\).*/\\2/g' "
"| while read line; do "
"if [[ $line != udp* ]] && [[ $line != Active* ]]; then "
"printf '%x\n' $line; "
"fi; "
"done";
"done"
"\"";
return runnable;
}
QList<Port> usedPorts(const QByteArray &output) const
QList<Port> usedPorts(const QByteArray &output) const override
{
QList<Port> ports;
QList<QByteArray> portStrings = output.split('\n');