aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksandermj@chromium.org>2024-04-01 08:51:09 +0000
committerAleksander Morgado <aleksandermj@chromium.org>2024-04-01 09:07:10 +0000
commit3c4fa90c92fe64e01a5d6dbb28778fc5af3460a1 (patch)
treea9cfa4b521876487fcf95800ef85e9e3b37b0fcf
parentf08803e8589aed29c1566aa069fb261c73175c00 (diff)
shared-quectel: don't assume that parent object supports location
The generic MBIM modem implementation does not have location capabilities support, so the relevant function pointers in the interface are NULL. Fixes: 306566ad7ea8b08241904eefb18507fdf7e7993f
-rw-r--r--src/plugins/quectel/mm-shared-quectel.c60
1 files changed, 40 insertions, 20 deletions
diff --git a/src/plugins/quectel/mm-shared-quectel.c b/src/plugins/quectel/mm-shared-quectel.c
index 03829933..375cbd5b 100644
--- a/src/plugins/quectel/mm-shared-quectel.c
+++ b/src/plugins/quectel/mm-shared-quectel.c
@@ -687,33 +687,25 @@ probe_qgps_ready (MMBaseModem *_self,
}
static void
-parent_load_capabilities_ready (MMIfaceModemLocation *self,
- GAsyncResult *res,
- GTask *task)
+quectel_load_capabilities (GTask *task)
{
- Private *priv;
- MMModemLocationSource sources;
- GError *error = NULL;
+ MMSharedQuectel *self;
+ Private *priv;
- priv = get_private (MM_SHARED_QUECTEL (self));
- sources = priv->iface_modem_location_parent->load_capabilities_finish (self, res, &error);
- if (error) {
- g_task_return_error (task, error);
- g_object_unref (task);
- return;
- }
+ self = MM_SHARED_QUECTEL (g_task_get_source_object (task));
+ priv = get_private (self);
/* Now our own check. If we don't have any GPS port, we're done */
if (!mm_base_modem_peek_port_gps (MM_BASE_MODEM (self))) {
+ MMModemLocationSource sources;
+
+ sources = GPOINTER_TO_UINT (g_task_get_task_data (task));
mm_obj_dbg (self, "no GPS data port found: no GPS capabilities");
g_task_return_int (task, sources);
g_object_unref (task);
return;
}
- /* Store parent supported sources in task data */
- g_task_set_task_data (task, GUINT_TO_POINTER (sources), NULL);
-
/* Probe QGPS support */
g_assert (priv->qgps_supported == FEATURE_SUPPORT_UNKNOWN);
mm_base_modem_at_command (MM_BASE_MODEM (self),
@@ -724,6 +716,27 @@ parent_load_capabilities_ready (MMIfaceModemLocation *self,
task);
}
+static void
+parent_load_capabilities_ready (MMIfaceModemLocation *self,
+ GAsyncResult *res,
+ GTask *task)
+{
+ Private *priv;
+ MMModemLocationSource sources;
+ GError *error = NULL;
+
+ priv = get_private (MM_SHARED_QUECTEL (self));
+ sources = priv->iface_modem_location_parent->load_capabilities_finish (self, res, &error);
+ if (error) {
+ g_task_return_error (task, error);
+ g_object_unref (task);
+ return;
+ }
+
+ g_task_set_task_data (task, GUINT_TO_POINTER (sources), NULL);
+ quectel_load_capabilities (task);
+}
+
void
mm_shared_quectel_location_load_capabilities (MMIfaceModemLocation *_self,
GAsyncReadyCallback callback,
@@ -735,10 +748,17 @@ mm_shared_quectel_location_load_capabilities (MMIfaceModemLocation *_self,
task = g_task_new (_self, NULL, callback, user_data);
priv = get_private (MM_SHARED_QUECTEL (_self));
- /* Chain up parent's setup */
- priv->iface_modem_location_parent->load_capabilities (_self,
- (GAsyncReadyCallback)parent_load_capabilities_ready,
- task);
+ /* Chain up parent's setup, if any */
+ if (priv->iface_modem_location_parent->load_capabilities &&
+ priv->iface_modem_location_parent->load_capabilities_finish) {
+ priv->iface_modem_location_parent->load_capabilities (_self,
+ (GAsyncReadyCallback)parent_load_capabilities_ready,
+ task);
+ return;
+ }
+
+ g_task_set_task_data (task, GUINT_TO_POINTER (MM_MODEM_LOCATION_SOURCE_NONE), NULL);
+ quectel_load_capabilities (task);
}
/*****************************************************************************/