forked from qt-creator/qt-creator
Utils: Rename Port::parseFrom function
It can parse both netstat and cat /proc/net/tcp output Change-Id: Iafe37be7ace6a1eda068340b1f07e24a71724db1 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -33,7 +33,7 @@ quint16 Port::number() const
|
|||||||
QTC_ASSERT(isValid(), return -1); return quint16(m_port);
|
QTC_ASSERT(isValid(), return -1); return quint16(m_port);
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<Port> Port::parseFromNetstatOutput(const QByteArray &output)
|
QList<Port> Port::parseFromCommandOutput(const QByteArray &output)
|
||||||
{
|
{
|
||||||
QList<Port> ports;
|
QList<Port> ports;
|
||||||
const QList<QByteArray> lines = output.split('\n');
|
const QList<QByteArray> lines = output.split('\n');
|
||||||
|
@@ -24,7 +24,8 @@ public:
|
|||||||
|
|
||||||
QString toString() const { return QString::number(m_port); }
|
QString toString() const { return QString::number(m_port); }
|
||||||
|
|
||||||
static QList<Port> parseFromNetstatOutput(const QByteArray &output);
|
// Parses the output of "netstat -an" and "cat /proc/net/tcp"
|
||||||
|
static QList<Port> parseFromCommandOutput(const QByteArray &output);
|
||||||
|
|
||||||
friend bool operator<(const Port &p1, const Port &p2) { return p1.number() < p2.number(); }
|
friend bool operator<(const Port &p1, const Port &p2) { return p1.number() < p2.number(); }
|
||||||
friend bool operator<=(const Port &p1, const Port &p2) { return p1.number() <= p2.number(); }
|
friend bool operator<=(const Port &p1, const Port &p2) { return p1.number() <= p2.number(); }
|
||||||
|
@@ -389,7 +389,7 @@ PortsGatheringMethod IDevice::portsGatheringMethod() const
|
|||||||
|
|
||||||
return {filePath("netstat"), {"-a", "-n"}};
|
return {filePath("netstat"), {"-a", "-n"}};
|
||||||
},
|
},
|
||||||
&Port::parseFromNetstatOutput};
|
&Port::parseFromCommandOutput};
|
||||||
};
|
};
|
||||||
|
|
||||||
DeviceProcessList *IDevice::createProcessListModel(QObject *parent) const
|
DeviceProcessList *IDevice::createProcessListModel(QObject *parent) const
|
||||||
|
Reference in New Issue
Block a user