// 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 #include #include #include #include #include #include #include #include #include #include #if QT_CONFIG(cpp_winrt) #include #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 networkListManager = nullptr; ComPtr connectionPoint = nullptr; #if QT_CONFIG(cpp_winrt) void emitWinRTUpdates(); winrt::event_token token; QMutex winrtLock; #endif QAtomicInteger ref = 0; DWORD cookie = 0; }; QT_END_NAMESPACE #endif // QNETWORKLISTMANAGEREVENTS_H