Unfriend the discovery class from the monitor
This commit is contained in:
parent
e4ff2d9422
commit
61bbd3cbdf
@ -431,7 +431,7 @@ void NetworkDeviceDiscoveryImpl::evaluateMonitor(NetworkDeviceMonitorImpl *monit
|
|||||||
|
|
||||||
// Try to ping first
|
// Try to ping first
|
||||||
qCDebug(dcNetworkDeviceDiscovery()) << monitor << "try to ping" << monitor->networkDeviceInfo().address().toString();
|
qCDebug(dcNetworkDeviceDiscovery()) << monitor << "try to ping" << monitor->networkDeviceInfo().address().toString();
|
||||||
monitor->m_lastConnectionAttempt = currentDateTime;
|
monitor->setLastConnectionAttempt(currentDateTime);
|
||||||
|
|
||||||
PingReply *reply = m_ping->ping(monitor->networkDeviceInfo().address());
|
PingReply *reply = m_ping->ping(monitor->networkDeviceInfo().address());
|
||||||
connect(reply, &PingReply::finished, monitor, [=](){
|
connect(reply, &PingReply::finished, monitor, [=](){
|
||||||
@ -457,7 +457,9 @@ void NetworkDeviceDiscoveryImpl::processArpTraffic(const QNetworkInterface &inte
|
|||||||
monitor->setLastSeen(now);
|
monitor->setLastSeen(now);
|
||||||
monitor->setReachable(true);
|
monitor->setReachable(true);
|
||||||
if (monitor->networkDeviceInfo().address() != address) {
|
if (monitor->networkDeviceInfo().address() != address) {
|
||||||
monitor->m_networkDeviceInfo.setAddress(address);
|
NetworkDeviceInfo info = monitor->networkDeviceInfo();
|
||||||
|
info.setAddress(address);
|
||||||
|
monitor->setNetworkDeviceInfo(info);
|
||||||
qCDebug(dcNetworkDeviceDiscovery()) << "NetworkDeviceMonitor" << monitor << "ip address changed";
|
qCDebug(dcNetworkDeviceDiscovery()) << "NetworkDeviceMonitor" << monitor << "ip address changed";
|
||||||
emit monitor->networkDeviceInfoChanged(monitor->networkDeviceInfo());
|
emit monitor->networkDeviceInfoChanged(monitor->networkDeviceInfo());
|
||||||
}
|
}
|
||||||
@ -546,7 +548,7 @@ void NetworkDeviceDiscoveryImpl::evaluateMonitors()
|
|||||||
evaluateMonitor(monitor);
|
evaluateMonitor(monitor);
|
||||||
|
|
||||||
// Check if there is any monitor which has not be seen since
|
// Check if there is any monitor which has not be seen since
|
||||||
if (monitor->m_lastConnectionAttempt.isValid() && longerAgoThan(monitor->lastSeen(), m_monitorInterval)) {
|
if (monitor->lastConnectionAttempt().isValid() && longerAgoThan(monitor->lastSeen(), m_monitorInterval)) {
|
||||||
monitorRequiresRediscovery = true;
|
monitorRequiresRediscovery = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -82,7 +82,7 @@ QDateTime NetworkDeviceMonitorImpl::lastSeen() const
|
|||||||
return m_lastSeen;
|
return m_lastSeen;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkDeviceMonitorImpl::setLastSeen(const QDateTime lastSeen)
|
void NetworkDeviceMonitorImpl::setLastSeen(const QDateTime &lastSeen)
|
||||||
{
|
{
|
||||||
if (m_lastSeen == lastSeen)
|
if (m_lastSeen == lastSeen)
|
||||||
return;
|
return;
|
||||||
@ -92,4 +92,14 @@ void NetworkDeviceMonitorImpl::setLastSeen(const QDateTime lastSeen)
|
|||||||
emit lastSeenChanged(m_lastSeen);
|
emit lastSeenChanged(m_lastSeen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QDateTime NetworkDeviceMonitorImpl::lastConnectionAttempt() const
|
||||||
|
{
|
||||||
|
return m_lastConnectionAttempt;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkDeviceMonitorImpl::setLastConnectionAttempt(const QDateTime &lastConnectionAttempt)
|
||||||
|
{
|
||||||
|
m_lastConnectionAttempt = lastConnectionAttempt;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,8 +42,6 @@ class NetworkDeviceMonitorImpl : public NetworkDeviceMonitor
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
friend class NetworkDeviceDiscoveryImpl;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit NetworkDeviceMonitorImpl(const MacAddress &macAddress, QObject *parent = nullptr);
|
explicit NetworkDeviceMonitorImpl(const MacAddress &macAddress, QObject *parent = nullptr);
|
||||||
~NetworkDeviceMonitorImpl();
|
~NetworkDeviceMonitorImpl();
|
||||||
@ -57,7 +55,10 @@ public:
|
|||||||
void setReachable(bool reachable);
|
void setReachable(bool reachable);
|
||||||
|
|
||||||
QDateTime lastSeen() const override;
|
QDateTime lastSeen() const override;
|
||||||
void setLastSeen(const QDateTime lastSeen);
|
void setLastSeen(const QDateTime &lastSeen);
|
||||||
|
|
||||||
|
QDateTime lastConnectionAttempt() const;
|
||||||
|
void setLastConnectionAttempt(const QDateTime &lastConnectionAttempt);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NetworkDeviceInfo m_networkDeviceInfo;
|
NetworkDeviceInfo m_networkDeviceInfo;
|
||||||
|
|||||||
Reference in New Issue
Block a user