1 | /* |
2 | SPDX-FileCopyrightText: 2008, 2011 Will Stephenson <wstephenson@kde.org> |
3 | SPDX-FileCopyrightText: 2011-2013 Lamarque V. Souza <lamarque@kde.org> |
4 | SPDX-FileCopyrightText: 2013 Daniel Nicoletti <dantti12@gmail.com> |
5 | SPDX-FileCopyrightText: 2013 Jan Grulich <jgrulich@redhat.com> |
6 | |
7 | SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL |
8 | */ |
9 | |
10 | #ifndef NETWORKMANAGERQT_WIRELESSDEVICE_H |
11 | #define NETWORKMANAGERQT_WIRELESSDEVICE_H |
12 | |
13 | #include "accesspoint.h" |
14 | #include "device.h" |
15 | #include "wirelessnetwork.h" |
16 | #include <networkmanagerqt/networkmanagerqt_export.h> |
17 | |
18 | #include <QDBusPendingReply> |
19 | |
20 | namespace NetworkManager |
21 | { |
22 | class WirelessDevicePrivate; |
23 | |
24 | /*! |
25 | * \class NetworkManager::WirelessDevice |
26 | * \inheaderfile NetworkManagerQt/WirelessDevice |
27 | * \inmodule NetworkManagerQt |
28 | * |
29 | * \brief A wireless network interface. |
30 | */ |
31 | class NETWORKMANAGERQT_EXPORT WirelessDevice : public Device |
32 | { |
33 | Q_OBJECT |
34 | |
35 | public: |
36 | /*! |
37 | * \typedef NetworkManager::WirelessDevice::Ptr |
38 | */ |
39 | typedef QSharedPointer<WirelessDevice> Ptr; |
40 | /*! |
41 | * \typedef NetworkManager::WirelessDevice::List |
42 | */ |
43 | typedef QList<Ptr> List; |
44 | /*! |
45 | * The device's current operating mode |
46 | * |
47 | * \value Unknown |
48 | * not associated with a network |
49 | * \value Adhoc |
50 | * part of an adhoc network |
51 | * \value Infra |
52 | * a station in an infrastructure wireless network |
53 | * \value ApMode |
54 | * access point in an infrastructure network |
55 | */ |
56 | enum OperationMode { |
57 | Unknown = 0, |
58 | Adhoc, |
59 | Infra, |
60 | ApMode, |
61 | }; |
62 | Q_ENUM(OperationMode) |
63 | /*! |
64 | * Capabilities (currently all encryption/authentication related) of the device |
65 | * \note FreqValid, Freq2Ghz, Freq5Ghz are available in runtime NM >= 1.0.2 |
66 | * |
67 | * The device's current operating mode |
68 | * |
69 | * \value NoCapability |
70 | * Null capability |
71 | * \value Wep40 |
72 | * 40 bit WEP cipher |
73 | * \value Wep104 |
74 | * 104 bit WEP cipher |
75 | * \value Tkip |
76 | * TKIP encryption cipher |
77 | * \value Ccmp |
78 | * CCMP encryption cipher |
79 | * \value WpaWpa |
80 | * WPA authentication protocol |
81 | * \value Rsn |
82 | * RSN authethication protocol |
83 | * \value ApCap |
84 | * The device supports Access Point mode. |
85 | * \value AdhocCap |
86 | * The device supports Ad-Hoc mode. |
87 | * \value FreqValid |
88 | * The device properly reports information about supported frequencies |
89 | * \value Freq2Ghz |
90 | * The device supports 2.4Ghz frequencies |
91 | * \value Freq5Ghz |
92 | * The device supports 5Ghz frequencies |
93 | * \value Mesh |
94 | * The device supports acting as a mesh point |
95 | * \value IBSSRsn |
96 | * device supports WPA2/RSN in an IBSS network |
97 | */ |
98 | enum Capability { |
99 | NoCapability = 0x0, |
100 | Wep40 = 0x1, |
101 | Wep104 = 0x2, |
102 | Tkip = 0x4, |
103 | Ccmp = 0x8, |
104 | Wpa = 0x10, |
105 | Rsn = 0x20, |
106 | ApCap = 0x40, |
107 | AdhocCap = 0x80, |
108 | FreqValid = 0x100, |
109 | Freq2Ghz = 0x200, |
110 | Freq5Ghz = 0x400, |
111 | Mesh = 0x1000, |
112 | IBSSRsn = 0x2000, |
113 | }; |
114 | Q_DECLARE_FLAGS(Capabilities, Capability) |
115 | /*! |
116 | * Creates a new WirelessDevice object. |
117 | * |
118 | * \a path the DBus path of the devise |
119 | */ |
120 | explicit WirelessDevice(const QString &path, QObject *parent = nullptr); |
121 | /*! |
122 | * Destroys a WirelessDevice object. |
123 | */ |
124 | ~WirelessDevice() override; |
125 | /*! |
126 | * Return the type |
127 | */ |
128 | Type type() const override; |
129 | /*! |
130 | * List of wireless networks currently visible to the hardware |
131 | */ |
132 | QStringList accessPoints() const; |
133 | /*! |
134 | * Asks the device for a new scan of available wireless networks |
135 | * |
136 | * \a options Options of scan |
137 | * |
138 | * No documentation for options yet, see |
139 | * https://projects.gnome.org/NetworkManager/developers/api/09/spec.html#org.freedesktop.NetworkManager.Device.Wireless |
140 | */ |
141 | QDBusPendingReply<> requestScan(const QVariantMap &options = QVariantMap()); |
142 | /*! |
143 | * AccessPoint pointer this interface is currently associated with |
144 | */ |
145 | AccessPoint::Ptr activeAccessPoint() const; |
146 | /*! |
147 | * The permanent hardware address of the network interface |
148 | */ |
149 | QString permanentHardwareAddress() const; |
150 | /*! |
151 | * The hardware address currently used by the network interface |
152 | */ |
153 | QString hardwareAddress() const; |
154 | |
155 | /*! |
156 | * Retrieves the operation mode of this network. |
157 | * |
158 | * Returns the current mode |
159 | * \sa OperationMode |
160 | */ |
161 | WirelessDevice::OperationMode mode() const; |
162 | /*! |
163 | * Retrieves the effective bit rate currently attainable by this device. |
164 | * |
165 | * Returns the bitrate in Kbit/s |
166 | */ |
167 | int bitRate() const; |
168 | /*! |
169 | * The LastScan property value, converted to QDateTime |
170 | * \since 5.62.0 |
171 | * \note will always return invalid QDateTime when runtime NM < 1.12 |
172 | * Returns |
173 | */ |
174 | QDateTime lastScan() const; |
175 | /*! |
176 | * The time the last RequestScan function was called |
177 | * \since 5.62.0 |
178 | * Returns |
179 | */ |
180 | QDateTime lastRequestScan() const; |
181 | /*! |
182 | * Retrieves the capabilities of this wifi network. |
183 | * |
184 | * Returns the flag set describing the capabilities |
185 | * \sa Capabilities |
186 | */ |
187 | WirelessDevice::Capabilities wirelessCapabilities() const; |
188 | |
189 | /*! |
190 | * Helper method to convert wire representation of operation mode to enum |
191 | */ |
192 | static WirelessDevice::OperationMode convertOperationMode(uint); |
193 | /*! |
194 | * Helper method to convert wire representation of capabilities to enum |
195 | */ |
196 | static WirelessDevice::Capabilities convertCapabilities(uint); |
197 | /*! |
198 | * Finds access point object given its Unique Network Identifier. |
199 | * |
200 | * \a uni the identifier of the AP to find from this network interface |
201 | * Returns a valid AccessPoint object if a network having the given UNI for this device is known to the system, 0 otherwise |
202 | */ |
203 | AccessPoint::Ptr findAccessPoint(const QString &uni); |
204 | |
205 | /*! |
206 | * Return the current list of networks |
207 | */ |
208 | WirelessNetwork::List networks() const; |
209 | |
210 | /*! |
211 | * Find a network with the given \a ssid, a Null object is |
212 | * returned if it can not be found |
213 | */ |
214 | WirelessNetwork::Ptr findNetwork(const QString &ssid) const; |
215 | |
216 | Q_SIGNALS: |
217 | /*! |
218 | * This signal is emitted when the bitrate of this network has changed. |
219 | * |
220 | * \a bitrate the new bitrate value for this network |
221 | */ |
222 | void bitRateChanged(int bitrate); |
223 | /*! |
224 | * The active network changed. |
225 | */ |
226 | void activeAccessPointChanged(const QString &); |
227 | /*! |
228 | * The device switched operating mode. |
229 | */ |
230 | void modeChanged(WirelessDevice::OperationMode); |
231 | /*! |
232 | * The device changed its capabilities |
233 | */ |
234 | void wirelessCapabilitiesChanged(Capabilities); |
235 | /*! |
236 | * The device changed its hardware address |
237 | */ |
238 | void hardwareAddressChanged(const QString &); |
239 | /*! |
240 | * The device changed its permanent hardware address |
241 | */ |
242 | void permanentHardwareAddressChanged(const QString &); |
243 | /*! |
244 | * The device changed its properties |
245 | */ |
246 | void wirelessPropertiesChanged(uint); // TODO this is bogus, remove |
247 | /*! |
248 | * A new wireless access point appeared |
249 | */ |
250 | void accessPointAppeared(const QString &uni); |
251 | /*! |
252 | * A wireless access point disappeared |
253 | */ |
254 | void accessPointDisappeared(const QString &uni); |
255 | /*! |
256 | * A wireless network appeared |
257 | */ |
258 | void networkAppeared(const QString &ssid); |
259 | /*! |
260 | * A wireless network disappeared |
261 | */ |
262 | void networkDisappeared(const QString &ssid); |
263 | /*! |
264 | * The LastScan property has changed, meaning a scan has just finished |
265 | * \since 5.62.0 |
266 | * \ |
267 | ote will never be emitted when runtime NM < 1.12 |
268 | * \sa lastScanTime |
269 | */ |
270 | void lastScanChanged(const QDateTime &dateTime); |
271 | |
272 | private: |
273 | Q_DECLARE_PRIVATE(WirelessDevice) |
274 | }; |
275 | |
276 | } // namespace NetworkManager |
277 | #endif // NETWORKMANAGERQT_WIRELESSDEVICE_H |
278 | |