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 | QString m_activatingConnection; |
54 | QString m_primaryConnection; |
55 | NetworkManager::ConnectionSettings::ConnectionType m_primaryConnectionType; |
56 | NetworkManager::Device::MeteredStatus m_metered; |
57 | NetworkManager::DnsConfiguration m_globalDnsConfiguration; |
58 | QString m_version; |
59 | // to store NetworkManager's version. |
60 | int m_x; |
61 | int m_y; |
62 | int m_z; |
63 | void parseVersion(const QString &version); |
64 | int compareVersion(const QString &version); |
65 | int compareVersion(const int x, const int y, const int z) const; |
66 | bool checkVersion(const int x, const int y, const int z) const; |
67 | NetworkManager::Device::Types m_supportedInterfaceTypes; |
68 | NetworkManager::Device::Types supportedInterfaceTypes() const; |
69 | |
70 | QMap<QString, ActiveConnection::Ptr> m_activeConnections; |
71 | ActiveConnection::Ptr findRegisteredActiveConnection(const QString &); |
72 | // manage device children |
73 | Device::Ptr findRegisteredNetworkInterface(const QString &uni); |
74 | Device::Ptr createNetworkInterface(const QString &uni); |
75 | QMap<QString, Device::Ptr> networkInterfaceMap; |
76 | // for frontend to call |
77 | QString version() const; |
78 | NetworkManager::Status status() const; |
79 | Device::List networkInterfaces(); |
80 | Device::Ptr findNetworkInterface(const QString &uni); |
81 | Device::Ptr findDeviceByIpIface(const QString &iface); |
82 | bool isNetworkingEnabled() const; |
83 | bool isWirelessEnabled() const; |
84 | bool isWirelessHardwareEnabled() const; |
85 | bool isWwanEnabled() const; |
86 | bool isWwanHardwareEnabled() const; |
87 | bool isWimaxEnabled() const; |
88 | // TODO: mark it deprecated somehow? |
89 | bool isWimaxHardwareEnabled() const; |
90 | QDBusPendingReply<QDBusObjectPath> activateConnection(const QString &connectionUni, const QString &interfaceUni, const QString &connectionParameter); |
91 | QDBusPendingReply<QDBusObjectPath, QDBusObjectPath> |
92 | addAndActivateConnection(const NMVariantMapMap &connection, const QString &interfaceUni, const QString &connectionParameter); |
93 | QDBusPendingReply<QDBusObjectPath, QDBusObjectPath, QVariantMap> |
94 | addAndActivateConnection2(const NMVariantMapMap &connection, const QString &interfaceUni, const QString &connectionParameter, const QVariantMap &options); |
95 | QDBusPendingReply<> deactivateConnection(const QString &activeConnection); |
96 | ActiveConnection::List activeConnections(); |
97 | QStringList activeConnectionsPaths() const; |
98 | QDBusPendingReply<QString, QString> getLogging(); |
99 | void setNetworkingEnabled(bool enabled); |
100 | void setWirelessEnabled(bool enabled); |
101 | void setWwanEnabled(bool enabled); |
102 | // TODO: mark it deprecated somehow? |
103 | void setWimaxEnabled(bool enabled); |
104 | void sleep(bool sleep); |
105 | void setLogging(NetworkManager::LogLevel, NetworkManager::LogDomains); |
106 | NMStringMap permissions(); |
107 | Connectivity connectivity() const; |
108 | QDBusPendingReply<uint> checkConnectivity(); |
109 | ActiveConnection::Ptr primaryConnection(); |
110 | ActiveConnection::Ptr activatingConnection(); |
111 | NetworkManager::ConnectionSettings::ConnectionType primaryConnectionType(); |
112 | bool isStartingUp() const; |
113 | NetworkManager::Device::MeteredStatus metered() const; |
114 | NetworkManager::DnsConfiguration globalDnsConfiguration() const; |
115 | void setGlobalDnsConfiguration(const NetworkManager::DnsConfiguration &configuration); |
116 | protected Q_SLOTS: |
117 | void init(); |
118 | void onDeviceAdded(const QDBusObjectPath &state); |
119 | void onDeviceRemoved(const QDBusObjectPath &state); |
120 | void dbusPropertiesChanged(const QString &interfaceName, const QVariantMap &properties, const QStringList &invalidatedProperties); |
121 | void propertiesChanged(const QVariantMap &changedProperties); |
122 | void dbusInterfacesAdded(const QDBusObjectPath &path, const QVariantMap &addedInterfaces); |
123 | void daemonRegistered(); |
124 | void daemonUnregistered(); |
125 | |
126 | private: |
127 | void connectivityChanged(uint connectivity); |
128 | void stateChanged(uint state); |
129 | static NetworkManager::Connectivity convertConnectivity(uint connectivity); |
130 | static NetworkManager::Status convertNMState(uint state); |
131 | }; |
132 | } |
133 | #endif |
134 | |