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 * Represents an access point
26 */
27class NETWORKMANAGERQT_EXPORT AccessPoint : public QObject
28{
29 Q_OBJECT
30public:
31 typedef QSharedPointer<AccessPoint> Ptr;
32 typedef QList<Ptr> List;
33 /**
34 * The access point's current operating mode
35 */
36 enum OperationMode {
37 Unknown = 0, /**< not associated with a network */
38 Adhoc, /**< part of an adhoc network */
39 Infra, /**< a station in an infrastructure wireless network */
40 ApMode, /**< access point in an infrastructure network */
41 };
42 /**
43 * General capabilities of an access point
44 */
45 enum Capability {
46 None = 0x0, /**< Null capability - says nothing about the access point */
47 Privacy = 0x1, /**< Access point supports privacy measures */
48 };
49 /**
50 * Flags describing the access point's capabilities according to WPA (Wifi Protected Access)
51 */
52 enum WpaFlag {
53 PairWep40 = 0x1,
54 PairWep104 = 0x2,
55 PairTkip = 0x4,
56 PairCcmp = 0x8,
57 GroupWep40 = 0x10,
58 GroupWep104 = 0x20,
59 GroupTkip = 0x40,
60 GroupCcmp = 0x80,
61 KeyMgmtPsk = 0x100,
62 KeyMgmt8021x = 0x200,
63 KeyMgmtSAE = 0x400,
64 KeyMgmtEapSuiteB192 = 0x2000,
65 };
66 Q_DECLARE_FLAGS(Capabilities, Capability)
67 Q_FLAG(Capabilities)
68 Q_DECLARE_FLAGS(WpaFlags, WpaFlag)
69 Q_FLAG(WpaFlags)
70 explicit AccessPoint(const QString &path, QObject *parent = nullptr);
71 ~AccessPoint() override;
72
73 /**
74 * @return path of the access point
75 */
76 QString uni() const;
77 /**
78 * @return capabilities of an access point
79 */
80 Capabilities capabilities() const;
81 /**
82 * @return flags describing the access point's capabilities according to WPA (Wifi Protected Access).
83 * @see WpaFlag
84 */
85 AccessPoint::WpaFlags wpaFlags() const;
86 /**
87 * @return Flags describing the access point's capabilities according to the RSN (Robust Secure Network) protocol.
88 * @see WpaFlag
89 */
90 AccessPoint::WpaFlags rsnFlags() const;
91 /**
92 * @return The Service Set Identifier identifying the access point.
93 */
94 QString ssid() const;
95 /**
96 * @return raw SSID, encoded as a byte array
97 */
98 QByteArray rawSsid() const;
99 /**
100 * @return The radio channel frequency in use by the access point, in MHz.
101 */
102 uint frequency() const;
103 /**
104 * @return The hardware address (BSSID) of the access point.
105 */
106 QString hardwareAddress() const;
107 /**
108 * @return The maximum bitrate this access point is capable of, in kilobits/second (Kb/s).
109 */
110 uint maxBitRate() const;
111 /**
112 * @return Describes the operating mode of the access point.
113 */
114 OperationMode mode() const;
115 /**
116 * @return The current signal quality of the access point, in percent.
117 */
118 int signalStrength() const;
119 /**
120 * @return The timestamp (in CLOCK_BOOTTIME seconds) for the last time the access point
121 * was found in scan results. A value of -1 means the access point has never been found in scan results.
122 * @since 5.14.0
123 */
124 int lastSeen() const;
125
126 /**
127 * Helper method to convert wire representation of operation @p mode to enum
128 */
129 static OperationMode convertOperationMode(uint mode);
130
131Q_SIGNALS:
132 /**
133 * This signal is emitted when the signal strength of this network has changed.
134 *
135 * @param strength the new signal strength value for this network
136 */
137 void signalStrengthChanged(int strength);
138
139 /**
140 * This signal is emitted when the bitrate of this network has changed.
141 *
142 * @param bitrate the new bitrate value for this network
143 */
144 void bitRateChanged(int bitrate);
145
146 /**
147 * This signal is emitted when the capabilities of this network have changed.
148 *
149 * @param caps the new capabilities
150 */
151 void capabilitiesChanged(AccessPoint::Capabilities caps);
152
153 /**
154 * This signal is emitted when the WPA flags in use by this access point change
155 *
156 * @param flags the new flags
157 */
158 void wpaFlagsChanged(AccessPoint::WpaFlags flags);
159
160 /**
161 * This signal is emitted when the RSN(WPA2) flags in use by this access point change
162 *
163 * @param flags the new flags
164 */
165 void rsnFlagsChanged(AccessPoint::WpaFlags flags);
166 /**
167 * This signal is emitted when the ssid of this Access Point changes
168 *
169 * @param ssid the new SSID
170 */
171 void ssidChanged(const QString &ssid);
172
173 /**
174 * This signal is emitted when the frequency used by this Access Point changes
175 *
176 * @param frequency the new frequency
177 */
178 void frequencyChanged(uint frequency);
179
180 /**
181 * This signal is emitted when the timestamp for the last time the access point was found
182 * in scan results changes
183 *
184 * @param lastSeen the timestamp for the last time the access point was found in scan results.
185 * @since 5.14.0
186 * @see lastSeen
187 */
188 void lastSeenChanged(int lastSeen);
189
190private:
191 Q_DECLARE_PRIVATE(AccessPoint)
192
193 AccessPointPrivate *const d_ptr;
194};
195
196Q_DECLARE_OPERATORS_FOR_FLAGS(AccessPoint::WpaFlags)
197
198}
199#endif
200

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