From: Guillaume Desmottes Date: Tue, 18 May 2010 20:19:28 +0000 (+0200) Subject: actually implement location bluring X-Git-Tag: azimuth-0.2~4 X-Git-Url: https://vcs.maemo.org/git/?p=azimuth;a=commitdiff_plain;h=f418b16fe12e5a4248ecc7d45cf0d3bd38dbd588 actually implement location bluring --- diff --git a/src/azimuth.c b/src/azimuth.c index 392805c..712ea9d 100644 --- a/src/azimuth.c +++ b/src/azimuth.c @@ -68,6 +68,21 @@ update_gps (Azimuth *self) } static void +update_blur (Azimuth *self) +{ + AzimuthPrivate *priv = AZIMUTH_GET_PRIVATE (self); + gboolean blur; + + if (priv->publisher == NULL) + return; + + blur = gconf_client_get_bool (priv->gconf, + AZIMUTH_GCONF_KEY_BLUR, NULL); + + position_publisher_set_blur (priv->publisher, blur); +} + +static void enabled_changed (Azimuth *self, gboolean enabled) { @@ -79,7 +94,9 @@ enabled_changed (Azimuth *self, return; g_print ("enable publishing\n"); - priv->publisher = position_publisher_new (TRUE); + priv->publisher = position_publisher_new (); + + update_blur (self); } else { @@ -112,11 +129,17 @@ gconf_notification_cb (GConfClient *client, enabled_changed (self, enabled); } - if (!tp_strdiff (key, AZIMUTH_GCONF_KEY_START_GPS) && + else if (!tp_strdiff (key, AZIMUTH_GCONF_KEY_START_GPS) && value->type == GCONF_VALUE_BOOL) { update_gps (self); } + + else if (!tp_strdiff (key, AZIMUTH_GCONF_KEY_BLUR) && + value->type == GCONF_VALUE_BOOL) + { + update_blur (self); + } } static void @@ -208,9 +231,10 @@ azimuth_run (Azimuth *self) { g_print ("publishing is enabled\n"); g_assert (priv->publisher == NULL); - priv->publisher = position_publisher_new (TRUE); + priv->publisher = position_publisher_new (); update_gps (self); + update_blur (self); } else { diff --git a/src/position-publisher.c b/src/position-publisher.c index 332c8d0..c0c57fd 100644 --- a/src/position-publisher.c +++ b/src/position-publisher.c @@ -168,6 +168,15 @@ update_position (PositionPublisher *self, { PositionPublisherPrivate *priv = POSITION_PUBLISHER_GET_PRIVATE (self); + if (priv->blur) + { + /* Truncate at 1 decimal place */ + lon = ((int) (lon * 10)) / 10.0; + lat = ((int) (lat * 10)) / 10.0; + + /* FIXME: change accuracy (not that easy as accuracy is in meters) */ + } + g_print ("update position: lat: %f lon: %f alt: %f accuracy: %f\n", lat, lon, alt, accuracy); @@ -379,9 +388,19 @@ position_publisher_set_property (GObject *object, } PositionPublisher * -position_publisher_new (gboolean blur) +position_publisher_new (void) { return g_object_new (POSITION_PUBLISHER_TYPE, - "blur", blur, NULL); } + +void +position_publisher_set_blur (PositionPublisher *self, + gboolean blur) +{ + PositionPublisherPrivate *priv = POSITION_PUBLISHER_GET_PRIVATE (self); + + g_print ("%s blurring location\n", blur ? "Start": "Stop"); + priv->blur = blur; + g_object_notify (G_OBJECT (self), "blur"); +} diff --git a/src/position-publisher.h b/src/position-publisher.h index 97b1e9f..1ad94f0 100644 --- a/src/position-publisher.h +++ b/src/position-publisher.h @@ -52,7 +52,10 @@ GType position_publisher_get_type (void); #define POSITION_PUBLISHER_GET_CLASS(obj) \ (G_TYPE_INSTANCE_GET_CLASS ((obj), POSITION_PUBLISHER_TYPE, PositionPublisherClass)) -PositionPublisher * position_publisher_new (gboolean start_gps); +PositionPublisher * position_publisher_new (void); + +void position_publisher_set_blur (PositionPublisher *self, + gboolean blur); G_END_DECLS