From 590d8130ace366a9c00fa41ee8cdfe300fb1f6b0 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 | 6 ++++++ src/gclue-config.c | 29 ++++++++++++++++++++++++++++- src/gclue-config.h | 1 + src/gclue-locator.c | 10 +++++++--- 4 files changed, 42 insertions(+), 4 deletions(-) diff --git a/data/geoclue.conf.in b/data/geoclue.conf.in index 4b8f81b..d98e0f1 100644 --- a/data/geoclue.conf.in +++ b/data/geoclue.conf.in @@ -7,6 +7,12 @@ # separated by a ';'. whitelist=@demo_agent@gnome-shell +# NMEASource configuration options +[networksource] + +# Fetch location from NMEA sources on local network? +use-nmea-source=true + # WiFi source configuration options [wifi] diff --git a/src/gclue-config.c b/src/gclue-config.c index 2ef5f83..2fe81ea 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; @@ -111,7 +112,7 @@ load_agent_config (GClueConfig *config) static void load_app_configs (GClueConfig *config) { - const char *known_groups[] = { "agent", "wifi", NULL }; + const char *known_groups[] = { "agent", "wifi", "networksource", NULL }; GClueConfigPrivate *priv = config->priv; gsize num_groups = 0, i; char **groups; @@ -232,6 +233,25 @@ load_wifi_config (GClueConfig *config) } static void +load_network_source_config (GClueConfig *config) +{ + GClueConfigPrivate *priv = config->priv; + GError *error = NULL; + + priv->use_nmea_source = g_key_file_get_boolean (priv->key_file, + "networksource", + "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; + } +} + +static void gclue_config_init (GClueConfig *config) { GError *error = NULL; @@ -256,6 +276,7 @@ gclue_config_init (GClueConfig *config) load_agent_config (config); load_app_configs (config); load_wifi_config (config); + load_network_source_config (config); } GClueConfig * @@ -383,6 +404,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 5f60304..870a3b2 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" @@ -282,6 +283,7 @@ gclue_locator_constructed (GObject *object) { GClueLocator *locator = GCLUE_LOCATOR (object); GClueLocationSource *submit_source = NULL; + GClueConfig *gconfig = gclue_config_get_singleton (); GList *node; G_OBJECT_CLASS (gclue_locator_parent_class)->constructed (object); @@ -303,9 +305,11 @@ gclue_locator_constructed (GObject *object) submit_source = GCLUE_LOCATION_SOURCE (gps); #endif #if GCLUE_USE_NMEA_SOURCE - 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); + } #endif for (node = locator->priv->sources; node != NULL; node = node->next) { -- 2.1.0