diff --git a/components/mmplugin/signalindicator.cpp b/components/mmplugin/signalindicator.cpp index cff4dba3..226d733b 100644 --- a/components/mmplugin/signalindicator.cpp +++ b/components/mmplugin/signalindicator.cpp @@ -71,6 +71,11 @@ bool SignalIndicator::mobileDataSupported() const bool SignalIndicator::mobileDataEnabled() const { + // if wwan is globally disabled + if (!NetworkManager::isWwanEnabled()) { + return false; + } + // no modem -> no mobile data -> report disabled if (!m_nmModem) { return false; @@ -104,19 +109,20 @@ bool SignalIndicator::needsAPNAdded() const void SignalIndicator::setMobileDataEnabled(bool enabled) { + // ensure that wwan is on + if (enabled && !NetworkManager::isWwanEnabled()) { + NetworkManager::setWwanEnabled(true); + } + if (!m_nmModem) { return; } - if (!enabled) { - m_nmModem->setAutoconnect(false); - // we need to also set all connections to not autoconnect (#182) - for (NetworkManager::Connection::Ptr con : m_nmModem->availableConnections()) { - con->settings()->setAutoconnect(false); - con->update(con->settings()->toMap()); - } - m_nmModem->disconnectInterface(); - } else { + + if (enabled) { + // enable mobile data... + m_nmModem->setAutoconnect(true); + // activate the connection that was last used QDateTime latestTimestamp; NetworkManager::Connection::Ptr latestCon; @@ -131,6 +137,7 @@ void SignalIndicator::setMobileDataEnabled(bool enabled) latestCon = con; } } + // if we found the last used connection if (!latestCon.isNull()) { // set it to autoconnect and connect it immediately @@ -138,6 +145,22 @@ void SignalIndicator::setMobileDataEnabled(bool enabled) latestCon->update(latestCon->settings()->toMap()); NetworkManager::activateConnection(latestCon->path(), m_nmModem->uni(), ""); } + + } else { + // disable mobile data... + + // we do not call NetworkManager::setWwanEnabled(false), because it turns off cellular + + // turn off autoconnect + m_nmModem->setAutoconnect(false); + // we need to also set all connections to not autoconnect (#182) + for (NetworkManager::Connection::Ptr con : m_nmModem->availableConnections()) { + con->settings()->setAutoconnect(false); + con->update(con->settings()->toMap()); + } + + // disconnect network + m_nmModem->disconnectInterface(); } } diff --git a/kcms/cellularnetwork/modem.cpp b/kcms/cellularnetwork/modem.cpp index a0a90833..2de0c591 100644 --- a/kcms/cellularnetwork/modem.cpp +++ b/kcms/cellularnetwork/modem.cpp @@ -143,6 +143,11 @@ bool Modem::needsAPNAdded() const bool Modem::mobileDataEnabled() const { + // if wwan is globally disabled + if (!NetworkManager::isWwanEnabled()) { + return false; + } + // no modem -> no mobile data -> report disabled if (!m_nmModem) { return false; @@ -171,20 +176,20 @@ bool Modem::mobileDataEnabled() const void Modem::setMobileDataEnabled(bool enabled) { + // ensure that wwan is on + if (enabled && !NetworkManager::isWwanEnabled()) { + NetworkManager::setWwanEnabled(true); + } + if (!m_nmModem) { return; } - if (!enabled) { - m_nmModem->setAutoconnect(false); - // we need to also set all connections to not autoconnect (#182) - for (NetworkManager::Connection::Ptr con : m_nmModem->availableConnections()) { - con->settings()->setAutoconnect(false); - con->update(con->settings()->toMap()); - } - m_nmModem->disconnectInterface(); - } else { + if (enabled) { + // enable mobile data... + m_nmModem->setAutoconnect(true); + // activate the connection that was last used QDateTime latestTimestamp; NetworkManager::Connection::Ptr latestCon; @@ -199,6 +204,7 @@ void Modem::setMobileDataEnabled(bool enabled) latestCon = con; } } + // if we found the last used connection if (!latestCon.isNull()) { // set it to autoconnect and connect it immediately @@ -206,6 +212,22 @@ void Modem::setMobileDataEnabled(bool enabled) latestCon->update(latestCon->settings()->toMap()); NetworkManager::activateConnection(latestCon->path(), m_nmModem->uni(), ""); } + + } else { + // disable mobile data... + + // we do not call NetworkManager::setWwanEnabled(false), because it turns off cellular + + // turn off autoconnect + m_nmModem->setAutoconnect(false); + // we need to also set all connections to not autoconnect (#182) + for (NetworkManager::Connection::Ptr con : m_nmModem->availableConnections()) { + con->settings()->setAutoconnect(false); + con->update(con->settings()->toMap()); + } + + // disconnect network + m_nmModem->disconnectInterface(); } } diff --git a/kcms/cellularnetwork/ui/SimPage.qml b/kcms/cellularnetwork/ui/SimPage.qml index 30be0663..2e71f0d5 100644 --- a/kcms/cellularnetwork/ui/SimPage.qml +++ b/kcms/cellularnetwork/ui/SimPage.qml @@ -71,7 +71,7 @@ FormCard.FormCardPage { icon.name: "globe" text: i18n("Modify APNs") description: i18n("Configure access point names for your carrier.") - enabled: simEnabled && enabledConnections.wwanEnabled + enabled: simEnabled onClicked: kcm.push("ProfileList.qml", { "modem": sim.modem }); } @@ -93,7 +93,7 @@ FormCard.FormCardPage { icon.name: "unlock" text: i18n("SIM Lock") description: i18n("Modify SIM lock settings.") - // enabled: simEnabled + enabled: simEnabled onClicked: kcm.push("SimLockPage.qml", { "sim": sim }); }