1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the plugins of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#ifndef QNETWORKMANAGERSERVICE_H
41#define QNETWORKMANAGERSERVICE_H
42
43//
44// W A R N I N G
45// -------------
46//
47// This file is not part of the Qt API. It exists purely as an
48// implementation detail. This header file may change from version to
49// version without notice, or even be removed.
50//
51// We mean it.
52//
53
54#include <QtDBus/QtDBus>
55#include <QtDBus/QDBusConnection>
56#include <QtDBus/QDBusError>
57#include <QtDBus/QDBusInterface>
58#include <QtDBus/QDBusMessage>
59#include <QtDBus/QDBusReply>
60
61#include <QtDBus/QDBusPendingCallWatcher>
62#include <QtDBus/QDBusObjectPath>
63#include <QtDBus/QDBusContext>
64#include <QtDBus/QDBusAbstractInterface>
65#include <QMap>
66
67#ifndef QT_NO_DBUS
68
69#ifndef NETWORK_MANAGER_H
70typedef enum NMDeviceType
71{
72 DEVICE_TYPE_UNKNOWN = 0,
73 DEVICE_TYPE_ETHERNET,
74 DEVICE_TYPE_WIFI,
75 DEVICE_TYPE_MODEM = 8
76} NMDeviceType;
77
78typedef enum
79{
80 NM_DEVICE_STATE_UNKNOWN = 0,
81 NM_DEVICE_STATE_UNMANAGED = 10,
82 NM_DEVICE_STATE_UNAVAILABLE = 20,
83 NM_DEVICE_STATE_DISCONNECTED = 30,
84 NM_DEVICE_STATE_PREPARE = 40,
85 NM_DEVICE_STATE_CONFIG = 50,
86 NM_DEVICE_STATE_NEED_AUTH = 60,
87 NM_DEVICE_STATE_IP_CONFIG = 70,
88 NM_DEVICE_STATE_ACTIVATED = 100,
89 NM_DEVICE_STATE_DEACTIVATING = 110,
90 NM_DEVICE_STATE_FAILED = 120
91} NMDeviceState;
92
93typedef enum
94{
95 NM_ACTIVE_CONNECTION_STATE_UNKNOWN = 0,
96 NM_ACTIVE_CONNECTION_STATE_ACTIVATING,
97 NM_ACTIVE_CONNECTION_STATE_ACTIVATED,
98 NM_ACTIVE_CONNECTION_STATE_DEACTIVATED = 4
99} NMActiveConnectionState;
100
101#define NM_DBUS_SERVICE "org.freedesktop.NetworkManager"
102
103#define NM_DBUS_PATH "/org/freedesktop/NetworkManager"
104#define NM_DBUS_INTERFACE "org.freedesktop.NetworkManager"
105#define NM_DBUS_INTERFACE_DEVICE NM_DBUS_INTERFACE ".Device"
106#define NM_DBUS_INTERFACE_DEVICE_WIRED NM_DBUS_INTERFACE_DEVICE ".Wired"
107#define NM_DBUS_INTERFACE_DEVICE_WIRELESS NM_DBUS_INTERFACE_DEVICE ".Wireless"
108#define NM_DBUS_INTERFACE_DEVICE_MODEM NM_DBUS_INTERFACE_DEVICE ".Modem"
109#define NM_DBUS_PATH_ACCESS_POINT NM_DBUS_PATH "/AccessPoint"
110#define NM_DBUS_INTERFACE_ACCESS_POINT NM_DBUS_INTERFACE ".AccessPoint"
111
112#define NM_DBUS_PATH_SETTINGS "/org/freedesktop/NetworkManager/Settings"
113
114#define NM_DBUS_IFACE_SETTINGS_CONNECTION "org.freedesktop.NetworkManager.Settings.Connection"
115#define NM_DBUS_IFACE_SETTINGS "org.freedesktop.NetworkManager.Settings"
116#define NM_DBUS_INTERFACE_ACTIVE_CONNECTION NM_DBUS_INTERFACE ".Connection.Active"
117#define NM_DBUS_INTERFACE_IP4_CONFIG NM_DBUS_INTERFACE ".IP4Config"
118
119#define NM_DBUS_SERVICE_USER_SETTINGS "org.freedesktop.NetworkManagerUserSettings"
120#define NM_DBUS_SERVICE_SYSTEM_SETTINGS "org.freedesktop.NetworkManagerSystemSettings"
121
122#define NM_802_11_AP_FLAGS_NONE 0x00000000
123#define NM_802_11_AP_FLAGS_PRIVACY 0x00000001
124#endif
125
126QT_BEGIN_NAMESPACE
127
128typedef QMap< QString, QMap<QString,QVariant> > QNmSettingsMap;
129typedef QList<quint32> ServerThing;
130
131QT_END_NAMESPACE
132
133Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(QNmSettingsMap))
134Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(ServerThing))
135
136QT_BEGIN_NAMESPACE
137
138class QNetworkManagerInterface : public QDBusAbstractInterface
139{
140 Q_OBJECT
141
142public:
143 typedef enum
144 {
145 NM_STATE_UNKNOWN = 0,
146 NM_STATE_ASLEEP = 10,
147 NM_STATE_DISCONNECTED = 20,
148 NM_STATE_DISCONNECTING = 30,
149 NM_STATE_CONNECTING = 40,
150 NM_STATE_CONNECTED_LOCAL = 50,
151 NM_STATE_CONNECTED_SITE = 60,
152 NM_STATE_CONNECTED_GLOBAL = 70
153 } NMState;
154
155 QNetworkManagerInterface(QObject *parent = nullptr);
156 ~QNetworkManagerInterface();
157
158 QList <QDBusObjectPath> getDevices();
159 void activateConnection(QDBusObjectPath connection,QDBusObjectPath device, QDBusObjectPath specificObject);
160 void deactivateConnection(QDBusObjectPath connectionPath);
161
162 QDBusObjectPath path() const;
163
164 bool wirelessEnabled() const;
165 bool wirelessHardwareEnabled() const;
166 QList <QDBusObjectPath> activeConnections() const;
167 NMState state();
168 QString version() const;
169 bool setConnections();
170
171Q_SIGNALS:
172 void deviceAdded(QDBusObjectPath);
173 void deviceRemoved(QDBusObjectPath);
174 void propertiesChanged(QMap<QString,QVariant>);
175 void stateChanged(quint32);
176 void activationFinished(QDBusPendingCallWatcher*);
177 void propertiesReady();
178 void devicesListReady();
179
180private Q_SLOTS:
181 void propertiesSwap(QMap<QString,QVariant>);
182
183private:
184 QVariantMap propertyMap;
185 QList<QDBusObjectPath> devicesPathList;
186
187};
188
189class QNetworkManagerInterfaceAccessPoint : public QDBusAbstractInterface
190{
191 Q_OBJECT
192
193public:
194
195 enum DeviceState {
196 Unknown = 0,
197 Unmanaged,
198 Unavailable,
199 Disconnected,
200 Prepare,
201 Config,
202 NeedAuthentication,
203 IpConfig,
204 Activated,
205 Failed
206 };
207
208 enum ApFlag {
209 ApNone = 0x0,
210 Privacy = 0x1
211 };
212
213 Q_DECLARE_FLAGS(ApFlags, ApFlag)
214
215 enum ApSecurityFlag {
216 ApSecurityNone = 0x0,
217 PairWep40 = 0x1,
218 PairWep104 = 0x2,
219 PairTkip = 0x4,
220 PairCcmp = 0x8,
221 GroupWep40 = 0x10,
222 GroupWep104 = 0x20,
223 GroupTkip = 0x40,
224 GroupCcmp = 0x80,
225 KeyPsk = 0x100,
226 Key8021x = 0x200
227 };
228
229 Q_DECLARE_FLAGS(ApSecurityFlags, ApSecurityFlag)
230
231 explicit QNetworkManagerInterfaceAccessPoint(const QString &dbusPathName, QObject *parent = nullptr);
232 ~QNetworkManagerInterfaceAccessPoint();
233
234 quint32 flags() const;
235 quint32 wpaFlags() const;
236 quint32 rsnFlags() const;
237 QString ssid() const;
238 quint32 frequency() const;
239 QString hwAddress() const;
240 quint32 mode() const;
241 quint32 maxBitrate() const;
242 quint32 strength() const;
243 // bool setConnections();
244
245Q_SIGNALS:
246 void propertiesChanged(QMap<QString,QVariant>);
247 void propertiesReady();
248
249private Q_SLOTS:
250 void propertiesSwap(QMap<QString,QVariant>);
251
252private:
253 QVariantMap propertyMap;
254};
255
256class QNetworkManagerInterfaceDevice : public QDBusAbstractInterface
257{
258 Q_OBJECT
259
260public:
261
262 explicit QNetworkManagerInterfaceDevice(const QString &deviceObjectPath, QObject *parent = nullptr);
263 ~QNetworkManagerInterfaceDevice();
264
265 QString udi() const;
266 QString networkInterface() const;
267 quint32 ip4Address() const;
268 quint32 state() const;
269 quint32 deviceType() const;
270
271 QDBusObjectPath ip4config() const;
272
273Q_SIGNALS:
274 void stateChanged(const QString &, quint32);
275 void propertiesChanged(QMap<QString,QVariant>);
276 void connectionsChanged(QStringList);
277 void propertiesReady();
278private Q_SLOTS:
279 void propertiesSwap(QMap<QString,QVariant>);
280private:
281 QVariantMap propertyMap;
282};
283
284class QNetworkManagerInterfaceDeviceWired : public QDBusAbstractInterface
285{
286 Q_OBJECT
287
288public:
289
290 explicit QNetworkManagerInterfaceDeviceWired(const QString &ifaceDevicePath,
291 QObject *parent = nullptr);
292 ~QNetworkManagerInterfaceDeviceWired();
293
294 QString hwAddress() const;
295 quint32 speed() const;
296 bool carrier() const;
297 QStringList availableConnections();
298
299Q_SIGNALS:
300 void propertiesChanged(QMap<QString,QVariant>);
301 void propertiesReady();
302 void carrierChanged(bool);
303
304private Q_SLOTS:
305 void propertiesSwap(QMap<QString,QVariant>);
306
307private:
308 QVariantMap propertyMap;
309};
310
311class QNetworkManagerInterfaceDeviceWireless : public QDBusAbstractInterface
312{
313 Q_OBJECT
314
315public:
316
317 enum DeviceCapability {
318 None = 0x0,
319 Wep40 = 0x1,
320 Wep104 = 0x2,
321 Tkip = 0x4,
322 Ccmp = 0x8,
323 Wpa = 0x10,
324 Rsn = 0x20
325 };
326
327 explicit QNetworkManagerInterfaceDeviceWireless(const QString &ifaceDevicePath,
328 QObject *parent = nullptr);
329 ~QNetworkManagerInterfaceDeviceWireless();
330
331 QList <QDBusObjectPath> getAccessPoints();
332
333 QString hwAddress() const;
334 quint32 mode() const;
335 quint32 bitrate() const;
336 QDBusObjectPath activeAccessPoint() const;
337 quint32 wirelessCapabilities() const;
338 bool setConnections();
339
340 void requestScan();
341Q_SIGNALS:
342 void propertiesChanged(QMap<QString,QVariant>);
343 void propertiesReady();
344
345private Q_SLOTS:
346 void propertiesSwap(QMap<QString,QVariant>);
347
348private:
349 QVariantMap propertyMap;
350 QList <QDBusObjectPath> accessPointsList;
351 QString interfacePath;
352};
353
354class QNetworkManagerInterfaceDeviceModem : public QDBusAbstractInterface
355{
356 Q_OBJECT
357
358public:
359
360 enum ModemCapability {
361 None = 0x0,
362 Pots = 0x1,
363 Cmda_Edvo = 0x2,
364 Gsm_Umts = 0x4,
365 Lte = 0x08
366 };
367 Q_DECLARE_FLAGS(ModemCapabilities, ModemCapability)
368
369 explicit QNetworkManagerInterfaceDeviceModem(const QString &ifaceDevicePath,
370 QObject *parent = nullptr);
371 ~QNetworkManagerInterfaceDeviceModem();
372
373 ModemCapabilities modemCapabilities() const;
374 ModemCapabilities currentCapabilities() const;
375
376Q_SIGNALS:
377 void propertiesChanged(QMap<QString,QVariant>);
378 void propertiesReady();
379
380private Q_SLOTS:
381 void propertiesSwap(QMap<QString,QVariant>);
382
383private:
384 QVariantMap propertyMap;
385};
386
387Q_DECLARE_OPERATORS_FOR_FLAGS(QNetworkManagerInterfaceDeviceModem::ModemCapabilities)
388
389class QNetworkManagerSettings : public QDBusAbstractInterface
390{
391 Q_OBJECT
392
393public:
394
395 explicit QNetworkManagerSettings(const QString &settingsService, QObject *parent = nullptr);
396 ~QNetworkManagerSettings();
397
398 QList <QDBusObjectPath> listConnections();
399 QString getConnectionByUuid(const QString &uuid);
400 bool setConnections();
401
402Q_SIGNALS:
403 void newConnection(QDBusObjectPath);
404 void connectionsListReady();
405private:
406 QList <QDBusObjectPath> connectionsList;
407 QString interfacePath;
408};
409
410class QNetworkManagerSettingsConnection : public QDBusAbstractInterface
411{
412 Q_OBJECT
413
414public:
415
416 QNetworkManagerSettingsConnection(const QString &settingsService, const QString &connectionObjectPath, QObject *parent = nullptr);
417 ~QNetworkManagerSettingsConnection();
418
419 QNmSettingsMap getSettings();
420 bool setConnections();
421 NMDeviceType getType();
422 bool isAutoConnect();
423 quint64 getTimestamp();
424 QString getId();
425 QString getUuid();
426 QString getSsid();
427 QString getMacAddress();
428 QStringList getSeenBssids();
429
430Q_SIGNALS:
431 void updated();
432 void removed(const QString &path);
433 void settingsReady();
434
435private Q_SLOTS:
436 void slotSettingsRemoved();
437private:
438 QNmSettingsMap settingsMap;
439 QString interfacepath;
440};
441
442class QNetworkManagerConnectionActive : public QDBusAbstractInterface
443{
444 Q_OBJECT
445
446public:
447
448 enum ActiveConnectionState {
449 Unknown = 0,
450 Activating = 1,
451 Activated = 2
452 };
453
454 explicit QNetworkManagerConnectionActive(const QString &dbusPathName, QObject *parent = nullptr);
455 ~ QNetworkManagerConnectionActive();
456
457 QDBusObjectPath connection() const;
458 QDBusObjectPath specificObject() const;
459 QStringList devices() const;
460 quint32 state() const;
461 bool defaultRoute() const;
462 bool default6Route() const;
463
464
465Q_SIGNALS:
466 void propertiesChanged(QMap<QString,QVariant>);
467 void propertiesReady();
468
469private Q_SLOTS:
470 void propertiesSwap(QMap<QString,QVariant>);
471
472private:
473 QVariantMap propertyMap;
474};
475
476class QNetworkManagerIp4Config : public QDBusAbstractInterface
477{
478 Q_OBJECT
479
480public:
481 explicit QNetworkManagerIp4Config(const QString &dbusPathName, QObject *parent = nullptr);
482 ~QNetworkManagerIp4Config();
483
484 QStringList domains() const;
485};
486
487class PropertiesDBusInterface : public QDBusAbstractInterface
488{
489public:
490 PropertiesDBusInterface(const QString &service, const QString &path,
491 const QString &interface, const QDBusConnection &connection,
492 QObject *parent = nullptr)
493 : QDBusAbstractInterface(service, path, interface.toLatin1().data(), connection, parent)
494 {}
495};
496
497QT_END_NAMESPACE
498
499#endif // QT_NO_DBUS
500#endif //QNETWORKMANAGERSERVICE_H
501

source code of qtbase/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h