KPublicTransport

wifimonitor_nm.cpp
1/*
2 SPDX-FileCopyrightText: 2022 Volker Krause <vkrause@kde.org>
3 SPDX-License-Identifier: LGPL-2.0-or-later
4*/
5
6#include "wifimonitor_p.h"
7
8#include <NetworkManagerQt/Manager>
9#include <NetworkManagerQt/WirelessSetting>
10
11using namespace KPublicTransport;
12
13WifiMonitor::WifiMonitor(QObject *parent)
14 : QObject(parent)
15{
16 const auto getSsid = [this](){
17 const auto connections = NetworkManager::activeConnections();
18 for (const auto &con : connections) {
19 if (con->type() != NetworkManager::ConnectionSettings::Wireless) {
20 continue;
21 }
22 setSsid(QString::fromUtf8(con->connection()->settings()->setting(NetworkManager::Setting::Wireless).staticCast<NetworkManager::WirelessSetting>()->ssid()));
23 break;
24 }
25 };
26
27 connect(NetworkManager::notifier(), &NetworkManager::Notifier::activatingConnectionChanged, this, getSsid);
28 connect(NetworkManager::notifier(), &NetworkManager::Notifier::activeConnectionAdded, this, getSsid);
29 connect(NetworkManager::notifier(), &NetworkManager::Notifier::activeConnectionRemoved, this, getSsid);
30 connect(NetworkManager::notifier(), &NetworkManager::Notifier::networkingEnabledChanged, this, &WifiMonitor::statusChanged);
31 connect(NetworkManager::notifier(), &NetworkManager::Notifier::wirelessEnabledChanged, this, &WifiMonitor::statusChanged);
32
33 getSsid();
34}
35
36WifiMonitor::~WifiMonitor() = default;
37
38WifiMonitor::Status WifiMonitor::status() const
39{
41 return NotAvailable;
42 }
43
44 return NetworkManager::isWirelessEnabled() ? Available : WifiNotEnabled;
45}
46
47void WifiMonitor::requestPermissions()
48{
49}
Query operations and data types for accessing realtime public transport information from online servi...
NETWORKMANAGERQT_EXPORT ActiveConnection::List activeConnections()
NETWORKMANAGERQT_EXPORT bool isWirelessEnabled()
NETWORKMANAGERQT_EXPORT bool isNetworkingEnabled()
QString fromUtf8(QByteArrayView str)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:59:57 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.