File indexing completed on 2024-04-14 14:30:34

0001 /*
0002     SPDX-FileCopyrightText: 2008 Will Stephenson <wstephenson@kde.org>
0003     SPDX-FileCopyrightText: 2011-2013 Lamarque V. Souza <lamarque@kde.org>
0004     SPDX-FileCopyrightText: 2013 Jan Grulich <jgrulich@redhat.com>
0005 
0006     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0007 */
0008 
0009 #ifndef NETWORKMANAGERQT_ACCESSPOINT_H
0010 #define NETWORKMANAGERQT_ACCESSPOINT_H
0011 
0012 #include <networkmanagerqt/networkmanagerqt_export.h>
0013 
0014 #include <nm-version.h>
0015 
0016 #include <QObject>
0017 #include <QSharedPointer>
0018 #include <QVariantMap>
0019 
0020 namespace NetworkManager
0021 {
0022 class AccessPointPrivate;
0023 
0024 /**
0025  * Represents an access point
0026  */
0027 class NETWORKMANAGERQT_EXPORT AccessPoint : public QObject
0028 {
0029     Q_OBJECT
0030 public:
0031     typedef QSharedPointer<AccessPoint> Ptr;
0032     typedef QList<Ptr> List;
0033     /**
0034      * The access point's current operating mode
0035      */
0036     enum OperationMode {
0037         Unknown = 0, /**< not associated with a network */
0038         Adhoc, /**< part of an adhoc network */
0039         Infra, /**< a station in an infrastructure wireless network */
0040         ApMode, /**< access point in an infrastructure network */
0041     };
0042     /**
0043      * General capabilities of an access point
0044      */
0045     enum Capability {
0046         None = 0x0, /**< Null capability - says nothing about the access point */
0047         Privacy = 0x1, /**< Access point supports privacy measures */
0048     };
0049     /**
0050      * Flags describing the access point's capabilities according to WPA (Wifi Protected Access)
0051      */
0052     enum WpaFlag {
0053         PairWep40 = 0x1,
0054         PairWep104 = 0x2,
0055         PairTkip = 0x4,
0056         PairCcmp = 0x8,
0057         GroupWep40 = 0x10,
0058         GroupWep104 = 0x20,
0059         GroupTkip = 0x40,
0060         GroupCcmp = 0x80,
0061         KeyMgmtPsk = 0x100,
0062         KeyMgmt8021x = 0x200,
0063         KeyMgmtSAE = 0x400,
0064         KeyMgmtEapSuiteB192 = 0x2000,
0065     };
0066     Q_DECLARE_FLAGS(Capabilities, Capability)
0067     Q_FLAG(Capabilities)
0068     Q_DECLARE_FLAGS(WpaFlags, WpaFlag)
0069     Q_FLAG(WpaFlags)
0070     explicit AccessPoint(const QString &path, QObject *parent = nullptr);
0071     ~AccessPoint() override;
0072 
0073     /**
0074      * @return path of the access point
0075      */
0076     QString uni() const;
0077     /**
0078      * @return capabilities of an access point
0079      */
0080     Capabilities capabilities() const;
0081     /**
0082      * @return flags describing the access point's capabilities according to WPA (Wifi Protected Access).
0083      * @see WpaFlag
0084      */
0085     AccessPoint::WpaFlags wpaFlags() const;
0086     /**
0087      * @return Flags describing the access point's capabilities according to the RSN (Robust Secure Network) protocol.
0088      * @see WpaFlag
0089      */
0090     AccessPoint::WpaFlags rsnFlags() const;
0091     /**
0092      * @return The Service Set Identifier identifying the access point.
0093      */
0094     QString ssid() const;
0095     /**
0096      * @return raw SSID, encoded as a byte array
0097      */
0098     QByteArray rawSsid() const;
0099     /**
0100      * @return The radio channel frequency in use by the access point, in MHz.
0101      */
0102     uint frequency() const;
0103     /**
0104      * @return The hardware address (BSSID) of the access point.
0105      */
0106     QString hardwareAddress() const;
0107     /**
0108      * @return The maximum bitrate this access point is capable of, in kilobits/second (Kb/s).
0109      */
0110     uint maxBitRate() const;
0111     /**
0112      * @return Describes the operating mode of the access point.
0113      */
0114     OperationMode mode() const;
0115     /**
0116      * @return The current signal quality of the access point, in percent.
0117      */
0118     int signalStrength() const;
0119     /**
0120      * @return The timestamp (in CLOCK_BOOTTIME seconds) for the last time the access point
0121      * was found in scan results. A value of -1 means the access point has never been found in scan results.
0122      * @since 5.14.0
0123      */
0124     int lastSeen() const;
0125 
0126     /**
0127      * Helper method to convert wire representation of operation @p mode to enum
0128      */
0129     static OperationMode convertOperationMode(uint mode);
0130 
0131 Q_SIGNALS:
0132     /**
0133      * This signal is emitted when the signal strength of this network has changed.
0134      *
0135      * @param strength the new signal strength value for this network
0136      */
0137     void signalStrengthChanged(int strength);
0138 
0139     /**
0140      * This signal is emitted when the bitrate of this network has changed.
0141      *
0142      * @param bitrate the new bitrate value for this network
0143      */
0144     void bitRateChanged(int bitrate);
0145 
0146     /**
0147      * This signal is emitted when the capabilities of this network have changed.
0148      *
0149      * @param caps the new capabilities
0150      */
0151     void capabilitiesChanged(AccessPoint::Capabilities caps);
0152 
0153     /**
0154      * This signal is emitted when the WPA flags in use by this access point change
0155      *
0156      * @param flags the new flags
0157      */
0158     void wpaFlagsChanged(AccessPoint::WpaFlags flags);
0159 
0160     /**
0161      * This signal is emitted when the RSN(WPA2) flags in use by this access point change
0162      *
0163      * @param flags the new flags
0164      */
0165     void rsnFlagsChanged(AccessPoint::WpaFlags flags);
0166     /**
0167      * This signal is emitted when the ssid of this Access Point changes
0168      *
0169      * @param ssid the new SSID
0170      */
0171     void ssidChanged(const QString &ssid);
0172 
0173     /**
0174      * This signal is emitted when the frequency used by this Access Point changes
0175      *
0176      * @param frequency the new frequency
0177      */
0178     void frequencyChanged(uint frequency);
0179 
0180     /**
0181      * This signal is emitted when the timestamp for the last time the access point was found
0182      * in scan results changes
0183      *
0184      * @param lastSeen the timestamp for the last time the access point was found in scan results.
0185      * @since 5.14.0
0186      * @see lastSeen
0187      */
0188     void lastSeenChanged(int lastSeen);
0189 
0190 private:
0191     Q_DECLARE_PRIVATE(AccessPoint)
0192 
0193     AccessPointPrivate *const d_ptr;
0194 };
0195 
0196 Q_DECLARE_OPERATORS_FOR_FLAGS(AccessPoint::WpaFlags)
0197 
0198 }
0199 #endif