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

committed by
Aleksander Morgado

parent
f168ffd032
commit
aa2cd2288a
@@ -1376,17 +1376,13 @@ modem_load_current_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_current_bands_ready (MMIfaceModem *self,
|
load_current_bands_ready (MMIfaceModem *self,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
GSimpleAsyncResult *operation_result)
|
GTask *task)
|
||||||
{
|
{
|
||||||
GArray *bands;
|
GArray *bands;
|
||||||
const gchar *response;
|
const gchar *response;
|
||||||
@@ -1397,9 +1393,7 @@ load_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 (operation_result);
|
|
||||||
} else {
|
} else {
|
||||||
/* Parse bands from Icera response into MM band numbers */
|
/* Parse bands from Icera response into MM band numbers */
|
||||||
parsed = parse_bands (response, &len);
|
parsed = parse_bands (response, &len);
|
||||||
@@ -1412,12 +1406,9 @@ load_current_bands_ready (MMIfaceModem *self,
|
|||||||
}
|
}
|
||||||
g_slist_free_full (parsed, (GDestroyNotify) band_free);
|
g_slist_free_full (parsed, (GDestroyNotify) band_free);
|
||||||
|
|
||||||
g_simple_async_result_set_op_res_gpointer (operation_result,
|
g_task_return_pointer (task, bands, (GDestroyNotify)g_array_unref);
|
||||||
bands,
|
|
||||||
(GDestroyNotify)g_array_unref);
|
|
||||||
g_simple_async_result_complete (operation_result);
|
|
||||||
g_object_unref (operation_result);
|
|
||||||
}
|
}
|
||||||
|
g_object_unref (task);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -1431,10 +1422,7 @@ modem_load_current_bands (MMIfaceModem *self,
|
|||||||
3,
|
3,
|
||||||
FALSE,
|
FALSE,
|
||||||
(GAsyncReadyCallback)load_current_bands_ready,
|
(GAsyncReadyCallback)load_current_bands_ready,
|
||||||
g_simple_async_result_new (G_OBJECT (self),
|
g_task_new (self, NULL, callback, user_data));
|
||||||
callback,
|
|
||||||
user_data,
|
|
||||||
modem_load_current_bands));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
Reference in New Issue
Block a user