77 QReadLocker lock(&monitorLock);
78 if (monitor ==
nullptr)
82 Q_Q(QNetworkConnectionMonitor);
88 const QNetworkConnectionMonitor::InterfaceType hadInterfaceType = interface;
89 const nw_path_status_t previousStatus = status;
91 status = nw_path_get_status(state);
92 if (wasReachable != isReachable() || previousStatus == nw_path_status_invalid)
93 emit q->reachabilityChanged(isReachable());
95 nw_path_enumerate_interfaces(state, ^(nw_interface_t nwInterface) {
96 if (nw_path_uses_interface_type(state, nw_interface_get_type(nwInterface))) {
97 const nw_interface_type_t type = nw_interface_get_type(nwInterface);
100 case nw_interface_type_wifi:
101 interface = QNetworkConnectionMonitor::InterfaceType::WiFi;
103 case nw_interface_type_cellular:
104 interface = QNetworkConnectionMonitor::InterfaceType::Cellular;
106 case nw_interface_type_wired:
107 interface = QNetworkConnectionMonitor::InterfaceType::Ethernet;
110 interface = QNetworkConnectionMonitor::InterfaceType::Unknown;
120 if (hadInterfaceType != interface)
121 emit q->interfaceTypeChanged(interface);
142 QWriteLocker lock(&monitorLock);
143 monitor = nw_path_monitor_create();
144 if (monitor ==
nullptr) {
145 qCWarning(lcNetMon,
"Failed to create a path monitor, cannot determine current reachability.");
149 nw_path_monitor_set_update_handler(monitor, [
this](nw_path_t path){
153 auto queue = qt_reachability_queue();
155 qCWarning(lcNetMon,
"Failed to create a dispatch queue to schedule a probe on");
161 nw_path_monitor_set_queue(monitor, queue);
162 nw_path_monitor_start(monitor);