File indexing completed on 2024-10-06 03:43:48

0001 /*
0002     SPDX-FileCopyrightText: 2008, 2010 Will Stephenson <wstephenson@kde.org>
0003     SPDX-FileCopyrightText: 2013 Jan Grulich <jgrulich@redhat.com>
0004 
0005     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0006 */
0007 
0008 #ifndef NETWORKMANAGERQT_NETWORKMANAGER_P_H
0009 #define NETWORKMANAGERQT_NETWORKMANAGER_P_H
0010 
0011 #include <QDBusServiceWatcher>
0012 #include <QMap>
0013 
0014 #include "activeconnection.h"
0015 #include "dbus/networkmanagerinterface.h"
0016 #include "device.h"
0017 
0018 #include "manager.h"
0019 
0020 namespace NetworkManager
0021 {
0022 class Device;
0023 class ActiveConnection;
0024 
0025 class NetworkManagerPrivate : public NetworkManager::Notifier
0026 {
0027     Q_OBJECT
0028 public:
0029     static const QString DBUS_SERVICE;
0030     static const QString DBUS_DAEMON_INTERFACE;
0031     static const QString DBUS_DAEMON_PATH;
0032     static const QString DBUS_SETTINGS_PATH;
0033     static const QString FDO_DBUS_PROPERTIES;
0034     static const QString FDO_DBUS_OBJECT_MANAGER;
0035 
0036     // Functions useful also for other classes
0037     static QVariantMap retrieveInitialProperties(const QString &interfaceName, const QString &path);
0038 
0039     NetworkManagerPrivate();
0040     ~NetworkManagerPrivate() override;
0041     QDBusServiceWatcher watcher;
0042     OrgFreedesktopNetworkManagerInterface iface;
0043     NetworkManager::Status nmState;
0044     Connectivity m_connectivity;
0045     bool m_isNetworkingEnabled;
0046     bool m_isWimaxEnabled;
0047     // TODO: mark it deprecated somehow?
0048     bool m_isWimaxHardwareEnabled;
0049     bool m_isWirelessEnabled;
0050     bool m_isWirelessHardwareEnabled;
0051     bool m_isWwanEnabled;
0052     bool m_isWwanHardwareEnabled;
0053     QString m_activatingConnection;
0054     QString m_primaryConnection;
0055     NetworkManager::ConnectionSettings::ConnectionType m_primaryConnectionType;
0056     NetworkManager::Device::MeteredStatus m_metered;
0057     NetworkManager::DnsConfiguration m_globalDnsConfiguration;
0058     QString m_version;
0059     // to store NetworkManager's version.
0060     int m_x;
0061     int m_y;
0062     int m_z;
0063     void parseVersion(const QString &version);
0064     int compareVersion(const QString &version);
0065     int compareVersion(const int x, const int y, const int z) const;
0066     bool checkVersion(const int x, const int y, const int z) const;
0067     NetworkManager::Device::Types m_supportedInterfaceTypes;
0068     NetworkManager::Device::Types supportedInterfaceTypes() const;
0069 
0070     QMap<QString, ActiveConnection::Ptr> m_activeConnections;
0071     ActiveConnection::Ptr findRegisteredActiveConnection(const QString &);
0072     // manage device children
0073     Device::Ptr findRegisteredNetworkInterface(const QString &uni);
0074     Device::Ptr createNetworkInterface(const QString &uni);
0075     QMap<QString, Device::Ptr> networkInterfaceMap;
0076     // for frontend to call
0077     QString version() const;
0078     NetworkManager::Status status() const;
0079     Device::List networkInterfaces();
0080     Device::Ptr findNetworkInterface(const QString &uni);
0081     Device::Ptr findDeviceByIpIface(const QString &iface);
0082     bool isNetworkingEnabled() const;
0083     bool isWirelessEnabled() const;
0084     bool isWirelessHardwareEnabled() const;
0085     bool isWwanEnabled() const;
0086     bool isWwanHardwareEnabled() const;
0087     bool isWimaxEnabled() const;
0088     // TODO: mark it deprecated somehow?
0089     bool isWimaxHardwareEnabled() const;
0090     QDBusPendingReply<QDBusObjectPath> activateConnection(const QString &connectionUni, const QString &interfaceUni, const QString &connectionParameter);
0091     QDBusPendingReply<QDBusObjectPath, QDBusObjectPath>
0092     addAndActivateConnection(const NMVariantMapMap &connection, const QString &interfaceUni, const QString &connectionParameter);
0093     QDBusPendingReply<QDBusObjectPath, QDBusObjectPath, QVariantMap>
0094     addAndActivateConnection2(const NMVariantMapMap &connection, const QString &interfaceUni, const QString &connectionParameter, const QVariantMap &options);
0095     QDBusPendingReply<> deactivateConnection(const QString &activeConnection);
0096     ActiveConnection::List activeConnections();
0097     QStringList activeConnectionsPaths() const;
0098     QDBusPendingReply<QString, QString> getLogging();
0099     void setNetworkingEnabled(bool enabled);
0100     void setWirelessEnabled(bool enabled);
0101     void setWwanEnabled(bool enabled);
0102     // TODO: mark it deprecated somehow?
0103     void setWimaxEnabled(bool enabled);
0104     void sleep(bool sleep);
0105     void setLogging(NetworkManager::LogLevel, NetworkManager::LogDomains);
0106     NMStringMap permissions();
0107     Connectivity connectivity() const;
0108     QDBusPendingReply<uint> checkConnectivity();
0109     ActiveConnection::Ptr primaryConnection();
0110     ActiveConnection::Ptr activatingConnection();
0111     NetworkManager::ConnectionSettings::ConnectionType primaryConnectionType();
0112     bool isStartingUp() const;
0113     NetworkManager::Device::MeteredStatus metered() const;
0114     NetworkManager::DnsConfiguration globalDnsConfiguration() const;
0115     void setGlobalDnsConfiguration(const NetworkManager::DnsConfiguration &configuration);
0116 protected Q_SLOTS:
0117     void init();
0118     void onDeviceAdded(const QDBusObjectPath &state);
0119     void onDeviceRemoved(const QDBusObjectPath &state);
0120     void dbusPropertiesChanged(const QString &interfaceName, const QVariantMap &properties, const QStringList &invalidatedProperties);
0121     void propertiesChanged(const QVariantMap &changedProperties);
0122     void dbusInterfacesAdded(const QDBusObjectPath &path, const QVariantMap &addedInterfaces);
0123     void daemonRegistered();
0124     void daemonUnregistered();
0125 
0126 private:
0127     void connectivityChanged(uint connectivity);
0128     void stateChanged(uint state);
0129     static NetworkManager::Connectivity convertConnectivity(uint connectivity);
0130     static NetworkManager::Status convertNMState(uint state);
0131 };
0132 }
0133 #endif