Commit 31cb248a authored by Devin Lin's avatar Devin Lin 🎨
Browse files

mmplugin: Add support for checking if a SIM is missing

parent c6feac9c
Pipeline #231076 passed with stage
in 1 minute and 37 seconds
......@@ -35,6 +35,14 @@ bool SignalIndicator::simLocked() const
return m_modem->unlockRequired() == MM_MODEM_LOCK_SIM_PIN;
}
bool SignalIndicator::simEmpty() const
{
if (!m_modem) {
return false;
}
return m_modemDevice && m_modemDevice->sim() && m_modemDevice->sim()->uni() == QStringLiteral("/");
}
bool SignalIndicator::available() const
{
return !ModemManager::modemDevices().isEmpty();
......@@ -42,7 +50,7 @@ bool SignalIndicator::available() const
bool SignalIndicator::mobileDataSupported() const
{
return m_nmModem && m_modemDevice->sim();
return m_nmModem && m_modemDevice->sim() && !simEmpty();
}
bool SignalIndicator::mobileDataEnabled() const
......@@ -142,6 +150,8 @@ void SignalIndicator::updateModem()
});
}
}
connect(m_modemDevice->sim().get(), &ModemManager::Sim::simIdentifierChanged, this, &SignalIndicator::simEmptyChanged);
if (m_modem) {
connect(m_modem.get(), &ModemManager::Modem::signalQualityChanged, this, &SignalIndicator::strengthChanged);
......
......@@ -20,6 +20,7 @@ class SignalIndicator : public QObject
Q_PROPERTY(int strength READ strength NOTIFY strengthChanged)
Q_PROPERTY(QString name READ name NOTIFY nameChanged)
Q_PROPERTY(bool simLocked READ simLocked NOTIFY simLockedChanged)
Q_PROPERTY(bool simEmpty READ simEmpty NOTIFY simEmptyChanged)
Q_PROPERTY(bool available READ available NOTIFY availableChanged)
Q_PROPERTY(bool mobileDataSupported READ mobileDataSupported NOTIFY mobileDataSupportedChanged)
Q_PROPERTY(bool mobileDataEnabled READ mobileDataEnabled WRITE setMobileDataEnabled NOTIFY mobileDataEnabledChanged)
......@@ -31,6 +32,7 @@ public:
int strength() const;
QString name() const;
bool simLocked() const;
bool simEmpty() const;
bool available() const;
bool mobileDataSupported() const;
bool mobileDataEnabled() const;
......@@ -42,6 +44,7 @@ Q_SIGNALS:
void strengthChanged();
void nameChanged();
void simLockedChanged();
void simEmptyChanged();
void availableChanged();
void mobileDataSupportedChanged();
void mobileDataEnabledChanged();
......
......@@ -14,18 +14,20 @@ MobileShell.QuickSetting {
return i18n("APN needs to be configured in the settings");
} else if (PlasmaMM.SignalIndicator.mobileDataSupported) {
return enabled ? i18n("On") : i18n("Off");
} else if (PlasmaMM.SignalIndicator.simEmpty) {
return i18n("No SIM inserted");
} else {
return i18n("Not Available");
}
}
settingsCommand: "plasma-open-settings kcm_mobile_broadband"
settingsCommand: "plasma-open-settings kcm_cellular_network"
enabled: PlasmaMM.SignalIndicator.mobileDataEnabled
function toggle() {
if (PlasmaMM.SignalIndicator.needsAPNAdded || !PlasmaMM.SignalIndicator.mobileDataSupported) {
// open settings if unable to toggle mobile data
MobileShell.ShellUtil.executeCommand("plasma-open-settings kcm_mobile_broadband");
MobileShell.ShellUtil.executeCommand("plasma-open-settings kcm_cellular_network");
} else {
PlasmaMM.SignalIndicator.mobileDataEnabled = !PlasmaMM.SignalIndicator.mobileDataEnabled;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment