aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2012-08-23 17:41:31 +0200
committerAleksander Morgado <aleksander@lanedo.com>2012-08-23 18:56:23 +0200
commit3753184eb149c9f12ea8d24f65da3a9339f890ae (patch)
tree013d94a77d1f65cd3c1b0014ef946cf380d26ad2
parent3cdfa93c7376a10092cc771ff79430bc3e77fb75 (diff)
mbm: implement custom PIN retry count loading
-rw-r--r--plugins/mbm/mm-broadband-modem-mbm.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/plugins/mbm/mm-broadband-modem-mbm.c b/plugins/mbm/mm-broadband-modem-mbm.c
index 41f21121..94f2d18a 100644
--- a/plugins/mbm/mm-broadband-modem-mbm.c
+++ b/plugins/mbm/mm-broadband-modem-mbm.c
@@ -464,6 +464,65 @@ factory_reset (MMIfaceModem *self,
}
/*****************************************************************************/
+/* Load unlock retries (Modem interface) */
+
+static MMUnlockRetries *
+load_unlock_retries_finish (MMIfaceModem *self,
+ GAsyncResult *res,
+ GError **error)
+{
+ MMUnlockRetries *unlock_retries;
+ const gchar *response;
+ gint matched;
+ guint a, b, c ,d;
+
+ response = mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, error);
+ if (!response)
+ return NULL;
+
+ matched = sscanf (response, "*EPIN: %d, %d, %d, %d",
+ &a, &b, &c, &d);
+ if (matched != 4) {
+ g_set_error (error,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_FAILED,
+ "Could not parse PIN retries results: '%s'",
+ response);
+ return NULL;
+ }
+
+ if (a > 998) {
+ g_set_error (error,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_FAILED,
+ "Invalid PIN attempts left: '%u'",
+ a);
+ return NULL;
+ }
+
+ unlock_retries = mm_unlock_retries_new ();
+ mm_unlock_retries_set (unlock_retries, MM_MODEM_LOCK_SIM_PIN, a);
+ mm_unlock_retries_set (unlock_retries, MM_MODEM_LOCK_SIM_PUK, b);
+ mm_unlock_retries_set (unlock_retries, MM_MODEM_LOCK_SIM_PIN2, c);
+ mm_unlock_retries_set (unlock_retries, MM_MODEM_LOCK_SIM_PUK2, d);
+ return unlock_retries;
+}
+
+static void
+load_unlock_retries (MMIfaceModem *self,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ mm_dbg ("loading unlock retries (mbm)...");
+ mm_base_modem_at_command (MM_BASE_MODEM (self),
+ "*EPIN?",
+ 3,
+ FALSE,
+ callback,
+ user_data);
+}
+
+/*****************************************************************************/
/* Setup/Cleanup unsolicited events (3GPP interface) */
static void
@@ -915,6 +974,8 @@ iface_modem_init (MMIfaceModem *iface)
iface->reset_finish = reset_finish;
iface->factory_reset = factory_reset;
iface->factory_reset_finish = factory_reset_finish;
+ iface->load_unlock_retries = load_unlock_retries;
+ iface->load_unlock_retries_finish = load_unlock_retries_finish;
}
static void