1 | /* |
2 | SPDX-FileCopyrightText: 2009, 2011 Will Stephenson <wstephenson@kde.org> |
3 | SPDX-FileCopyrightText: 2011-2013 Lamarque V. Souza <lamarque@kde.org> |
4 | SPDX-FileCopyrightText: 2013 Jan Grulich <jgrulich@redhat.com> |
5 | |
6 | SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL |
7 | */ |
8 | |
9 | #ifndef NETWORKMANAGERQT_WIRELESSNETWORK_H |
10 | #define NETWORKMANAGERQT_WIRELESSNETWORK_H |
11 | |
12 | #include "accesspoint.h" |
13 | #include <networkmanagerqt/networkmanagerqt_export.h> |
14 | |
15 | #include <QObject> |
16 | #include <QSharedPointer> |
17 | |
18 | namespace NetworkManager |
19 | { |
20 | class WirelessDevice; |
21 | class WirelessNetworkPrivate; |
22 | |
23 | /** |
24 | * This class represents a wireless network, which aggregates all |
25 | * access points with the same SSID |
26 | */ |
27 | class NETWORKMANAGERQT_EXPORT WirelessNetwork : public QObject |
28 | { |
29 | Q_OBJECT |
30 | friend class WirelessDevice; |
31 | friend class WirelessDevicePrivate; |
32 | |
33 | public: |
34 | typedef QSharedPointer<WirelessNetwork> Ptr; |
35 | typedef QList<Ptr> List; |
36 | ~WirelessNetwork() override; |
37 | /** |
38 | * ESSID of the network |
39 | */ |
40 | QString ssid() const; |
41 | |
42 | /** |
43 | * Signal strength of the network. Syntactic sugar around tracking the reference access |
44 | * point and watching its signal strength |
45 | */ |
46 | int signalStrength() const; |
47 | |
48 | /** |
49 | * The uni of the current 'best' (strongest) Access Point. Note that this may change or disappear over time. |
50 | * Get the Access Point object using @ref WirelessDevice::findAccessPoint() on the NetworkInterface this network was obtained from. |
51 | * Use @ref WirelessDevice::accessPointDisappeared() or |
52 | * WirelessNetwork::referenceAccessPointChanged() to detect this. |
53 | */ |
54 | AccessPoint::Ptr referenceAccessPoint() const; |
55 | |
56 | /** |
57 | * List of access points |
58 | * @warning Subject to change, do not store! |
59 | */ |
60 | AccessPoint::List accessPoints() const; |
61 | |
62 | /** |
63 | * The uni of device associated with this network. |
64 | */ |
65 | QString device() const; |
66 | |
67 | Q_SIGNALS: |
68 | /** |
69 | * Indicate that the signal strength changed |
70 | * @param strength strength as a percentage. |
71 | */ |
72 | void signalStrengthChanged(int strength); |
73 | /** |
74 | * Indicate that the reference access point changed |
75 | * @param apUni new access point or empty string if none |
76 | */ |
77 | void referenceAccessPointChanged(const QString &apUni); |
78 | /** |
79 | * Indicate that this network has no more access points |
80 | * (meaning the network has disappeared from view of the network interface) |
81 | * @param ssid the SSID of this network |
82 | */ |
83 | void disappeared(const QString &ssid); |
84 | |
85 | private: |
86 | Q_DECLARE_PRIVATE(WirelessNetwork) |
87 | Q_PRIVATE_SLOT(d_func(), void accessPointAppeared(const QString &)) |
88 | Q_PRIVATE_SLOT(d_func(), void accessPointDisappeared(const QString &)) |
89 | Q_PRIVATE_SLOT(d_func(), void updateStrength()) |
90 | |
91 | WirelessNetworkPrivate *const d_ptr; |
92 | |
93 | NETWORKMANAGERQT_NO_EXPORT explicit WirelessNetwork(const AccessPoint::Ptr &accessPoint, WirelessDevice *device); |
94 | }; |
95 | |
96 | } |
97 | #endif // NETWORKMANAGERQT_WIRELESSNETWORK_H |
98 | |