diff --git a/applet/contents/ui/Toolbar.qml b/applet/contents/ui/Toolbar.qml index 7f8adbf7..5453cf9b 100644 --- a/applet/contents/ui/Toolbar.qml +++ b/applet/contents/ui/Toolbar.qml @@ -1,171 +1,179 @@ /* Copyright 2013-2017 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 . */ import QtQuick 2.2 import QtQuick.Layouts 1.2 import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.networkmanagement 0.2 as PlasmaNM import org.kde.kquickcontrolsaddons 2.0 GridLayout { id: toolbar function closeSearch() { searchToggleButton.checked = false } rows: 2 columns: 2 PlasmaCore.Svg { id: lineSvg imagePath: "widgets/line" } PlasmaNM.EnabledConnections { id: enabledConnections onWirelessEnabledChanged: { wifiSwitchButton.checked = wifiSwitchButton.enabled && enabled } onWirelessHwEnabledChanged: { wifiSwitchButton.enabled = enabled && availableDevices.wirelessDeviceAvailable && !planeModeSwitchButton.airplaneModeEnabled } onWwanEnabledChanged: { wwanSwitchButton.checked = wwanSwitchButton.enabled && enabled } onWwanHwEnabledChanged: { wwanSwitchButton.enabled = enabled && availableDevices.modemDeviceAvailable && !planeModeSwitchButton.airplaneModeEnabled } } Row { Layout.fillWidth: true SwitchButton { id: wifiSwitchButton checked: enabled && enabledConnections.wirelessEnabled enabled: enabledConnections.wirelessHwEnabled && availableDevices.wirelessDeviceAvailable && !planeModeSwitchButton.airplaneModeEnabled tooltip: i18n("Enable wireless") icon: enabled ? "network-wireless-on" : "network-wireless-off" visible: availableDevices.wirelessDeviceAvailable onClicked: { handler.enableWireless(checked); } } SwitchButton { id: wwanSwitchButton checked: enabled && enabledConnections.wwanEnabled enabled: enabledConnections.wwanHwEnabled && availableDevices.modemDeviceAvailable && !planeModeSwitchButton.airplaneModeEnabled tooltip: i18n("Enable mobile network") icon: enabled ? "network-mobile-on" : "network-mobile-off" visible: availableDevices.modemDeviceAvailable onClicked: { handler.enableWwan(checked); } } SwitchButton { id: planeModeSwitchButton + property bool initialized: false property bool airplaneModeEnabled: false checked: airplaneModeEnabled tooltip: i18n("Enable airplane mode") icon: airplaneModeEnabled ? "network-flightmode-on" : "network-flightmode-off" + visible: availableDevices.modemDeviceAvailable || availableDevices.wirelessDeviceAvailable onClicked: { handler.enableAirplaneMode(checked); airplaneModeEnabled = !airplaneModeEnabled; } Binding { - target: connectionIconProvider - property: "airplaneMode" + target: configuration + property: "airplaneModeEnabled" value: planeModeSwitchButton.airplaneModeEnabled + when: planeModeSwitchButton.initialized + } + + Component.onCompleted: { + airplaneModeEnabled = configuration.airplaneModeEnabled + initialized = true } } } Row { Layout.column: 1 PlasmaComponents.ToolButton { id: searchToggleButton iconSource: "search" tooltip: i18ndc("plasma-nm", "button tooltip", "Search the connections") checkable: true } PlasmaComponents.ToolButton { id: openEditorButton iconSource: "configure" tooltip: i18n("Configure network connections...") visible: mainWindow.kcmAuthorized onClicked: { KCMShell.open(mainWindow.kcm) } } } PlasmaComponents.TextField { id: searchTextField Layout.row: 1 Layout.columnSpan: 2 Layout.fillWidth: true Layout.leftMargin: units.smallSpacing Layout.rightMargin: units.smallSpacing Layout.bottomMargin: units.smallSpacing focus: true clearButtonShown: true placeholderText: i18ndc("plasma-nm", "text field placeholder text", "Search...") visible: searchToggleButton.checked onVisibleChanged: if (!visible) text = "" Keys.onEscapePressed: { //Check if the searchbar is actually visible before accepting the escape key. Otherwise, the escape key cannot dismiss the applet until one interacts with some other element. if (searchToggleButton.checked) { searchToggleButton.checked = false; } else { event.accepted = false; } } onTextChanged: { // Show search field when starting to type directly if (text.length && !searchToggleButton.checked) { searchToggleButton.checked = true } appletProxyModel.setFilterRegExp(text) } } } diff --git a/applet/contents/ui/main.qml b/applet/contents/ui/main.qml index e9a26818..6d2e5b17 100644 --- a/applet/contents/ui/main.qml +++ b/applet/contents/ui/main.qml @@ -1,99 +1,100 @@ /* Copyright 2013-2017 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 . */ import QtQuick 2.2 import org.kde.plasma.plasmoid 2.0 import org.kde.plasma.networkmanagement 0.2 as PlasmaNM import org.kde.kquickcontrolsaddons 2.0 import QtQuick.Layouts 1.1 Item { id: mainWindow property bool showSections: true readonly property string kcm: "kcm_networkmanagement.desktop" readonly property bool kcmAuthorized: KCMShell.authorize(kcm).length == 1 Plasmoid.toolTipMainText: i18n("Networks") Plasmoid.toolTipSubText: networkStatus.activeConnections Plasmoid.icon: connectionIconProvider.connectionTooltipIcon Plasmoid.switchWidth: units.gridUnit * 10 Plasmoid.switchHeight: units.gridUnit * 10 Plasmoid.compactRepresentation: CompactRepresentation { } Plasmoid.fullRepresentation: PopupDialog { id: dialogItem Layout.minimumWidth: units.iconSizes.medium * 10 Layout.minimumHeight: units.gridUnit * 20 anchors.fill: parent focus: true } function action_openKCM() { KCMShell.open(kcm) } function action_showPortal() { Qt.openUrlExternally("http://networkcheck.kde.org") } Component.onCompleted: { if (kcmAuthorized) { plasmoid.setAction("openKCM", i18n("&Configure Network Connections..."), "preferences-system-network"); } plasmoid.setAction("showPortal", i18n("Open Network Login Page..."), "internet-services"); var action = plasmoid.action("showPortal"); action.visible = Qt.binding(function() { return connectionIconProvider.needsPortal; }) } PlasmaNM.NetworkStatus { id: networkStatus } PlasmaNM.ConnectionIcon { id: connectionIconProvider } PlasmaNM.Handler { id: handler onWirelessScanTimerEnabled: { if (enabled) { scanTimer.restart() } else { scanTimer.stop() } } } Timer { id: scanTimer interval: 15000 repeat: true running: plasmoid.expanded && !connectionIconProvider.airplaneMode onTriggered: handler.requestScan() } PlasmaNM.Configuration { + id: configuration unlockModemOnDetection: plasmoid.configuration.unlockModemOnDetection manageVirtualConnections: plasmoid.configuration.manageVirtualConnections } } diff --git a/kded/networkmanagement.notifyrc b/kded/networkmanagement.notifyrc index 7c008814..183f3b16 100644 --- a/kded/networkmanagement.notifyrc +++ b/kded/networkmanagement.notifyrc @@ -1,828 +1,829 @@ [Global] IconName=applications-internet Name=Network management Name[ar]=إدارة الشّبكات Name[bs]=Upravljanje mrežom Name[ca]=Gestió de la xarxa Name[ca@valencia]=Gestió de la xarxa Name[cs]=Správa sítě Name[da]=Netværkshåndtering Name[de]=Netzwerkverwaltung Name[el]=Διαχείριση δικτύων Name[en_GB]=Network management Name[es]=Gestión de redes Name[et]=Võrguhaldur Name[eu]=Sare-kudeaketa Name[fi]=Verkonhallinta Name[fr]=Gestion du réseau Name[gl]=Xestión da rede Name[he]=ניהול רשת Name[hu]=Hálózatkezelés Name[ia]=Gestion de rete Name[id]=Pengelolaan jaringan Name[it]=Gestione della rete Name[ja]=ネットワーク管理 Name[ko]=네트워크 관리 Name[lt]=Tinklo valdymas Name[nb]=Nettverksstyring Name[nds]=Nettwarkpleeg Name[nl]=Netwerkbeheer Name[nn]=Nettverksstyring Name[pa]=ਨੈੱਟਵਰਕ ਪਰਬੰਧ Name[pl]=Zarządzanie siecią Name[pt]=Gestão de rede Name[pt_BR]=Gerenciamento de redes Name[ru]=Управление сетью Name[sk]=Správa siete Name[sl]=Upravljanje omrežij Name[sr]=Управљање мрежом Name[sr@ijekavian]=Управљање мрежом Name[sr@ijekavianlatin]=Upravljanje mrežom Name[sr@latin]=Upravljanje mrežom Name[sv]=Nätverkshantering Name[tr]=Ağ yönetimi Name[uk]=Керування мережею Name[x-test]=xxNetwork managementxx Name[zh_CN]=网络管理 Name[zh_TW]=網路管理 Comment=Network management Comment[ar]=إدارة الشّبكات Comment[bs]=Upravljanje mrežom Comment[ca]=Gestió de la xarxa Comment[ca@valencia]=Gestió de la xarxa Comment[cs]=Správa sítě Comment[da]=Netværkshåndtering Comment[de]=Netzwerkverwaltung Comment[el]=Διαχείριση δικτύων Comment[en_GB]=Network management Comment[es]=Gestión de redes Comment[et]=Võrguhaldur Comment[eu]=Sare-kudeaketa Comment[fi]=Verkonhallinta Comment[fr]=Gestion du réseau Comment[gl]=Xestión da rede Comment[he]=ניהול רשת Comment[hu]=Hálózatkezelés Comment[ia]=Gestion de rete Comment[id]=Pengelolaan jaringan Comment[it]=Gestione della rete Comment[ja]=ネットワーク管理 Comment[ko]=네트워크 관리 Comment[lt]=Tinklo valdymas Comment[nb]=Nettverksstyring Comment[nds]=Nettwarkpleeg Comment[nl]=Netwerkbeheer Comment[nn]=Nettverksstyring Comment[pa]=ਨੈੱਟਵਰਕ ਪਰਬੰਧ Comment[pl]=Zarządzanie siecią Comment[pt]=Gestão de rede Comment[pt_BR]=Gerenciamento de redes Comment[ru]=Управление сетью Comment[sk]=Správa siete Comment[sl]=Upravljanje omrežij Comment[sr]=Управљање мрежом Comment[sr@ijekavian]=Управљање мрежом Comment[sr@ijekavianlatin]=Upravljanje mrežom Comment[sr@latin]=Upravljanje mrežom Comment[sv]=Nätverkshantering Comment[tr]=Ağ yönetimi Comment[uk]=Керування мережею Comment[x-test]=xxNetwork managementxx Comment[zh_CN]=网络管理 Comment[zh_TW]=網路管理 [Event/ConnectionActivated] Name=Connection activated Name[ar]=فُعّل الاتّصال Name[ast]=Activóse una conexón Name[bs]=Konekcija aktivirana Name[ca]=Connexió activada Name[ca@valencia]=Connexió activada Name[cs]=Spojení aktivováno Name[da]=Forbindelse aktiveret Name[de]=Verbindung aktiviert Name[el]=Η σύνδεση ενεργοποιήθηκε Name[en_GB]=Connection activated Name[es]=Conexión activada Name[et]=Ühendus on aktiivne Name[eu]=Konexioa aktibatu da Name[fi]=Yhteys muodostettu Name[fr]=Connexion activée Name[gl]=Activouse unha conexión Name[he]=החיבור פעיל Name[hu]=Kapcsolat aktiválva Name[ia]=Connexion activate Name[id]=Koneksi yang diaktifkan Name[it]=Connessione attivata Name[ja]=接続が有効化されました Name[ko]=연결 활성화됨 Name[lt]=Ryšys aktyvuotas Name[nb]=Tilkobling aktivert Name[nds]=Verbinnen anmaakt Name[nl]=Verbinding geactiveerd Name[nn]=Kopla til Name[pa]=ਕੁਨੈਕਸ਼ਨ ਸਰਗਰਮ ਹੈ Name[pl]=Nawiązano połączenie Name[pt]=Ligação activada Name[pt_BR]=Conexão ativada Name[ru]=Соединение установлено Name[sk]=Pripojenie aktivované Name[sl]=Povezava omogočena Name[sr]=Веза активирана Name[sr@ijekavian]=Веза активирана Name[sr@ijekavianlatin]=Veza aktivirana Name[sr@latin]=Veza aktivirana Name[sv]=Anslutning aktiverad Name[tr]=Bağlantı etkinleştirildi Name[uk]=З’єднання задіяно Name[x-test]=xxConnection activatedxx Name[zh_CN]=连接已激活 Name[zh_TW]=連線已啟動 IconName=applications-internet Urgency=Low Action=Popup [Event/ConnectionDeactivated] Name=Connection deactivated Name[ar]=عُطّل الاتّصال Name[ast]=Desactivóse la conexón Name[bs]=Konekcija deaktivirana Name[ca]=Connexió desactivada Name[ca@valencia]=Connexió desactivada Name[cs]=Spojení deaktivováno Name[da]=Forbindelse deaktiveret Name[de]=Verbindung deaktiviert Name[el]=Η σύνδεση απενεργοποιήθηκε Name[en_GB]=Connection deactivated Name[es]=Conexión desactivada Name[et]=Ühendus ei ole aktiivne Name[eu]=Konexioa desaktibatu da Name[fi]=Yhteys katkaistu Name[fr]=Connexion désactivée Name[gl]=Desactivouse a conexión Name[he]=החיבור לא פעיל Name[hu]=Kapcsolat deaktiválva Name[ia]=Connexion deactivate Name[id]=Koneksi yang dinonaktifkan Name[it]=Connessione disattivata Name[ja]=接続が無効化されました Name[ko]=연결 비활성화됨 Name[lt]=Ryšys išjungtas Name[nb]=Tilkobling deaktivert Name[nds]=Verbinnen utmaakt Name[nl]=Verbinding gedeactiveerd Name[nn]=Kopla frå Name[pa]=ਕਨੈਕਸ਼ਨ ਡਿ-ਐਕਟੀਵੇਟ ਹੈ Name[pl]=Zerwano połączenie Name[pt]=Ligação desactivada Name[pt_BR]=Conexão desativada Name[ru]=Соединение отключено Name[sk]=Pripojenie deaktivované Name[sl]=Povezava onemogočena Name[sr]=Веза деактивирана Name[sr@ijekavian]=Веза деактивирана Name[sr@ijekavianlatin]=Veza deaktivirana Name[sr@latin]=Veza deaktivirana Name[sv]=Anslutning inaktiverad Name[tr]=Bağlantı sonlandırıldı Name[uk]=З’єднання вимкнено Name[x-test]=xxConnection deactivatedxx Name[zh_CN]=连接已取消激活 Name[zh_TW]=連線已中止 IconName=applications-internet +Urgency=Low Action=Popup [Event/ConnectionAdded] Name=Connection added Name[ar]=أُضيف الاتّصال Name[ast]=Amestóse una conexón Name[bs]=Konekcija dodana Name[ca]=S'ha afegit una connexió Name[ca@valencia]=S'ha afegit una connexió Name[cs]=Spojení bylo přidáno Name[da]=Forbindelse tilføjet Name[de]=Verbindung hinzugefügt Name[el]=Η σύνδεση προστέθηκε Name[en_GB]=Connection added Name[es]=Conexión añadida Name[et]=Ühendus lisati Name[eu]=Konexioa gehitu da Name[fi]=Yhteys lisätty Name[fr]=Connexion ajoutée Name[gl]=Engadiuse unha conexión Name[he]=נוסף חיבור Name[hu]=Kapcsolat hozzáadva Name[ia]=Connexion addite Name[id]=Koneksi yang ditambahkan Name[it]=Connessione aggiunta Name[ja]=接続が追加されました Name[ko]=연결 추가됨 Name[lt]=Ryšys pridėtas Name[nb]=Tilkobling lagt til Name[nds]=Verbinnen toföögt Name[nl]=Verbinding toegevoegd Name[nn]=Lagt til tilkopling Name[pa]=ਕੁਨੈਕਸ਼ਨ ਜੋੜਿਆ Name[pl]=Dodano połączenie Name[pt]=Ligação adicionada Name[pt_BR]=Conexão adicionada Name[ru]=Соединение добавлено Name[sk]=Pripojenie pridané Name[sl]=Povezava dodana Name[sr]=Веза додата Name[sr@ijekavian]=Веза додата Name[sr@ijekavianlatin]=Veza dodata Name[sr@latin]=Veza dodata Name[sv]=Anslutning har lagts till Name[tr]=Bağlantı eklendi Name[uk]=Додано з’єднання Name[x-test]=xxConnection addedxx Name[zh_CN]=连接已添加 Name[zh_TW]=連線已新增 IconName=applications-internet Action=None [Event/ConnectionRemoved] Name=Connection removed Name[ar]=أُزيل الاتّصال Name[ast]=Desanicióse la conexón Name[bs]=Konekcija uklonjena Name[ca]=S'ha eliminat una connexió Name[ca@valencia]=S'ha eliminat una connexió Name[cs]=Spojení bylo odstraněno Name[da]=Forbindelse fjernet Name[de]=Verbindung entfernt Name[el]=Η σύνδεση αφαιρέθηκε Name[en_GB]=Connection removed Name[es]=Conexión eliminada Name[et]=Ühendus eemaldati Name[eu]=Konexioa kendu da Name[fi]=Yhteys poistettu Name[fr]=Connexion supprimée Name[gl]=Retirouse unha conexión Name[he]=הוסר חיבור Name[hu]=Kapcsolat eltávolítva Name[ia]=Connexion removite Name[id]=Koneksi yang dihapus Name[it]=Connessione rimossa Name[ja]=接続が削除されました Name[ko]=연결 삭제됨 Name[lt]=Ryšys pašalintas Name[nb]=Tilkobling fjernet Name[nds]=Verbinnen wegmaakt Name[nl]=Verbinding verwijderd Name[nn]=Fjerna tilkopling Name[pa]=ਕੁਨੈਕਸ਼ਨ ਹਟਾਇਆ Name[pl]=Usunięto połączenie Name[pt]=Ligação removida Name[pt_BR]=Conexão removida Name[ru]=Соединение удалено Name[sk]=Pripojenie odstránené Name[sl]=Povezava odstranjena Name[sr]=Веза уклоњена Name[sr@ijekavian]=Веза уклоњена Name[sr@ijekavianlatin]=Veza uklonjena Name[sr@latin]=Veza uklonjena Name[sv]=Anslutning borttagen Name[tr]=Bağlantı silindi Name[uk]=Вилучено з’єднання Name[x-test]=xxConnection removedxx Name[zh_CN]=连接已删除 Name[zh_TW]=連線已移除 IconName=applications-internet Action=None [Event/ConnectionUpdated] Name=Connection updated Name[ar]=حُدّث الاتّصال Name[ast]=Anovóse la conexón Name[bs]=Konekcija ažurirana Name[ca]=S'ha actualitzat una connexió Name[ca@valencia]=S'ha actualitzat una connexió Name[cs]=Spojení bylo aktualizováno Name[da]=Forbindelse opdateret Name[de]=Verbindung aktualisiert Name[el]=Η σύνδεση ενημερώθηκε Name[en_GB]=Connection updated Name[es]=Conexión actualizada Name[et]=Ühendust uuendati Name[eu]=Konexioa eguneratu da Name[fi]=Yhteys päivitetty Name[fr]=Connexion mise à jour Name[gl]=Actualizouse unha conexión Name[he]=חיבור עודכן Name[hu]=Kapcsolat frissítve Name[ia]=Connexion actualisate Name[id]=Koneksi yang diperbarui Name[it]=Connessione aggiornata Name[ja]=接続が更新されました Name[ko]=연결 업데이트됨 Name[lt]=Ryšys atnaujintas Name[nb]=Tilkobling oppdatert Name[nds]=Verbinnen opfrischt Name[nl]=Verbinding bijgewerkt Name[nn]=Oppdatert tilkopling Name[pa]=ਕੁਨੈਕਸ਼ਨ ਅੱਪਡੇਟ ਕੀਤਾ Name[pl]=Uaktualniono połączenie Name[pt]=Ligação actualizada Name[pt_BR]=Conexão atualizada Name[ru]=Соединение обновлено Name[sk]=Pripojenie aktualizované Name[sl]=Povezava posodobljena Name[sr]=Веза ажурирана Name[sr@ijekavian]=Веза ажурирана Name[sr@ijekavianlatin]=Veza ažurirana Name[sr@latin]=Veza ažurirana Name[sv]=Anslutning uppdaterad Name[tr]=Bağlantı güncellendi Name[uk]=Оновлено з’єднання Name[x-test]=xxConnection updatedxx Name[zh_CN]=连接已更新 Name[zh_TW]=連線已更新 IconName=applications-internet Action=None [Event/DeviceFailed] Name=Device failed Name[ar]=فشل الجهاز Name[ast]=El preséu falló Name[bs]=Uređaj pao Name[ca]=El dispositiu ha fallat Name[ca@valencia]=El dispositiu ha fallat Name[cs]=Zařízení selhalo Name[da]=Enheden fejlede Name[de]=Gerät nicht bereit Name[el]=Η συσκευή απέτυχε Name[en_GB]=Device failed Name[es]=El dispositivo ha fallado Name[et]=Seade nurjus Name[eu]=Gailuak huts egin du Name[fi]=Laite lakkasi toimimasta Name[fr]=Le périphérique a rencontré une erreur Name[gl]=O dispositivo fallou. Name[he]=ההתקן נכשל Name[hu]=Az eszköz meghiúsult Name[ia]=Dispositivo falleva Name[id]=Perangkat yang gagal Name[it]=Dispositivo non funzionante Name[ko]=장치 오류 Name[lt]=Įrenginys patyrė nesėkmę Name[nb]=Enhet sviktet Name[nds]=Reedschap-Fehler Name[nl]=Apparaat is mislukt Name[nn]=Eining svikta Name[pa]=ਜੰਤਰ ਫੇਲ੍ਹ ਹੈ Name[pl]=Niepowodzenie urządzenia Name[pt]=Não foi possível activar o dispositivo Name[pt_BR]=Falha no dispositivo Name[ru]=Сбой устройства Name[sk]=Zariadenie zlyhalo Name[sl]=Naprava je spodletela Name[sr]=Уређај пропао Name[sr@ijekavian]=Уређај пропао Name[sr@ijekavianlatin]=Uređaj propao Name[sr@latin]=Uređaj propao Name[sv]=Enhet misslyckades Name[tr]=Aygıt başarısız oldu Name[uk]=Помилка пристрою Name[x-test]=xxDevice failedxx Name[zh_CN]=设备失败 Name[zh_TW]=裝置失敗 IconName=applications-internet Action=Popup [Event/FailedToActivateConnection] Name=Failed to activate connection Name[ar]=فشل تفعيل الاتّصال Name[ast]=Fallu al activar la conexón Name[bs]=Neuspjela aktivacija konekcije Name[ca]=Ha fallat en activar la connexió Name[ca@valencia]=Ha fallat en activar la connexió Name[cs]=Spojení nelze aktivovat Name[da]=Kunne ikke aktivere forbindelsen Name[de]=Die Verbindung kann nicht aktiviert werden Name[el]=Αποτυχία ενεργοποίησης σύνδεσης Name[en_GB]=Failed to activate connection Name[es]=La activación de la conexión ha fallado Name[et]=Ühenduse aktiveerimine nurjus Name[eu]=Konexioa aktibatzeak huts egin du Name[fi]=Yhteyden muodostaminen epäonnistui Name[fr]=Impossible d'activer la connexion Name[gl]=Non se puido activar a conexión Name[he]=נכשל בהפעלת החיבור Name[hu]=Nem sikerült aktiválni a kapcsolatot Name[ia]=Il faleva activar connexion Name[id]=Gagal mengaktifkan koneksi Name[it]=Attivazione del dispositivo non riuscita Name[ja]=接続の有効化に失敗しました Name[ko]=연결을 활성화할 수 없음 Name[lt]=Nepavyko aktyvuoti ryšio Name[nb]=Klarte ikke å aktivere tilkobling Name[nds]=Verbinnen lett sik nich anmaken Name[nl]=Activeren van verbinding is mislukt Name[nn]=Klarte ikkje å starta tilkopling Name[pa]=ਕੁਨੈਕਸ਼ਨ ਸਰਗਰਮ ਕਰਨ ਲਈ ਫੇਲ੍ਹ ਹੈ Name[pl]=Nieudane nawiązywanie połączenia Name[pt]=Não foi possível activar a ligação Name[pt_BR]=Falha ao ativar a conexão Name[ru]=Не удалось задействовать соединение Name[sk]=Zlyhalo aktivovanie pripojenia Name[sl]=Povezave ni bilo mogoče omogočiti Name[sr]=Пропало активирање везе Name[sr@ijekavian]=Пропало активирање везе Name[sr@ijekavianlatin]=Propalo aktiviranje veze Name[sr@latin]=Propalo aktiviranje veze Name[sv]=Aktivering av anslutningen misslyckades Name[tr]=Bağlantı etkinleştirilemedi Name[uk]=Не вдалося задіяти з’єднання Name[x-test]=xxFailed to activate connectionxx Name[zh_CN]=连接激活失败 Name[zh_TW]=啟動連線失敗 IconName=applications-internet Action=Popup [Event/FailedToAddConnection] Name=Failed to add connection Name[ar]=فشلت إضافة الاتّصال Name[ast]=Fallu al amestar la conexón Name[bs]=Neuspjelo dodavanje konekcije Name[ca]=Ha fallat en afegir la connexió Name[ca@valencia]=Ha fallat en afegir la connexió Name[cs]=Přidání spojení selhalo Name[da]=Kunne ikke tilføje forbindelsen Name[de]=Die Verbindung kann nicht hinzugefügt werden Name[el]=Αποτυχία προσθήκης σύνδεσης Name[en_GB]=Failed to add connection Name[es]=Ha ocurrido un fallo al añadir la conexión Name[et]=Ühenduse lisamine nurjus Name[eu]=Konexioa gehitzeak huts egin du Name[fi]=Yhteyden lisääminen epäonnistui Name[fr]=Impossible d'ajouter la connexion Name[gl]=Non se puido engadir a conexión Name[he]=נכשל בהוספת חיבור Name[hu]=Nem sikerült hozzáadni a kapcsolatot Name[ia]=Il falleva adder connexion Name[id]=Gagal menambahkan koneksi Name[it]=Aggiunta della connessione non riuscita Name[ja]=接続の追加に失敗しました Name[ko]=연결을 추가할 수 없음 Name[lt]=Nepavyko pridėti ryšio Name[nb]=Klarte ikke å legge til tilkobling Name[nds]=Verbinnen lett sik nich tofögen Name[nl]=Toevoegen van verbinding is mislukt Name[nn]=Klarte ikkje å leggja til tilkopling Name[pa]=ਕਨੈਕਸ਼ਨ ਜੋੜਨ ਲਈ ਫੇਲ੍ਹ ਹੈ Name[pl]=Nieudane dodawanie połączenia Name[pt]=Não foi possível adicionar a ligação Name[pt_BR]=Falha ao adicionar uma conexão Name[ru]=Не удалось добавить соединение Name[sk]=Zlyhalo pridanie pripojenia Name[sl]=Povezave ni bilo mogoče dodati Name[sr]=Пропало додавање везе Name[sr@ijekavian]=Пропало додавање везе Name[sr@ijekavianlatin]=Propalo dodavanje veze Name[sr@latin]=Propalo dodavanje veze Name[sv]=Tillägg av anslutning misslyckades Name[tr]=Bağlantı eklenemedi Name[uk]=Не вдалося додати з’єднання Name[x-test]=xxFailed to add connectionxx Name[zh_CN]=添加连接失败 Name[zh_TW]=新增連線失敗 IconName=applications-internet Action=Popup [Event/FailedToDeactivateConnection] Name=Failed to deactivate connection Name[ar]=فشل تعطيل الاتّصال Name[ast]=Fallu al desactivar la conexón Name[bs]=Neuspjelo deaktiviranje konekcije Name[ca]=Ha fallat en desactivar la connexió Name[ca@valencia]=Ha fallat en desactivar la connexió Name[cs]=Spojení nelze deaktivovat Name[da]=Kunne ikke deaktivere forbindelsen Name[de]=Die Verbindung kann nicht deaktiviert werden Name[el]=Αποτυχία απενεργοποίησης σύνδεσης Name[en_GB]=Failed to deactivate connection Name[es]=La desactivación de la conexión ha fallado Name[et]=Ühenduse deaktiveerimine nurjus Name[eu]=Konexioa desaktibatzeak huts egin du Name[fi]=Yhteyden katkaiseminen epäonnistui Name[fr]=Impossible de désactiver la connexion Name[gl]=Non se puido desactivar a conexión Name[he]=נכשל בכיבוי חיבור Name[hu]=Nem sikerült deaktiválni a kapcsolatot Name[ia]=Il falleva deactivar connexion Name[id]=Gagal menonaktifkan koneksi Name[it]=Disattivazione della connessione non riuscita Name[ja]=接続の無効化に失敗しました Name[ko]=연결을 비활성화할 수 없음 Name[lt]=Nepavyko išjungti ryšio Name[nb]=Klarte ikke å deaktivere tilkobling Name[nds]=Verbinnen lett sik nich utmaken Name[nl]=Deactiveren van verbinding is mislukt Name[nn]=Klarte ikkje å stoppa tilkopling Name[pa]=ਕਨੈਕਸ਼ਨ ਡਿ-ਐਕਟੀਵੇਟ ਕਰਨ ਲਈ ਫੇਲ੍ਹ ਹੈ Name[pl]=Nieudane wyłączanie połączenia Name[pt]=Não foi possível desactivar a ligação Name[pt_BR]=Falha ao desativar a conexão Name[ru]=Не удалось отключить соединение Name[sk]=Zlyhala deaktivácia pripojenia Name[sl]=Povezave ni bilo mogoče onemogočiti Name[sr]=Пропало деактивирање везе Name[sr@ijekavian]=Пропало деактивирање везе Name[sr@ijekavianlatin]=Propalo deaktiviranje veze Name[sr@latin]=Propalo deaktiviranje veze Name[sv]=Inaktivering av anslutningen misslyckades Name[tr]=Bağlantı kapatılamadı Name[uk]=Не вдалося вимкнути з’єднання Name[x-test]=xxFailed to deactivate connectionxx Name[zh_CN]=取消激活连接失败 Name[zh_TW]=中止連線失敗 IconName=applications-internet Action=Popup [Event/FailedToRemoveConnection] Name=Failed to remove connection Name[ar]=فشلت إزالة الاتّصال Name[ast]=Fallu al desaniciar la conexón Name[bs]=Neuspjelo uklanjanje konekcije Name[ca]=Ha fallat en eliminar la connexió Name[ca@valencia]=Ha fallat en eliminar la connexió Name[cs]=Spojení nelze odstranit Name[da]=Kunne ikke fjerne forbindelsen Name[de]=Die Verbindung kann nicht entfernt werden Name[el]=Αποτυχία αφαίρεσης σύνδεσης Name[en_GB]=Failed to remove connection Name[es]=La eliminación de la conexión ha fallado Name[et]=Ühenduse eemaldamine nurjus Name[eu]=Konexioa kentzeak huts egin du Name[fi]=Yhteyden poisto epäonnistui Name[fr]=Impossible de supprimer la connexion Name[gl]=Non se puido retirar a conexión Name[he]=נכשל בהסרת חיבור Name[hu]=Nem sikerült eltávolítani a kapcsolatot Name[ia]=Il afelleva remover connexion Name[id]=Gagal menghapus koneksi Name[it]=Rimozione della connessione non riuscita Name[ja]=接続の削除に失敗しました Name[ko]=연결을 삭제할 수 없음 Name[lt]=Nepavyko pašalinti ryšio Name[nb]=Klarte ikke å fjerne tilkobling Name[nds]=Verbinnen lett sik nich wegmaken Name[nl]=Verwijderen van verbinding is mislukt Name[nn]=Klarte ikkje å fjerna tilkopling Name[pa]=ਕਨੈਕਸ਼ਨ ਹਟਾਉਣ ਲਈ ਫੇਲ੍ਹ ਹੈ Name[pl]=Nieudane usuwanie połączenia Name[pt]=Não foi possível remover a ligação Name[pt_BR]=Falha ao remover a conexão Name[ru]=Не удалось удалить соединение Name[sk]=Zlyhalo odstránenie pripojenie Name[sl]=Povezave ni bilo mogoče odstraniti Name[sr]=Пропало уклањање везе Name[sr@ijekavian]=Пропало уклањање везе Name[sr@ijekavianlatin]=Propalo uklanjanje veze Name[sr@latin]=Propalo uklanjanje veze Name[sv]=Borttagning av anslutning misslyckades Name[tr]=Bağlantı silinemedi Name[uk]=Не вдалося вилучити з’єднання Name[x-test]=xxFailed to remove connectionxx Name[zh_CN]=删除连接失败 Name[zh_TW]=移除連線失敗 IconName=applications-internet Action=Popup [Event/FailedToGetSecrets] Name=Failed to get secrets Name[ar]=فشل جلب الأسرار Name[ast]=Fallu al consiguir los secretos Name[bs]=Nesupjelo uzimanje tajni Name[ca]=Ha fallat en obtenir els secrets Name[ca@valencia]=Ha fallat en obtindre els secrets Name[cs]=Selhalo získávání přístupu Name[da]=Kunne ikke hente hemmeligheder Name[de]=Anmeldedaten können nicht bezogen werden Name[el]=Αποτυχία ανάκτησης κωδικών Name[en_GB]=Failed to get secrets Name[es]=La obtención de claves secretas ha fallado Name[et]=Saladuste hankimine nurjus Name[eu]=Sekretuak eskuratzeak huts egin du Name[fi]=Salaisuuksien saaminen epäonnistui Name[fr]=Impossible d'obtenir les informations secrètes Name[gl]=Non se puideron obter os segredos Name[he]=נכשל בקבלת סיסמאות Name[hu]=Nem sikerült megszerezni a titkos adatokat Name[ia]=Il falleva obtener secretos Name[id]=Gagal mendapatkan rahasiaan Name[it]=Impossibile ottenere i segreti Name[ja]=シークレットの取得に失敗しました Name[ko]=비밀 정보를 가져올 수 없음 Name[lt]=Nepavyko gauti paslapčių Name[nb]=Klarte ikke hente hemmeligheter Name[nds]=Anmellinformatschonen laat sik nich halen Name[nl]=Geheimen ophalen is mislukt Name[nn]=Klarte ikkje henta løyndomar Name[pa]=ਭੇਤ ਲੈਣ ਲਈ ਫੇਲ੍ਹ ਹੈ Name[pl]=Nieudane uzyskiwanie danych poufnych Name[pt]=Não foi possível obter as senhas Name[pt_BR]=Falha ao obter as senhas Name[ru]=Не удалось получить пароли и ключи Name[sk]=Zlyhalo získanie secrets Name[sl]=Ni bilo mogoče dobiti skrivnosti Name[sr]=Пропало добављање тајни Name[sr@ijekavian]=Пропало добављање тајни Name[sr@ijekavianlatin]=Propalo dobavljanje tajni Name[sr@latin]=Propalo dobavljanje tajni Name[sv]=Misslyckades hämta hemligheter Name[tr]=Sırlar alınamadı Name[uk]=Не вдалося отримати дані для розпізнавання Name[x-test]=xxFailed to get secretsxx Name[zh_CN]=获取密码失败 Name[zh_TW]=取得密碼失敗 IconName=applications-internet Action=Popup [Event/FailedToUpdateConnection] Name=Failed to update connection Name[ar]=فشل تحدي الاتّصال Name[ast]=Fallu al anovar la conexón Name[bs]=Neuspjelo ažuriranje konekcije Name[ca]=Ha fallat en actualitzar la connexió Name[ca@valencia]=Ha fallat en actualitzar la connexió Name[cs]=Spojení nelze aktualizovat Name[da]=Kunne ikke opdatere forbindelsen Name[de]=Die Verbindung kann nicht aktualisiert werden Name[el]=Αποτυχία ενημέρωσης σύνδεσης Name[en_GB]=Failed to update connection Name[es]=La actualización de la conexión ha fallado Name[et]=Ühenduse uuendamine nurjus Name[eu]=Konexioa eguneratzeak huts egin du Name[fi]=Yhteyden päivittäminen epäonnistui Name[fr]=Impossible de mettre à jour la connexion Name[gl]=Non se puido actualizar a conexión Name[he]=נכשל בעדכון חיבור Name[hu]=Nem sikerült frissíteni a kapcsolatot Name[ia]=Il falleva actualisar connexion Name[id]=Gagal memperbarui koneksi Name[it]=Aggiornamento della connessione non riuscito Name[ja]=接続の更新に失敗しました Name[ko]=연결을 업데이트할 수 없음 Name[lt]=Nepavyko atnaujinti ryšio Name[nb]=Klarte ikke å oppdatere tilkobling Name[nds]=Verbinnen lett sik nich opfrischen Name[nl]=Bijwerken van verbinding is mislukt Name[nn]=Klarte ikkje å oppdatera tilkopling Name[pa]=ਕਨੈਕਸ਼ਨ ਅੱਪਡੇਟ ਕਰਨ ਲਈ ਫੇਲ੍ਹ ਹੈ Name[pl]=Nieudane uaktualnianie połączenia Name[pt]=Não foi possível actualizar a ligação Name[pt_BR]=Falha ao atualizar a conexão Name[ru]=Не удалось обновить соединение Name[sk]=Zlyhala aktualizácia pripojenia Name[sl]=Povezave ni bilo mogoče posodobiti Name[sr]=Пропало ажурирање везе Name[sr@ijekavian]=Пропало ажурирање везе Name[sr@ijekavianlatin]=Propalo ažuriranje veze Name[sr@latin]=Propalo ažuriranje veze Name[sv]=Misslyckades uppdatera anslutning Name[tr]=Bağlantı güncellenemedi Name[uk]=Не вдалося оновити з’єднання Name[x-test]=xxFailed to update connectionxx Name[zh_CN]=更新连接失败 Name[zh_TW]=更新連線失敗 IconName=applications-internet Action=Popup [Event/MissingVpnPlugin] Name=Missing VPN plugin Name[ar]=ملحقة VPN مفقودة Name[bg]=Лшпсваща приставка за VPN Name[bs]=Nedostaje VPN dodatak Name[ca]=Manca el connector VPN Name[ca@valencia]=Falta el connector VPN Name[cs]=Chybějící modul VPN Name[da]=Mangler VPN-plugin Name[de]=Fehlendes VPN-Modul Name[el]=Λείπει το πρόσθετο VPN Name[en_GB]=Missing VPN plugin Name[es]=Falta el complemento VPN Name[et]=VPN-i plugin puudub Name[eu]=VPN plugina falta da Name[fi]=Puuttuva VPN-liitännäinen Name[fr]=Module VPN manquant Name[gl]=Non se atopou o complemento de VPN Name[he]=חסר תוסף VPN Name[hu]=Hiányzó VPN bővítmény Name[ia]=Plugin de VPN mancante Name[id]=Plugin VPN yang hilang Name[it]=Estensione VPN mancante Name[ja]=見つからない VPN プラグイン Name[ko]=VPN 플러그인 없음 Name[lt]=Trūksta VPN priedo Name[nb]=Mangler VPN-programtillegg Name[nds]=VPN-Moduul fehlt Name[nl]=VPN-plug-in ontbreekt Name[nn]=Manglar VPN-tillegg Name[pa]=VPN ਪਲੱਗਇਨ ਗ਼ੈਰ-ਮੌਜੂਦ ਹੈ Name[pl]=Brak wtyczki VPN Name[pt]='Plugin' de VPN em falta Name[pt_BR]=Plugin de VPN ausente Name[ru]=Отсутствует модуль VPN Name[sk]=Chýba VPN plugin Name[sl]=Manjka vstavek VPN Name[sr]=Недостаје ВПН прикључак Name[sr@ijekavian]=Недостаје ВПН прикључак Name[sr@ijekavianlatin]=Nedostaje VPN priključak Name[sr@latin]=Nedostaje VPN priključak Name[sv]=Saknar VPN-insticksprogram Name[tr]=VPN eklentisi eksik Name[uk]=Не вистачає додатка VPN Name[x-test]=xxMissing VPN pluginxx Name[zh_CN]=缺少 VPN 插件 Name[zh_TW]=遺失 VPN 外掛程式 IconName=applications-internet Action=Popup [Event/NoLongerConnected] Name=No longer connected to a network Name[ar]=لم تعد متّصلًا بأيّ شّبكة Name[ca]=No connectat a cap xarxa Name[ca@valencia]=No connectat a cap xarxa Name[da]=Ikke længere forbundet til et netværk Name[de]=Nicht mehr mit einem Netzwerk verbunden Name[el]=Χωρίς σύνδεση πλέον σε κάποιο δίκτυο Name[en_GB]=No longer connected to a network Name[es]=Ya no está conectado a una red Name[et]=Pole enam võrku ühendatud Name[eu]=Jada ez dago sarera konektatuta Name[fi]=Ei enää yhteydessä verkkoon Name[fr]=Vous n'êtes plus connecté à un réseau Name[gl]=Xa non está conectado a unha rede Name[he]=לא מחובר יותר לרשת Name[hu]=Nem kapcsolódik tovább hálózathoz Name[id]=Tidak lagi terkoneksi ke sebuah jaringan Name[it]=Non sei più connesso a una rete Name[ja]=ネットワークに接続できません Name[ko]=더 이상 네트워크에 연결되지 않음 Name[lt]=Daugiau nebeprisijungta prie tinklo Name[nl]=Niet langer verbonden met een netwerk Name[nn]=Ikkje lenger tilkopla eit nettverk Name[pa]=ਹੁਣ ਨੈੱਟਵਰਕ ਨਾਲ ਕਨੈਕਟ ਨਹੀਂ ਹੈ Name[pl]=Brak połączenia do sieci Name[pt]=Não está mais ligado a nenhuma rede Name[pt_BR]=Não está mais conectado a uma rede Name[ru]=Вы больше не подключены к сети. Name[sk]=Už nepripojený k sieti Name[sl]=Niste več povezani z omrežjem Name[sr]=Више нисте повезани на мрежу Name[sr@ijekavian]=Више нисте повезани на мрежу Name[sr@ijekavianlatin]=Više niste povezani na mrežu Name[sr@latin]=Više niste povezani na mrežu Name[sv]=Inte längre ansluten till ett nätverk Name[tr]=Artık bir ağa bağlı değil Name[uk]=Більше не з’єднано із мережею Name[x-test]=xxNo longer connected to a networkxx Name[zh_CN]=已断开网络连接 Name[zh_TW]=已不再連線到網路 IconName=applications-internet Action=Popup [Event/CaptivePortal] Name=Captive portal detected Name[ast]=Deteutóse un portal cativu Name[ca]=S'ha detectat un portal captiu Name[ca@valencia]=S'ha detectat un portal captiu Name[da]=Captive portal detekteret Name[de]=Captive-Portal erkannt Name[en_GB]=Captive portal detected Name[es]=Se ha detectado un portal cautivo Name[et]=Tuvastati pääsuleht Name[eu]=Atari gatibua detektatu da Name[fi]=Verkon kirjautumissivu havaittu Name[fr]=Portail captif détecté Name[gl]=Detectouse un portal cativo Name[hu]=Hitelesítési portál észlelve Name[id]=Terdeteksi portal captive Name[it]=Captive portal rilevato Name[ko]=인증 포털 감지됨 Name[lt]=Aptiktas belaisvis portalas Name[nl]=Vangstportaal gedetecteerd Name[nn]=Oppdaga innloggingsside Name[pa]=ਕੈਪਟਿਵ ਪੋਰਟਲ ਖੋਜਿਆ Name[pl]=Wykryto portal Captive Name[pt]=Foi detectado um portal captivo Name[pt_BR]=Captive portal detectado Name[ru]=Обнаружено подключение, требующее дополнительной аутентификации. Name[sk]=Zistil sa zajatý portál Name[sl]=Zaznan prijavni portal Name[sr]=Откривен приступни портал Name[sr@ijekavian]=Откривен приступни портал Name[sr@ijekavianlatin]=Otkriven pristupni portal Name[sr@latin]=Otkriven pristupni portal Name[sv]=Captive portal detekterades Name[tr]=Captive portal tespit edildi Name[uk]=Виявлено керований портал Name[x-test]=xxCaptive portal detectedxx Name[zh_CN]=检测到强制网络门户 Name[zh_TW]=偵測到強制入口 Urgency=Low IconName=dialog-password Action=Popup diff --git a/libs/configuration.cpp b/libs/configuration.cpp index ea9ebf52..1dec19c2 100644 --- a/libs/configuration.cpp +++ b/libs/configuration.cpp @@ -1,78 +1,110 @@ /* Copyright 2017 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 "configuration.h" #include #include Q_GLOBAL_STATIC_WITH_ARGS(KSharedConfigPtr, config, (KSharedConfig::openConfig(QLatin1String("plasma-nm")))) bool Configuration::unlockModemOnDetection() { KConfigGroup grp(*config, QLatin1String("General")); if (grp.isValid()) { return grp.readEntry(QLatin1String("UnlockModemOnDetection"), true); } return true; } void Configuration::setUnlockModemOnDetection(bool unlock) { KConfigGroup grp(*config, QLatin1String("General")); if (grp.isValid()) { grp.writeEntry(QLatin1String("UnlockModemOnDetection"), unlock); } } bool Configuration::manageVirtualConnections() { KConfigGroup grp(*config, QLatin1String("General")); if (grp.isValid()) { return grp.readEntry(QLatin1String("ManageVirtualConnections"), false); } return true; } void Configuration::setManageVirtualConnections(bool manage) { KConfigGroup grp(*config, QLatin1String("General")); if (grp.isValid()) { grp.writeEntry(QLatin1String("ManageVirtualConnections"), manage); } } +bool Configuration::airplaneModeEnabled() +{ + // Check whether other devices are disabled to assume airplane mode is enabled + // after suspend + const bool isWifiDisabled = !NetworkManager::isWirelessEnabled() || !NetworkManager::isWirelessHardwareEnabled(); + const bool isWwanDisabled = !NetworkManager::isWwanEnabled() || !NetworkManager::isWwanHardwareEnabled(); + + KConfigGroup grp(*config, QLatin1String("General")); + + if (grp.isValid()) { + if (grp.readEntry(QLatin1String("AirplaneModeEnabled"), false)) { + // We can assume that airplane mode is still activated after resume + if (isWifiDisabled && isWwanDisabled) + return true; + else { + setAirplaneModeEnabled(false); + } + } + } + + return false; +} + +void Configuration::setAirplaneModeEnabled(bool enabled) +{ + KConfigGroup grp(*config, QLatin1String("General")); + + if (grp.isValid()) { + grp.writeEntry(QLatin1String("AirplaneModeEnabled"), enabled); + } +} + bool Configuration::showPasswordDialog() { KConfigGroup grp(*config, QLatin1String("General")); if (grp.isValid()) { return grp.readEntry(QLatin1String("ShowPasswordDialog"), true); } return true; } diff --git a/libs/configuration.h b/libs/configuration.h index 6c2a1231..b2192f85 100644 --- a/libs/configuration.h +++ b/libs/configuration.h @@ -1,46 +1,51 @@ /* Copyright 2017 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 . */ #ifndef PLASMA_NM_CONFIGURATION_H #define PLASMA_NM_CONFIGURATION_H #include #include class Q_DECL_EXPORT Configuration : public QObject { Q_PROPERTY(bool unlockModemOnDetection READ unlockModemOnDetection WRITE setUnlockModemOnDetection) Q_PROPERTY(bool manageVirtualConnections READ manageVirtualConnections WRITE setManageVirtualConnections) + Q_PROPERTY(bool airplaneModeEnabled READ airplaneModeEnabled WRITE setAirplaneModeEnabled) + //Readonly constant property, as this value should only be set by the platform Q_PROPERTY(bool showPasswordDialog READ showPasswordDialog CONSTANT) Q_OBJECT public: static bool unlockModemOnDetection(); static void setUnlockModemOnDetection(bool unlock); static bool manageVirtualConnections(); static void setManageVirtualConnections(bool manage); + static bool airplaneModeEnabled(); + static void setAirplaneModeEnabled(bool enabled); + static bool showPasswordDialog(); }; #endif // PLAMA_NM_CONFIGURATION_H diff --git a/libs/declarative/connectionicon.cpp b/libs/declarative/connectionicon.cpp index 6a29012b..cefe6df1 100644 --- a/libs/declarative/connectionicon.cpp +++ b/libs/declarative/connectionicon.cpp @@ -1,664 +1,649 @@ /* 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 "configuration.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(); setIcons(); QDBusPendingReply pendingReply = NetworkManager::checkConnectivity(); QDBusPendingCallWatcher *callWatcher = new QDBusPendingCallWatcher(pendingReply); connect(callWatcher, &QDBusPendingCallWatcher::finished, this, [this] (QDBusPendingCallWatcher *watcher) { QDBusPendingReply reply = *watcher; if (reply.isValid()) { connectivityChanged((NetworkManager::Connectivity)reply.value()); } watcher->deleteLater(); }); } 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) { const bool needsPortal = conn == NetworkManager::Portal; if (needsPortal != m_needsPortal) { m_needsPortal = needsPortal; Q_EMIT needsPortalChanged(needsPortal); } 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; } if (activeConnection->type() == NetworkManager::ConnectionSettings::ConnectionType::WireGuard) { vpn = 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(); // 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::WireGuard) { connection = activeConnection; } else if (type == NetworkManager::ConnectionSettings::Wired) { if (connection && (connection->type() != NetworkManager::ConnectionSettings::Vpn || connection->type() != NetworkManager::ConnectionSettings::WireGuard)) { 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 if (type == 29) { // TODO change to WireGuard enum value once it is added // WireGuard is a VPN but is not implemented // in NetworkManager as a VPN, so we don't want to // do anything just because it has a device // associated with it. } else { // Ignore other devices (bond/bridge/team etc.) setDisconnectedIcon(); } } } else { setDisconnectedIcon(); } } void ConnectionIcon::setDisconnectedIcon() { - if (m_airplaneMode) { + if (Configuration::airplaneModeEnabled()) { 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/handler.cpp b/libs/handler.cpp index 0095aa75..0c93eeba 100644 --- a/libs/handler.cpp +++ b/libs/handler.cpp @@ -1,637 +1,636 @@ /* Copyright 2013-2014 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 "handler.h" #include "connectioneditordialog.h" #include "uiutils.h" #include "debug.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if WITH_MODEMMANAGER_SUPPORT #include #include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #define AGENT_SERVICE "org.kde.kded5" #define AGENT_PATH "/modules/networkmanagement" #define AGENT_IFACE "org.kde.plasmanetworkmanagement" Handler::Handler(QObject *parent) : QObject(parent) , m_tmpWirelessEnabled(NetworkManager::isWirelessEnabled()) , m_tmpWwanEnabled(NetworkManager::isWwanEnabled()) { initKdedModule(); QDBusConnection::sessionBus().connect(QStringLiteral(AGENT_SERVICE), QStringLiteral(AGENT_PATH), QStringLiteral(AGENT_IFACE), QStringLiteral("registered"), this, SLOT(initKdedModule())); QDBusConnection::sessionBus().connect(QStringLiteral(AGENT_SERVICE), QStringLiteral(AGENT_PATH), QStringLiteral(AGENT_IFACE), QStringLiteral("secretsError"), this, SLOT(secretAgentError(QString, QString))); // Interval (in ms) between attempts to scan for wifi networks m_wirelessScanRetryTimer.setInterval(2000); m_wirelessScanRetryTimer.setSingleShot(true); } Handler::~Handler() { } void Handler::activateConnection(const QString& connection, const QString& device, const QString& specificObject) { NetworkManager::Connection::Ptr con = NetworkManager::findConnection(connection); if (!con) { qCWarning(PLASMA_NM) << "Not possible to activate this connection"; return; } if (con->settings()->connectionType() == NetworkManager::ConnectionSettings::Vpn) { NetworkManager::VpnSetting::Ptr vpnSetting = con->settings()->setting(NetworkManager::Setting::Vpn).staticCast(); if (vpnSetting) { qCDebug(PLASMA_NM) << "Checking VPN" << con->name() << "type:" << vpnSetting->serviceType(); bool pluginMissing = false; // Check missing plasma-nm VPN plugin const KService::List services = KServiceTypeTrader::self()->query("PlasmaNetworkManagement/VpnUiPlugin", QString::fromLatin1("[X-NetworkManager-Services]=='%1'").arg(vpnSetting->serviceType())); pluginMissing = services.isEmpty(); // Check missing NetworkManager VPN plugin if (!pluginMissing) { GSList *plugins = nullptr; plugins = nm_vpn_plugin_info_list_load(); NMVpnPluginInfo *plugin_info = nm_vpn_plugin_info_list_find_by_service(plugins, vpnSetting->serviceType().toStdString().c_str()); pluginMissing = !plugin_info; } if (pluginMissing) { qCWarning(PLASMA_NM) << "VPN" << vpnSetting->serviceType() << "not found, skipping"; KNotification *notification = new KNotification("MissingVpnPlugin", KNotification::CloseOnTimeout, this); notification->setComponentName("networkmanagement"); notification->setTitle(con->name()); notification->setText(i18n("Missing VPN plugin")); notification->setPixmap(QIcon::fromTheme("dialog-warning").pixmap(KIconLoader::SizeHuge)); notification->sendEvent(); return; } } } #if WITH_MODEMMANAGER_SUPPORT if (con->settings()->connectionType() == NetworkManager::ConnectionSettings::Gsm) { NetworkManager::ModemDevice::Ptr nmModemDevice = NetworkManager::findNetworkInterface(device).objectCast(); if (nmModemDevice) { ModemManager::ModemDevice::Ptr mmModemDevice = ModemManager::findModemDevice(nmModemDevice->udi()); if (mmModemDevice) { ModemManager::Modem::Ptr modem = mmModemDevice->interface(ModemManager::ModemDevice::ModemInterface).objectCast(); NetworkManager::GsmSetting::Ptr gsmSetting = con->settings()->setting(NetworkManager::Setting::Gsm).staticCast(); if (gsmSetting && gsmSetting->pinFlags() == NetworkManager::Setting::NotSaved && modem && modem->unlockRequired() > MM_MODEM_LOCK_NONE) { QDBusInterface managerIface("org.kde.plasmanetworkmanagement", "/org/kde/plasmanetworkmanagement", "org.kde.plasmanetworkmanagement", QDBusConnection::sessionBus(), this); managerIface.call("unlockModem", mmModemDevice->uni()); connect(modem.data(), &ModemManager::Modem::unlockRequiredChanged, this, &Handler::unlockRequiredChanged); m_tmpConnectionPath = connection; m_tmpDevicePath = device; m_tmpSpecificPath = specificObject; return; } } } } #endif QDBusPendingReply reply = NetworkManager::activateConnection(connection, device, specificObject); QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this); watcher->setProperty("action", Handler::ActivateConnection); watcher->setProperty("connection", con->name()); connect(watcher, &QDBusPendingCallWatcher::finished, this, &Handler::replyFinished); } QString Handler::wifiCode(const QString& connectionPath, const QString& ssid, int _securityType) const { NetworkManager::WirelessSecurityType securityType = static_cast(_securityType); QString ret = QStringLiteral("WIFI:S:") + ssid + QLatin1Char(';'); if (securityType != NetworkManager::NoneSecurity) { switch (securityType) { case NetworkManager::NoneSecurity: break; case NetworkManager::StaticWep: ret += "T:WEP;"; break; case NetworkManager::WpaPsk: case NetworkManager::Wpa2Psk: ret += "T:WPA;"; break; default: case NetworkManager::DynamicWep: case NetworkManager::WpaEap: case NetworkManager::Wpa2Eap: case NetworkManager::Leap: return {}; } } NetworkManager::Connection::Ptr connection = NetworkManager::findConnection(connectionPath); if(!connection) return {}; const auto key = QStringLiteral("802-11-wireless-security"); auto reply = connection->secrets(key); const auto secret = reply.argumentAt<0>()[key]; QString pass; switch (securityType) { case NetworkManager::NoneSecurity: break; case NetworkManager::WpaPsk: case NetworkManager::Wpa2Psk: pass = secret["psk"].toString(); break; default: return {}; } if (!pass.isEmpty()) ret += QStringLiteral("P:") + pass + QLatin1Char(';'); return ret + QLatin1Char(';'); } void Handler::addAndActivateConnection(const QString& device, const QString& specificObject, const QString& password) { NetworkManager::AccessPoint::Ptr ap; NetworkManager::WirelessDevice::Ptr wifiDev; for (const NetworkManager::Device::Ptr &dev : NetworkManager::networkInterfaces()) { if (dev->type() == NetworkManager::Device::Wifi) { wifiDev = dev.objectCast(); ap = wifiDev->findAccessPoint(specificObject); if (ap) { break; } } } if (!ap) { return; } NetworkManager::ConnectionSettings::Ptr settings = NetworkManager::ConnectionSettings::Ptr(new NetworkManager::ConnectionSettings(NetworkManager::ConnectionSettings::Wireless)); settings->setId(ap->ssid()); settings->setUuid(NetworkManager::ConnectionSettings::createNewUuid()); settings->setAutoconnect(true); settings->addToPermissions(KUser().loginName(), QString()); NetworkManager::WirelessSetting::Ptr wifiSetting = settings->setting(NetworkManager::Setting::Wireless).dynamicCast(); wifiSetting->setInitialized(true); wifiSetting = settings->setting(NetworkManager::Setting::Wireless).dynamicCast(); wifiSetting->setSsid(ap->ssid().toUtf8()); if (ap->mode() == NetworkManager::AccessPoint::Adhoc) { wifiSetting->setMode(NetworkManager::WirelessSetting::Adhoc); } NetworkManager::WirelessSecuritySetting::Ptr wifiSecurity = settings->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast(); NetworkManager::WirelessSecurityType securityType = NetworkManager::findBestWirelessSecurity(wifiDev->wirelessCapabilities(), true, (ap->mode() == NetworkManager::AccessPoint::Adhoc), ap->capabilities(), ap->wpaFlags(), ap->rsnFlags()); if (securityType != NetworkManager::NoneSecurity) { wifiSecurity->setInitialized(true); wifiSetting->setSecurity("802-11-wireless-security"); } if (securityType == NetworkManager::Leap || securityType == NetworkManager::DynamicWep || securityType == NetworkManager::Wpa2Eap || securityType == NetworkManager::WpaEap) { if (securityType == NetworkManager::DynamicWep || securityType == NetworkManager::Leap) { wifiSecurity->setKeyMgmt(NetworkManager::WirelessSecuritySetting::Ieee8021x); if (securityType == NetworkManager::Leap) { wifiSecurity->setAuthAlg(NetworkManager::WirelessSecuritySetting::Leap); } } else { wifiSecurity->setKeyMgmt(NetworkManager::WirelessSecuritySetting::WpaEap); } m_tmpConnectionUuid = settings->uuid(); m_tmpDevicePath = device; m_tmpSpecificPath = specificObject; QPointer editor = new ConnectionEditorDialog(settings); editor->show(); KWindowSystem::setState(editor->winId(), NET::KeepAbove); KWindowSystem::forceActiveWindow(editor->winId()); connect(editor.data(), &ConnectionEditorDialog::accepted, [editor, this] () { addConnection(editor->setting()); }); connect(editor.data(), &ConnectionEditorDialog::finished, [editor] () { if (editor) { editor->deleteLater(); } }); editor->setModal(true); editor->show(); } else { if (securityType == NetworkManager::StaticWep) { wifiSecurity->setKeyMgmt(NetworkManager::WirelessSecuritySetting::Wep); wifiSecurity->setWepKey0(password); if (KWallet::Wallet::isEnabled()) { wifiSecurity->setWepKeyFlags(NetworkManager::Setting::AgentOwned); } } else { if (ap->mode() == NetworkManager::AccessPoint::Adhoc) { wifiSecurity->setKeyMgmt(NetworkManager::WirelessSecuritySetting::WpaNone); } else { wifiSecurity->setKeyMgmt(NetworkManager::WirelessSecuritySetting::WpaPsk); } wifiSecurity->setPsk(password); if (KWallet::Wallet::isEnabled()) { wifiSecurity->setPskFlags(NetworkManager::Setting::AgentOwned); } } QDBusPendingReply reply = NetworkManager::addAndActivateConnection(settings->toMap(), device, specificObject); QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this); watcher->setProperty("action", Handler::AddAndActivateConnection); watcher->setProperty("connection", settings->name()); connect(watcher, &QDBusPendingCallWatcher::finished, this, &Handler::replyFinished); } settings.clear(); } void Handler::addConnection(const NMVariantMapMap& map) { QDBusPendingReply reply = NetworkManager::addConnection(map); QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this); watcher->setProperty("action", AddConnection); watcher->setProperty("connection", map.value("connection").value("id")); connect(watcher, &QDBusPendingCallWatcher::finished, this, &Handler::replyFinished); } void Handler::deactivateConnection(const QString& connection, const QString& device) { NetworkManager::Connection::Ptr con = NetworkManager::findConnection(connection); if (!con) { qCWarning(PLASMA_NM) << "Not possible to deactivate this connection"; return; } QDBusPendingReply<> reply; for (const NetworkManager::ActiveConnection::Ptr &active : NetworkManager::activeConnections()) { if (active->uuid() == con->uuid() && ((!active->devices().isEmpty() && active->devices().first() == device) || active->vpn())) { if (active->vpn()) { reply = NetworkManager::deactivateConnection(active->path()); } else { NetworkManager::Device::Ptr device = NetworkManager::findNetworkInterface(active->devices().first()); if (device) { reply = device->disconnectInterface(); } } } } QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this); watcher->setProperty("action", Handler::DeactivateConnection); connect(watcher, &QDBusPendingCallWatcher::finished, this, &Handler::replyFinished); } void Handler::disconnectAll() { for (const NetworkManager::Device::Ptr &device : NetworkManager::networkInterfaces()) { device->disconnectInterface(); } } void Handler::enableAirplaneMode(bool enable) { if (enable) { m_tmpWirelessEnabled = NetworkManager::isWirelessEnabled(); m_tmpWwanEnabled = NetworkManager::isWwanEnabled(); enableBluetooth(false); enableWireless(false); enableWwan(false); } else { enableBluetooth(true); if (m_tmpWirelessEnabled) { enableWireless(true); } if (m_tmpWwanEnabled) { enableWwan(true); } } } void Handler::enableBluetooth(bool enable) { qDBusRegisterMetaType< QMap >(); QDBusMessage message = QDBusMessage::createMethodCall("org.bluez", "/", "org.freedesktop.DBus.ObjectManager", "GetManagedObjects"); QDBusPendingReply > reply = QDBusConnection::systemBus().asyncCall(message); QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this); connect(watcher, &QDBusPendingCallWatcher::finished, [this, enable] (QDBusPendingCallWatcher *watcher) { QDBusPendingReply > reply = *watcher; if (reply.isValid()) { for (const QDBusObjectPath &path : reply.value().keys()) { const QString objPath = path.path(); qCDebug(PLASMA_NM) << "inspecting path" << objPath; const QStringList interfaces = reply.value().value(path).keys(); qCDebug(PLASMA_NM) << "interfaces:" << interfaces; if (interfaces.contains("org.bluez.Adapter1")) { // We need to check previous state first if (!enable) { QDBusMessage message = QDBusMessage::createMethodCall("org.bluez", objPath, "org.freedesktop.DBus.Properties", "Get"); QList arguments; arguments << QLatin1Literal("org.bluez.Adapter1"); arguments << QLatin1Literal("Powered"); message.setArguments(arguments); QDBusPendingReply getReply = QDBusConnection::systemBus().asyncCall(message); QDBusPendingCallWatcher *getWatcher = new QDBusPendingCallWatcher(getReply, this); connect(getWatcher, &QDBusPendingCallWatcher::finished, [this, objPath] (QDBusPendingCallWatcher *watcher) { QDBusPendingReply reply = *watcher; if (reply.isValid()) { m_bluetoothAdapters.insert(objPath, reply.value().toBool()); QDBusMessage message = QDBusMessage::createMethodCall("org.bluez", objPath, "org.freedesktop.DBus.Properties", "Set"); QList arguments; arguments << QLatin1Literal("org.bluez.Adapter1"); arguments << QLatin1Literal("Powered"); arguments << QVariant::fromValue(QDBusVariant(QVariant(false))); message.setArguments(arguments); QDBusConnection::systemBus().asyncCall(message); } - + watcher->deleteLater(); }); - getWatcher->deleteLater(); } else if (enable && m_bluetoothAdapters.value(objPath)) { QDBusMessage message = QDBusMessage::createMethodCall("org.bluez", objPath, "org.freedesktop.DBus.Properties", "Set"); QList arguments; arguments << QLatin1Literal("org.bluez.Adapter1"); arguments << QLatin1Literal("Powered"); arguments << QVariant::fromValue(QDBusVariant(QVariant(enable))); message.setArguments(arguments); QDBusConnection::systemBus().asyncCall(message); } } } } + watcher->deleteLater(); }); - watcher->deleteLater(); } void Handler::enableNetworking(bool enable) { NetworkManager::setNetworkingEnabled(enable); } void Handler::enableWireless(bool enable) { NetworkManager::setWirelessEnabled(enable); } void Handler::enableWwan(bool enable) { NetworkManager::setWwanEnabled(enable); } void Handler::removeConnection(const QString& connection) { NetworkManager::Connection::Ptr con = NetworkManager::findConnection(connection); if (!con || con->uuid().isEmpty()) { qCWarning(PLASMA_NM) << "Not possible to remove connection " << connection; return; } // Remove slave connections for (const NetworkManager::Connection::Ptr &connection : NetworkManager::listConnections()) { NetworkManager::ConnectionSettings::Ptr settings = connection->settings(); if (settings->master() == con->uuid()) { connection->remove(); } } QDBusPendingReply<> reply = con->remove(); QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this); watcher->setProperty("action", Handler::RemoveConnection); watcher->setProperty("connection", con->name()); connect(watcher, &QDBusPendingCallWatcher::finished, this, &Handler::replyFinished); } void Handler::updateConnection(const NetworkManager::Connection::Ptr& connection, const NMVariantMapMap& map) { QDBusPendingReply<> reply = connection->update(map); QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this); watcher->setProperty("action", UpdateConnection); watcher->setProperty("connection", connection->name()); connect(watcher, &QDBusPendingCallWatcher::finished, this, &Handler::replyFinished); } void Handler::requestScan(const QString &interface) { for (NetworkManager::Device::Ptr device : NetworkManager::networkInterfaces()) { if (device->type() == NetworkManager::Device::Wifi) { NetworkManager::WirelessDevice::Ptr wifiDevice = device.objectCast(); if (wifiDevice && wifiDevice->state() != NetworkManager::WirelessDevice::Unavailable) { if (!interface.isEmpty() && interface != wifiDevice->interfaceName()) { continue; } qCDebug(PLASMA_NM) << "Requesting wifi scan on device" << wifiDevice->interfaceName(); QDBusPendingReply<> reply = wifiDevice->requestScan(); QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this); watcher->setProperty("action", Handler::RequestScan); watcher->setProperty("interface", wifiDevice->interfaceName()); connect(watcher, &QDBusPendingCallWatcher::finished, this, &Handler::replyFinished); } } } } void Handler::scanRequestFailed(const QString &interface) { if (m_wirelessScanRetryTimer.isActive()) { return; } qCDebug(PLASMA_NM) << "Trying soon a new scan on" << interface; emit wirelessScanTimerEnabled(false); auto retryAction = [this,interface]() { m_wirelessScanRetryTimer.disconnect(); requestScan(interface); }; connect(&m_wirelessScanRetryTimer, &QTimer::timeout, this, retryAction); m_wirelessScanRetryTimer.start(); } void Handler::initKdedModule() { QDBusMessage initMsg = QDBusMessage::createMethodCall(QStringLiteral(AGENT_SERVICE), QStringLiteral(AGENT_PATH), QStringLiteral(AGENT_IFACE), QStringLiteral("init")); QDBusConnection::sessionBus().send(initMsg); } void Handler::secretAgentError(const QString &connectionPath, const QString &message) { // If the password was wrong, forget it removeConnection(connectionPath); emit connectionActivationFailed(connectionPath, message); } void Handler::replyFinished(QDBusPendingCallWatcher * watcher) { QDBusPendingReply<> reply = *watcher; if (reply.isError() || !reply.isValid()) { KNotification *notification = nullptr; QString error = reply.error().message(); Handler::HandlerAction action = (Handler::HandlerAction)watcher->property("action").toUInt(); switch (action) { case Handler::ActivateConnection: notification = new KNotification("FailedToActivateConnection", KNotification::CloseOnTimeout, this); notification->setTitle(i18n("Failed to activate %1", watcher->property("connection").toString())); break; case Handler::AddAndActivateConnection: notification = new KNotification("FailedToAddConnection", KNotification::CloseOnTimeout, this); notification->setTitle(i18n("Failed to add %1", watcher->property("connection").toString())); break; case Handler::AddConnection: notification = new KNotification("FailedToAddConnection", KNotification::CloseOnTimeout, this); notification->setTitle(i18n("Failed to add connection %1", watcher->property("connection").toString())); break; case Handler::DeactivateConnection: notification = new KNotification("FailedToDeactivateConnection", KNotification::CloseOnTimeout, this); notification->setTitle(i18n("Failed to deactivate %1", watcher->property("connection").toString())); break; case Handler::RemoveConnection: notification = new KNotification("FailedToRemoveConnection", KNotification::CloseOnTimeout, this); notification->setTitle(i18n("Failed to remove %1", watcher->property("connection").toString())); break; case Handler::UpdateConnection: notification = new KNotification("FailedToUpdateConnection", KNotification::CloseOnTimeout, this); notification->setTitle(i18n("Failed to update connection %1", watcher->property("connection").toString())); break; case Handler::RequestScan: { const QString interface = watcher->property("interface").toString(); qCWarning(PLASMA_NM) << "Wireless scan on" << interface << "failed:" << error; scanRequestFailed(interface); break; } default: break; } if (notification) { notification->setComponentName("networkmanagement"); notification->setText(error); notification->setPixmap(QIcon::fromTheme("dialog-warning").pixmap(KIconLoader::SizeHuge)); notification->sendEvent(); } } else { KNotification *notification = nullptr; Handler::HandlerAction action = (Handler::HandlerAction)watcher->property("action").toUInt(); switch (action) { case Handler::AddConnection: notification = new KNotification("ConnectionAdded", KNotification::CloseOnTimeout, this); notification->setText(i18n("Connection %1 has been added", watcher->property("connection").toString())); break; case Handler::RemoveConnection: notification = new KNotification("ConnectionRemoved", KNotification::CloseOnTimeout, this); notification->setText(i18n("Connection %1 has been removed", watcher->property("connection").toString())); break; case Handler::UpdateConnection: notification = new KNotification("ConnectionUpdated", KNotification::CloseOnTimeout, this); notification->setText(i18n("Connection %1 has been updated", watcher->property("connection").toString())); break; case Handler::RequestScan: qCDebug(PLASMA_NM) << "Wireless scan on" << watcher->property("interface").toString() << "succeeded"; emit wirelessScanTimerEnabled(true); break; default: break; } if (notification) { notification->setComponentName("networkmanagement"); notification->setTitle(watcher->property("connection").toString()); notification->setPixmap(QIcon::fromTheme("dialog-information").pixmap(KIconLoader::SizeHuge)); notification->sendEvent(); } } watcher->deleteLater(); } #if WITH_MODEMMANAGER_SUPPORT void Handler::unlockRequiredChanged(MMModemLock modemLock) { if (modemLock == MM_MODEM_LOCK_NONE) { activateConnection(m_tmpConnectionPath, m_tmpDevicePath, m_tmpSpecificPath); } } #endif