Skip to content

Commit c23b068

Browse files
committed
chore: cleanup and lint
1 parent b12ad1b commit c23b068

File tree

11 files changed

+21
-61
lines changed

11 files changed

+21
-61
lines changed

src/network/nm/accesspoint.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
#include "accesspoint.hpp"
22

3-
#include <qcontainerfwd.h>
43
#include <qdbusconnection.h>
54
#include <qlogging.h>
65
#include <qloggingcategory.h>
76
#include <qobject.h>
87
#include <qstring.h>
9-
#include <qtypes.h>
108

119
#include "../../dbus/properties.hpp"
1210
#include "nm/dbus_nm_accesspoint.h"

src/network/nm/accesspoint.hpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
#pragma once
22

3-
#include <qcontainerfwd.h>
43
#include <qdbusextratypes.h>
5-
#include <qdbusservicewatcher.h>
6-
#include <qhash.h>
74
#include <qobject.h>
8-
#include <qqmlintegration.h>
9-
#include <qqmllist.h>
105
#include <qtmetamacros.h>
116
#include <qtypes.h>
127

@@ -46,7 +41,11 @@ class NMAccessPoint: public QObject {
4641
Q_OBJECT;
4742

4843
public:
49-
explicit NMAccessPoint(const QString& path, NMWirelessCapabilities::Enum caps, QObject* parent = nullptr);
44+
explicit NMAccessPoint(
45+
const QString& path,
46+
NMWirelessCapabilities::Enum caps,
47+
QObject* parent = nullptr
48+
);
5049

5150
[[nodiscard]] bool isValid() const;
5251
[[nodiscard]] QString path() const;

src/network/nm/backend.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
#include "backend.hpp"
22

3-
#include <qcontainerfwd.h>
43
#include <qdbusextratypes.h>
5-
#include <qdbusservicewatcher.h>
6-
#include <qhash.h>
74
#include <qobject.h>
8-
#include <qqmlintegration.h>
9-
#include <qqmllist.h>
105
#include <qtmetamacros.h>
11-
#include <qtypes.h>
126

137
#include "../../dbus/properties.hpp"
148
#include "../network.hpp"

src/network/nm/backend.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
#pragma once
22

3-
#include <qcontainerfwd.h>
43
#include <qdbusextratypes.h>
5-
#include <qdbusservicewatcher.h>
64
#include <qhash.h>
75
#include <qobject.h>
8-
#include <qqmlintegration.h>
9-
#include <qqmllist.h>
106
#include <qtmetamacros.h>
117
#include <qtypes.h>
128

src/network/nm/connection.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
#include "connection.hpp"
22

3-
#include <qcontainerfwd.h>
43
#include <qdbusconnection.h>
54
#include <qlogging.h>
65
#include <qloggingcategory.h>
76
#include <qobject.h>
87
#include <qstring.h>
9-
#include <qtypes.h>
108

119
#include "../../dbus/properties.hpp"
1210
#include "nm/utils.hpp"

src/network/nm/connection.hpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
#pragma once
22

3-
#include <qcontainerfwd.h>
43
#include <qdbusextratypes.h>
5-
#include <qdbusservicewatcher.h>
6-
#include <qhash.h>
74
#include <qobject.h>
8-
#include <qqmlintegration.h>
9-
#include <qqmllist.h>
105
#include <qtmetamacros.h>
116
#include <qtypes.h>
127

src/network/nm/device.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
#include "device.hpp"
22

3-
#include <qcontainerfwd.h>
43
#include <qdbusconnection.h>
54
#include <qlogging.h>
65
#include <qloggingcategory.h>
76
#include <qobject.h>
87
#include <qstring.h>
9-
#include <qtypes.h>
108

119
#include "../../dbus/properties.hpp"
1210

src/network/nm/device.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
#pragma once
22

3-
#include <qcontainerfwd.h>
43
#include <qdbusextratypes.h>
5-
#include <qdbusservicewatcher.h>
64
#include <qhash.h>
75
#include <qobject.h>
8-
#include <qqmlintegration.h>
9-
#include <qqmllist.h>
106
#include <qtmetamacros.h>
117
#include <qtypes.h>
128

src/network/nm/enums.hpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
#pragma once
22

3-
#include <qcontainerfwd.h>
4-
#include <qdbusextratypes.h>
5-
#include <qdbusservicewatcher.h>
6-
#include <qhash.h>
73
#include <qobject.h>
84
#include <qqmlintegration.h>
9-
#include <qqmllist.h>
105
#include <qtmetamacros.h>
116
#include <qtypes.h>
127

src/network/nm/wireless.cpp

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
#include "wireless.hpp"
22

3-
#include <qcontainerfwd.h>
43
#include <qdbusconnection.h>
54
#include <qlogging.h>
65
#include <qloggingcategory.h>
76
#include <qobject.h>
87
#include <qstring.h>
9-
#include <qtypes.h>
108

119
#include "dbus_types.hpp"
1210
#include "nm/enums.hpp"
@@ -90,11 +88,18 @@ void NMWirelessNetwork::updateSignalStrength() {
9088
NMAccessPoint* selectedAp = nullptr;
9189

9290
for (auto* ap: this->mAccessPoints.values()) {
91+
// Always prefer the active AP if found.
92+
if (ap->path() == this->mActiveApPath.path()) {
93+
selectedStrength = ap->signalStrength();
94+
selectedAp = ap;
95+
break;
96+
}
97+
98+
// Otherwise, track the strongest signal.
9399
if (selectedStrength <= ap->signalStrength()) {
94100
selectedStrength = ap->signalStrength();
95101
selectedAp = ap;
96102
}
97-
if (ap->path() == this->mActiveApPath.path()) break;
98103
}
99104

100105
if (selectedStrength != this->mSignalStrength) {
@@ -124,9 +129,7 @@ void NMWirelessNetwork::addAccessPoint(NMAccessPoint* ap) {
124129

125130
void NMWirelessNetwork::removeAccessPoint(NMAccessPoint* ap) {
126131
auto* found = this->mAccessPoints.take(ap->path());
127-
if (!found) {
128-
qCWarning(logNetworkManager) << "Backend network" << this->ssid() << "is not in sync!";
129-
} else {
132+
if (found) {
130133
if (this->mAccessPoints.isEmpty()) {
131134
emit this->disappeared();
132135
} else {
@@ -149,9 +152,7 @@ void NMWirelessNetwork::addConnectionSettings(NMConnectionSettings* conn) {
149152

150153
void NMWirelessNetwork::removeConnectionSettings(NMConnectionSettings* conn) {
151154
auto* found = this->mConnections.take(conn->path());
152-
if (!found) {
153-
qCWarning(logNetworkManager) << "Backend network" << this->ssid() << "is not in sync!";
154-
} else {
155+
if (found) {
155156
QObject::disconnect(conn, nullptr, this, nullptr);
156157
this->updateReferenceConnection();
157158
if (mConnections.isEmpty()) {
@@ -162,7 +163,6 @@ void NMWirelessNetwork::removeConnectionSettings(NMConnectionSettings* conn) {
162163

163164
void NMWirelessNetwork::addActiveConnection(NMActiveConnection* active) {
164165
if (this->mActiveConnection) {
165-
qCWarning(logNetworkManager) << "Backend network" << this->ssid() << "is not in sync!";
166166
return;
167167
}
168168
this->setState(active->state());
@@ -181,8 +181,6 @@ void NMWirelessNetwork::removeActiveConnection(NMActiveConnection* active) {
181181
this->setState(NMConnectionState::Deactivated);
182182
this->setReason(NMConnectionStateReason::None);
183183
this->mActiveConnection = nullptr;
184-
} else {
185-
qCWarning(logNetworkManager) << "Backend network" << this->ssid() << "is not in sync!";
186184
}
187185
};
188186

@@ -228,13 +226,11 @@ void NMWirelessDevice::onAccessPointPathAdded(const QDBusObjectPath& path) {
228226

229227
void NMWirelessDevice::onAccessPointPathRemoved(const QDBusObjectPath& path) {
230228
auto* ap = mAccessPoints.take(path.path());
231-
232229
if (!ap) {
233-
qCDebug(logNetworkManager) << "NetworkManager sent removal signal for" << path.path()
230+
qCDebug(logNetworkManager) << "Sent removal signal for" << path.path()
234231
<< "which is not registered.";
235232
return;
236233
}
237-
238234
emit ap->disappeared();
239235
delete ap;
240236
}
@@ -286,14 +282,12 @@ void NMWirelessDevice::registerAccessPoint(const QString& path) {
286282
}
287283

288284
NMWirelessNetwork* NMWirelessDevice::registerNetwork(const QString& ssid) {
289-
auto* backend = new NMWirelessNetwork(ssid, this);
290285
// clang-format off
286+
auto* backend = new NMWirelessNetwork(ssid, this);
291287
backend->setActiveApPath(this->activeApPath());
292288
QObject::connect(this, &NMWirelessDevice::activeAccessPointChanged, backend, &NMWirelessNetwork::setActiveApPath);
293-
// clang-format on
294289

295290
auto* frontend = new WifiNetwork(ssid, this);
296-
// clang-format off
297291
frontend->setSignalStrength(backend->signalStrength());
298292
frontend->setState(static_cast<NetworkConnectionState::Enum>(backend->state()));
299293
frontend->setKnown(backend->known());
@@ -347,7 +341,8 @@ void NMWirelessDevice::onAccessPointLoaded(NMAccessPoint* ap) {
347341

348342
void NMWirelessDevice::onConnectionLoaded(NMConnectionSettings* conn) {
349343
const ConnectionSettingsMap& settings = conn->settings();
350-
// Early return for invalid connections
344+
// Skip connections that have empty settings,
345+
// or who are this devices own hotspots.
351346
if (settings["connection"]["id"].toString().isEmpty()
352347
|| settings["connection"]["uuid"].toString().isEmpty()
353348
|| !settings.contains("802-11-wireless")
@@ -369,10 +364,10 @@ void NMWirelessDevice::onConnectionLoaded(NMConnectionSettings* conn) {
369364
}
370365

371366
void NMWirelessDevice::onActiveConnectionLoaded(NMActiveConnection* active) {
372-
QString connPath = active->connection().path();
367+
QString activeConnPath = active->connection().path();
373368
for (auto* net: this->mBackendNetworks.values()) {
374369
for (auto* conn: net->connections()) {
375-
if (connPath == conn->path()) {
370+
if (activeConnPath == conn->path()) {
376371
net->addActiveConnection(active);
377372
return;
378373
}

0 commit comments

Comments
 (0)