File indexing completed on 2024-03-03 04:08:45

0001 /*
0002     SPDX-FileCopyrightText: 2009, 2011 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_WIRELESSNETWORK_H
0010 #define NETWORKMANAGERQT_WIRELESSNETWORK_H
0011 
0012 #include "accesspoint.h"
0013 #include <networkmanagerqt/networkmanagerqt_export.h>
0014 
0015 #include <QObject>
0016 #include <QSharedPointer>
0017 
0018 namespace NetworkManager
0019 {
0020 class WirelessDevice;
0021 class WirelessNetworkPrivate;
0022 
0023 /**
0024  * This class represents a wireless network, which aggregates all
0025  * access points with the same SSID
0026  */
0027 class NETWORKMANAGERQT_EXPORT WirelessNetwork : public QObject
0028 {
0029     Q_OBJECT
0030     friend class WirelessDevice;
0031     friend class WirelessDevicePrivate;
0032 
0033 public:
0034     typedef QSharedPointer<WirelessNetwork> Ptr;
0035     typedef QList<Ptr> List;
0036     ~WirelessNetwork() override;
0037     /**
0038      * ESSID of the network
0039      */
0040     QString ssid() const;
0041 
0042     /**
0043      * Signal strength of the network.  Syntactic sugar around tracking the reference access
0044      * point and watching its signal strength
0045      */
0046     int signalStrength() const;
0047 
0048     /**
0049      * The uni of the current 'best' (strongest) Access Point. Note that this may change or disappear over time.
0050      * Get the Access Point object using @ref WirelessDevice::findAccessPoint() on the NetworkInterface this network was obtained from.
0051      * Use @ref WirelessDevice::accessPointDisappeared() or
0052      * WirelessNetwork::referenceAccessPointChanged() to detect this.
0053      */
0054     AccessPoint::Ptr referenceAccessPoint() const;
0055 
0056     /**
0057      * List of access points
0058      * @warning Subject to change, do not store!
0059      */
0060     AccessPoint::List accessPoints() const;
0061 
0062     /**
0063      * The uni of device associated with this network.
0064      */
0065     QString device() const;
0066 
0067 Q_SIGNALS:
0068     /**
0069      * Indicate that the signal strength changed
0070      * @param strength strength as a percentage.
0071      */
0072     void signalStrengthChanged(int strength);
0073     /**
0074      * Indicate that the reference access point changed
0075      * @param apUni new access point or empty string if none
0076      */
0077     void referenceAccessPointChanged(const QString &apUni);
0078     /**
0079      * Indicate that this network has no more access points
0080      * (meaning the network has disappeared from view of the network interface)
0081      * @param ssid the SSID of this network
0082      */
0083     void disappeared(const QString &ssid);
0084 
0085 private:
0086     Q_DECLARE_PRIVATE(WirelessNetwork)
0087     Q_PRIVATE_SLOT(d_func(), void accessPointAppeared(const QString &))
0088     Q_PRIVATE_SLOT(d_func(), void accessPointDisappeared(const QString &))
0089     Q_PRIVATE_SLOT(d_func(), void updateStrength())
0090 
0091     WirelessNetworkPrivate *const d_ptr;
0092 
0093     NETWORKMANAGERQT_NO_EXPORT explicit WirelessNetwork(const AccessPoint::Ptr &accessPoint, WirelessDevice *device);
0094 };
0095 
0096 }
0097 #endif // NETWORKMANAGERQT_WIRELESSNETWORK_H