summaryrefslogtreecommitdiffstats
path: root/src/plugins/networkinformation/networkmanager/qnetworkmanagerservice.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/networkinformation/networkmanager/qnetworkmanagerservice.h')
-rw-r--r--src/plugins/networkinformation/networkmanager/qnetworkmanagerservice.h81
1 files changed, 32 insertions, 49 deletions
diff --git a/src/plugins/networkinformation/networkmanager/qnetworkmanagerservice.h b/src/plugins/networkinformation/networkmanager/qnetworkmanagerservice.h
index 93fa23870f..5201e8485b 100644
--- a/src/plugins/networkinformation/networkmanager/qnetworkmanagerservice.h
+++ b/src/plugins/networkinformation/networkmanager/qnetworkmanagerservice.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QNETWORKMANAGERSERVICE_H
#define QNETWORKMANAGERSERVICE_H
@@ -51,9 +15,11 @@
// We mean it.
//
-#include <QtDBus/QDBusAbstractInterface>
-#include <QtDBus/QDBusPendingCallWatcher>
-#include <QtDBus/QDBusObjectPath>
+#include <QtCore/qvariant.h>
+#include <QtCore/qmap.h>
+#include <QtDBus/qdbusabstractinterface.h>
+
+#include <optional>
// Matches 'NMDeviceState' from https://developer.gnome.org/NetworkManager/stable/nm-dbus-types.html
enum NMDeviceState {
@@ -72,13 +38,16 @@ enum NMDeviceState {
QT_BEGIN_NAMESPACE
+class QDBusObjectPath;
+class QNetworkManagerNetworkInformationBackend;
+
// This tiny class exists for the purpose of seeing if NetworkManager is available without
// initializing everything the derived/full class needs.
class QNetworkManagerInterfaceBase : public QDBusAbstractInterface
{
Q_OBJECT
public:
- QNetworkManagerInterfaceBase(QObject *parent = nullptr);
+ explicit QNetworkManagerInterfaceBase(QObject *parent = nullptr);
~QNetworkManagerInterfaceBase() = default;
static bool networkManagerAvailable();
@@ -150,18 +119,27 @@ public:
NM_DEVICE_TYPE_WIFI_P2P = 30,
NM_DEVICE_TYPE_VRF = 31,
};
+ // Matches 'NMMetered' from
+ // https://developer-old.gnome.org/NetworkManager/stable/nm-dbus-types.html#NMMetered
+ enum NMMetered {
+ NM_METERED_UNKNOWN,
+ NM_METERED_YES,
+ NM_METERED_NO,
+ NM_METERED_GUESS_YES,
+ NM_METERED_GUESS_NO,
+ };
- QNetworkManagerInterface(QObject *parent = nullptr);
+ explicit QNetworkManagerInterface(QObject *parent = nullptr);
~QNetworkManagerInterface();
+ void setBackend(QNetworkManagerNetworkInformationBackend *ourBackend);
+
NMState state() const;
NMConnectivityState connectivityState() const;
NMDeviceType deviceType() const;
+ NMMetered meteredState() const;
-Q_SIGNALS:
- void stateChanged(NMState);
- void connectivityChanged(NMConnectivityState);
- void deviceTypeChanged(NMDeviceType);
+ bool isValid() const { return QDBusAbstractInterface::isValid() && validDBusConnection; }
private Q_SLOTS:
void setProperties(const QString &interfaceName, const QMap<QString, QVariant> &map,
@@ -170,16 +148,21 @@ private Q_SLOTS:
private:
Q_DISABLE_COPY_MOVE(QNetworkManagerInterface)
- NMDeviceType extractDeviceType(QDBusObjectPath devicePath) const;
+ NMDeviceType extractDeviceType(const QDBusObjectPath &devicePath) const;
+ NMMetered extractDeviceMetered(const QDBusObjectPath &devicePath) const;
+
+ std::optional<QDBusObjectPath> primaryConnectionDevicePath() const;
QVariantMap propertyMap;
+ QNetworkManagerNetworkInformationBackend *backend = nullptr;
+ bool validDBusConnection = true;
};
class PropertiesDBusInterface : public QDBusAbstractInterface
{
public:
PropertiesDBusInterface(const QString &service, const QString &path, const QString &interface,
- const QDBusConnection &connection, QObject *parent = 0)
+ const QDBusConnection &connection, QObject *parent = nullptr)
: QDBusAbstractInterface(service, path, interface.toLatin1().data(), connection, parent)
{
}