wavecom: port load_supported_modes to GTask
This commit is contained in:
@@ -93,16 +93,13 @@ load_supported_modes_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 g_array_ref (g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
supported_ms_classes_query_ready (MMBaseModem *self,
|
supported_ms_classes_query_ready (MMBaseModem *self,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
GSimpleAsyncResult *simple)
|
GTask *task)
|
||||||
{
|
{
|
||||||
GArray *all;
|
GArray *all;
|
||||||
GArray *combinations;
|
GArray *combinations;
|
||||||
@@ -114,10 +111,8 @@ supported_ms_classes_query_ready (MMBaseModem *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) {
|
||||||
/* Let the error be critical. */
|
g_task_return_error (task, error);
|
||||||
g_simple_async_result_take_error (simple, error);
|
g_object_unref (task);
|
||||||
g_simple_async_result_complete (simple);
|
|
||||||
g_object_unref (simple);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,13 +129,12 @@ supported_ms_classes_query_ready (MMBaseModem *self,
|
|||||||
|
|
||||||
/* If none received, error */
|
/* If none received, error */
|
||||||
if (mode_all == MM_MODEM_MODE_NONE) {
|
if (mode_all == MM_MODEM_MODE_NONE) {
|
||||||
g_simple_async_result_set_error (simple,
|
g_task_return_new_error (task,
|
||||||
MM_CORE_ERROR,
|
MM_CORE_ERROR,
|
||||||
MM_CORE_ERROR_FAILED,
|
MM_CORE_ERROR_FAILED,
|
||||||
"Couldn't get supported mobile station classes: '%s'",
|
"Couldn't get supported mobile station classes: '%s'",
|
||||||
response);
|
response);
|
||||||
g_simple_async_result_complete (simple);
|
g_object_unref (task);
|
||||||
g_object_unref (simple);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,9 +180,8 @@ supported_ms_classes_query_ready (MMBaseModem *self,
|
|||||||
g_array_unref (all);
|
g_array_unref (all);
|
||||||
g_array_unref (combinations);
|
g_array_unref (combinations);
|
||||||
|
|
||||||
g_simple_async_result_set_op_res_gpointer (simple, filtered, (GDestroyNotify) g_array_unref);
|
g_task_return_pointer (task, filtered, (GDestroyNotify) g_array_unref);
|
||||||
g_simple_async_result_complete (simple);
|
g_object_unref (task);
|
||||||
g_object_unref (simple);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -196,16 +189,17 @@ load_supported_modes (MMIfaceModem *self,
|
|||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
|
GTask *task;
|
||||||
|
|
||||||
|
task = g_task_new (self, NULL, callback, user_data);
|
||||||
|
|
||||||
mm_base_modem_at_command (
|
mm_base_modem_at_command (
|
||||||
MM_BASE_MODEM (self),
|
MM_BASE_MODEM (self),
|
||||||
"+CGCLASS=?",
|
"+CGCLASS=?",
|
||||||
3,
|
3,
|
||||||
FALSE,
|
FALSE,
|
||||||
(GAsyncReadyCallback)supported_ms_classes_query_ready,
|
(GAsyncReadyCallback)supported_ms_classes_query_ready,
|
||||||
g_simple_async_result_new (G_OBJECT (self),
|
task);
|
||||||
callback,
|
|
||||||
user_data,
|
|
||||||
load_supported_modes));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
Reference in New Issue
Block a user