summaryrefslogtreecommitdiff
path: root/src/mm-sim-mbim.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mm-sim-mbim.c')
-rw-r--r--src/mm-sim-mbim.c75
1 files changed, 75 insertions, 0 deletions
diff --git a/src/mm-sim-mbim.c b/src/mm-sim-mbim.c
index 7233acd50..7795c2143 100644
--- a/src/mm-sim-mbim.c
+++ b/src/mm-sim-mbim.c
@@ -248,6 +248,79 @@ send_puk (MMSim *self,
}
/*****************************************************************************/
+/* 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
+pin_set_enable_ready (MbimDevice *device,
+ GAsyncResult *res,
+ GSimpleAsyncResult *simple)
+{
+ GError *error = NULL;
+ MbimMessage *response;
+
+ response = mbim_device_command_finish (device, res, &error);
+ if (response) {
+ mbim_message_command_done_get_result (response, &error);
+ mbim_message_unref (response);
+ }
+
+ if (error)
+ g_simple_async_result_take_error (simple, error);
+ else
+ g_simple_async_result_set_op_res_gboolean (simple, TRUE);
+ 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)
+{
+ MbimDevice *device;
+ MbimMessage *message;
+ GSimpleAsyncResult *result;
+ GError *error = NULL;
+
+ if (!peek_device (self, &device, callback, user_data))
+ return;
+
+ result = g_simple_async_result_new (G_OBJECT (self), callback, user_data, send_puk);
+
+ mm_dbg ("%s PIN ...", enabled ? "Enabling" : "Disabling");
+ message = (mbim_message_basic_connect_pin_set_request_new (
+ MBIM_PIN_TYPE_PIN1,
+ enabled ? MBIM_PIN_OPERATION_ENABLE : MBIM_PIN_OPERATION_DISABLE,
+ pin,
+ "",
+ &error));
+ if (!message) {
+ g_simple_async_result_take_error (result, error);
+ g_simple_async_result_complete_in_idle (result);
+ g_object_unref (result);
+ return;
+ }
+
+ mbim_device_command (device,
+ message,
+ 10,
+ NULL,
+ (GAsyncReadyCallback)pin_set_enable_ready,
+ result);
+ mbim_message_unref (message);
+}
+
+/*****************************************************************************/
MMSim *
mm_sim_mbim_new_finish (GAsyncResult *res,
@@ -298,4 +371,6 @@ mm_sim_mbim_class_init (MMSimMbimClass *klass)
sim_class->send_pin_finish = send_pin_finish;
sim_class->send_puk = send_puk;
sim_class->send_puk_finish = send_puk_finish;
+ sim_class->enable_pin = enable_pin;
+ sim_class->enable_pin_finish = enable_pin_finish;
}