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

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