| 1 | /* |
| 2 | SPDX-FileCopyrightText: 2008, 2010 Will Stephenson <wstephenson@kde.org> |
| 3 | SPDX-FileCopyrightText: 2013 Jan Grulich <jgrulich@redhat.com> |
| 4 | |
| 5 | SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL |
| 6 | */ |
| 7 | |
| 8 | #ifndef NETWORKMANAGERQT_NETWORKMANAGER_P_H |
| 9 | #define NETWORKMANAGERQT_NETWORKMANAGER_P_H |
| 10 | |
| 11 | #include <QDBusServiceWatcher> |
| 12 | #include <QMap> |
| 13 | |
| 14 | #include "activeconnection.h" |
| 15 | #include "dbus/networkmanagerinterface.h" |
| 16 | #include "device.h" |
| 17 | |
| 18 | #include "manager.h" |
| 19 | |
| 20 | namespace NetworkManager |
| 21 | { |
| 22 | class Device; |
| 23 | class ActiveConnection; |
| 24 | |
| 25 | class NetworkManagerPrivate : public NetworkManager::Notifier |
| 26 | { |
| 27 | Q_OBJECT |
| 28 | public: |
| 29 | static const QString DBUS_SERVICE; |
| 30 | static const QString DBUS_DAEMON_INTERFACE; |
| 31 | static const QString DBUS_DAEMON_PATH; |
| 32 | static const QString DBUS_SETTINGS_PATH; |
| 33 | static const QString FDO_DBUS_PROPERTIES; |
| 34 | static const QString FDO_DBUS_OBJECT_MANAGER; |
| 35 | |
| 36 | // Functions useful also for other classes |
| 37 | static QVariantMap retrieveInitialProperties(const QString &interfaceName, const QString &path); |
| 38 | |
| 39 | NetworkManagerPrivate(); |
| 40 | ~NetworkManagerPrivate() override; |
| 41 | QDBusServiceWatcher watcher; |
| 42 | OrgFreedesktopNetworkManagerInterface iface; |
| 43 | NetworkManager::Status nmState; |
| 44 | Connectivity m_connectivity; |
| 45 | bool m_isNetworkingEnabled; |
| 46 | bool m_isWimaxEnabled; |
| 47 | // TODO: mark it deprecated somehow? |
| 48 | bool m_isWimaxHardwareEnabled; |
| 49 | bool m_isWirelessEnabled; |
| 50 | bool m_isWirelessHardwareEnabled; |
| 51 | bool m_isWwanEnabled; |
| 52 | bool m_isWwanHardwareEnabled; |
| 53 | bool m_isConnectivityCheckAvailable; |
| 54 | bool m_isConnectivityCheckEnabled; |
| 55 | QString m_connectivityCheckUri; |
| 56 | QString m_activatingConnection; |
| 57 | QString m_primaryConnection; |
| 58 | NetworkManager::ConnectionSettings::ConnectionType m_primaryConnectionType; |
| 59 | NetworkManager::Device::MeteredStatus m_metered; |
| 60 | NetworkManager::DnsConfiguration m_globalDnsConfiguration; |
| 61 | QString m_version; |
| 62 | // to store NetworkManager's version. |
| 63 | int m_x; |
| 64 | int m_y; |
| 65 | int m_z; |
| 66 | void parseVersion(const QString &version); |
| 67 | int compareVersion(const QString &version); |
| 68 | int compareVersion(const int x, const int y, const int z) const; |
| 69 | bool checkVersion(const int x, const int y, const int z) const; |
| 70 | NetworkManager::Device::Types m_supportedInterfaceTypes; |
| 71 | NetworkManager::Device::Types supportedInterfaceTypes() const; |
| 72 | |
| 73 | QMap<QString, ActiveConnection::Ptr> m_activeConnections; |
| 74 | ActiveConnection::Ptr findRegisteredActiveConnection(const QString &); |
| 75 | // manage device children |
| 76 | Device::Ptr findRegisteredNetworkInterface(const QString &uni); |
| 77 | Device::Ptr createNetworkInterface(const QString &uni); |
| 78 | QMap<QString, Device::Ptr> networkInterfaceMap; |
| 79 | // for frontend to call |
| 80 | QString version() const; |
| 81 | NetworkManager::Status status() const; |
| 82 | Device::List networkInterfaces(); |
| 83 | Device::Ptr findNetworkInterface(const QString &uni); |
| 84 | Device::Ptr findDeviceByIpIface(const QString &iface); |
| 85 | bool isNetworkingEnabled() const; |
| 86 | bool isWirelessEnabled() const; |
| 87 | bool isWirelessHardwareEnabled() const; |
| 88 | bool isWwanEnabled() const; |
| 89 | bool isWwanHardwareEnabled() const; |
| 90 | bool isWimaxEnabled() const; |
| 91 | // TODO: mark it deprecated somehow? |
| 92 | bool isWimaxHardwareEnabled() const; |
| 93 | QDBusPendingReply<QDBusObjectPath> activateConnection(const QString &connectionUni, const QString &interfaceUni, const QString &connectionParameter); |
| 94 | QDBusPendingReply<QDBusObjectPath, QDBusObjectPath> |
| 95 | addAndActivateConnection(const NMVariantMapMap &connection, const QString &interfaceUni, const QString &connectionParameter); |
| 96 | QDBusPendingReply<QDBusObjectPath, QDBusObjectPath, QVariantMap> |
| 97 | addAndActivateConnection2(const NMVariantMapMap &connection, const QString &interfaceUni, const QString &connectionParameter, const QVariantMap &options); |
| 98 | QDBusPendingReply<> deactivateConnection(const QString &activeConnection); |
| 99 | ActiveConnection::List activeConnections(); |
| 100 | QStringList activeConnectionsPaths() const; |
| 101 | QDBusPendingReply<QString, QString> getLogging(); |
| 102 | void setNetworkingEnabled(bool enabled); |
| 103 | void setWirelessEnabled(bool enabled); |
| 104 | void setWwanEnabled(bool enabled); |
| 105 | // TODO: mark it deprecated somehow? |
| 106 | void setWimaxEnabled(bool enabled); |
| 107 | void sleep(bool sleep); |
| 108 | void setLogging(NetworkManager::LogLevel, NetworkManager::LogDomains); |
| 109 | NMStringMap permissions(); |
| 110 | Connectivity connectivity() const; |
| 111 | QDBusPendingReply<uint> checkConnectivity(); |
| 112 | ActiveConnection::Ptr primaryConnection(); |
| 113 | ActiveConnection::Ptr activatingConnection(); |
| 114 | NetworkManager::ConnectionSettings::ConnectionType primaryConnectionType(); |
| 115 | bool isStartingUp() const; |
| 116 | NetworkManager::Device::MeteredStatus metered() const; |
| 117 | NetworkManager::DnsConfiguration globalDnsConfiguration() const; |
| 118 | void setGlobalDnsConfiguration(const NetworkManager::DnsConfiguration &configuration); |
| 119 | bool isConnectivityCheckAvailable() const; |
| 120 | bool isConnectivityCheckEnabled() const; |
| 121 | QString connectivityCheckUri() const; |
| 122 | protected Q_SLOTS: |
| 123 | void init(); |
| 124 | void onDeviceAdded(const QDBusObjectPath &state); |
| 125 | void onDeviceRemoved(const QDBusObjectPath &state); |
| 126 | void dbusPropertiesChanged(const QString &interfaceName, const QVariantMap &properties, const QStringList &invalidatedProperties); |
| 127 | void propertiesChanged(const QVariantMap &changedProperties); |
| 128 | void dbusInterfacesAdded(const QDBusObjectPath &path, const QVariantMap &addedInterfaces); |
| 129 | void daemonRegistered(); |
| 130 | void daemonUnregistered(); |
| 131 | |
| 132 | private: |
| 133 | void connectivityChanged(uint connectivity); |
| 134 | void stateChanged(uint state); |
| 135 | static NetworkManager::Connectivity convertConnectivity(uint connectivity); |
| 136 | static NetworkManager::Status convertNMState(uint state); |
| 137 | }; |
| 138 | } |
| 139 | #endif |
| 140 | |