aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorBen Chan <benchan@chromium.org>2017-10-06 16:04:00 -0700
committerAleksander Morgado <aleksander@aleksander.es>2017-10-07 10:41:20 +0200
commitd0bbc43fa7601c395c3208b199eaa43dc24a16c4 (patch)
tree85752cdd9bb1c80245222421acfde98c081bcf91 /plugins
parent2768df24b487b82c78b0623000c51d5a0cb30367 (diff)
iridium: port load_operator_{code,name} to use GTask
Diffstat (limited to 'plugins')
-rw-r--r--plugins/iridium/mm-broadband-modem-iridium.c47
1 files changed, 29 insertions, 18 deletions
diff --git a/plugins/iridium/mm-broadband-modem-iridium.c b/plugins/iridium/mm-broadband-modem-iridium.c
index 3a37ab62..567df4e2 100644
--- a/plugins/iridium/mm-broadband-modem-iridium.c
+++ b/plugins/iridium/mm-broadband-modem-iridium.c
@@ -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)
{
+ 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 */
- return g_strdup ("90103");
+ 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;
-
- 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);
+ GTask *task;
+
+ 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=?.