diff options
-rw-r--r-- | src/mm-sim.c | 57 |
1 files changed, 46 insertions, 11 deletions
diff --git a/src/mm-sim.c b/src/mm-sim.c index b7624854..95a1eec5 100644 --- a/src/mm-sim.c +++ b/src/mm-sim.c @@ -159,6 +159,19 @@ handle_change_pin_context_free (HandleChangePinContext *ctx) } static void +after_change_unlock_retries_ready (MMIfaceModem *self, + GAsyncResult *res, + HandleChangePinContext *ctx) +{ + /* We just want to ensure that we tried to update the unlock + * retries, no big issue if it failed */ + mm_iface_modem_update_unlock_retries_finish (self, res, NULL); + + mm_gdbus_sim_complete_change_pin (MM_GDBUS_SIM (ctx->self), ctx->invocation); + handle_change_pin_context_free (ctx); +} + +static void handle_change_pin_ready (MMSim *self, GAsyncResult *res, HandleChangePinContext *ctx) @@ -166,12 +179,17 @@ handle_change_pin_ready (MMSim *self, GError *error = NULL; MM_SIM_GET_CLASS (self)->change_pin_finish (self, res, &error); - if (error) + if (error) { g_dbus_method_invocation_take_error (ctx->invocation, error); - else - mm_gdbus_sim_complete_change_pin (MM_GDBUS_SIM (ctx->self), ctx->invocation); + handle_change_pin_context_free (ctx); + return; + } - handle_change_pin_context_free (ctx); + /* Before returning success, ensure that we get the unlock retry + * counts updated properly. */ + mm_iface_modem_update_unlock_retries (MM_IFACE_MODEM (self->priv->modem), + (GAsyncReadyCallback)after_change_unlock_retries_ready, + ctx); } static void @@ -309,6 +327,19 @@ handle_enable_pin_context_free (HandleEnablePinContext *ctx) } static void +after_enable_unlock_retries_ready (MMIfaceModem *self, + GAsyncResult *res, + HandleEnablePinContext *ctx) +{ + /* We just want to ensure that we tried to update the unlock + * retries, no big issue if it failed */ + mm_iface_modem_update_unlock_retries_finish (self, res, NULL); + + mm_gdbus_sim_complete_enable_pin (MM_GDBUS_SIM (ctx->self), ctx->invocation); + handle_enable_pin_context_free (ctx); +} + +static void handle_enable_pin_ready (MMSim *self, GAsyncResult *res, HandleEnablePinContext *ctx) @@ -316,16 +347,20 @@ handle_enable_pin_ready (MMSim *self, GError *error = NULL; MM_SIM_GET_CLASS (self)->enable_pin_finish (self, res, &error); - if (error) + if (error) { g_dbus_method_invocation_take_error (ctx->invocation, error); - else { - mm_gdbus_sim_complete_enable_pin (MM_GDBUS_SIM (self), ctx->invocation); - - /* Signal about the new lock state */ - g_signal_emit (self, signals[SIGNAL_PIN_LOCK_ENABLED], 0, ctx->enabled); + handle_enable_pin_context_free (ctx); + return; } - handle_enable_pin_context_free (ctx); + /* Signal about the new lock state */ + g_signal_emit (self, signals[SIGNAL_PIN_LOCK_ENABLED], 0, ctx->enabled); + + /* Before returning success, ensure that we get the unlock retry + * counts updated properly. */ + mm_iface_modem_update_unlock_retries (MM_IFACE_MODEM (self->priv->modem), + (GAsyncReadyCallback)after_enable_unlock_retries_ready, + ctx); } static void |