aboutsummaryrefslogtreecommitdiff
path: root/libmm-glib
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2019-12-31 16:41:28 +0100
committerAleksander Morgado <aleksander@aleksander.es>2019-12-31 16:42:44 +0100
commit9805ffe1b0ecac78fd7009717ad4be623e74c68a (patch)
tree69c5484432149a25ee0ae202006c2efdcd4cff55 /libmm-glib
parent21e5b1d68336ec5a19f71e36c035e19d29623ca2 (diff)
libmm-glib,nmea: new method to get list of traces
Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/issues/120
Diffstat (limited to 'libmm-glib')
-rw-r--r--libmm-glib/mm-location-gps-nmea.c36
-rw-r--r--libmm-glib/mm-location-gps-nmea.h7
2 files changed, 40 insertions, 3 deletions
diff --git a/libmm-glib/mm-location-gps-nmea.c b/libmm-glib/mm-location-gps-nmea.c
index c4c742f0..8bc7db90 100644
--- a/libmm-glib/mm-location-gps-nmea.c
+++ b/libmm-glib/mm-location-gps-nmea.c
@@ -153,6 +153,42 @@ mm_location_gps_nmea_get_trace (MMLocationGpsNmea *self,
/*****************************************************************************/
static void
+build_all_foreach (const gchar *trace_type,
+ const gchar *trace,
+ GPtrArray **built)
+{
+ if (*built == NULL)
+ *built = g_ptr_array_new ();
+ g_ptr_array_add (*built, g_strdup (trace));
+}
+
+/**
+ * mm_location_gps_nmea_get_traces:
+ * @self: a #MMLocationGpsNmea.
+ *
+ * Gets all cached traces.
+ *
+ * Returns: (transfer full): The list of traces, or %NULL if none available. The returned value should be freed with g_strfreev().
+ * Since: 1.14
+ */
+gchar **
+mm_location_gps_nmea_get_traces (MMLocationGpsNmea *self)
+{
+ GPtrArray *built = NULL;
+
+ g_hash_table_foreach (self->priv->traces,
+ (GHFunc)build_all_foreach,
+ &built);
+ if (!built)
+ return NULL;
+
+ g_ptr_array_add (built, NULL);
+ return (gchar **) g_ptr_array_free (built, FALSE);
+}
+
+/*****************************************************************************/
+
+static void
build_full_foreach (const gchar *trace_type,
const gchar *trace,
GString **built)
diff --git a/libmm-glib/mm-location-gps-nmea.h b/libmm-glib/mm-location-gps-nmea.h
index 6c31d984..286069c3 100644
--- a/libmm-glib/mm-location-gps-nmea.h
+++ b/libmm-glib/mm-location-gps-nmea.h
@@ -59,9 +59,10 @@ GType mm_location_gps_nmea_get_type (void);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MMLocationGpsNmea, g_object_unref)
#endif
-const gchar *mm_location_gps_nmea_get_trace (MMLocationGpsNmea *self,
- const gchar *trace_type);
-gchar *mm_location_gps_nmea_build_full (MMLocationGpsNmea *self);
+const gchar *mm_location_gps_nmea_get_trace (MMLocationGpsNmea *self,
+ const gchar *trace_type);
+gchar **mm_location_gps_nmea_get_traces (MMLocationGpsNmea *self);
+gchar *mm_location_gps_nmea_build_full (MMLocationGpsNmea *self);
/*****************************************************************************/
/* ModemManager/libmm-glib/mmcli specific methods */