-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdetector.cpp
More file actions
37 lines (34 loc) · 956 Bytes
/
detector.cpp
File metadata and controls
37 lines (34 loc) · 956 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "detector.h"
Detector::Detector()
{
foreach (QNetworkInterface nic, QNetworkInterface::allInterfaces()) {
if(!nic.hardwareAddress().contains("00:00:00:00:00:00") && !nic.flags().testFlag(QNetworkInterface::IsLoopBack)){
if(!macs.contains(nic.hardwareAddress())){
macs.append(nic.hardwareAddress());
}
}
}
emit sendMacs(macs);
}
void Detector::getMacs()
{
if(macs.size()){
emit sendMacs(macs);
}
}
void Detector::watch()
{
while(true){
foreach (QNetworkInterface nic, QNetworkInterface::allInterfaces()) {
foreach (QString mac, macs) {
if(nic.hardwareAddress() == mac){
if(!nic.flags().testFlag(QNetworkInterface::IsUp)){
emit down(mac);
} else {
emit up(mac);
}
}
}
}
}
}