broadband-modem-qmi: port modem_load_supported_bands to use GTask
This commit is contained in:

committed by
Aleksander Morgado

parent
59c8ba8642
commit
834674b21c
@@ -2063,24 +2063,23 @@ modem_load_supported_bands_finish (MMIfaceModem *_self,
|
|||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
MMBroadbandModemQmi *self = MM_BROADBAND_MODEM_QMI (_self);
|
MMBroadbandModemQmi *self = MM_BROADBAND_MODEM_QMI (_self);
|
||||||
|
GArray *supported_bands;
|
||||||
|
|
||||||
if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error))
|
supported_bands = g_task_propagate_pointer (G_TASK (res), error);
|
||||||
return NULL;
|
if (supported_bands) {
|
||||||
|
|
||||||
if (self->priv->supported_bands)
|
if (self->priv->supported_bands)
|
||||||
g_array_unref (self->priv->supported_bands);
|
g_array_unref (self->priv->supported_bands);
|
||||||
|
|
||||||
/* Cache the supported bands value */
|
/* Cache the supported bands value */
|
||||||
self->priv->supported_bands = g_array_ref (g_simple_async_result_get_op_res_gpointer (
|
self->priv->supported_bands = g_array_ref (supported_bands);
|
||||||
G_SIMPLE_ASYNC_RESULT (res)));
|
}
|
||||||
|
return supported_bands;
|
||||||
return g_array_ref (self->priv->supported_bands);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
dms_get_band_capabilities_ready (QmiClientDms *client,
|
dms_get_band_capabilities_ready (QmiClientDms *client,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
GSimpleAsyncResult *simple)
|
GTask *task)
|
||||||
{
|
{
|
||||||
QmiMessageDmsGetBandCapabilitiesOutput *output;
|
QmiMessageDmsGetBandCapabilitiesOutput *output;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
@@ -2088,10 +2087,10 @@ dms_get_band_capabilities_ready (QmiClientDms *client,
|
|||||||
output = qmi_client_dms_get_band_capabilities_finish (client, res, &error);
|
output = qmi_client_dms_get_band_capabilities_finish (client, res, &error);
|
||||||
if (!output) {
|
if (!output) {
|
||||||
g_prefix_error (&error, "QMI operation failed: ");
|
g_prefix_error (&error, "QMI operation failed: ");
|
||||||
g_simple_async_result_take_error (simple, error);
|
g_task_return_error (task, error);
|
||||||
} else if (!qmi_message_dms_get_band_capabilities_output_get_result (output, &error)) {
|
} else if (!qmi_message_dms_get_band_capabilities_output_get_result (output, &error)) {
|
||||||
g_prefix_error (&error, "Couldn't get band capabilities: ");
|
g_prefix_error (&error, "Couldn't get band capabilities: ");
|
||||||
g_simple_async_result_take_error (simple, error);
|
g_task_return_error (task, error);
|
||||||
} else {
|
} else {
|
||||||
GArray *mm_bands;
|
GArray *mm_bands;
|
||||||
QmiDmsBandCapability qmi_bands = 0;
|
QmiDmsBandCapability qmi_bands = 0;
|
||||||
@@ -2110,22 +2109,19 @@ dms_get_band_capabilities_ready (QmiClientDms *client,
|
|||||||
|
|
||||||
if (mm_bands->len == 0) {
|
if (mm_bands->len == 0) {
|
||||||
g_array_unref (mm_bands);
|
g_array_unref (mm_bands);
|
||||||
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 parse the list of supported bands");
|
"Couldn't parse the list of supported bands");
|
||||||
} else {
|
} else {
|
||||||
g_simple_async_result_set_op_res_gpointer (simple,
|
g_task_return_pointer (task, mm_bands, (GDestroyNotify)g_array_unref);
|
||||||
mm_bands,
|
|
||||||
(GDestroyNotify)g_array_unref);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (output)
|
if (output)
|
||||||
qmi_message_dms_get_band_capabilities_output_unref (output);
|
qmi_message_dms_get_band_capabilities_output_unref (output);
|
||||||
|
|
||||||
g_simple_async_result_complete (simple);
|
g_object_unref (task);
|
||||||
g_object_unref (simple);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -2133,26 +2129,20 @@ modem_load_supported_bands (MMIfaceModem *self,
|
|||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
GSimpleAsyncResult *result;
|
|
||||||
QmiClient *client = NULL;
|
QmiClient *client = NULL;
|
||||||
|
|
||||||
if (!ensure_qmi_client (MM_BROADBAND_MODEM_QMI (self),
|
if (!assure_qmi_client (MM_BROADBAND_MODEM_QMI (self),
|
||||||
QMI_SERVICE_DMS, &client,
|
QMI_SERVICE_DMS, &client,
|
||||||
callback, user_data))
|
callback, user_data))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
result = g_simple_async_result_new (G_OBJECT (self),
|
|
||||||
callback,
|
|
||||||
user_data,
|
|
||||||
modem_load_supported_bands);
|
|
||||||
|
|
||||||
mm_dbg ("loading band capabilities...");
|
mm_dbg ("loading band capabilities...");
|
||||||
qmi_client_dms_get_band_capabilities (QMI_CLIENT_DMS (client),
|
qmi_client_dms_get_band_capabilities (QMI_CLIENT_DMS (client),
|
||||||
NULL,
|
NULL,
|
||||||
5,
|
5,
|
||||||
NULL,
|
NULL,
|
||||||
(GAsyncReadyCallback)dms_get_band_capabilities_ready,
|
(GAsyncReadyCallback)dms_get_band_capabilities_ready,
|
||||||
result);
|
g_task_new (self, NULL, callback, user_data));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
Reference in New Issue
Block a user