File indexing completed on 2023-12-03 12:27:02

0001 /*
0002     SPDX-FileCopyrightText: 2013 Jan Grulich <jgrulich@redhat.com>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005 */
0006 
0007 #ifndef PLASMA_NM_NETWORK_STATUS_H
0008 #define PLASMA_NM_NETWORK_STATUS_H
0009 
0010 #include <QObject>
0011 #include <QUrl>
0012 
0013 #include <qqmlregistration.h>
0014 
0015 #include <NetworkManagerQt/Manager>
0016 
0017 class NetworkStatus : public QObject
0018 {
0019     Q_OBJECT
0020     QML_ELEMENT
0021 
0022     /**
0023      * Returns a formated list of active connections or NM status when there is no active connection
0024      */
0025     Q_PROPERTY(QString activeConnections READ activeConnections NOTIFY activeConnectionsChanged)
0026 
0027     /**
0028      * Returns the KDE portal network check website URL
0029      */
0030     Q_PROPERTY(QUrl networkCheckUrl READ networkCheckUrl CONSTANT)
0031 
0032     /**
0033      * Returns the network connectivity state
0034      */
0035     Q_PROPERTY(NetworkManager::Connectivity connectivity READ connectivity NOTIFY connectivityChanged)
0036 public:
0037     enum SortedConnectionType {
0038         Wired,
0039         Wireless,
0040         Gsm,
0041         Cdma,
0042         Pppoe,
0043         Adsl,
0044         Infiniband,
0045         OLPCMesh,
0046         Bluetooth,
0047         Wireguard,
0048         Vpn,
0049         Other,
0050     };
0051 
0052     static SortedConnectionType connectionTypeToSortedType(NetworkManager::ConnectionSettings::ConnectionType type);
0053 
0054     explicit NetworkStatus(QObject *parent = nullptr);
0055     ~NetworkStatus() override;
0056 
0057     static QUrl networkCheckUrl();
0058 
0059     QString activeConnections() const;
0060     QString networkStatus() const;
0061     NetworkManager::Connectivity connectivity() const;
0062 
0063 private Q_SLOTS:
0064     void activeConnectionsChanged();
0065     void defaultChanged();
0066     void statusChanged(NetworkManager::Status status);
0067     void changeActiveConnections();
0068 
0069 Q_SIGNALS:
0070     void activeConnectionsChanged(const QString &activeConnections);
0071     void connectivityChanged(NetworkManager::Connectivity connectivity);
0072 
0073 private:
0074     QString m_activeConnections;
0075     QString m_networkStatus;
0076     NetworkManager::Connectivity m_connectivity = NetworkManager::UnknownConnectivity;
0077 
0078     QString checkUnknownReason() const;
0079 };
0080 
0081 #endif // PLAMA_NM_NETWORK_STATUS_H