blob: d91cd8a4cc61d512a37607fe70493bfc0492a503 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
// 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 QNETWORKLISTMANAGEREVENTS_H
#define QNETWORKLISTMANAGEREVENTS_H
#include <QtNetwork/private/qtnetworkglobal_p.h>
#include <QtNetwork/qnetworkinformation.h>
#include <QtCore/qstring.h>
#include <QtCore/qobject.h>
#include <QtCore/qloggingcategory.h>
#include <QtCore/qmutex.h>
#include <objbase.h>
#include <ocidl.h>
#include <netlistmgr.h>
#include <wrl/client.h>
#include <wrl/wrappers/corewrappers.h>
#if QT_CONFIG(cpp_winrt)
#include <QtCore/private/qt_winrtbase_p.h>
#endif
using namespace Microsoft::WRL;
QT_BEGIN_NAMESPACE
Q_DECLARE_LOGGING_CATEGORY(lcNetInfoNLM)
class QNetworkListManagerEvents : public QObject, public INetworkListManagerEvents
{
Q_OBJECT
public:
QNetworkListManagerEvents();
virtual ~QNetworkListManagerEvents();
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject) override;
ULONG STDMETHODCALLTYPE AddRef() override { return ++ref; }
ULONG STDMETHODCALLTYPE Release() override
{
if (--ref == 0) {
delete this;
return 0;
}
return ref;
}
HRESULT STDMETHODCALLTYPE ConnectivityChanged(NLM_CONNECTIVITY newConnectivity) override;
[[nodiscard]] bool start();
void stop();
[[nodiscard]] bool checkBehindCaptivePortal();
signals:
void connectivityChanged(NLM_CONNECTIVITY);
void transportMediumChanged(QNetworkInformation::TransportMedium);
void isMeteredChanged(bool);
private:
ComPtr<INetworkListManager> networkListManager = nullptr;
ComPtr<IConnectionPoint> connectionPoint = nullptr;
#if QT_CONFIG(cpp_winrt)
void emitWinRTUpdates();
winrt::event_token token;
QMutex winrtLock;
#endif
QAtomicInteger<ULONG> ref = 0;
DWORD cookie = 0;
};
QT_END_NAMESPACE
#endif // QNETWORKLISTMANAGEREVENTS_H
|