Merge PR #529: Provide access to the network device discovery cache

This commit is contained in:
jenkins 2022-06-16 00:20:52 +02:00
commit f33d674d3c
3 changed files with 13 additions and 2 deletions

View File

@ -250,6 +250,11 @@ bool NetworkDeviceDiscoveryImpl::sendArpRequest(const QHostAddress &address)
return false; return false;
} }
QHash<MacAddress, NetworkDeviceInfo> NetworkDeviceDiscoveryImpl::cache() const
{
return m_networkInfoCache;
}
void NetworkDeviceDiscoveryImpl::setEnabled(bool enabled) void NetworkDeviceDiscoveryImpl::setEnabled(bool enabled)
{ {
m_enabled = enabled; m_enabled = enabled;
@ -373,6 +378,8 @@ void NetworkDeviceDiscoveryImpl::loadNetworkDeviceCache()
} }
m_cacheSettings->endGroup(); // NetworkDeviceInfos m_cacheSettings->endGroup(); // NetworkDeviceInfos
qCInfo(dcNetworkDeviceDiscovery()) << "Loaded" << m_networkInfoCache.count() << "network device infos from cache.";
// We just did some housekeeping while loading from the cache // We just did some housekeeping while loading from the cache
m_lastCacheHousekeeping = QDateTime::currentDateTime(); m_lastCacheHousekeeping = QDateTime::currentDateTime();
} }
@ -598,7 +605,7 @@ void NetworkDeviceDiscoveryImpl::finishDiscovery()
m_running = false; m_running = false;
emit runningChanged(m_running); emit runningChanged(m_running);
emit networkDeviceInfoCacheUpdated(); emit cacheUpdated();
m_lastDiscovery = QDateTime::currentDateTime(); m_lastDiscovery = QDateTime::currentDateTime();

View File

@ -78,6 +78,8 @@ public:
bool sendArpRequest(const QHostAddress &address) override; bool sendArpRequest(const QHostAddress &address) override;
QHash<MacAddress, NetworkDeviceInfo> cache() const override;
protected: protected:
void setEnabled(bool enabled) override; void setEnabled(bool enabled) override;

View File

@ -67,9 +67,11 @@ public:
virtual bool sendArpRequest(const QHostAddress &address) = 0; virtual bool sendArpRequest(const QHostAddress &address) = 0;
virtual QHash<MacAddress, NetworkDeviceInfo> cache() const = 0;
signals: signals:
void runningChanged(bool running); void runningChanged(bool running);
void networkDeviceInfoCacheUpdated(); void cacheUpdated();
}; };