huawei: port set_current_bands to use GTask
This commit is contained in:

committed by
Aleksander Morgado

parent
8b9402da2b
commit
5d9c4d70a1
@@ -888,24 +888,23 @@ set_current_bands_finish (MMIfaceModem *self,
|
|||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error);
|
return g_task_propagate_boolean (G_TASK (res), error);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
syscfg_set_ready (MMBaseModem *self,
|
syscfg_set_ready (MMBaseModem *self,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
GSimpleAsyncResult *operation_result)
|
GTask *task)
|
||||||
{
|
{
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
if (!mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, &error))
|
if (!mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, &error))
|
||||||
/* Let the error be critical */
|
/* Let the error be critical */
|
||||||
g_simple_async_result_take_error (operation_result, error);
|
g_task_return_error (task, error);
|
||||||
else
|
else
|
||||||
g_simple_async_result_set_op_res_gboolean (operation_result, TRUE);
|
g_task_return_boolean (task, TRUE);
|
||||||
|
|
||||||
g_simple_async_result_complete (operation_result);
|
g_object_unref (task);
|
||||||
g_object_unref (operation_result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -914,27 +913,23 @@ set_current_bands (MMIfaceModem *self,
|
|||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
GSimpleAsyncResult *result;
|
GTask *task;
|
||||||
gchar *cmd;
|
gchar *cmd;
|
||||||
guint32 huawei_band = 0x3FFFFFFF;
|
guint32 huawei_band = 0x3FFFFFFF;
|
||||||
gchar *bands_string;
|
gchar *bands_string;
|
||||||
|
|
||||||
result = g_simple_async_result_new (G_OBJECT (self),
|
task = g_task_new (self, NULL, callback, user_data);
|
||||||
callback,
|
|
||||||
user_data,
|
|
||||||
set_current_bands);
|
|
||||||
|
|
||||||
bands_string = mm_common_build_bands_string ((MMModemBand *)bands_array->data,
|
bands_string = mm_common_build_bands_string ((MMModemBand *)bands_array->data,
|
||||||
bands_array->len);
|
bands_array->len);
|
||||||
|
|
||||||
if (!bands_array_to_huawei (bands_array, &huawei_band)) {
|
if (!bands_array_to_huawei (bands_array, &huawei_band)) {
|
||||||
g_simple_async_result_set_error (result,
|
g_task_return_new_error (task,
|
||||||
MM_CORE_ERROR,
|
MM_CORE_ERROR,
|
||||||
MM_CORE_ERROR_FAILED,
|
MM_CORE_ERROR_FAILED,
|
||||||
"Invalid bands requested: '%s'",
|
"Invalid bands requested: '%s'",
|
||||||
bands_string);
|
bands_string);
|
||||||
g_simple_async_result_complete_in_idle (result);
|
g_object_unref (task);
|
||||||
g_object_unref (result);
|
|
||||||
g_free (bands_string);
|
g_free (bands_string);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -945,7 +940,7 @@ set_current_bands (MMIfaceModem *self,
|
|||||||
3,
|
3,
|
||||||
FALSE,
|
FALSE,
|
||||||
(GAsyncReadyCallback)syscfg_set_ready,
|
(GAsyncReadyCallback)syscfg_set_ready,
|
||||||
result);
|
task);
|
||||||
g_free (cmd);
|
g_free (cmd);
|
||||||
g_free (bands_string);
|
g_free (bands_string);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user