sim-qmi: enable/disable PIN using QMI
This commit is contained in:
@@ -438,6 +438,83 @@ change_pin (MMSim *self,
|
|||||||
qmi_message_dms_uim_change_pin_input_unref (input);
|
qmi_message_dms_uim_change_pin_input_unref (input);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* Enable PIN */
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
enable_pin_finish (MMSim *self,
|
||||||
|
GAsyncResult *res,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
dms_uim_set_pin_protection_ready (QmiClientDms *client,
|
||||||
|
GAsyncResult *res,
|
||||||
|
GSimpleAsyncResult *simple)
|
||||||
|
{
|
||||||
|
QmiMessageDmsUimSetPinProtectionOutput *output = NULL;
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
|
output = qmi_client_dms_uim_set_pin_protection_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_set_pin_protection_output_get_result (output, &error)) {
|
||||||
|
g_prefix_error (&error, "Couldn't enable 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_set_pin_protection_output_unref (output);
|
||||||
|
|
||||||
|
g_simple_async_result_complete (simple);
|
||||||
|
g_object_unref (simple);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
enable_pin (MMSim *self,
|
||||||
|
const gchar *pin,
|
||||||
|
gboolean enabled,
|
||||||
|
GAsyncReadyCallback callback,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
QmiMessageDmsUimSetPinProtectionInput *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,
|
||||||
|
enable_pin);
|
||||||
|
|
||||||
|
mm_dbg ("%s PIN...",
|
||||||
|
enabled ? "Enabling" : "Disabling");
|
||||||
|
|
||||||
|
input = qmi_message_dms_uim_set_pin_protection_input_new ();
|
||||||
|
qmi_message_dms_uim_set_pin_protection_input_set_info (
|
||||||
|
input,
|
||||||
|
QMI_DMS_UIM_PIN_ID_PIN,
|
||||||
|
enabled,
|
||||||
|
pin,
|
||||||
|
NULL);
|
||||||
|
qmi_client_dms_uim_set_pin_protection (QMI_CLIENT_DMS (client),
|
||||||
|
input,
|
||||||
|
5,
|
||||||
|
NULL,
|
||||||
|
(GAsyncReadyCallback)dms_uim_set_pin_protection_ready,
|
||||||
|
result);
|
||||||
|
qmi_message_dms_uim_set_pin_protection_input_unref (input);
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
MMSim *
|
MMSim *
|
||||||
@@ -499,4 +576,6 @@ mm_sim_qmi_class_init (MMSimQmiClass *klass)
|
|||||||
sim_class->send_puk_finish = send_puk_finish;
|
sim_class->send_puk_finish = send_puk_finish;
|
||||||
sim_class->change_pin = change_pin;
|
sim_class->change_pin = change_pin;
|
||||||
sim_class->change_pin_finish = change_pin_finish;
|
sim_class->change_pin_finish = change_pin_finish;
|
||||||
|
sim_class->enable_pin = enable_pin;
|
||||||
|
sim_class->enable_pin_finish = enable_pin_finish;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user