diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2012-07-02 15:40:29 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2012-08-29 17:26:41 +0200 |
commit | 30bdc8d592ae83480b93c0788ae9be6d48976901 (patch) | |
tree | ea647f37ae562595e9b3756d6b04c3d23bc7efef | |
parent | d1d5322f510e6c121ed797953802c0a32d685b2d (diff) |
sim-qmi: send PUK using QMI
-rw-r--r-- | src/mm-sim-qmi.c | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/src/mm-sim-qmi.c b/src/mm-sim-qmi.c index b68e0274..529f55e9 100644 --- a/src/mm-sim-qmi.c +++ b/src/mm-sim-qmi.c @@ -287,6 +287,82 @@ send_pin (MMSim *self, } /*****************************************************************************/ +/* Send PUK */ + +static gboolean +send_puk_finish (MMSim *self, + GAsyncResult *res, + GError **error) +{ + return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error); +} + +static void +dms_uim_unblock_pin_ready (QmiClientDms *client, + GAsyncResult *res, + GSimpleAsyncResult *simple) +{ + QmiMessageDmsUimUnblockPinOutput *output = NULL; + GError *error = NULL; + + output = qmi_client_dms_uim_unblock_pin_finish (client, res, &error); + if (!output) { + g_prefix_error (&error, "QMI operation failed: "); + g_simple_async_result_take_error (simple, error); + } else if (!qmi_message_dms_uim_unblock_pin_output_get_result (output, &error)) { + g_prefix_error (&error, "Couldn't unblock PIN: "); + g_simple_async_result_take_error (simple, error); + } else { + g_simple_async_result_set_op_res_gboolean (simple, TRUE); + } + + if (output) + qmi_message_dms_uim_unblock_pin_output_unref (output); + + g_simple_async_result_complete (simple); + g_object_unref (simple); +} + +static void +send_puk (MMSim *self, + const gchar *puk, + const gchar *new_pin, + GAsyncReadyCallback callback, + gpointer user_data) +{ + QmiMessageDmsUimUnblockPinInput *input; + GSimpleAsyncResult *result; + QmiClient *client = NULL; + + if (!ensure_qmi_client (MM_SIM_QMI (self), + QMI_SERVICE_DMS, &client, + callback, user_data)) + return; + + result = g_simple_async_result_new (G_OBJECT (self), + callback, + user_data, + send_puk); + + mm_dbg ("Sending PUK..."); + + input = qmi_message_dms_uim_unblock_pin_input_new (); + qmi_message_dms_uim_unblock_pin_input_set_info ( + input, + QMI_DMS_UIM_PIN_ID_PIN, + puk, + new_pin, + NULL); + qmi_client_dms_uim_unblock_pin (QMI_CLIENT_DMS (client), + input, + 5, + NULL, + (GAsyncReadyCallback)dms_uim_unblock_pin_ready, + result); + qmi_message_dms_uim_unblock_pin_input_unref (input); +} + +/*****************************************************************************/ MMSim * mm_sim_qmi_new_finish (GAsyncResult *res, @@ -339,4 +415,6 @@ mm_sim_qmi_class_init (MMSimQmiClass *klass) sim_class->load_imsi_finish = load_imsi_finish; sim_class->send_pin = send_pin; sim_class->send_pin_finish = send_pin_finish; + sim_class->send_puk = send_puk; + sim_class->send_puk_finish = send_puk_finish; } |