icera: port modem_load_supported_bands to use GTask
This commit is contained in:

committed by
Aleksander Morgado

parent
4ecc8a13fd
commit
f168ffd032
@@ -1231,17 +1231,13 @@ modem_load_supported_bands_finish (MMIfaceModem *self,
|
|||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error))
|
return g_task_propagate_pointer (G_TASK (res), error);
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return (GArray *) g_array_ref (g_simple_async_result_get_op_res_gpointer (
|
|
||||||
G_SIMPLE_ASYNC_RESULT (res)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
load_supported_bands_ready (MMBaseModem *self,
|
load_supported_bands_ready (MMBaseModem *self,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
GSimpleAsyncResult *simple)
|
GTask *task)
|
||||||
{
|
{
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
SupportedBandsContext *ctx = NULL;
|
SupportedBandsContext *ctx = NULL;
|
||||||
@@ -1250,7 +1246,7 @@ load_supported_bands_ready (MMBaseModem *self,
|
|||||||
|
|
||||||
mm_base_modem_at_sequence_finish (self, res, (gpointer) &ctx, &error);
|
mm_base_modem_at_sequence_finish (self, res, (gpointer) &ctx, &error);
|
||||||
if (error)
|
if (error)
|
||||||
g_simple_async_result_take_error (simple, error);
|
g_task_return_error (task, error);
|
||||||
else {
|
else {
|
||||||
bands = g_array_sized_new (FALSE, FALSE, sizeof (MMModemBand), ctx->idx);
|
bands = g_array_sized_new (FALSE, FALSE, sizeof (MMModemBand), ctx->idx);
|
||||||
|
|
||||||
@@ -1270,12 +1266,9 @@ load_supported_bands_ready (MMBaseModem *self,
|
|||||||
g_array_prepend_val (bands, b->band);
|
g_array_prepend_val (bands, b->band);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_simple_async_result_set_op_res_gpointer (simple,
|
g_task_return_pointer (task, bands, (GDestroyNotify) g_array_unref);
|
||||||
bands,
|
|
||||||
(GDestroyNotify) g_array_unref);
|
|
||||||
}
|
}
|
||||||
g_simple_async_result_complete (simple);
|
g_object_unref (task);
|
||||||
g_object_unref (simple);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@@ -1303,7 +1296,7 @@ load_supported_bands_response_processor (MMBaseModem *self,
|
|||||||
static void
|
static void
|
||||||
load_supported_bands_get_current_bands_ready (MMIfaceModem *self,
|
load_supported_bands_get_current_bands_ready (MMIfaceModem *self,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
GSimpleAsyncResult *operation_result)
|
GTask *task)
|
||||||
{
|
{
|
||||||
SupportedBandsContext *ctx;
|
SupportedBandsContext *ctx;
|
||||||
const gchar *response;
|
const gchar *response;
|
||||||
@@ -1314,9 +1307,8 @@ load_supported_bands_get_current_bands_ready (MMIfaceModem *self,
|
|||||||
response = mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, &error);
|
response = mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, &error);
|
||||||
if (!response) {
|
if (!response) {
|
||||||
mm_dbg ("Couldn't query current bands: '%s'", error->message);
|
mm_dbg ("Couldn't query current bands: '%s'", error->message);
|
||||||
g_simple_async_result_take_error (operation_result, error);
|
g_task_return_error (task, error);
|
||||||
g_simple_async_result_complete (operation_result);
|
g_object_unref (task);
|
||||||
g_object_unref (operation_result);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1354,7 +1346,7 @@ load_supported_bands_get_current_bands_ready (MMIfaceModem *self,
|
|||||||
ctx,
|
ctx,
|
||||||
(GDestroyNotify) supported_bands_context_free,
|
(GDestroyNotify) supported_bands_context_free,
|
||||||
(GAsyncReadyCallback) load_supported_bands_ready,
|
(GAsyncReadyCallback) load_supported_bands_ready,
|
||||||
operation_result);
|
task);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -1373,10 +1365,7 @@ modem_load_supported_bands (MMIfaceModem *self,
|
|||||||
3,
|
3,
|
||||||
FALSE,
|
FALSE,
|
||||||
(GAsyncReadyCallback)load_supported_bands_get_current_bands_ready,
|
(GAsyncReadyCallback)load_supported_bands_get_current_bands_ready,
|
||||||
g_simple_async_result_new (G_OBJECT (self),
|
g_task_new (self, NULL, callback, user_data));
|
||||||
callback,
|
|
||||||
user_data,
|
|
||||||
modem_load_supported_bands));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
Reference in New Issue
Block a user