From 540a9eb0d35e13944eb7183156a85a364268b86c Mon Sep 17 00:00:00 2001 From: Ankit Date: Sun, 5 Jul 2015 15:00:55 +0530 Subject: [PATCH] Add config option for NMEA source This patch adds configuration option which will tell us whether we want to use GClueNMEASource or not. https://bugs.freedesktop.org/show_bug.cgi?id=90974 --- data/geoclue.conf.in | 3 +++ src/gclue-config.c | 19 +++++++++++++++++++ src/gclue-config.h | 1 + src/gclue-locator.c | 10 +++++++--- 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/data/geoclue.conf.in b/data/geoclue.conf.in index 4b8f81b..5256982 100644 --- a/data/geoclue.conf.in +++ b/data/geoclue.conf.in @@ -26,6 +26,9 @@ url=https://location.services.mozilla.com/v1/geolocate?key=geoclue # submit-data=false +# Fetch location from NMEA sources on local network? +use-nmea-source=true + # URL to submission API of Mozilla Location Service submission-url=https://location.services.mozilla.com/v1/submit?key=geoclue diff --git a/src/gclue-config.c b/src/gclue-config.c index 2ef5f83..a84bb26 100644 --- a/src/gclue-config.c +++ b/src/gclue-config.c @@ -56,6 +56,7 @@ struct _GClueConfigPrivate char *wifi_url; gboolean wifi_submit; + gboolean use_nmea_source; char *wifi_submit_url; char *wifi_submit_nick; @@ -211,6 +212,18 @@ load_wifi_config (GClueConfig *config) return; } + priv->use_nmea_source = g_key_file_get_boolean (priv->key_file, + "wifi", + "use-nmea-source", + &error); + if (error != NULL) { + g_debug ("Failed to get config wifi/use-nmea-source: %s", + error->message); + g_error_free (error); + + return; + } + priv->wifi_submit_url = g_key_file_get_string (priv->key_file, "wifi", "submission-url", @@ -383,6 +396,12 @@ gclue_config_get_wifi_submit_data (GClueConfig *config) return config->priv->wifi_submit; } +gboolean +gclue_config_get_use_nmea_source (GClueConfig *config) +{ + return config->priv->use_nmea_source; +} + void gclue_config_set_wifi_submit_data (GClueConfig *config, gboolean submit) diff --git a/src/gclue-config.h b/src/gclue-config.h index 93e12c5..f0ce5de 100644 --- a/src/gclue-config.h +++ b/src/gclue-config.h @@ -78,6 +78,7 @@ const char * gclue_config_get_wifi_submit_nick (GClueConfig *config); void gclue_config_set_wifi_submit_nick (GClueConfig *config, const char *nick); gboolean gclue_config_get_wifi_submit_data (GClueConfig *config); +gboolean gclue_config_get_use_nmea_source (GClueConfig *config); void gclue_config_set_wifi_submit_data (GClueConfig *config, gboolean submit); diff --git a/src/gclue-locator.c b/src/gclue-locator.c index 82f06e5..99aad55 100644 --- a/src/gclue-locator.c +++ b/src/gclue-locator.c @@ -28,6 +28,7 @@ #include "public-api/gclue-enum-types.h" #include "gclue-wifi.h" +#include "gclue-config.h" #if GCLUE_USE_3G_SOURCE #include "gclue-3g.h" @@ -281,6 +282,7 @@ gclue_locator_constructed (GObject *object) GClueLocator *locator = GCLUE_LOCATOR (object); GClueLocationSource *submit_source = NULL; GList *node; + GClueConfig *gconfig = gclue_config_get_singleton (); G_OBJECT_CLASS (gclue_locator_parent_class)->constructed (object); @@ -300,9 +302,11 @@ gclue_locator_constructed (GObject *object) locator->priv->sources = g_list_append (locator->priv->sources, gps); submit_source = GCLUE_LOCATION_SOURCE (gps); #endif - GClueNMEASource *nmea = gclue_nmea_source_get_singleton (); - locator->priv->sources = g_list_append (locator->priv->sources, - nmea); + if (gclue_config_get_use_nmea_source (gconfig)) { + GClueNMEASource *nmea = gclue_nmea_source_get_singleton (); + locator->priv->sources = g_list_append (locator->priv->sources, + nmea); + } for (node = locator->priv->sources; node != NULL; node = node->next) { g_signal_connect (G_OBJECT (node->data), -- 2.1.0