1/*
2 SPDX-FileCopyrightText: 2008 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_ACCESSPOINT_H
10#define NETWORKMANAGERQT_ACCESSPOINT_H
11
12#include <networkmanagerqt/networkmanagerqt_export.h>
13
14#include <nm-version.h>
15
16#include <QObject>
17#include <QSharedPointer>
18#include <QVariantMap>
19
20namespace NetworkManager
21{
22class AccessPointPrivate;
23
24/*!
25 * \class NetworkManager::AccessPoint
26 * \inheaderfile NetworkManagerQt/AccessPoint
27 * \inmodule NetworkManagerQt
28 *
29 * \brief Represents an access point.
30 */
31class NETWORKMANAGERQT_EXPORT AccessPoint : public QObject
32{
33 Q_OBJECT
34public:
35 /*!
36 * \typedef NetworkManager::AccessPoint::Ptr
37 */
38 typedef QSharedPointer<AccessPoint> Ptr;
39 /*!
40 * \typedef NetworkManager::AccessPoint::List
41 */
42 typedef QList<Ptr> List;
43 /*!
44 *
45 * The access point's current operating mode
46 *
47 * \value Unknown
48 * Not associated with a network
49 * \value Adhoc
50 * A station in an infrastructure wireless network
51 * \value ApMode
52 * Access point in an infrastructure network
53 */
54 enum OperationMode {
55 Unknown = 0,
56 Adhoc,
57 Infra,
58 ApMode,
59 };
60 /*!
61 *
62 * General capabilities of an access point
63 *
64 * \value None
65 * Null capability - says nothing about the access point
66 * \value Privacy
67 * Access point supports privacy measures
68 */
69 enum Capability {
70 None = 0x0,
71 Privacy = 0x1,
72 };
73 /*!
74 *
75 * Flags describing the access point's capabilities according to WPA (Wifi Protected Access)
76 *
77 * \value PairWep40
78 * \value PairWep104
79 * \value PairTkip
80 * \value PairCcmp
81 * \value GroupWep40
82 * \value GroupWep104
83 * \value GroupTkip
84 * \value GroupCcmp
85 * \value KeyMgmtPsk
86 * \value KeyMgmt8021x
87 * \value KeyMgmtSAE
88 * \value KeyMgmtOWE
89 * \value KeyMgmtOWETM
90 * \value KeyMgmtEapSuiteB192
91 */
92 enum WpaFlag {
93 PairWep40 = 0x1,
94 PairWep104 = 0x2,
95 PairTkip = 0x4,
96 PairCcmp = 0x8,
97 GroupWep40 = 0x10,
98 GroupWep104 = 0x20,
99 GroupTkip = 0x40,
100 GroupCcmp = 0x80,
101 KeyMgmtPsk = 0x100,
102 KeyMgmt8021x = 0x200,
103 KeyMgmtSAE = 0x400,
104 KeyMgmtOWE = 0x800,
105 KeyMgmtOWETM = 0x1000,
106 KeyMgmtEapSuiteB192 = 0x2000,
107 };
108 Q_DECLARE_FLAGS(Capabilities, Capability)
109 Q_FLAG(Capabilities)
110 Q_DECLARE_FLAGS(WpaFlags, WpaFlag)
111 Q_FLAG(WpaFlags)
112 /*!
113 */
114 explicit AccessPoint(const QString &path, QObject *parent = nullptr);
115 ~AccessPoint() override;
116
117 /*!
118 * \brief Returns path of the access point.
119 */
120 QString uni() const;
121 /*!
122 * \brief Returns capabilities of an access point.
123 */
124 Capabilities capabilities() const;
125 /*!
126 * \brief Returns flags describing the access point's capabilities according to WPA (Wifi Protected Access).
127 * \sa WpaFlag
128 */
129 AccessPoint::WpaFlags wpaFlags() const;
130 /*!
131 * \brief Returns Flags describing the access point's capabilities according to the RSN (Robust Secure Network) protocol.
132 * \sa WpaFlag
133 */
134 AccessPoint::WpaFlags rsnFlags() const;
135 /*!
136 * \brief Returns The Service Set Identifier identifying the access point.
137 */
138 QString ssid() const;
139 /*!
140 * \brief Returns raw SSID, encoded as a byte array.
141 */
142 QByteArray rawSsid() const;
143 /*!
144 * \brief Returns The radio channel frequency in use by the access point, in MHz.
145 */
146 uint frequency() const;
147 /*!
148 * \brief Returns The hardware address (BSSID) of the access point.
149 */
150 QString hardwareAddress() const;
151 /*!
152 * \brief Returns The maximum bitrate this access point is capable of, in kilobits/second (Kb/s).
153 */
154 uint maxBitRate() const;
155 /*!
156 * \brief Returns Describes the operating mode of the access point.
157 */
158 OperationMode mode() const;
159 /*!
160 * \brief Returns The current signal quality of the access point, in percent.
161 */
162 int signalStrength() const;
163 /*!
164 * \brief Returns The timestamp (in CLOCK_BOOTTIME seconds) for the last time the access point
165 * was found in scan results. A value of -1 means the access point has never been found in scan results.
166 * \since 5.14.0
167 */
168 int lastSeen() const;
169 /*!
170 * The bandwidth announced by the access point in MHz.
171 * \since 6.12.0.
172 */
173 uint bandwidth() const;
174 /*!
175 * \brief Helper method to convert wire representation of operation \a mode to enum.
176 */
177 static OperationMode convertOperationMode(uint mode);
178
179Q_SIGNALS:
180 /*!
181 * \brief This signal is emitted when the signal strength of this network has changed.
182 *
183 * \a strength the new signal strength value for this network
184 */
185 void signalStrengthChanged(int strength);
186
187 /*!
188 * \brief This signal is emitted when the bitrate of this network has changed.
189 *
190 * \a bitrate the new bitrate value for this network
191 */
192 void bitRateChanged(int bitrate);
193
194 /*!
195 * \brief This signal is emitted when the capabilities of this network have changed.
196 *
197 * \a caps the new capabilities
198 */
199 void capabilitiesChanged(AccessPoint::Capabilities caps);
200
201 /*!
202 * \brief This signal is emitted when the WPA flags in use by this access point change.
203 *
204 * \a flags the new flags
205 */
206 void wpaFlagsChanged(AccessPoint::WpaFlags flags);
207
208 /*!
209 * \brief This signal is emitted when the RSN(WPA2) flags in use by this access point change.
210 *
211 * \a flags the new flags
212 */
213 void rsnFlagsChanged(AccessPoint::WpaFlags flags);
214 /*!
215 * \brief This signal is emitted when the ssid of this Access Point changes.
216 *
217 * \a ssid the new SSID
218 */
219 void ssidChanged(const QString &ssid);
220
221 /*!
222 * \brief This signal is emitted when the frequency used by this Access Point changes.
223 *
224 * \a frequency the new frequency
225 */
226 void frequencyChanged(uint frequency);
227
228 /*!
229 * \brief This signal is emitted when the timestamp for the last time the access point was found
230 * in scan results changes.
231 *
232 * \a lastSeen the timestamp for the last time the access point was found in scan results.
233 * \since 5.14.0
234 */
235 void lastSeenChanged(int lastSeen);
236
237 /*!
238 * This signal is emitted when bandwidth announced by the access point changes.
239 *
240 * \a lastSeen the bandwidth announced by the access point in MHz.
241 * \since 6.12.0
242 */
243 void bandwidthChanged(uint bandwidth);
244
245private:
246 Q_DECLARE_PRIVATE(AccessPoint)
247
248 AccessPointPrivate *const d_ptr;
249};
250
251Q_DECLARE_OPERATORS_FOR_FLAGS(AccessPoint::WpaFlags)
252
253}
254#endif
255

source code of networkmanager-qt/src/accesspoint.h