iridium: port load_operator_{code,name} to use GTask

This commit is contained in:
Ben Chan
2017-10-06 16:04:00 -07:00
committed by Aleksander Morgado
parent 2768df24b4
commit d0bbc43fa7

View File

@@ -44,40 +44,51 @@ G_DEFINE_TYPE_EXTENDED (MMBroadbandModemIridium, mm_broadband_modem_iridium, MM_
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM_MESSAGING, iface_modem_messaging_init));
/*****************************************************************************/
/* Operator Code and Name loading (3GPP interface) */
/* Operator Code loading (3GPP interface) */
static gchar *
load_operator_code_finish (MMIfaceModem3gpp *self,
GAsyncResult *res,
GError **error)
{
/* Only "90103" operator code is assumed */
return g_strdup ("90103");
return g_task_propagate_pointer (G_TASK (res), error);
}
static void
load_operator_code (MMIfaceModem3gpp *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
GTask *task;
task = g_task_new (self, NULL, callback, user_data);
/* Only "90103" operator code is assumed */
g_task_return_pointer (task, g_strdup ("90103"), g_free);
g_object_unref (task);
}
/*****************************************************************************/
/* Operator Name loading (3GPP interface) */
static gchar *
load_operator_name_finish (MMIfaceModem3gpp *self,
GAsyncResult *res,
GError **error)
{
/* Only "IRIDIUM" operator name is assumed */
return g_strdup ("IRIDIUM");
return g_task_propagate_pointer (G_TASK (res), error);
}
static void
load_operator_name_or_code (MMIfaceModem3gpp *self,
GAsyncReadyCallback callback,
gpointer user_data)
load_operator_name (MMIfaceModem3gpp *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
GSimpleAsyncResult *result;
GTask *task;
result = g_simple_async_result_new (G_OBJECT (self),
callback,
user_data,
load_operator_name_or_code);
g_simple_async_result_set_op_res_gboolean (result, TRUE);
g_simple_async_result_complete_in_idle (result);
g_object_unref (result);
task = g_task_new (self, NULL, callback, user_data);
/* Only "IRIDIUM" operator name is assumed */
g_task_return_pointer (task, g_strdup ("IRIDIUM"), g_free);
g_object_unref (task);
}
/*****************************************************************************/
@@ -385,9 +396,9 @@ static void
iface_modem_3gpp_init (MMIfaceModem3gpp *iface)
{
/* Fixed operator code and name to be reported */
iface->load_operator_name = load_operator_name_or_code;
iface->load_operator_name = load_operator_name;
iface->load_operator_name_finish = load_operator_name_finish;
iface->load_operator_code = load_operator_name_or_code;
iface->load_operator_code = load_operator_code;
iface->load_operator_code_finish = load_operator_code_finish;
/* Don't try to scan networks with AT+COPS=?.