543
QString UiUtils::shortToolTipFromWirelessSecurity(NetworkManager::Utils::WirelessSecurityType type)
547
case NetworkManager::Utils::None:
548
tip = i18nc("@info:tooltip no security", "Insecure");
550
case NetworkManager::Utils::StaticWep:
551
tip = i18nc("@info:tooltip WEP security", "WEP");
553
case NetworkManager::Utils::Leap:
554
tip = i18nc("@info:tooltip LEAP security", "LEAP");
556
case NetworkManager::Utils::DynamicWep:
557
tip = i18nc("@info:tooltip Dynamic WEP security", "Dynamic WEP");
559
case NetworkManager::Utils::WpaPsk:
560
tip = i18nc("@info:tooltip WPA-PSK security", "WPA-PSK");
562
case NetworkManager::Utils::WpaEap:
563
tip = i18nc("@info:tooltip WPA-EAP security", "WPA-EAP");
565
case NetworkManager::Utils::Wpa2Psk:
566
tip = i18nc("@info:tooltip WPA2-PSK security", "WPA2-PSK");
568
case NetworkManager::Utils::Wpa2Eap:
569
tip = i18nc("@info:tooltip WPA2-EAP security", "WPA2-EAP");
572
tip = i18nc("@info:tooltip unknown security", "Unknown security type");
578
QString UiUtils::connectionDetails(const Device::Ptr& device, const Connection::Ptr& connection, const QStringList& keys)
580
const QString format = "<tr><td align=\"right\" width=\"50%\"><b>%1</b></td><td align=\"left\" width=\"50%\"> %2</td></tr>";
583
const bool connected = device && connection && device->activeConnection() &&
584
device->activeConnection()->connection() == connection && device->activeConnection()->state() == ActiveConnection::Activated;
586
foreach (const QString& key, keys) {
587
if (key == "interface:name") {
590
if (device->ipInterfaceName().isEmpty()) {
591
name = device->interfaceName();
593
name = device->ipInterfaceName();
595
details += QString(format).arg(i18n("System name:"), name);
597
} else if (key == "ipv4:address") {
598
if (device && device->ipV4Config().isValid() && connected) {
599
if (device->ipV4Config().addresses().isEmpty()) {
602
QHostAddress addr = device->ipV4Config().addresses().first().ip();
603
if (!addr.isNull()) {
604
details += QString(format).arg(i18n("IPv4 Address:"), addr.toString());
607
} else if (key == "ipv4:gateway") {
608
if (device && device->ipV4Config().isValid() && connected) {
609
if (device->ipV4Config().addresses().isEmpty()) {
612
QHostAddress addr = device->ipV4Config().addresses().first().gateway();
613
if (!addr.isNull()) {
614
details += QString(format).arg(i18n("IPv4 Gateway:"), addr.toString());
617
} else if (key == "ipv6:address") {
618
if (device && device->ipV6Config().isValid() && connected) {
619
if (device->ipV6Config().addresses().isEmpty()) {
622
QHostAddress addr = device->ipV6Config().addresses().first().ip();
623
if (!addr.isNull()) {
624
details += QString(format).arg(i18n("IPv6 Address:"), addr.toString());
627
} else if (key == "ipv6:gateway") {
628
if (device && device->ipV6Config().isValid() && connected) {
629
if (device->ipV6Config().addresses().isEmpty()) {
632
QHostAddress addr = device->ipV6Config().addresses().first().gateway();
633
if (!addr.isNull() && addr.toString() != "::") {
634
details += QString(format).arg(i18n("IPv6 Gateway:"), addr.toString());
637
} else if (key == "interface:driver") {
639
details += QString(format).arg(i18n("Driver:"), device->driver());
647
QString UiUtils::bluetoothDetails(const BluetoothDevice::Ptr& btDevice, const QStringList& keys)
649
const QString format = "<tr><td align=\"right\" width=\"50%\"><b>%1</b></td><td align=\"left\" width=\"50%\"> %2</td></tr>";
652
foreach (const QString& key, keys) {
653
if (key == "bluetooth:name") {
655
details += QString(format).arg(i18nc("Name", "Bluetooth name"), btDevice->name());
657
} else if (key == "interface:hardwareAddress") {
659
details += QString(format).arg(i18n("MAC Address:"), btDevice->hardwareAddress());
667
QString UiUtils::modemDetails(const ModemDevice::Ptr& modemDevice, const QStringList& keys)
669
#if WITH_MODEMMANAGER_SUPPORT
670
const QString format = "<tr><td align=\"right\" width=\"50%\"><b>%1</b></td><td align=\"left\" width=\"50%\"> %2</td></tr>";
672
ModemManager::Modem::Ptr modemNetwork;
673
ModemManager::Modem3gpp::Ptr gsmNet;
674
ModemManager::ModemCdma::Ptr cdmaNet;
676
ModemManager::ModemDevice::Ptr modem = ModemManager::findModemDevice(modemDevice->udi());
678
modemNetwork = modem->interface(ModemManager::ModemDevice::ModemInterface).objectCast<ModemManager::Modem>();
679
gsmNet = modem->interface(ModemManager::ModemDevice::GsmInterface).objectCast<ModemManager::Modem3gpp>();
680
cdmaNet = modem->interface(ModemManager::ModemDevice::CdmaInterface).objectCast<ModemManager::ModemCdma>();
683
foreach (const QString& key, keys) {
684
if (key == "mobile:operator") {
686
details += QString(format).arg(i18n("Operator:"), gsmNet->operatorName());
687
} else if (cdmaNet) {
688
details += QString(format).arg(i18n("Network ID:"), cdmaNet->nid());
690
} else if (key == "mobile:quality") {
692
details += QString(format).arg(i18n("Signal Quality:"), QString("%1%").arg(modemNetwork->signalQuality().signal));
694
} else if (key == "mobile:technology") {
696
details += QString(format).arg(i18n("Access Technology:"), UiUtils::convertAccessTechnologyToString(modemNetwork->accessTechnologies()));
698
} else if (key == "mobile:mode") {
700
details += QString(format).arg(i18n("Allowed Mode:"), UiUtils::convertAllowedModeToString(modemNetwork->currentModes().allowed));
702
} else if (key == "mobile:unlock") {
704
details += QString(format).arg(i18n("Unlock Required:"), UiUtils::convertLockReasonToString(modemNetwork->unlockRequired()));
706
} else if (key == "mobile:imei") {
708
details += QString(format).arg(i18n("IMEI:"), modemNetwork->equipmentIdentifier());
710
} else if (key == "mobile:imsi") {
712
ModemManager::Sim::Ptr simCard;
713
simCard = modemDevice->getModemCardIface();
715
details += QString(format).arg(i18n("IMSI:"), simCard->imsi());
722
Q_UNUSED(modemDevice)
728
QString UiUtils::vpnDetails(const VpnConnection::Ptr& vpnConnection, const VpnSetting::Ptr& vpnSetting, const QStringList& keys)
730
const QString format = "<tr><td align=\"right\" width=\"50%\"><b>%1</b></td><td align=\"left\" width=\"50%\"> %2</td></tr>";
733
foreach (const QString& key, keys) {
734
if (key == "vpn:plugin") {
736
details += QString(format).arg(i18n("VPN plugin:"), vpnSetting->serviceType().section('.', -1));
738
} else if (key == "vpn:banner") {
740
details += QString(format).arg(i18n("Banner:"), vpnConnection->banner().simplified());
748
QString UiUtils::wimaxDetails(const NetworkManager::WimaxDevice::Ptr& wimaxDevice, const WimaxNsp::Ptr& wimaxNsp, const NetworkManager::Connection::Ptr& connection, const QStringList& keys)
750
const QString format = "<tr><td align=\"right\" width=\"50%\"><b>%1</b></td><td align=\"left\" width=\"50%\"> %2</td></tr>";
753
const bool connected = wimaxDevice && connection && wimaxDevice->activeConnection() &&
754
wimaxDevice->activeConnection()->connection() == connection && wimaxDevice->activeConnection()->state() == ActiveConnection::Activated;
756
foreach (const QString& key, keys) {
757
if (key == "wimax:bsid") {
758
if (connected && wimaxDevice) {
759
details += QString(format).arg(i18n("Bsid:"), wimaxDevice->bsid());
761
} else if (key == "wimax:nsp") {
763
details += QString(format).arg(i18n("NSP Name:"), wimaxNsp->name());
765
} else if (key == "wimax:signal") {
767
details += QString(format).arg(i18n("Signal Quality:"), i18n("%1%", wimaxNsp->signalQuality()));
769
} else if (key == "wimax:type") {
771
details += QString(format).arg(i18n("Network Type:"), UiUtils::convertNspTypeToString(wimaxNsp->networkType()));
779
QString UiUtils::wiredDetails(const WiredDevice::Ptr& wiredDevice, const NetworkManager::Connection::Ptr& connection, const QStringList& keys)
781
const QString format = "<tr><td align=\"right\" width=\"50%\"><b>%1</b></td><td align=\"left\" width=\"50%\"> %2</td></tr>";
784
const bool connected = wiredDevice && connection && wiredDevice->activeConnection() &&
785
wiredDevice->activeConnection()->connection() == connection && wiredDevice->activeConnection()->state() == ActiveConnection::Activated;
787
foreach (const QString& key, keys) {
788
if (key == "interface:bitrate") {
789
if (wiredDevice && connected) {
790
details += QString(format).arg(i18n("Connection speed:"), UiUtils::connectionSpeed(wiredDevice->bitRate()));
792
} else if (key == "interface:hardwareaddress") {
794
details += QString(format).arg(i18n("MAC Address:"), wiredDevice->permanentHardwareAddress());
802
QString UiUtils::wirelessDetails(const WirelessDevice::Ptr& wirelessDevice, const AccessPoint::Ptr& ap, const NetworkManager::Connection::Ptr& connection, const QStringList& keys)
804
const QString format = "<tr><td align=\"right\" width=\"50%\"><b>%1</b></td><td align=\"left\" width=\"50%\"> %2</td></tr>";
807
const bool connected = wirelessDevice && connection && wirelessDevice->activeConnection() &&
808
wirelessDevice->activeConnection()->connection() == connection && wirelessDevice->activeConnection()->state() == ActiveConnection::Activated;
811
foreach (const QString& key, keys) {
812
if (key == "interface:bitrate") {
813
if (wirelessDevice && connected) {
814
details += QString(format).arg(i18n("Connection speed:"), UiUtils::connectionSpeed(wirelessDevice->bitRate()));
816
} else if (key == "interface:hardwareaddress") {
817
if (wirelessDevice) {
818
details += QString(format).arg(i18n("MAC Address:"), wirelessDevice->permanentHardwareAddress());
820
} else if (key == "wireless:mode") {
821
if (wirelessDevice) {
822
details += QString(format).arg(i18n("Mode:"), UiUtils::operationModeToString(wirelessDevice->mode()));
824
} else if (key == "wireless:signal") {
826
details += QString(format).arg(i18n("Signal strength:"), i18n("%1%", ap->signalStrength()));
828
} else if (key == "wireless:ssid") {
830
details += QString(format).arg(i18n("Access point (SSID):"), ap->ssid());
832
} else if (key == "wireless:accesspoint") {
834
details += QString(format).arg(i18n("Access point (BSSID):"), ap->hardwareAddress());
836
} else if (key == "wireless:channel") {
838
details += QString(format).arg(i18nc("Wifi AP channel and frequency", "Channel:"), i18n("%1 (%2 MHz)", NetworkManager::Utils::findChannel(ap->frequency()), ap->frequency()));
840
} else if (key == "wireless:security") {
841
NetworkManager::Utils::WirelessSecurityType security = Utils::Unknown;
843
security = NetworkManager::Utils::findBestWirelessSecurity(wirelessDevice->wirelessCapabilities(), true, (wirelessDevice->mode() == NetworkManager::WirelessDevice::Adhoc),
844
ap->capabilities(), ap->wpaFlags(), ap->rsnFlags());
845
if (security != Utils::Unknown) {
846
details += QString(format).arg(i18n("Security:"), UiUtils::labelFromWirelessSecurity(security));
848
} else if (connection) {
849
// Necessary for example for AdHoc connections
850
security = Utils::securityTypeFromConnectionSetting(connection->settings());
851
if (security != Utils::Unknown) {
852
details += QString(format).arg(i18n("Security:"), UiUtils::labelFromWirelessSecurity(security));
855
} else if (key == "wireless:band") {
857
details += QString(format).arg(i18n("Frequency band:"), UiUtils::wirelessBandToString(NetworkManager::Utils::findFrequencyBand(ap->frequency())));
865
550
QString UiUtils::formatDateRelative(const QDateTime & lastUsed)
867
552
QString lastUsedText;
868
553
if (lastUsed.isValid()) {
869
554
const QDateTime now = QDateTime::currentDateTime();
870
555
if (lastUsed.daysTo(now) == 0 ) {
871
int secondsAgo = lastUsed.secsTo(now);
556
const int secondsAgo = lastUsed.secsTo(now);
872
557
if (secondsAgo < (60 * 60 )) {
873
int minutesAgo = secondsAgo / 60;
558
const int minutesAgo = secondsAgo / 60;
874
559
lastUsedText = i18ncp(
875
560
"Label for last used time for a network connection used in the last hour, as the number of minutes since usage",
876
561
"One minute ago",
877
562
"%1 minutes ago",
880
int hoursAgo = secondsAgo / (60 * 60);
565
const int hoursAgo = secondsAgo / (60 * 60);
881
566
lastUsedText = i18ncp(
882
567
"Label for last used time for a network connection used in the last day, as the number of hours since usage",