broadband-modem-mbim: port modem_3gpp_load_operator_name to use GTask

This commit is contained in:
Ben Chan
2017-07-10 16:10:40 -07:00
parent fb38601ef4
commit 9401aa70e5

View File

@@ -2537,37 +2537,32 @@ modem_3gpp_enable_unsolicited_events (MMIfaceModem3gpp *self,
/* Load operator name (3GPP interface) */ /* Load operator name (3GPP interface) */
static gchar * static gchar *
modem_3gpp_load_operator_name_finish (MMIfaceModem3gpp *_self, modem_3gpp_load_operator_name_finish (MMIfaceModem3gpp *self,
GAsyncResult *res, GAsyncResult *res,
GError **error) GError **error)
{ {
MMBroadbandModemMbim *self = MM_BROADBAND_MODEM_MBIM (_self); return g_task_propagate_pointer (G_TASK (res), error);
if (self->priv->current_operator_name)
return g_strdup (self->priv->current_operator_name);
g_set_error (error,
MM_CORE_ERROR,
MM_CORE_ERROR_FAILED,
"Current operator name is still unknown");
return NULL;
} }
static void static void
modem_3gpp_load_operator_name (MMIfaceModem3gpp *self, modem_3gpp_load_operator_name (MMIfaceModem3gpp *_self,
GAsyncReadyCallback callback, GAsyncReadyCallback callback,
gpointer user_data) gpointer user_data)
{ {
GSimpleAsyncResult *result; MMBroadbandModemMbim *self = MM_BROADBAND_MODEM_MBIM (_self);
GTask *task;
/* Just finish the async operation */ task = g_task_new (self, NULL, callback, user_data);
result = g_simple_async_result_new (G_OBJECT (self), if (self->priv->current_operator_name)
callback, g_task_return_pointer (task,
user_data, g_strdup (self->priv->current_operator_name),
modem_3gpp_load_operator_name); g_free);
g_simple_async_result_set_op_res_gboolean (result, TRUE); else
g_simple_async_result_complete_in_idle (result); g_task_return_new_error (task,
g_object_unref (result); MM_CORE_ERROR,
MM_CORE_ERROR_FAILED,
"Current operator name is still unknown");
g_object_unref (task);
} }
/*****************************************************************************/ /*****************************************************************************/