@@ -62,6 +62,11 @@ void NMWirelessNetwork::updateReferenceConnection() {
6262 }
6363}
6464
65+ void NMWirelessNetwork::setActiveApPath (const QDBusObjectPath& path) {
66+ if (this ->mActiveApPath == path) return ;
67+ this ->mActiveApPath = path;
68+ }
69+
6570void NMWirelessNetwork::setState (NMConnectionState::Enum state) {
6671 if (this ->mState == state) return ;
6772 this ->mState = state;
@@ -85,15 +90,11 @@ void NMWirelessNetwork::updateSignalStrength() {
8590 NMAccessPoint* selectedAp = nullptr ;
8691
8792 for (auto * ap: this ->mAccessPoints .values ()) {
88- if (ap->active ()) {
89- selectedStrength = ap->signalStrength ();
90- selectedAp = ap;
91- break ;
92- }
9393 if (selectedStrength <= ap->signalStrength ()) {
9494 selectedStrength = ap->signalStrength ();
9595 selectedAp = ap;
9696 }
97+ if (ap->path () == this ->mActiveApPath .path ()) break ;
9798 }
9899
99100 if (selectedStrength != this ->mSignalStrength ) {
@@ -217,22 +218,10 @@ void NMWirelessDevice::initWireless() {
217218 QObject::connect (this , &NMWirelessDevice::accessPointLoaded, this , &NMWirelessDevice::onAccessPointLoaded);
218219 QObject::connect (this , &NMWirelessDevice::connectionLoaded, this , &NMWirelessDevice::onConnectionLoaded);
219220 QObject::connect (this , &NMWirelessDevice::activeConnectionLoaded, this , &NMWirelessDevice::onActiveConnectionLoaded);
220- QObject::connect (this , &NMWirelessDevice::activeAccessPointChanged, this , &NMWirelessDevice::onActiveAccessPointChanged);
221221 // clang-format on
222222 this ->registerAccessPoints ();
223223}
224224
225- void NMWirelessDevice::onActiveAccessPointChanged (const QDBusObjectPath& path) {
226- // Make previous AP inactive
227- auto * prevAp = this ->mAccessPoints .value (this ->mActiveApPath );
228- if (prevAp) prevAp->setActive (false );
229-
230- // Make current AP active
231- this ->mActiveApPath = path.path ();
232- auto * curAp = this ->mAccessPoints .value (path.path ());
233- if (curAp) curAp->setActive (true );
234- }
235-
236225void NMWirelessDevice::onAccessPointPathAdded (const QDBusObjectPath& path) {
237226 this ->registerAccessPoint (path.path ());
238227}
@@ -279,7 +268,6 @@ void NMWirelessDevice::registerAccessPoint(const QString& path) {
279268 }
280269
281270 auto * ap = new NMAccessPoint (path, this ->capabilities (), this );
282- if (ap->path () == this ->mActiveApPath ) ap->setActive (true );
283271
284272 if (!ap->isValid ()) {
285273 qCWarning (logNetworkManager) << " Ignoring invalid registration of" << path;
@@ -298,9 +286,13 @@ void NMWirelessDevice::registerAccessPoint(const QString& path) {
298286}
299287
300288NMWirelessNetwork* NMWirelessDevice::registerNetwork (const QString& ssid) {
301- auto * frontend = new WifiNetwork (ssid, this );
302289 auto * backend = new NMWirelessNetwork (ssid, this );
290+ // clang-format off
291+ backend->setActiveApPath (this ->activeApPath ());
292+ QObject::connect (this , &NMWirelessDevice::activeAccessPointChanged, backend, &NMWirelessNetwork::setActiveApPath);
293+ // clang-format on
303294
295+ auto * frontend = new WifiNetwork (ssid, this );
304296 // clang-format off
305297 frontend->setSignalStrength (backend->signalStrength ());
306298 frontend->setState (static_cast <NetworkConnectionState::Enum>(backend->state ()));
0 commit comments