...
 
Commits (2)
......@@ -48,6 +48,7 @@ struct _GClueLocationSourcePrivate
GClueAccuracyLevel avail_accuracy_level;
gboolean compute_movement;
gboolean scramble_location;
GClueCompass *compass;
......@@ -62,6 +63,7 @@ enum
PROP_TIME_THRESHOLD,
PROP_AVAILABLE_ACCURACY_LEVEL,
PROP_COMPUTE_MOVEMENT,
PROP_SCRAMBLE_LOCATION,
LAST_PROP
};
......@@ -137,6 +139,10 @@ gclue_location_source_get_property (GObject *object,
g_value_set_boolean (value, source->priv->compute_movement);
break;
case PROP_SCRAMBLE_LOCATION:
g_value_set_boolean (value, source->priv->scramble_location);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
......@@ -167,6 +173,10 @@ gclue_location_source_set_property (GObject *object,
source->priv->compute_movement = g_value_get_boolean (value);
break;
case PROP_SCRAMBLE_LOCATION:
source->priv->scramble_location = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
......@@ -247,6 +257,17 @@ gclue_location_source_class_init (GClueLocationSourceClass *klass)
g_object_class_install_property (object_class,
PROP_COMPUTE_MOVEMENT,
gParamSpecs[PROP_COMPUTE_MOVEMENT]);
gParamSpecs[PROP_SCRAMBLE_LOCATION] =
g_param_spec_boolean ("scramble-location",
"ScrambleLocation",
"Enable location scrambling",
FALSE,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY);
g_object_class_install_property (object_class,
PROP_SCRAMBLE_LOCATION,
gParamSpecs[PROP_SCRAMBLE_LOCATION]);
}
static void
......@@ -373,6 +394,33 @@ gclue_location_source_set_location (GClueLocationSource *source,
cur_location = priv->location;
priv->location = gclue_location_duplicate (location);
if (priv->scramble_location) {
gdouble latitude, distance, accuracy;
latitude = geocode_location_get_latitude
(GEOCODE_LOCATION (priv->location));
accuracy = geocode_location_get_accuracy
(GEOCODE_LOCATION (priv->location));
/* Randomization is needed to stop apps from calculationg the
* actual location.
*/
distance = (gdouble) g_random_int_range (1000, 3000);
/* 1 km in latitude is always N degrees */
if (g_random_boolean ())
latitude += distance * N;
else
latitude -= distance * N;
accuracy += 3000;
g_object_set (G_OBJECT (priv->location),
"latitude", latitude,
"accuracy", latitude,
NULL);
g_debug ("location scrambled");
}
speed = gclue_location_get_speed (location);
if (speed == GCLUE_LOCATION_SPEED_UNKNOWN) {
if (cur_location != NULL && priv->compute_movement) {
......
......@@ -24,6 +24,7 @@
#include <string.h>
#include <config.h>
#include "gclue-wifi.h"
#include "gclue-config.h"
#include "gclue-error.h"
#include "gclue-mozilla.h"
......@@ -569,8 +570,12 @@ gclue_wifi_constructed (GObject *object)
G_OBJECT_CLASS (gclue_wifi_parent_class)->constructed (object);
if (wifi->priv->accuracy_level == GCLUE_ACCURACY_LEVEL_CITY)
goto refresh_n_exit;
if (wifi->priv->accuracy_level == GCLUE_ACCURACY_LEVEL_CITY) {
GClueConfig *config = gclue_config_get_singleton ();
if (!gclue_config_get_enable_wifi_source (config))
goto refresh_n_exit;
}
/* FIXME: We should be using async variant */
priv->supplicant = wpa_supplicant_proxy_new_for_bus_sync
......@@ -629,15 +634,26 @@ gclue_wifi_get_singleton (GClueAccuracyLevel level)
{
static GClueWifi *wifi[] = { NULL, NULL };
guint i;
gboolean scramble_location = FALSE;
g_return_val_if_fail (level >= GCLUE_ACCURACY_LEVEL_CITY, NULL);
if (level == GCLUE_ACCURACY_LEVEL_NEIGHBORHOOD)
level = GCLUE_ACCURACY_LEVEL_CITY;
i = (level == GCLUE_ACCURACY_LEVEL_CITY)? 0 : 1;
if (level == GCLUE_ACCURACY_LEVEL_CITY) {
GClueConfig *config = gclue_config_get_singleton ();
i = 0;
if (!gclue_config_get_enable_wifi_source (config))
scramble_location = TRUE;
} else {
i = 1;
}
if (wifi[i] == NULL) {
wifi[i] = g_object_new (GCLUE_TYPE_WIFI,
"accuracy-level", level,
"scramble-location", scramble_location,
NULL);
g_object_weak_ref (G_OBJECT (wifi[i]),
on_wifi_destroyed,
......