diff --git a/libs/declarative/connectionicon.cpp b/libs/declarative/connectionicon.cpp index 39281015..55bf06e2 100644 --- a/libs/declarative/connectionicon.cpp +++ b/libs/declarative/connectionicon.cpp @@ -1,637 +1,640 @@ /* Copyright 2013 Jan Grulich This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ #include "connectionicon.h" #include "uiutils.h" #include #include #include #include #include #include #include #include #include #if WITH_MODEMMANAGER_SUPPORT #include #include #endif ConnectionIcon::ConnectionIcon(QObject* parent) : QObject(parent) , m_signal(0) , m_wirelessNetwork(nullptr) , m_connecting(false) , m_limited(false) , m_vpn(false) , m_airplaneMode(false) #if WITH_MODEMMANAGER_SUPPORT , m_modemNetwork(nullptr) #endif { connect(NetworkManager::notifier(), &NetworkManager::Notifier::primaryConnectionChanged, this, &ConnectionIcon::primaryConnectionChanged); connect(NetworkManager::notifier(), &NetworkManager::Notifier::activatingConnectionChanged, this, &ConnectionIcon::activatingConnectionChanged); connect(NetworkManager::notifier(), &NetworkManager::Notifier::activeConnectionAdded, this, &ConnectionIcon::activeConnectionAdded); connect(NetworkManager::notifier(), &NetworkManager::Notifier::connectivityChanged, this, &ConnectionIcon::connectivityChanged); connect(NetworkManager::notifier(), &NetworkManager::Notifier::deviceAdded, this, &ConnectionIcon::deviceAdded); connect(NetworkManager::notifier(), &NetworkManager::Notifier::deviceRemoved, this, &ConnectionIcon::deviceRemoved); connect(NetworkManager::notifier(), &NetworkManager::Notifier::networkingEnabledChanged, this, &ConnectionIcon::networkingEnabledChanged); connect(NetworkManager::notifier(), &NetworkManager::Notifier::statusChanged, this, &ConnectionIcon::statusChanged); connect(NetworkManager::notifier(), &NetworkManager::Notifier::wirelessEnabledChanged, this, &ConnectionIcon::wirelessEnabledChanged); connect(NetworkManager::notifier(), &NetworkManager::Notifier::wirelessHardwareEnabledChanged, this, &ConnectionIcon::wirelessEnabledChanged); connect(NetworkManager::notifier(), &NetworkManager::Notifier::wwanEnabledChanged, this, &ConnectionIcon::wwanEnabledChanged); connect(NetworkManager::notifier(), &NetworkManager::Notifier::wwanHardwareEnabledChanged, this, &ConnectionIcon::wwanEnabledChanged); for (const NetworkManager::Device::Ptr &device : NetworkManager::networkInterfaces()) { if (device->type() == NetworkManager::Device::Ethernet) { NetworkManager::WiredDevice::Ptr wiredDevice = device.staticCast(); if (wiredDevice) { connect(wiredDevice.data(), &NetworkManager::WiredDevice::carrierChanged, this, &ConnectionIcon::carrierChanged); } } else if (device->type() == NetworkManager::Device::Wifi) { NetworkManager::WirelessDevice::Ptr wifiDevice = device.staticCast(); if (wifiDevice) { connect(wifiDevice.data(), &NetworkManager::WirelessDevice::availableConnectionAppeared, this, &ConnectionIcon::wirelessNetworkAppeared); connect(wifiDevice.data(), &NetworkManager::WirelessDevice::networkAppeared, this, &ConnectionIcon::wirelessNetworkAppeared); } } } for (const NetworkManager::ActiveConnection::Ptr &activeConnection : NetworkManager::activeConnections()) { addActiveConnection(activeConnection->path()); } setStates(); connectivityChanged(); setIcons(); } ConnectionIcon::~ConnectionIcon() { } bool ConnectionIcon::connecting() const { return m_connecting; } QString ConnectionIcon::connectionIcon() const { if (m_vpn && !m_connectionIcon.contains("available")) { return m_connectionIcon + "-locked"; } if (m_limited && !m_connectionIcon.contains("available")) { return m_connectionIcon + "-limited"; } return m_connectionIcon; } QString ConnectionIcon::connectionTooltipIcon() const { return m_connectionTooltipIcon; } bool ConnectionIcon::airplaneMode() const { return m_airplaneMode; } void ConnectionIcon::setAirplaneMode(bool airplaneMode) { if (m_airplaneMode != airplaneMode) { m_airplaneMode = airplaneMode; Q_EMIT airplaneModeChanged(airplaneMode); setIcons(); } } void ConnectionIcon::activatingConnectionChanged(const QString& connection) { Q_UNUSED(connection); setIcons(); } void ConnectionIcon::addActiveConnection(const QString &activeConnection) { NetworkManager::ActiveConnection::Ptr active = NetworkManager::findActiveConnection(activeConnection); if (active) { NetworkManager::VpnConnection::Ptr vpnConnection; connect(active.data(), &NetworkManager::ActiveConnection::destroyed, this, &ConnectionIcon::activeConnectionDestroyed); if (active->vpn()) { vpnConnection = active.objectCast(); connect(vpnConnection.data(), &NetworkManager::VpnConnection::stateChanged, this, &ConnectionIcon::vpnConnectionStateChanged); } else { connect(active.data(), &NetworkManager::ActiveConnection::stateChanged, this, &ConnectionIcon::activeConnectionStateChanged, Qt::UniqueConnection); } } } void ConnectionIcon::activeConnectionAdded(const QString &activeConnection) { addActiveConnection(activeConnection); setStates(); } void ConnectionIcon::activeConnectionStateChanged(NetworkManager::ActiveConnection::State state) { Q_UNUSED(state); setStates(); } void ConnectionIcon::activeConnectionDestroyed() { setStates(); } void ConnectionIcon::carrierChanged(bool carrier) { Q_UNUSED(carrier); setIcons(); } void ConnectionIcon::connectivityChanged() { NetworkManager::Connectivity conn = NetworkManager::connectivity(); setLimited(conn == NetworkManager::Portal || conn == NetworkManager::Limited); } void ConnectionIcon::deviceAdded(const QString& device) { NetworkManager::Device::Ptr dev = NetworkManager::findNetworkInterface(device); if (!dev) { return; } if (dev->type() == NetworkManager::Device::Ethernet) { NetworkManager::WiredDevice::Ptr wiredDev = dev.objectCast(); connect(wiredDev.data(), &NetworkManager::WiredDevice::carrierChanged, this, &ConnectionIcon::carrierChanged); } } void ConnectionIcon::deviceRemoved(const QString& device) { Q_UNUSED(device); if (NetworkManager::status() == NetworkManager::Disconnected) { setDisconnectedIcon(); } } #if WITH_MODEMMANAGER_SUPPORT void ConnectionIcon::modemNetworkRemoved() { m_modemNetwork.clear(); } void ConnectionIcon::modemSignalChanged(const ModemManager::SignalQualityPair &signalQuality) { int diff = m_signal - signalQuality.signal; if (diff >= 10 || diff <= -10) { m_signal = signalQuality.signal; setIconForModem(); } } #endif void ConnectionIcon::networkingEnabledChanged(bool enabled) { if (!enabled) { setConnectionIcon("network-unavailable"); } } void ConnectionIcon::primaryConnectionChanged(const QString& connection) { if (!connection.isEmpty()) { setIcons(); } } void ConnectionIcon::statusChanged(NetworkManager::Status status) { if (status == NetworkManager::Disconnected) { setDisconnectedIcon(); } } void ConnectionIcon::vpnConnectionStateChanged(NetworkManager::VpnConnection::State state, NetworkManager::VpnConnection::StateChangeReason reason) { Q_UNUSED(state); Q_UNUSED(reason); setStates(); setIcons(); } void ConnectionIcon::wirelessEnabledChanged(bool enabled) { Q_UNUSED(enabled); setIcons(); } void ConnectionIcon::wwanEnabledChanged(bool enabled) { Q_UNUSED(enabled); setIcons(); } void ConnectionIcon::wirelessNetworkAppeared(const QString& network) { Q_UNUSED(network); setIcons(); } void ConnectionIcon::setStates() { bool connecting = false; bool vpn = false; for (const NetworkManager::ActiveConnection::Ptr &activeConnection : NetworkManager::activeConnections()) { NetworkManager::VpnConnection::Ptr vpnConnection; if (activeConnection->vpn()) { vpnConnection = activeConnection.objectCast(); } if (!vpnConnection) { if (activeConnection->state() == NetworkManager::ActiveConnection::Activating && UiUtils::isConnectionTypeSupported(activeConnection->type())) { connecting = true; } } else { if (vpnConnection->state() == NetworkManager::VpnConnection::Activated) { vpn = true; } else if (vpnConnection->state() == NetworkManager::VpnConnection::Prepare || vpnConnection->state() == NetworkManager::VpnConnection::NeedAuth || vpnConnection->state() == NetworkManager::VpnConnection::Connecting || vpnConnection->state() == NetworkManager::VpnConnection::GettingIpConfig) { connecting = true; } } } setVpn(vpn); setConnecting(connecting); } void ConnectionIcon::setIcons() { m_signal = 0; #if WITH_MODEMMANAGER_SUPPORT if (m_modemNetwork) { disconnect(m_modemNetwork.data(), nullptr, this, nullptr); m_modemNetwork.clear(); } #endif if (m_wirelessNetwork) { disconnect(m_wirelessNetwork.data(), nullptr, this, nullptr); m_wirelessNetwork.clear(); } NetworkManager::ActiveConnection::Ptr connection = NetworkManager::activatingConnection(); - if (!connection) { + + // Set icon based on the current primary connection if the activating connection is virtual + // since we're not setting icons for virtual connections + if (!connection || (connection && UiUtils::isConnectionTypeVirtual(connection->type()))) { connection = NetworkManager::primaryConnection(); } /* Fallback: If we still don't have an active connection with default route or the default route goes through a connection of generic type (some type of VPNs) we need to go through all other active connections and pick the one with highest probability of being the main one (order is: vpn, wired, wireless, gsm, cdma, bluetooth) */ if ((!connection && !NetworkManager::activeConnections().isEmpty()) || (connection && connection->type() == NetworkManager::ConnectionSettings::Generic) || (connection && connection->type() == NetworkManager::ConnectionSettings::Tun)) { for (const NetworkManager::ActiveConnection::Ptr &activeConnection : NetworkManager::activeConnections()) { const NetworkManager::ConnectionSettings::ConnectionType type = activeConnection->type(); if (type == NetworkManager::ConnectionSettings::Bluetooth) { if (connection && connection->type() <= NetworkManager::ConnectionSettings::Bluetooth) { connection = activeConnection; } } else if (type == NetworkManager::ConnectionSettings::Cdma) { if (connection && connection->type() <= NetworkManager::ConnectionSettings::Cdma) { connection = activeConnection; } } else if (type == NetworkManager::ConnectionSettings::Gsm) { if (connection && connection->type() <= NetworkManager::ConnectionSettings::Gsm) { connection = activeConnection; } } else if (type == NetworkManager::ConnectionSettings::Vpn) { connection = activeConnection; } else if (type == NetworkManager::ConnectionSettings::Wired) { if (connection && connection->type() != NetworkManager::ConnectionSettings::Vpn) { connection = activeConnection; } } else if (type == NetworkManager::ConnectionSettings::Wireless) { if (connection && (connection->type() != NetworkManager::ConnectionSettings::Vpn && (connection->type() != NetworkManager::ConnectionSettings::Wired))) { connection = activeConnection; } } } } if (connection && !connection->devices().isEmpty()) { NetworkManager::Device::Ptr device = NetworkManager::findNetworkInterface(connection->devices().first()); if (device) { NetworkManager::Device::Type type = device->type(); if (type == NetworkManager::Device::Wifi) { NetworkManager::WirelessDevice::Ptr wifiDevice = device.objectCast(); if (wifiDevice->mode() == NetworkManager::WirelessDevice::Adhoc) { setWirelessIconForSignalStrength(100); } else { NetworkManager::AccessPoint::Ptr ap = wifiDevice->activeAccessPoint(); if (ap) { setWirelessIcon(device, ap->ssid()); } } } else if (type == NetworkManager::Device::Ethernet) { setConnectionIcon("network-wired-activated"); setConnectionTooltipIcon("network-wired-activated"); } else if (type == NetworkManager::Device::Modem) { #if WITH_MODEMMANAGER_SUPPORT setModemIcon(device); #else setConnectionIcon("network-mobile-0"); setConnectionTooltipIcon("phone"); #endif } else if (type == NetworkManager::Device::Bluetooth) { NetworkManager::BluetoothDevice::Ptr btDevice = device.objectCast(); if (btDevice) { if (btDevice->bluetoothCapabilities().testFlag(NetworkManager::BluetoothDevice::Dun)) { #if WITH_MODEMMANAGER_SUPPORT setModemIcon(device); #else setConnectionIcon("network-mobile-0"); setConnectionTooltipIcon("phone"); #endif } else { setConnectionIcon("network-bluetooth-activated"); setConnectionTooltipIcon("preferences-system-bluetooth"); } } } else { // Ignore other devices (bond/bridge/team etc.) setDisconnectedIcon(); } } } else { setDisconnectedIcon(); } } void ConnectionIcon::setDisconnectedIcon() { if (m_airplaneMode) { setConnectionIcon(QStringLiteral("network-flightmode-on")); return; } if (NetworkManager::status() == NetworkManager::Unknown || NetworkManager::status() == NetworkManager::Asleep) { setConnectionIcon("network-unavailable"); return; } bool wired = false; bool wireless = false; bool modem = false; m_limited = false; m_vpn = false; for (const NetworkManager::Device::Ptr &device : NetworkManager::networkInterfaces()) { if (device->type() == NetworkManager::Device::Ethernet) { NetworkManager::WiredDevice::Ptr wiredDev = device.objectCast(); if (wiredDev->carrier()) { wired = true; } } else if (device->type() == NetworkManager::Device::Wifi && NetworkManager::isWirelessEnabled() && NetworkManager::isWirelessHardwareEnabled()) { NetworkManager::WirelessDevice::Ptr wifiDevice = device.objectCast(); if (!wifiDevice->accessPoints().isEmpty() || !wifiDevice->availableConnections().isEmpty()) { wireless = true; } } else if (device->type() == NetworkManager::Device::Modem && NetworkManager::isWwanEnabled() && NetworkManager::isWwanHardwareEnabled()) { modem = true; } } if (wired) { setConnectionIcon("network-wired-available"); setConnectionTooltipIcon("network-wired"); return; } else if (wireless) { setConnectionIcon("network-wireless-available"); setConnectionTooltipIcon("network-wireless-connected-00"); return; } else if (modem) { setConnectionIcon("network-mobile-available"); setConnectionTooltipIcon("phone"); return; } else { setConnectionIcon("network-unavailable"); setConnectionTooltipIcon("network-wired"); } } #if WITH_MODEMMANAGER_SUPPORT void ConnectionIcon::setModemIcon(const NetworkManager::Device::Ptr & device) { NetworkManager::ModemDevice::Ptr modemDevice = device.objectCast(); if (!modemDevice) { setConnectionIcon("network-mobile-100"); return; } ModemManager::ModemDevice::Ptr modem = ModemManager::findModemDevice(device->udi()); if (modem) { if (modem->hasInterface(ModemManager::ModemDevice::ModemInterface)) { m_modemNetwork = modem->interface(ModemManager::ModemDevice::ModemInterface).objectCast(); } } if (m_modemNetwork) { connect(m_modemNetwork.data(), &ModemManager::Modem::signalQualityChanged, this, &ConnectionIcon::modemSignalChanged, Qt::UniqueConnection); connect(m_modemNetwork.data(), &ModemManager::Modem::accessTechnologiesChanged, this, &ConnectionIcon::setIconForModem, Qt::UniqueConnection); connect(m_modemNetwork.data(), &ModemManager::Modem::destroyed, this, &ConnectionIcon::modemNetworkRemoved); m_signal = m_modemNetwork->signalQuality().signal; setIconForModem(); } else { setConnectionIcon("network-mobile-0"); setConnectionTooltipIcon("phone"); return; } } void ConnectionIcon::setIconForModem() { if (!m_signal) { m_signal = m_modemNetwork->signalQuality().signal; } QString strength = "00"; if (m_signal == 0) { strength = '0'; } else if (m_signal < 20) { strength = "20"; } else if (m_signal < 40) { strength = "40"; } else if (m_signal < 60) { strength = "60"; } else if (m_signal < 80) { strength = "80"; } else { strength = "100"; } QString result; switch(m_modemNetwork->accessTechnologies()) { case MM_MODEM_ACCESS_TECHNOLOGY_GSM: case MM_MODEM_ACCESS_TECHNOLOGY_GSM_COMPACT: result = "network-mobile-%1"; break; case MM_MODEM_ACCESS_TECHNOLOGY_GPRS: result = "network-mobile-%1-gprs"; break; case MM_MODEM_ACCESS_TECHNOLOGY_EDGE: result = "network-mobile-%1-edge"; break; case MM_MODEM_ACCESS_TECHNOLOGY_UMTS: result = "network-mobile-%1-umts"; break; case MM_MODEM_ACCESS_TECHNOLOGY_HSDPA: result = "network-mobile-%1-hsdpa"; break; case MM_MODEM_ACCESS_TECHNOLOGY_HSUPA: result = "network-mobile-%1-hsupa"; break; case MM_MODEM_ACCESS_TECHNOLOGY_HSPA: case MM_MODEM_ACCESS_TECHNOLOGY_HSPA_PLUS: result = "network-mobile-%1-hspa"; break; case MM_MODEM_ACCESS_TECHNOLOGY_LTE: result = "network-mobile-%1-lte"; break; default: result = "network-mobile-%1"; break; } setConnectionIcon(QString(result).arg(strength)); setConnectionTooltipIcon("phone"); } #endif void ConnectionIcon::setWirelessIcon(const NetworkManager::Device::Ptr &device, const QString& ssid) { NetworkManager::WirelessDevice::Ptr wirelessDevice = device.objectCast(); if (device) { m_wirelessNetwork = wirelessDevice->findNetwork(ssid); } else { m_wirelessNetwork.clear(); } if (m_wirelessNetwork) { connect(m_wirelessNetwork.data(), &NetworkManager::WirelessNetwork::signalStrengthChanged, this, &ConnectionIcon::setWirelessIconForSignalStrength, Qt::UniqueConnection); setWirelessIconForSignalStrength(m_wirelessNetwork->signalStrength()); } else { setDisconnectedIcon(); } } void ConnectionIcon::setWirelessIconForSignalStrength(int strength) { int iconStrength = 100; if (strength == 0) { iconStrength = 0; setConnectionTooltipIcon("network-wireless-connected-00"); } else if (strength < 20) { iconStrength = 20; setConnectionTooltipIcon("network-wireless-connected-20"); } else if (strength < 40) { iconStrength = 40; setConnectionTooltipIcon("network-wireless-connected-40"); } else if (strength < 60) { iconStrength = 60; setConnectionTooltipIcon("network-wireless-connected-60"); } else if (strength < 80) { iconStrength = 80; setConnectionTooltipIcon("network-wireless-connected-80"); } else if (strength < 100) { setConnectionTooltipIcon("network-wireless-connected-100"); } QString icon = QString("network-wireless-%1").arg(iconStrength); setConnectionIcon(icon); } void ConnectionIcon::setConnecting(bool connecting) { if (connecting != m_connecting) { m_connecting = connecting; Q_EMIT connectingChanged(m_connecting); } } void ConnectionIcon::setConnectionIcon(const QString & icon) { if (icon != m_connectionIcon) { m_connectionIcon = icon; Q_EMIT connectionIconChanged(connectionIcon()); } } void ConnectionIcon::setConnectionTooltipIcon(const QString & icon) { if (icon != m_connectionTooltipIcon) { m_connectionTooltipIcon = icon; Q_EMIT connectionTooltipIconChanged(m_connectionTooltipIcon); } } void ConnectionIcon::setVpn(bool vpn) { if (m_vpn != vpn) { m_vpn = vpn; Q_EMIT connectionIconChanged(connectionIcon()); } } void ConnectionIcon::setLimited(bool limited) { if (m_limited != limited) { m_limited = limited; Q_EMIT connectionIconChanged(connectionIcon()); } } diff --git a/libs/uiutils.cpp b/libs/uiutils.cpp index 6abeb99d..85cdc0a0 100644 --- a/libs/uiutils.cpp +++ b/libs/uiutils.cpp @@ -1,679 +1,692 @@ /* Copyright 2008-2010 Sebastian Kügler Copyright 2013-2014 Jan Grulich This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License or (at your option) version 3 or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of version 3 of the license. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ // Own #include "uiutils.h" #include "configuration.h" #include "debug.h" // KDE #include #include #include #include #include #include #include #include #include #include #if WITH_MODEMMANAGER_SUPPORT #include #include #include #include #include #endif // Qt #include #include #include using namespace NetworkManager; UiUtils::SortedConnectionType UiUtils::connectionTypeToSortedType(NetworkManager::ConnectionSettings::ConnectionType type) { switch (type) { case NetworkManager::ConnectionSettings::Unknown: return UiUtils::Unknown; break; case NetworkManager::ConnectionSettings::Adsl: return UiUtils::Adsl; break; case NetworkManager::ConnectionSettings::Bluetooth: return UiUtils::Bluetooth; break; case NetworkManager::ConnectionSettings::Bond: return UiUtils::Bond; break; case NetworkManager::ConnectionSettings::Bridge: return UiUtils::Bridge; break; case NetworkManager::ConnectionSettings::Cdma: return UiUtils::Cdma; break; case NetworkManager::ConnectionSettings::Gsm: return UiUtils::Gsm; break; case NetworkManager::ConnectionSettings::Infiniband: return UiUtils::Infiniband; break; case NetworkManager::ConnectionSettings::OLPCMesh: return UiUtils::OLPCMesh; break; case NetworkManager::ConnectionSettings::Pppoe: return UiUtils::Pppoe; break; case NetworkManager::ConnectionSettings::Team: return UiUtils::Team; break; case NetworkManager::ConnectionSettings::Vlan: return UiUtils::Vlan; break; case NetworkManager::ConnectionSettings::Vpn: return UiUtils::Vpn; break; case NetworkManager::ConnectionSettings::Wired: return UiUtils::Wired; break; case NetworkManager::ConnectionSettings::Wireless: return UiUtils::Wireless; break; default: return UiUtils::Unknown; break; } } bool UiUtils::isConnectionTypeSupported(NetworkManager::ConnectionSettings::ConnectionType type) { #if NM_CHECK_VERSION(1, 2, 0) if (type == NetworkManager::ConnectionSettings::Generic || type == NetworkManager::ConnectionSettings::Tun) { #else if (type == NetworkManager::ConnectionSettings::Generic) { #endif return false; } bool manageVirtualConnections = Configuration::manageVirtualConnections(); if (type == NetworkManager::ConnectionSettings::Bond || type == NetworkManager::ConnectionSettings::Bridge || type == NetworkManager::ConnectionSettings::Infiniband || type == NetworkManager::ConnectionSettings::Team || type == NetworkManager::ConnectionSettings::Vlan) { return manageVirtualConnections; } return true; } +bool UiUtils::isConnectionTypeVirtual(NetworkManager::ConnectionSettings::ConnectionType type) +{ + if (type == NetworkManager::ConnectionSettings::Bond || + type == NetworkManager::ConnectionSettings::Bridge || + type == NetworkManager::ConnectionSettings::Infiniband || + type == NetworkManager::ConnectionSettings::Team || + type == NetworkManager::ConnectionSettings::Vlan) { + return true; + } + + return false; +} + QString UiUtils::interfaceTypeLabel(const NetworkManager::Device::Type type, const NetworkManager::Device::Ptr iface) { QString deviceText; switch (type) { case NetworkManager::Device::Wifi: deviceText = i18nc("title of the interface widget in nm's popup", "Wi-Fi"); break; case NetworkManager::Device::Bluetooth: deviceText = i18nc("title of the interface widget in nm's popup", "Bluetooth"); break; case NetworkManager::Device::InfiniBand: deviceText = i18nc("title of the interface widget in nm's popup", "Infiniband"); break; case NetworkManager::Device::Adsl: deviceText = i18nc("title of the interface widget in nm's popup", "ADSL"); break; case NetworkManager::Device::Bond: deviceText = i18nc("title of the interface widget in nm's popup", "Virtual (bond)"); break; case NetworkManager::Device::Bridge: deviceText = i18nc("title of the interface widget in nm's popup", "Virtual (bridge)"); break; case NetworkManager::Device::Vlan: deviceText = i18nc("title of the interface widget in nm's popup", "Virtual (vlan)"); break; #if NM_CHECK_VERSION(0, 9, 10) case NetworkManager::Device::Team: deviceText = i18nc("title of the interface widget in nm's popup", "Virtual (team)"); break; #endif case NetworkManager::Device::Modem: { const NetworkManager::ModemDevice::Ptr nmModemIface = iface.objectCast(); if (nmModemIface) { switch(modemSubType(nmModemIface->currentCapabilities())) { case NetworkManager::ModemDevice::Pots: deviceText = i18nc("title of the interface widget in nm's popup", "Serial Modem"); break; case NetworkManager::ModemDevice::GsmUmts: case NetworkManager::ModemDevice::CdmaEvdo: case NetworkManager::ModemDevice::Lte: deviceText = i18nc("title of the interface widget in nm's popup", "Mobile Broadband"); break; case NetworkManager::ModemDevice::NoCapability: qCWarning(PLASMA_NM) << "Unhandled modem sub type: NetworkManager::ModemDevice::NoCapability"; break; } } } break; case NetworkManager::Device::Ethernet: default: deviceText = i18nc("title of the interface widget in nm's popup", "Wired Ethernet"); break; } return deviceText; } QString UiUtils::iconAndTitleForConnectionSettingsType(NetworkManager::ConnectionSettings::ConnectionType type, QString &title) { QString text; QString icon = QStringLiteral("network-wired"); switch (type) { case ConnectionSettings::Adsl: text = i18n("ADSL"); icon = QStringLiteral("network-modem"); break; case ConnectionSettings::Pppoe: text = i18n("DSL"); icon = QStringLiteral("network-modem"); break; case ConnectionSettings::Bluetooth: text = i18n("Bluetooth"); icon = QStringLiteral("network-bluetooth"); break; case ConnectionSettings::Bond: text = i18n("Bond"); break; case ConnectionSettings::Bridge: text = i18n("Bridge"); break; case ConnectionSettings::Gsm: case ConnectionSettings::Cdma: text = i18n("Mobile broadband"); icon = QStringLiteral("smartphone"); break; case ConnectionSettings::Infiniband: text = i18n("Infiniband"); break; case ConnectionSettings::OLPCMesh: text = i18n("Olpc mesh"); break; case ConnectionSettings::Vlan: text = i18n("VLAN"); break; case ConnectionSettings::Vpn: text = i18n("VPN"); icon = QStringLiteral("network-vpn"); break; case ConnectionSettings::Wired: text = i18n("Wired Ethernet"); icon = QStringLiteral("network-wired"); break; case ConnectionSettings::Wireless: text = i18n("Wi-Fi"); icon = QStringLiteral("network-wireless"); break; #if NM_CHECK_VERSION(0, 9, 10) case ConnectionSettings::Team: text = i18n("Team"); break; #endif default: text = i18n("Unknown connection type"); break; } title = text; return icon; } QString UiUtils::prettyInterfaceName(NetworkManager::Device::Type type, const QString &interfaceName) { QString ret; switch (type) { case NetworkManager::Device::Wifi: ret = i18n("Wireless Interface (%1)", interfaceName); break; case NetworkManager::Device::Ethernet: ret = i18n("Wired Interface (%1)", interfaceName); break; case NetworkManager::Device::Bluetooth: ret = i18n("Bluetooth (%1)", interfaceName); break; case NetworkManager::Device::Modem: ret = i18n("Modem (%1)", interfaceName); break; case NetworkManager::Device::Adsl: ret = i18n("ADSL (%1)", interfaceName); break; case NetworkManager::Device::Vlan: ret = i18n("VLan (%1)", interfaceName); break; case NetworkManager::Device::Bridge: ret = i18n("Bridge (%1)", interfaceName); break; default: ret = interfaceName; } return ret; } QString UiUtils::connectionStateToString(NetworkManager::Device::State state, const QString &connectionName) { QString stateString; switch (state) { case NetworkManager::Device::UnknownState: stateString = i18nc("description of unknown network interface state", "Unknown"); break; case NetworkManager::Device::Unmanaged: stateString = i18nc("description of unmanaged network interface state", "Unmanaged"); break; case NetworkManager::Device::Unavailable: stateString = i18nc("description of unavailable network interface state", "Unavailable"); break; case NetworkManager::Device::Disconnected: stateString = i18nc("description of unconnected network interface state", "Not connected"); break; case NetworkManager::Device::Preparing: stateString = i18nc("description of preparing to connect network interface state", "Preparing to connect"); break; case NetworkManager::Device::ConfiguringHardware: stateString = i18nc("description of configuring hardware network interface state", "Configuring interface"); break; case NetworkManager::Device::NeedAuth: stateString = i18nc("description of waiting for authentication network interface state", "Waiting for authorization"); break; case NetworkManager::Device::ConfiguringIp: stateString = i18nc("network interface doing dhcp request in most cases", "Setting network address"); break; case NetworkManager::Device::CheckingIp: stateString = i18nc("is other action required to fully connect? captive portals, etc.", "Checking further connectivity"); break; case NetworkManager::Device::WaitingForSecondaries: stateString = i18nc("a secondary connection (e.g. VPN) has to be activated first to continue", "Waiting for a secondary connection"); break; case NetworkManager::Device::Activated: if (connectionName.isEmpty()) { stateString = i18nc("network interface connected state label", "Connected"); } else { stateString = i18nc("network interface connected state label", "Connected to %1", connectionName); } break; case NetworkManager::Device::Deactivating: stateString = i18nc("network interface disconnecting state label", "Deactivating connection"); break; case NetworkManager::Device::Failed: stateString = i18nc("network interface connection failed state label", "Connection Failed"); break; default: stateString = i18nc("interface state", "Error: Invalid state"); } return stateString; } QString UiUtils::vpnConnectionStateToString(VpnConnection::State state) { QString stateString; switch (state) { case VpnConnection::Unknown: stateString = i18nc("The state of the VPN connection is unknown", "Unknown"); break; case VpnConnection::Prepare: stateString = i18nc("The VPN connection is preparing to connect", "Preparing to connect"); break; case VpnConnection::NeedAuth: stateString = i18nc("The VPN connection needs authorization credentials", "Needs authorization"); break; case VpnConnection::Connecting: stateString = i18nc("The VPN connection is being established", "Connecting"); break; case VpnConnection::GettingIpConfig: stateString = i18nc("The VPN connection is getting an IP address", "Setting network address"); break; case VpnConnection::Activated: stateString = i18nc("The VPN connection is active", "Activated"); break; case VpnConnection::Failed: stateString = i18nc("The VPN connection failed", "Failed"); break; case VpnConnection::Disconnected: stateString = i18nc("The VPN connection is disconnected", "Failed"); break; default: stateString = i18nc("interface state", "Error: Invalid state"); } return stateString; } QString UiUtils::operationModeToString(NetworkManager::WirelessDevice::OperationMode mode) { QString modeString; switch (mode) { case NetworkManager::WirelessDevice::WirelessDevice::Unknown: modeString = i18nc("wireless network operation mode", "Unknown"); break; case NetworkManager::WirelessDevice::Adhoc: modeString = i18nc("wireless network operation mode", "Adhoc"); break; case NetworkManager::WirelessDevice::WirelessDevice::Infra: modeString = i18nc("wireless network operation mode", "Infrastructure"); break; case NetworkManager::WirelessDevice::WirelessDevice::ApMode: modeString = i18nc("wireless network operation mode", "Access point"); break; default: modeString = I18N_NOOP("INCORRECT MODE FIX ME"); } return modeString; } QStringList UiUtils::wpaFlagsToStringList(NetworkManager::AccessPoint::WpaFlags flags) { /* for testing purposes flags = NetworkManager::AccessPoint::PairWep40 | NetworkManager::AccessPoint::PairWep104 | NetworkManager::AccessPoint::PairTkip | NetworkManager::AccessPoint::PairCcmp | NetworkManager::AccessPoint::GroupWep40 | NetworkManager::AccessPoint::GroupWep104 | NetworkManager::AccessPoint::GroupTkip | NetworkManager::AccessPoint::GroupCcmp | NetworkManager::AccessPoint::KeyMgmtPsk | NetworkManager::AccessPoint::KeyMgmt8021x; */ QStringList flagList; if (flags.testFlag(NetworkManager::AccessPoint::PairWep40)) flagList.append(i18nc("wireless network cipher", "Pairwise WEP40")); if (flags.testFlag(NetworkManager::AccessPoint::PairWep104)) flagList.append(i18nc("wireless network cipher", "Pairwise WEP104")); if (flags.testFlag(NetworkManager::AccessPoint::PairTkip)) flagList.append(i18nc("wireless network cipher", "Pairwise TKIP")); if (flags.testFlag(NetworkManager::AccessPoint::PairCcmp)) flagList.append(i18nc("wireless network cipher", "Pairwise CCMP")); if (flags.testFlag(NetworkManager::AccessPoint::GroupWep40)) flagList.append(i18nc("wireless network cipher", "Group WEP40")); if (flags.testFlag(NetworkManager::AccessPoint::GroupWep104)) flagList.append(i18nc("wireless network cipher", "Group WEP104")); if (flags.testFlag(NetworkManager::AccessPoint::GroupTkip)) flagList.append(i18nc("wireless network cipher", "Group TKIP")); if (flags.testFlag(NetworkManager::AccessPoint::GroupCcmp)) flagList.append(i18nc("wireless network cipher", "Group CCMP")); if (flags.testFlag(NetworkManager::AccessPoint::KeyMgmtPsk)) flagList.append(i18nc("wireless network cipher", "PSK")); if (flags.testFlag(NetworkManager::AccessPoint::KeyMgmt8021x)) flagList.append(i18nc("wireless network cipher", "802.1x")); return flagList; } QString UiUtils::connectionSpeed(double bitrate) { QString out; if (bitrate < 1000) { out = i18nc("connection speed", "%1 Bit/s", bitrate); } else if (bitrate < 1000000) { out = i18nc("connection speed", "%1 MBit/s", bitrate/1000); } else { out = i18nc("connection speed", "%1 GBit/s", bitrate/1000000); } return out; } QString UiUtils::wirelessBandToString(NetworkManager::WirelessSetting::FrequencyBand band) { switch (band) { case NetworkManager::WirelessSetting::Automatic: return QStringLiteral("automatic"); break; case NetworkManager::WirelessSetting::A: return QStringLiteral("a"); break; case NetworkManager::WirelessSetting::Bg: return QStringLiteral("b/g"); break; } return QString(); } #if WITH_MODEMMANAGER_SUPPORT QString UiUtils::convertAllowedModeToString(ModemManager::Modem::ModemModes modes) { if (modes.testFlag(MM_MODEM_MODE_4G)) { return i18nc("Gsm modes (2G/3G/any)","LTE"); } else if (modes.testFlag(MM_MODEM_MODE_3G)) { return i18nc("Gsm modes (2G/3G/any)","UMTS/HSxPA"); } else if (modes.testFlag(MM_MODEM_MODE_2G)) { return i18nc("Gsm modes (2G/3G/any)","GPRS/EDGE"); } else if (modes.testFlag(MM_MODEM_MODE_CS)) { return i18nc("Gsm modes (2G/3G/any)","GSM"); } else if (modes.testFlag(MM_MODEM_MODE_ANY)) { return i18nc("Gsm modes (2G/3G/any)","Any"); } return i18nc("Gsm modes (2G/3G/any)","Any"); } QString UiUtils::convertAccessTechnologyToString(ModemManager::Modem::AccessTechnologies tech) { if (tech.testFlag(MM_MODEM_ACCESS_TECHNOLOGY_LTE)) { return i18nc("Cellular access technology","LTE"); } else if (tech.testFlag(MM_MODEM_ACCESS_TECHNOLOGY_EVDOB)) { return i18nc("Cellular access technology","CDMA2000 EVDO revision B"); } else if (tech.testFlag(MM_MODEM_ACCESS_TECHNOLOGY_EVDOA)) { return i18nc("Cellular access technology","CDMA2000 EVDO revision A"); } else if (tech.testFlag(MM_MODEM_ACCESS_TECHNOLOGY_EVDO0)) { return i18nc("Cellular access technology","CDMA2000 EVDO revision 0"); } else if (tech.testFlag(MM_MODEM_ACCESS_TECHNOLOGY_1XRTT)) { return i18nc("Cellular access technology","CDMA2000 1xRTT"); } else if (tech.testFlag(MM_MODEM_ACCESS_TECHNOLOGY_HSPA_PLUS)) { return i18nc("Cellular access technology","HSPA+"); } else if (tech.testFlag(MM_MODEM_ACCESS_TECHNOLOGY_HSPA)) { return i18nc("Cellular access technology","HSPA"); } else if (tech.testFlag(MM_MODEM_ACCESS_TECHNOLOGY_HSUPA)) { return i18nc("Cellular access technology","HSUPA"); } else if (tech.testFlag(MM_MODEM_ACCESS_TECHNOLOGY_HSDPA)) { return i18nc("Cellular access technology","HSDPA"); } else if (tech.testFlag(MM_MODEM_ACCESS_TECHNOLOGY_UMTS)) { return i18nc("Cellular access technology","UMTS"); } else if (tech.testFlag(MM_MODEM_ACCESS_TECHNOLOGY_EDGE)) { return i18nc("Cellular access technology","EDGE"); } else if (tech.testFlag(MM_MODEM_ACCESS_TECHNOLOGY_GPRS)) { return i18nc("Cellular access technology","GPRS"); } else if (tech.testFlag(MM_MODEM_ACCESS_TECHNOLOGY_GSM_COMPACT)) { return i18nc("Cellular access technology","Compact GSM"); } else if (tech.testFlag(MM_MODEM_ACCESS_TECHNOLOGY_GSM)) { return i18nc("Cellular access technology","GSM"); } else if (tech.testFlag(MM_MODEM_ACCESS_TECHNOLOGY_POTS)) { return i18nc("Analog wireline modem","Analog"); } else if (tech.testFlag(MM_MODEM_ACCESS_TECHNOLOGY_UNKNOWN)) { return i18nc("Unknown cellular access technology","Unknown"); } else if (tech.testFlag(MM_MODEM_ACCESS_TECHNOLOGY_ANY)) { return i18nc("Any cellular access technology","Any"); } return i18nc("Unknown cellular access technology","Unknown"); } QString UiUtils::convertLockReasonToString(MMModemLock reason) { switch (reason) { case MM_MODEM_LOCK_NONE: return i18nc("possible SIM lock reason", "Modem is unlocked."); case MM_MODEM_LOCK_SIM_PIN: return i18nc("possible SIM lock reason", "SIM requires the PIN code."); case MM_MODEM_LOCK_SIM_PIN2: return i18nc("possible SIM lock reason", "SIM requires the PIN2 code."); case MM_MODEM_LOCK_SIM_PUK: return i18nc("possible SIM lock reason", "SIM requires the PUK code."); case MM_MODEM_LOCK_SIM_PUK2: return i18nc("possible SIM lock reason", "SIM requires the PUK2 code."); case MM_MODEM_LOCK_PH_SP_PIN: return i18nc("possible SIM lock reason", "Modem requires the service provider PIN code."); case MM_MODEM_LOCK_PH_SP_PUK: return i18nc("possible SIM lock reason", "Modem requires the service provider PUK code."); case MM_MODEM_LOCK_PH_NET_PIN: return i18nc("possible SIM lock reason", "Modem requires the network PIN code."); case MM_MODEM_LOCK_PH_NET_PUK: return i18nc("possible SIM lock reason", "Modem requires the network PUK code."); case MM_MODEM_LOCK_PH_SIM_PIN: return i18nc("possible SIM lock reason", "Modem requires the PIN code."); case MM_MODEM_LOCK_PH_CORP_PIN: return i18nc("possible SIM lock reason", "Modem requires the corporate PIN code."); case MM_MODEM_LOCK_PH_CORP_PUK: return i18nc("possible SIM lock reason", "Modem requires the corporate PUK code."); case MM_MODEM_LOCK_PH_FSIM_PIN: return i18nc("possible SIM lock reason", "Modem requires the PH-FSIM PIN code."); case MM_MODEM_LOCK_PH_FSIM_PUK: return i18nc("possible SIM lock reason", "Modem requires the PH-FSIM PUK code."); case MM_MODEM_LOCK_PH_NETSUB_PIN: return i18nc("possible SIM lock reason", "Modem requires the network subset PIN code."); case MM_MODEM_LOCK_PH_NETSUB_PUK: return i18nc("possible SIM lock reason", "Modem requires the network subset PUK code."); case MM_MODEM_LOCK_UNKNOWN: default: return i18nc("possible SIM lock reason", "Lock reason unknown."); } } #endif NetworkManager::ModemDevice::Capability UiUtils::modemSubType(NetworkManager::ModemDevice::Capabilities modemCaps) { if (modemCaps & NetworkManager::ModemDevice::Lte) { return NetworkManager::ModemDevice::Lte; } else if (modemCaps & NetworkManager::ModemDevice::CdmaEvdo) { return NetworkManager::ModemDevice::CdmaEvdo; } else if (modemCaps & NetworkManager::ModemDevice::GsmUmts) { return NetworkManager::ModemDevice::GsmUmts; } else if (modemCaps & NetworkManager::ModemDevice::Pots) { return NetworkManager::ModemDevice::Pots; } return NetworkManager::ModemDevice::NoCapability; } QString UiUtils::labelFromWirelessSecurity(NetworkManager::WirelessSecurityType type) { QString tip; switch (type) { case NetworkManager::NoneSecurity: tip = i18nc("@label no security", "Insecure"); break; case NetworkManager::StaticWep: tip = i18nc("@label WEP security", "WEP"); break; case NetworkManager::Leap: tip = i18nc("@label LEAP security", "LEAP"); break; case NetworkManager::DynamicWep: tip = i18nc("@label Dynamic WEP security", "Dynamic WEP"); break; case NetworkManager::WpaPsk: tip = i18nc("@label WPA-PSK security", "WPA-PSK"); break; case NetworkManager::WpaEap: tip = i18nc("@label WPA-EAP security", "WPA-EAP"); break; case NetworkManager::Wpa2Psk: tip = i18nc("@label WPA2-PSK security", "WPA2-PSK"); break; case NetworkManager::Wpa2Eap: tip = i18nc("@label WPA2-EAP security", "WPA2-EAP"); break; default: tip = i18nc("@label unknown security", "Unknown security type"); break; } return tip; } QString UiUtils::formatDateRelative(const QDateTime & lastUsed) { QString lastUsedText; if (lastUsed.isValid()) { const QDateTime now = QDateTime::currentDateTime(); if (lastUsed.daysTo(now) == 0 ) { const int secondsAgo = lastUsed.secsTo(now); if (secondsAgo < (60 * 60 )) { const int minutesAgo = secondsAgo / 60; lastUsedText = i18ncp( "Label for last used time for a network connection used in the last hour, as the number of minutes since usage", "One minute ago", "%1 minutes ago", minutesAgo); } else { const int hoursAgo = secondsAgo / (60 * 60); lastUsedText = i18ncp( "Label for last used time for a network connection used in the last day, as the number of hours since usage", "One hour ago", "%1 hours ago", hoursAgo); } } else if (lastUsed.daysTo(now) == 1) { lastUsedText = i18nc("Label for last used time for a network connection used the previous day", "Yesterday"); } else { lastUsedText = QLocale().toString(lastUsed.date(), QLocale::ShortFormat); } } else { lastUsedText = i18nc("Label for last used time for a " "network connection that has never been used", "Never"); } return lastUsedText; } QString UiUtils::formatLastUsedDateRelative(const QDateTime & lastUsed) { QString lastUsedText; if (lastUsed.isValid()) { const QDateTime now = QDateTime::currentDateTime(); if (lastUsed.daysTo(now) == 0 ) { const int secondsAgo = lastUsed.secsTo(now); if (secondsAgo < (60 * 60 )) { const int minutesAgo = secondsAgo / 60; lastUsedText = i18ncp( "Label for last used time for a network connection used in the last hour, as the number of minutes since usage", "Last used one minute ago", "Last used %1 minutes ago", minutesAgo); } else { const int hoursAgo = secondsAgo / (60 * 60); lastUsedText = i18ncp( "Label for last used time for a network connection used in the last day, as the number of hours since usage", "Last used one hour ago", "Last used %1 hours ago", hoursAgo); } } else if (lastUsed.daysTo(now) == 1) { lastUsedText = i18nc("Label for last used time for a network connection used the previous day", "Last used yesterday"); } else { lastUsedText = i18n("Last used on %1", QLocale().toString(lastUsed.date(), QLocale::ShortFormat)); } } else { lastUsedText = i18nc("Label for last used time for a " "network connection that has never been used", "Never used"); } return lastUsedText; } diff --git a/libs/uiutils.h b/libs/uiutils.h index 7b706e55..d0ff06c2 100644 --- a/libs/uiutils.h +++ b/libs/uiutils.h @@ -1,133 +1,139 @@ /* Copyright 2008-2010 Sebastian Kügler Copyright 2013-2014 Jan Grulich This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License or (at your option) version 3 or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of version 3 of the license. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #ifndef PLASMA_NM_UIUTILS_H #define PLASMA_NM_UIUTILS_H #include #include #include #include #include #include #include #include #include #include #if WITH_MODEMMANAGER_SUPPORT #include #include #endif class Q_DECL_EXPORT UiUtils { public: enum SortedConnectionType { Wired, Wireless, Gsm, Cdma, Pppoe, Adsl, Infiniband, OLPCMesh, Bluetooth, Vpn, Vlan, Bridge, Bond, Team, Unknown }; /* * @return sorted connection type used to prioritize specific connection types */ static SortedConnectionType connectionTypeToSortedType(NetworkManager::ConnectionSettings::ConnectionType type); /* * @return whether given connection type is supported * Currently ignored connection types: Bond, Bridge, Generic, Infiniband, Team, Vlan, Tun */ static bool isConnectionTypeSupported(NetworkManager::ConnectionSettings::ConnectionType type); + /** + * @return true if the connection is virtual. + * @param type Type of the network connection + */ + static bool isConnectionTypeVirtual(NetworkManager::ConnectionSettings::ConnectionType type); + /** * @return a human-readable description for the network interface type for use as label * @param type the type of the network interface */ static QString interfaceTypeLabel(const NetworkManager::Device::Type type, const NetworkManager::Device::Ptr iface); /** * @return a human-readable name for a given network interface according to the configured * naming style * @param type type of the network interface * @param interfaceName name of the network interface (eg eth0) */ static QString prettyInterfaceName(NetworkManager::Device::Type type, const QString &interfaceName); /** * @return a human-readable description of the connection state of a given network interface * @param state The connection state */ static QString connectionStateToString(NetworkManager::Device::State state, const QString &connectionName = QString()); static QString vpnConnectionStateToString(NetworkManager::VpnConnection::State state); static QString iconAndTitleForConnectionSettingsType(NetworkManager::ConnectionSettings::ConnectionType type, QString &title); /** * @return a human-readable description of operation mode. * @param mode the operation mode */ static QString operationModeToString(NetworkManager::WirelessDevice::OperationMode mode); /** * @return string list with a human-readable description of wpa flags. * @param flags the wpa flags */ static QStringList wpaFlagsToStringList(NetworkManager::AccessPoint::WpaFlags flags); /** * @return localized string showing a human-readable connection speed. 1000 is used as base. * @param bitrate bitrate of the connection per second */ static QString connectionSpeed(double bitrate); /** * @param band The band of a wireless network. The value corresponds to the type enum in Knm::WirelessSetting::EnumBand * @return A string representation */ static QString wirelessBandToString(NetworkManager::WirelessSetting::FrequencyBand band); #if WITH_MODEMMANAGER_SUPPORT static QString convertAllowedModeToString(ModemManager::Modem::ModemModes mode); static QString convertAccessTechnologyToString(ModemManager::Modem::AccessTechnologies tech); static QString convertLockReasonToString(MMModemLock reason); #endif static NetworkManager::ModemDevice::Capability modemSubType(NetworkManager::ModemDevice::Capabilities modemCaps); static QString labelFromWirelessSecurity(NetworkManager::WirelessSecurityType type); static QString formatDateRelative(const QDateTime & lastUsed); static QString formatLastUsedDateRelative(const QDateTime & lastUsed); }; #endif // UIUTILS_H