Commit 2ef233f7 authored by Jan Grulich's avatar Jan Grulich
Browse files

Add more PIN/PUK types for SIM/Modem unlocking

parent cc135643
......@@ -114,13 +114,35 @@ void ModemMonitor::requestPin(MMModemLock lock)
}
if (lock == MM_MODEM_LOCK_SIM_PIN) {
d->dialog = new PinDialog(modem, PinDialog::Pin);
d->dialog = new PinDialog(modem, PinDialog::SimPin);
} else if (lock == MM_MODEM_LOCK_SIM_PIN2) {
d->dialog = new PinDialog(modem, PinDialog::SimPin2);
} else if (lock == MM_MODEM_LOCK_SIM_PUK) {
d->dialog = new PinDialog(modem, PinDialog::PinPuk);
} else {
// TODO handle other lock types?
kWarning() << "Unhandled unlock request for '" << lock << "'";
return;
d->dialog = new PinDialog(modem, PinDialog::SimPuk);
} else if (lock == MM_MODEM_LOCK_SIM_PUK2 ) {
d->dialog = new PinDialog(modem, PinDialog::SimPuk);
} else if (lock == MM_MODEM_LOCK_PH_SP_PIN) {
d->dialog = new PinDialog(modem, PinDialog::ModemServiceProviderPin);
} else if (lock == MM_MODEM_LOCK_PH_SP_PUK) {
d->dialog = new PinDialog(modem, PinDialog::ModemServiceProviderPuk);
} else if (lock == MM_MODEM_LOCK_PH_NET_PIN) {
d->dialog = new PinDialog(modem, PinDialog::ModemNetworkPin);
} else if (lock == MM_MODEM_LOCK_PH_NET_PUK) {
d->dialog = new PinDialog(modem, PinDialog::ModemNetworkPuk);
} else if (lock == MM_MODEM_LOCK_PH_SIM_PIN) {
d->dialog = new PinDialog(modem, PinDialog::ModemPin);
} else if (lock == MM_MODEM_LOCK_PH_CORP_PIN) {
d->dialog = new PinDialog(modem, PinDialog::ModemCorporatePin);
} else if (lock == MM_MODEM_LOCK_PH_CORP_PUK) {
d->dialog = new PinDialog(modem, PinDialog::ModemCorporatePuk);
} else if (lock == MM_MODEM_LOCK_PH_FSIM_PIN) {
d->dialog = new PinDialog(modem, PinDialog::ModemPhFsimPin);
} else if (lock == MM_MODEM_LOCK_PH_FSIM_PUK) {
d->dialog = new PinDialog(modem, PinDialog::ModemPhFsimPuk);
} else if (lock == MM_MODEM_LOCK_PH_NETSUB_PIN) {
d->dialog = new PinDialog(modem, PinDialog::ModemNetworkSubsetPin);
} else if (lock == MM_MODEM_LOCK_PH_NETSUB_PUK) {
d->dialog = new PinDialog(modem, PinDialog::ModemNetworkSubsetPuk);
}
if (d->dialog.data()->exec() != QDialog::Accepted) {
......@@ -138,10 +160,23 @@ void ModemMonitor::requestPin(MMModemLock lock)
QDBusPendingCallWatcher *watcher = 0;
if (d->dialog.data()->type() == PinDialog::Pin) {
if (d->dialog.data()->type() == PinDialog::SimPin ||
d->dialog.data()->type() == PinDialog::SimPin2 ||
d->dialog.data()->type() == PinDialog::ModemServiceProviderPin ||
d->dialog.data()->type() == PinDialog::ModemNetworkPin ||
d->dialog.data()->type() == PinDialog::ModemPin ||
d->dialog.data()->type() == PinDialog::ModemCorporatePin ||
d->dialog.data()->type() == PinDialog::ModemPhFsimPin ||
d->dialog.data()->type() == PinDialog::ModemNetworkSubsetPin) {
QDBusPendingCall reply = sim->sendPin(d->dialog.data()->pin());
watcher = new QDBusPendingCallWatcher(reply, sim.data());
} else if (d->dialog.data()->type() == PinDialog::PinPuk) {
} else if (d->dialog.data()->type() == PinDialog::SimPuk ||
d->dialog.data()->type() == PinDialog::SimPuk2 ||
d->dialog.data()->type() == PinDialog::ModemServiceProviderPuk ||
d->dialog.data()->type() == PinDialog::ModemNetworkPuk ||
d->dialog.data()->type() == PinDialog::ModemCorporatePuk ||
d->dialog.data()->type() == PinDialog::ModemPhFsimPuk ||
d->dialog.data()->type() == PinDialog::ModemNetworkSubsetPuk) {
QDBusPendingCall reply = sim->sendPuk(d->dialog.data()->puk(), d->dialog.data()->pin());
watcher = new QDBusPendingCallWatcher(reply, sim.data());
}
......
......@@ -81,8 +81,71 @@ PinDialog::PinDialog(ModemManager::ModemInterface *modem, const Type type, QWidg
setDefaultButton(KDialog::Ok);
button(KDialog::Ok)->setText(i18nc("As in 'Unlock cell phone with this pin code'", "Unlock"));
setMainWidget(w);
#ifdef MODEMMANAGERQT_ONE
if (isPukDialog()) {
QString pukType;
if (m_type == PinDialog::SimPuk) {
pukType = "SIM PUK";
} else if (m_type == PinDialog::SimPuk2) {
pukType = "SIM PUK2";
} else if (m_type == PinDialog::ModemServiceProviderPuk) {
pukType = "Service provider PUK";
} else if (m_type == PinDialog::ModemNetworkPuk) {
pukType = "Network PUK";
} else if (m_type == PinDialog::ModemCorporatePuk) {
pukType = "Corporate PUK";
} else if (m_type == PinDialog::ModemPhFsimPuk) {
pukType = "PH-FSIM PUK";
} else {
pukType = "Network Subset PUK";
}
if (m_type == PinPuk) {
setWindowTitle(i18n("%1 unlock required", pukType));
ui->title->setText(i18n("%1 Unlock Required", pukType));
ui->prompt->setText(i18n("The mobile broadband device '%1' requires a %2 code before it can be used.", m_name, pukType));
ui->pukLabel->setText(i18n("%1 code:",pukType));
ui->pinLabel->setText(i18n("New PIN code:"));
ui->pin2Label->setText(i18n("Re-enter new PIN code:"));
ui->chkShowPass->setText(i18n("Show PIN/PUK code"));
ui->puk->setFocus();
ui->pukLabel->show();
ui->puk->show();
ui->pin2Label->show();
ui->pin2->show();
} else if (isPinDialog()) {
QString pinType;
if (m_type == PinDialog::SimPin) {
pinType = "SIM PIN";
} else if (m_type == PinDialog::SimPin2) {
pinType = "SIM PIN2";
} else if (m_type == PinDialog::ModemServiceProviderPin) {
pinType = "Service provider PIN";
} else if (m_type == PinDialog::ModemNetworkPin) {
pinType = "Network PIN";
} else if (m_type == PinDialog::ModemPin) {
pinType = "PIN";
} else if (m_type == PinDialog::ModemCorporatePin) {
pinType = "Corporate PIN";
} else if (m_type == PinDialog::ModemPhFsimPin) {
pinType = "PH-FSIM PIN";
} else {
pinType = "Network Subset PIN";
}
setWindowTitle(i18n("%1 unlock required", pinType));
ui->title->setText(i18n("%1 Unlock Required", pinType));
ui->prompt->setText(i18n("The mobile broadband device '%1' requires a %2 code before it can be used.", m_name, pinType));
ui->pinLabel->setText(i18n("%1 code:", pinType));
ui->chkShowPass->setText(i18n("Show PIN code"));
ui->pin->setFocus();
ui->pukLabel->hide();
ui->puk->hide();
ui->pin2Label->hide();
ui->pin2->hide();
}
#else
if (isPukDialog()) {
setWindowTitle(i18n("SIM PUK unlock required"));
ui->title->setText(i18n("SIM PUK Unlock Required"));
ui->prompt->setText(i18n("The mobile broadband device '%1' requires a SIM PUK code before it can be used.", m_name));
......@@ -96,7 +159,7 @@ PinDialog::PinDialog(ModemManager::ModemInterface *modem, const Type type, QWidg
ui->puk->show();
ui->pin2Label->show();
ui->pin2->show();
} else {
} else if (isPinDialog()) {
setWindowTitle(i18n("SIM PIN unlock required"));
ui->title->setText(i18n("SIM PIN Unlock Required"));
ui->prompt->setText(i18n("The mobile broadband device '%1' requires a SIM PIN code before it can be used.", m_name));
......@@ -109,7 +172,7 @@ PinDialog::PinDialog(ModemManager::ModemInterface *modem, const Type type, QWidg
ui->pin2Label->hide();
ui->pin2->hide();
}
#endif
ui->puk->clear();
ui->pin->clear();
ui->pin2->clear();
......@@ -140,7 +203,7 @@ void PinDialog::chkShowPassToggled(bool on)
ui->pin->setCursorPosition(0);
ui->pin2->setCursorPosition(0);
if (m_type == PinPuk) {
if (isPukDialog()) {
ui->puk->setFocus();
} else {
ui->pin->setFocus();
......@@ -208,7 +271,7 @@ void PinDialog::showErrorMessage(const PinDialog::ErrorCode error)
void PinDialog::accept()
{
if (m_type == PinPuk) {
if (isPukDialog()) {
if (pin() != pin2()) {
showErrorMessage(PinCodesDoNotMatch);
return;
......@@ -225,3 +288,24 @@ void PinDialog::accept()
QDialog::accept();
}
bool PinDialog::isPinDialog() const
{
#ifdef MODEMMANAGERQT_ONE
return (m_type == PinDialog::SimPin ||
m_type == PinDialog::SimPin2 ||
m_type == PinDialog::ModemServiceProviderPin ||
m_type == PinDialog::ModemNetworkPin ||
m_type == PinDialog::ModemPin ||
m_type == PinDialog::ModemCorporatePin ||
m_type == PinDialog::ModemPhFsimPin ||
m_type == PinDialog::ModemNetworkSubsetPin);
#else
return m_type == PinPuk;
#endif
}
bool PinDialog::isPukDialog() const
{
return !isPinDialog();
}
......@@ -43,10 +43,30 @@ class PinDialog : public KDialog
{
Q_OBJECT
public:
#ifdef MODEMMANAGERQT_ONE
enum Type {
SimPin,
SimPin2,
SimPuk,
SimPuk2,
ModemServiceProviderPin,
ModemServiceProviderPuk,
ModemNetworkPin,
ModemNetworkPuk,
ModemPin,
ModemCorporatePin,
ModemCorporatePuk,
ModemPhFsimPin,
ModemPhFsimPuk,
ModemNetworkSubsetPin,
ModemNetworkSubsetPuk
};
#else
enum Type {Pin, PinPuk};
#endif
enum ErrorCode {PinCodeTooShort, PinCodesDoNotMatch, PukCodeTooShort};
#ifdef MODEMMANAGERQT_ONE
explicit PinDialog(ModemManager::Modem *modem, const Type type = Pin, QWidget *parent=0);
explicit PinDialog(ModemManager::Modem *modem, const Type type = SimPin, QWidget *parent=0);
#else
explicit PinDialog(ModemManager::ModemInterface *modem, const Type type = Pin, QWidget *parent=0);
#endif
......@@ -66,6 +86,8 @@ private Q_SLOTS:
private:
void showErrorMessage(const PinDialog::ErrorCode);
bool isPukDialog() const;
bool isPinDialog() const;
Ui::PinWidget * ui;
QLabel* pixmapLabel;
QString m_name;
......
Markdown is supported
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