summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZeeshan Ali <zeenix@collabora.co.uk>2018-09-15 21:38:24 -0400
committerZeeshan Ali <zeenix@collabora.co.uk>2018-09-15 21:45:30 -0400
commitad619eb8922297ddaf88d0c1aebd2560c487bec8 (patch)
treeb9307fee43c4583b653b0e73c5d714b00c2a7220
parent52649d6c838a8c4e4a999de4cf5ba518a4c475cd (diff)
wifi: Use WiFi-based geolocation for city level accuracywip/disable-source-through-config
Since GeoIP can be easily extremely inaccurate, let's use WiFi-geolocation for city accuracy level. We scramble the location a bit so that apps requesting city accuracy level don't end up getting user's street location with 300 meters accuracy.
-rw-r--r--src/gclue-wifi.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/gclue-wifi.c b/src/gclue-wifi.c
index 527bbbf..ef951ed 100644
--- a/src/gclue-wifi.c
+++ b/src/gclue-wifi.c
@@ -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,