File indexing completed on 2024-07-21 07:58:12

0001 /*
0002     SPDX-FileCopyrightText: 2013 Jan Grulich <jgrulich@redhat.com>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005 */
0006 
0007 #include "enabledconnections.h"
0008 
0009 EnabledConnections::EnabledConnections(QObject *parent)
0010     : QObject(parent)
0011     , m_networkingEnabled(NetworkManager::isNetworkingEnabled())
0012     , m_wirelessEnabled(NetworkManager::isWirelessEnabled())
0013     , m_wirelessHwEnabled(NetworkManager::isWirelessHardwareEnabled())
0014     , m_wwanEnabled(NetworkManager::isWwanEnabled())
0015     , m_wwanHwEnabled(NetworkManager::isWwanHardwareEnabled())
0016 {
0017     connect(NetworkManager::notifier(), &NetworkManager::Notifier::networkingEnabledChanged, this, &EnabledConnections::onNetworkingEnabled);
0018     connect(NetworkManager::notifier(), &NetworkManager::Notifier::wirelessEnabledChanged, this, &EnabledConnections::onWirelessEnabled);
0019     connect(NetworkManager::notifier(), &NetworkManager::Notifier::wirelessHardwareEnabledChanged, this, &EnabledConnections::onWirelessHwEnabled);
0020     connect(NetworkManager::notifier(), &NetworkManager::Notifier::wwanEnabledChanged, this, &EnabledConnections::onWwanEnabled);
0021     connect(NetworkManager::notifier(), &NetworkManager::Notifier::wwanHardwareEnabledChanged, this, &EnabledConnections::onWwanHwEnabled);
0022 }
0023 
0024 EnabledConnections::~EnabledConnections() = default;
0025 
0026 bool EnabledConnections::isNetworkingEnabled() const
0027 {
0028     return m_networkingEnabled;
0029 }
0030 
0031 bool EnabledConnections::isWirelessEnabled() const
0032 {
0033     return m_wirelessEnabled;
0034 }
0035 
0036 bool EnabledConnections::isWirelessHwEnabled() const
0037 {
0038     return m_wirelessHwEnabled;
0039 }
0040 
0041 bool EnabledConnections::isWwanEnabled() const
0042 {
0043     return m_wwanEnabled;
0044 }
0045 
0046 bool EnabledConnections::isWwanHwEnabled() const
0047 {
0048     return m_wwanHwEnabled;
0049 }
0050 
0051 void EnabledConnections::onNetworkingEnabled(bool enabled)
0052 {
0053     m_networkingEnabled = enabled;
0054     Q_EMIT networkingEnabled(enabled);
0055 }
0056 
0057 void EnabledConnections::onWirelessEnabled(bool enabled)
0058 {
0059     m_wirelessEnabled = enabled;
0060     Q_EMIT wirelessEnabled(enabled);
0061 }
0062 
0063 void EnabledConnections::onWirelessHwEnabled(bool enabled)
0064 {
0065     m_wirelessHwEnabled = enabled;
0066     Q_EMIT wirelessHwEnabled(enabled);
0067 }
0068 
0069 void EnabledConnections::onWwanEnabled(bool enabled)
0070 {
0071     m_wwanEnabled = enabled;
0072     Q_EMIT wwanEnabled(enabled);
0073 }
0074 
0075 void EnabledConnections::onWwanHwEnabled(bool enabled)
0076 {
0077     m_wwanHwEnabled = enabled;
0078     Q_EMIT wwanHwEnabled(enabled);
0079 }
0080 
0081 #include "moc_enabledconnections.cpp"