summaryrefslogtreecommitdiffstats
path: root/src/network/kernel/qnetworkinformation.h
diff options
context:
space:
mode:
authorMårten Nordheim <marten.nordheim@qt.io>2020-12-18 15:35:20 +0100
committerMårten Nordheim <marten.nordheim@qt.io>2021-01-20 16:21:28 +0100
commit0875626e22ad4e709ddf505e701a8d699559f5b4 (patch)
tree968f74f6ed1433f0637d992952325a3b1a164ee8 /src/network/kernel/qnetworkinformation.h
parent7e7dacc109273fca9a72a1069d6228ea5e980d37 (diff)
Long live QNetworkInformation
The plugins are meant to indicate what they do support, meaning users of QNetworkInformation can choose to not care about which plugin is used and rather just request what they want. Task-number: QTBUG-86966 Change-Id: Ie130e1791250ec2a4470e3ba7081d982654af06c Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/network/kernel/qnetworkinformation.h')
-rw-r--r--src/network/kernel/qnetworkinformation.h96
1 files changed, 96 insertions, 0 deletions
diff --git a/src/network/kernel/qnetworkinformation.h b/src/network/kernel/qnetworkinformation.h
new file mode 100644
index 0000000000..6321300f40
--- /dev/null
+++ b/src/network/kernel/qnetworkinformation.h
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtNetwork module 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$
+**
+****************************************************************************/
+
+#ifndef QNETWORKINFORMATION_H
+#define QNETWORKINFORMATION_H
+
+#include <QtNetwork/qtnetworkglobal.h>
+#include <QtCore/qobject.h>
+#include <QtCore/qstringview.h>
+#include <QtCore/qstringlist.h>
+
+QT_BEGIN_NAMESPACE
+
+class QNetworkInformationBackend;
+class QNetworkInformationPrivate;
+class Q_NETWORK_EXPORT QNetworkInformation : public QObject
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QNetworkInformation)
+ Q_PROPERTY(Reachability reachability READ reachability)
+public:
+ enum class Reachability {
+ Unknown,
+ Disconnected,
+ Local,
+ Site,
+ Online,
+ };
+ Q_ENUM(Reachability)
+
+ enum class Feature {
+ Reachability = 0x1,
+ };
+ Q_ENUM(Feature)
+ Q_DECLARE_FLAGS(Features, Feature)
+
+ ~QNetworkInformation();
+
+ Reachability reachability() const;
+
+ QString backendName() const;
+
+ virtual bool supports(Features features) const;
+
+ static bool load(QStringView backend = {});
+ static bool load(Features features);
+ static QStringList availableBackends();
+ static QNetworkInformation *instance();
+
+Q_SIGNALS:
+ void reachabilityChanged(Reachability newReachability);
+
+private:
+ friend class QNetworkInformationPrivate;
+ QNetworkInformation(QNetworkInformationBackend *backend);
+};
+
+QT_END_NAMESPACE
+
+#endif