altair-lte: port load_supported_bands to use GTask

This commit is contained in:
Ben Chan
2017-07-18 22:33:23 -07:00
committed by Aleksander Morgado
parent 4ea38c26e0
commit 2d82c505e4

View File

@@ -248,11 +248,7 @@ load_supported_bands_finish (MMIfaceModem *self,
GAsyncResult *res,
GError **error)
{
if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error))
return NULL;
return (GArray *) g_array_ref (g_simple_async_result_get_op_res_gpointer (
G_SIMPLE_ASYNC_RESULT (res)));
return g_task_propagate_pointer (G_TASK (res), error);
}
#define BANDCAP_TAG "%BANDCAP: "
@@ -260,7 +256,7 @@ load_supported_bands_finish (MMIfaceModem *self,
static void
load_supported_bands_done (MMIfaceModem *self,
GAsyncResult *res,
GSimpleAsyncResult *operation_result)
GTask *task)
{
GArray *bands;
const gchar *response;
@@ -269,9 +265,8 @@ load_supported_bands_done (MMIfaceModem *self,
response = mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, &error);
if (!response) {
mm_dbg ("Couldn't query supported bands: '%s'", error->message);
g_simple_async_result_take_error (operation_result, error);
g_simple_async_result_complete_in_idle (operation_result);
g_object_unref (operation_result);
g_task_return_error (task, error);
g_object_unref (task);
return;
}
@@ -283,21 +278,17 @@ load_supported_bands_done (MMIfaceModem *self,
bands = mm_altair_parse_bands_response (response);
if (!bands) {
mm_dbg ("Failed to parse supported bands response");
g_simple_async_result_set_error (
operation_result,
g_task_return_new_error (
task,
MM_CORE_ERROR,
MM_CORE_ERROR_FAILED,
"Failed to parse supported bands response");
g_simple_async_result_complete_in_idle (operation_result);
g_object_unref (operation_result);
g_object_unref (task);
return;
}
g_simple_async_result_set_op_res_gpointer (operation_result,
bands,
(GDestroyNotify)g_array_unref);
g_simple_async_result_complete_in_idle (operation_result);
g_object_unref (operation_result);
g_task_return_pointer (task, bands, (GDestroyNotify)g_array_unref);
g_object_unref (task);
}
static void
@@ -305,12 +296,9 @@ load_supported_bands (MMIfaceModem *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
GSimpleAsyncResult *result;
GTask *task;
result = g_simple_async_result_new (G_OBJECT (self),
callback,
user_data,
load_supported_bands);
task = g_task_new (self, NULL, callback, user_data);
mm_base_modem_at_command (
MM_BASE_MODEM (self),
@@ -318,7 +306,7 @@ load_supported_bands (MMIfaceModem *self,
3,
FALSE,
(GAsyncReadyCallback)load_supported_bands_done,
result);
task);
}
/*****************************************************************************/