aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mm-broadband-modem-qmi.c54
1 files changed, 16 insertions, 38 deletions
diff --git a/src/mm-broadband-modem-qmi.c b/src/mm-broadband-modem-qmi.c
index 6ec57124..9c5d2268 100644
--- a/src/mm-broadband-modem-qmi.c
+++ b/src/mm-broadband-modem-qmi.c
@@ -575,35 +575,18 @@ modem_load_current_capabilities (MMIfaceModem *self,
/*****************************************************************************/
/* Supported capabilities loading (Modem interface) */
-typedef struct {
- MMBroadbandModemQmi *self;
- GSimpleAsyncResult *result;
-} LoadSupportedCapabilitiesContext;
-
-static void
-load_supported_capabilities_context_complete_and_free (LoadSupportedCapabilitiesContext *ctx)
-{
- g_simple_async_result_complete (ctx->result);
- g_object_unref (ctx->result);
- g_object_unref (ctx->self);
- g_slice_free (LoadSupportedCapabilitiesContext, ctx);
-}
-
static GArray *
modem_load_supported_capabilities_finish (MMIfaceModem *self,
GAsyncResult *res,
GError **error)
{
- if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error))
- return NULL;
-
- return g_array_ref (g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res)));
+ return g_task_propagate_pointer (G_TASK (res), error);
}
static void
dms_get_capabilities_ready (QmiClientDms *client,
GAsyncResult *res,
- LoadSupportedCapabilitiesContext *ctx)
+ GTask *task)
{
QmiMessageDmsGetCapabilitiesOutput *output = NULL;
GError *error = NULL;
@@ -611,11 +594,12 @@ dms_get_capabilities_ready (QmiClientDms *client,
output = qmi_client_dms_get_capabilities_finish (client, res, &error);
if (!output) {
g_prefix_error (&error, "QMI operation failed: ");
- g_simple_async_result_take_error (ctx->result, error);
+ g_task_return_error (task, error);
} else if (!qmi_message_dms_get_capabilities_output_get_result (output, &error)) {
g_prefix_error (&error, "Couldn't get supported capabilities: ");
- g_simple_async_result_take_error (ctx->result, error);
+ g_task_return_error (task, error);
} else {
+ MMBroadbandModemQmi *self;
guint i;
MMModemCapability mask = MM_MODEM_CAPABILITY_NONE;
MMModemCapability single;
@@ -623,6 +607,8 @@ dms_get_capabilities_ready (QmiClientDms *client,
GArray *supported_combinations;
GArray *filtered_combinations;
+ self = g_task_get_source_object (task);
+
qmi_message_dms_get_capabilities_output_get_info (
output,
NULL, /* info_max_tx_channel_rate */
@@ -639,9 +625,9 @@ dms_get_capabilities_ready (QmiClientDms *client,
}
/* Cache supported radio interfaces */
- if (ctx->self->priv->supported_radio_interfaces)
- g_array_unref (ctx->self->priv->supported_radio_interfaces);
- ctx->self->priv->supported_radio_interfaces = g_array_ref (radio_interface_list);
+ if (self->priv->supported_radio_interfaces)
+ g_array_unref (self->priv->supported_radio_interfaces);
+ self->priv->supported_radio_interfaces = g_array_ref (radio_interface_list);
supported_combinations = g_array_sized_new (FALSE, FALSE, sizeof (MMModemCapability), 7);
@@ -675,15 +661,15 @@ dms_get_capabilities_ready (QmiClientDms *client,
supported_combinations);
g_array_unref (supported_combinations);
- g_simple_async_result_set_op_res_gpointer (ctx->result,
- filtered_combinations,
- (GDestroyNotify) g_array_unref);
+ g_task_return_pointer (task,
+ filtered_combinations,
+ (GDestroyNotify) g_array_unref);
}
if (output)
qmi_message_dms_get_capabilities_output_unref (output);
- load_supported_capabilities_context_complete_and_free (ctx);
+ g_object_unref (task);
}
static void
@@ -691,28 +677,20 @@ modem_load_supported_capabilities (MMIfaceModem *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
- LoadSupportedCapabilitiesContext *ctx;
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,
callback, user_data))
return;
- ctx = g_slice_new (LoadSupportedCapabilitiesContext);
- ctx->self = g_object_ref (self);
- ctx->result = g_simple_async_result_new (G_OBJECT (self),
- callback,
- user_data,
- modem_load_supported_capabilities);
-
mm_dbg ("loading supported capabilities...");
qmi_client_dms_get_capabilities (QMI_CLIENT_DMS (client),
NULL,
5,
NULL,
(GAsyncReadyCallback)dms_get_capabilities_ready,
- ctx);
+ g_task_new (self, NULL, callback, user_data));
}
/*****************************************************************************/