diff options
author | Emilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk> | 2016-02-15 12:42:22 +0100 |
---|---|---|
committer | Zeeshan Ali (Khattak) <zeeshanak@gnome.org> | 2016-04-20 18:40:41 +0100 |
commit | 104ab575078812c012eadd983d905c6a0f0fea04 (patch) | |
tree | c6f5ea4c545815f799bb166059078bd11f7556f2 | |
parent | a3d29b68d02a52ac3c7b865584c05aa83bea78e3 (diff) | |
download | geoclue-104ab575078812c012eadd983d905c6a0f0fea04.tar.gz |
Expose the location's timestamp over D-Bus
https://bugs.freedesktop.org/show_bug.cgi?id=94157
-rw-r--r-- | docs/lib/libgeoclue-sections.txt | 3 | ||||
-rw-r--r-- | src/gclue-location.c | 3 | ||||
-rw-r--r-- | src/gclue-location.h | 1 | ||||
-rw-r--r-- | src/gclue-service-location.c | 15 | ||||
-rw-r--r-- | src/org.freedesktop.GeoClue2.Location.xml | 16 |
5 files changed, 38 insertions, 0 deletions
diff --git a/docs/lib/libgeoclue-sections.txt b/docs/lib/libgeoclue-sections.txt index 8d21a10..566c982 100644 --- a/docs/lib/libgeoclue-sections.txt +++ b/docs/lib/libgeoclue-sections.txt @@ -129,6 +129,9 @@ gclue_location_set_heading gclue_location_get_description gclue_location_dup_description gclue_location_set_description +gclue_location_get_timestamp +gclue_location_dup_timestamp +gclue_location_set_timestamp <SUBSECTION Standard> GCLUE_IS_LOCATION GCLUE_LOCATION diff --git a/src/gclue-location.c b/src/gclue-location.c index e6ee98c..b833a7a 100644 --- a/src/gclue-location.c +++ b/src/gclue-location.c @@ -326,6 +326,7 @@ gclue_location_new (gdouble latitude, * @speed: speed in meters per second * @heading: heading in degrees * @altitude: altitude of location in meters + * @timestamp: timestamp in seconds since the Epoch * @description: a description for the location * * Creates a new #GClueLocation object. @@ -339,6 +340,7 @@ gclue_location_new_full (gdouble latitude, gdouble speed, gdouble heading, gdouble altitude, + guint64 timestamp, const char *description) { return g_object_new (GCLUE_TYPE_LOCATION, @@ -348,6 +350,7 @@ gclue_location_new_full (gdouble latitude, "speed", speed, "heading", heading, "altitude", altitude, + "timestamp", timestamp, "description", description, NULL); } diff --git a/src/gclue-location.h b/src/gclue-location.h index 5f806e6..e96e479 100644 --- a/src/gclue-location.h +++ b/src/gclue-location.h @@ -86,6 +86,7 @@ GClueLocation *gclue_location_new_full gdouble speed, gdouble heading, gdouble altitude, + guint64 timestamp, const char *description); GClueLocation *gclue_location_create_from_gga diff --git a/src/gclue-service-location.c b/src/gclue-service-location.c index 4e5cc66..79faadf 100644 --- a/src/gclue-service-location.c +++ b/src/gclue-service-location.c @@ -90,8 +90,15 @@ gclue_service_location_get_property (GObject *object, { GClueDBusLocation *location; GClueLocation *loc; + GVariant *timestamp; + guint64 sec, usec; location = GCLUE_DBUS_LOCATION (object); + + timestamp = gclue_dbus_location_get_timestamp (location); + g_variant_get (timestamp, "(tt)", &sec, &usec); + g_variant_unref (timestamp); + loc = gclue_location_new_full (gclue_dbus_location_get_latitude (location), gclue_dbus_location_get_longitude (location), @@ -99,6 +106,7 @@ gclue_service_location_get_property (GObject *object, gclue_dbus_location_get_speed (location), gclue_dbus_location_get_heading (location), gclue_dbus_location_get_altitude (location), + sec, gclue_dbus_location_get_description (location)); g_value_take_object (value, loc); @@ -137,6 +145,7 @@ gclue_service_location_set_property (GObject *object, GClueLocation *loc; gdouble altitude; GeocodeLocation *g_loc; + GVariant *timestamp; location = GCLUE_DBUS_LOCATION (object); loc = g_value_get_object (value); @@ -153,6 +162,12 @@ gclue_service_location_set_property (GObject *object, (location, gclue_location_get_speed (loc)); gclue_dbus_location_set_heading (location, gclue_location_get_heading (loc)); + timestamp = g_variant_new + ("(tt)", + (guint64) geocode_location_get_timestamp (g_loc), + (guint64) 0); + gclue_dbus_location_set_timestamp + (location, timestamp); altitude = geocode_location_get_altitude (g_loc); if (altitude != GEOCODE_LOCATION_ALTITUDE_UNKNOWN) gclue_dbus_location_set_altitude (location, altitude); diff --git a/src/org.freedesktop.GeoClue2.Location.xml b/src/org.freedesktop.GeoClue2.Location.xml index fd53c79..f2be8e6 100644 --- a/src/org.freedesktop.GeoClue2.Location.xml +++ b/src/org.freedesktop.GeoClue2.Location.xml @@ -74,5 +74,21 @@ geocode-glib. --> <property name="Description" type="s" access="read"/> + + + <!-- + Timestamp: + + The timestamp when the location was determined, in seconds and + microseconds since the Epoch. This is the time of measurement if the + backend provided that information, otherwise the time when GeoClue + received the new location. + + Note that GeoClue can't guarantee that the timestamp will always + monotonically increase, as a backend may not respect that. + Also note that a timestamp can be very old, e.g. because of a cached + location. + --> + <property name="Timestamp" type="(tt)" access="read"/> </interface> </node> |