novatel-lte: port modem_after_sim_unlock to use GTask

This commit is contained in:
Ben Chan
2017-09-12 04:39:42 -07:00
committed by Aleksander Morgado
parent ced9264a1c
commit b56ea69589

View File

@@ -138,14 +138,14 @@ modem_after_sim_unlock_finish (MMIfaceModem *self,
GAsyncResult *res, GAsyncResult *res,
GError **error) GError **error)
{ {
return TRUE; return g_task_propagate_boolean (G_TASK (res), error);
} }
static gboolean static gboolean
after_sim_unlock_wait_cb (GSimpleAsyncResult *result) after_sim_unlock_wait_cb (GTask *task)
{ {
g_simple_async_result_complete (result); g_task_return_boolean (task, TRUE);
g_object_unref (result); g_object_unref (task);
return G_SOURCE_REMOVE; return G_SOURCE_REMOVE;
} }
@@ -154,16 +154,13 @@ modem_after_sim_unlock (MMIfaceModem *self,
GAsyncReadyCallback callback, GAsyncReadyCallback callback,
gpointer user_data) gpointer user_data)
{ {
GSimpleAsyncResult *result; GTask *task;
result = g_simple_async_result_new (G_OBJECT (self), task = g_task_new (self, NULL, callback, user_data);
callback,
user_data,
modem_after_sim_unlock);
/* A 3-second wait is necessary for SIM to become ready. /* A 3-second wait is necessary for SIM to become ready.
* Otherwise, a subsequent AT+CRSM command will likely fail. */ * Otherwise, a subsequent AT+CRSM command will likely fail. */
g_timeout_add_seconds (3, (GSourceFunc)after_sim_unlock_wait_cb, result); g_timeout_add_seconds (3, (GSourceFunc)after_sim_unlock_wait_cb, task);
} }
/*****************************************************************************/ /*****************************************************************************/