Warning, file /plasma/plasma-nm/libs/models/networkmodel.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002     SPDX-FileCopyrightText: 2013-2018 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_MODEL_H
0008 #define PLASMA_NM_NETWORK_MODEL_H
0009 
0010 #include <QAbstractListModel>
0011 #include <QQueue>
0012 
0013 #include "networkitemslist.h"
0014 
0015 #include <NetworkManagerQt/Manager>
0016 #include <NetworkManagerQt/Utils>
0017 #include <NetworkManagerQt/VpnConnection>
0018 #include <NetworkManagerQt/WirelessDevice>
0019 
0020 #include <ModemManagerQt/Modem>
0021 
0022 class Q_DECL_EXPORT NetworkModel : public QAbstractListModel
0023 {
0024     Q_OBJECT
0025 public:
0026     // Delay model updates to prevent jumping password entry in the applet.
0027     // This is an aggregate property, which is true whenever any of model items is true.
0028     // BUG: 435430, 389052
0029     Q_PROPERTY(bool delayModelUpdates READ delayModelUpdates NOTIFY delayModelUpdatesChanged)
0030 
0031     explicit NetworkModel(QObject *parent = nullptr);
0032     ~NetworkModel() override;
0033 
0034     enum ItemRole {
0035         ConnectionDetailsRole = Qt::UserRole + 1,
0036         ConnectionIconRole,
0037         ConnectionPathRole,
0038         ConnectionStateRole,
0039         DeviceName,
0040         DevicePathRole,
0041         DeviceStateRole,
0042         DuplicateRole,
0043         ItemUniqueNameRole,
0044         ItemTypeRole,
0045         LastUsedRole,
0046         LastUsedDateOnlyRole,
0047         NameRole,
0048         SecurityTypeRole,
0049         SecurityTypeStringRole,
0050         SectionRole,
0051         SignalRole,
0052         SlaveRole,
0053         SsidRole,
0054         SpecificPathRole,
0055         TimeStampRole,
0056         TypeRole,
0057         UniRole,
0058         UuidRole,
0059         VpnState,
0060         VpnType,
0061         RxBytesRole,
0062         TxBytesRole,
0063         // writable roles
0064         DelayModelUpdatesRole,
0065     };
0066     Q_ENUMS(ItemRole)
0067 
0068     enum ModelChangeType { ItemAdded, ItemRemoved, ItemPropertyChanged };
0069 
0070     int rowCount(const QModelIndex &parent) const override;
0071     QVariant data(const QModelIndex &index, int role) const override;
0072     bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
0073     QHash<int, QByteArray> roleNames() const override;
0074 
0075     bool delayModelUpdates() const;
0076 
0077 Q_SIGNALS:
0078     void delayModelUpdatesChanged();
0079 
0080 public Q_SLOTS:
0081     void onItemUpdated();
0082     void setDeviceStatisticsRefreshRateMs(const QString &devicePath, uint refreshRate);
0083 
0084 private Q_SLOTS:
0085     void accessPointSignalStrengthChanged(int signal);
0086     void activeConnectionAdded(const QString &activeConnection);
0087     void activeConnectionRemoved(const QString &activeConnection);
0088     void activeConnectionStateChanged(NetworkManager::ActiveConnection::State state);
0089     void activeVpnConnectionStateChanged(NetworkManager::VpnConnection::State state, NetworkManager::VpnConnection::StateChangeReason reason);
0090     void availableConnectionAppeared(const QString &connection);
0091     void availableConnectionDisappeared(const QString &connection);
0092     void connectionAdded(const QString &connection);
0093     void connectionRemoved(const QString &connection);
0094     void connectionUpdated();
0095     void deviceAdded(const QString &device);
0096     void deviceRemoved(const QString &device);
0097     void deviceStateChanged(NetworkManager::Device::State state, NetworkManager::Device::State oldState, NetworkManager::Device::StateChangeReason reason);
0098     void gsmNetworkAccessTechnologiesChanged(QFlags<MMModemAccessTechnology> accessTechnologies);
0099     void gsmNetworkCurrentModesChanged();
0100     void gsmNetworkSignalQualityChanged(const ModemManager::SignalQualityPair &signalQuality);
0101     void ipConfigChanged();
0102     void ipInterfaceChanged();
0103     void statusChanged(NetworkManager::Status status);
0104     void wirelessNetworkAppeared(const QString &ssid);
0105     void wirelessNetworkDisappeared(const QString &ssid);
0106     void wirelessNetworkSignalChanged(int signal);
0107     void wirelessNetworkReferenceApChanged(const QString &accessPoint);
0108 
0109     void initialize();
0110 
0111 private:
0112     bool m_delayModelUpdates = false;
0113     NetworkItemsList m_list;
0114     QQueue<QPair<ModelChangeType, NetworkModelItem *>> m_updateQueue;
0115 
0116     void addActiveConnection(const NetworkManager::ActiveConnection::Ptr &activeConnection);
0117     void addAvailableConnection(const QString &connection, const NetworkManager::Device::Ptr &device);
0118     void addConnection(const NetworkManager::Connection::Ptr &connection);
0119     void addDevice(const NetworkManager::Device::Ptr &device);
0120     void addWirelessNetwork(const NetworkManager::WirelessNetwork::Ptr &network, const NetworkManager::WirelessDevice::Ptr &device);
0121     void checkAndCreateDuplicate(const QString &connection, const QString &deviceUni);
0122     void initializeSignals();
0123     void initializeSignals(const NetworkManager::ActiveConnection::Ptr &activeConnection);
0124     void initializeSignals(const NetworkManager::Connection::Ptr &connection);
0125     void initializeSignals(const NetworkManager::Device::Ptr &device);
0126     void initializeSignals(const NetworkManager::WirelessNetwork::Ptr &network);
0127     void
0128     updateFromWirelessNetwork(NetworkModelItem *item, const NetworkManager::WirelessNetwork::Ptr &network, const NetworkManager::WirelessDevice::Ptr &device);
0129     void updateDelayModelUpdates();
0130     void flushUpdateQueue();
0131 
0132     void insertItem(NetworkModelItem *item);
0133     void removeItem(NetworkModelItem *item);
0134     void updateItem(NetworkModelItem *item);
0135 
0136     NetworkManager::WirelessSecurityType alternativeWirelessSecurity(const NetworkManager::WirelessSecurityType type);
0137 };
0138 
0139 #endif // PLASMA_NM_NETWORK_MODEL_H