summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTeemu Ikonen <tpikonen@mailbox.org>2021-11-22 12:06:26 +0200
committerTeemu Ikonen <tpikonen@mailbox.org>2021-11-28 16:07:38 +0200
commita5bb211a43092c0ceb0a60ec4aabf6beab417460 (patch)
tree11c3278587329aab8f5caaf2df65ae4e8b6b7969
parente4c61f8f76a3d6aa15a1d9b83c68aa1474fd0e82 (diff)
meson, location-source: Allow disabling compass in build
Add option 'compass' to meson_options.txt and set preprocessor directive GCLUE_USE_COMPASS from it. Print compass option value in build summary. Use GCLUE_USE_COMPASS in gclue-location-source.c for conditional compilation of compass functionality.
-rw-r--r--interface/meson.build10
-rw-r--r--meson.build5
-rw-r--r--meson_options.txt3
-rw-r--r--src/gclue-location-source.c14
-rw-r--r--src/meson.build8
5 files changed, 32 insertions, 8 deletions
diff --git a/interface/meson.build b/interface/meson.build
index 9e230a7..74954db 100644
--- a/interface/meson.build
+++ b/interface/meson.build
@@ -66,10 +66,12 @@ if get_option('enable-backend')
interface_prefix: 'fi.w1.wpa_supplicant1.',
annotations: annotations)
- compass_iface_sources = gnome.gdbus_codegen(
- 'compass-interface',
- 'net.hadess.SensorProxy.xml',
- interface_prefix: 'net.hadess.SensorProxy')
+ if get_option('compass')
+ compass_iface_sources = gnome.gdbus_codegen(
+ 'compass-interface',
+ 'net.hadess.SensorProxy.xml',
+ interface_prefix: 'net.hadess.SensorProxy')
+ endif
endif
install_data('org.freedesktop.GeoClue2.Agent.xml',
diff --git a/meson.build b/meson.build
index 7547887..0d9911a 100644
--- a/meson.build
+++ b/meson.build
@@ -35,6 +35,7 @@ conf.set10('GCLUE_USE_3G_SOURCE', get_option('3g-source'))
conf.set10('GCLUE_USE_CDMA_SOURCE', get_option('cdma-source'))
conf.set10('GCLUE_USE_MODEM_GPS_SOURCE', get_option('modem-gps-source'))
conf.set10('GCLUE_USE_NMEA_SOURCE', get_option('nmea-source'))
+conf.set10('GCLUE_USE_COMPASS', get_option('compass'))
configure_file(output: 'config.h', configuration : conf)
configinc = include_directories('.')
@@ -92,6 +93,7 @@ summary = '''
CDMA source: @8@
Modem GPS source: @9@
Network NMEA source: @10@
+ Compass: @11@
'''.format(gclue_version,
get_option('prefix'),
cc.get_id(),
@@ -102,5 +104,6 @@ summary = '''
get_option('3g-source'),
get_option('cdma-source'),
get_option('modem-gps-source'),
- get_option('nmea-source'))
+ get_option('nmea-source'),
+ get_option('compass'))
message(summary)
diff --git a/meson_options.txt b/meson_options.txt
index b1abf16..5b8c42d 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -22,6 +22,9 @@ option('modem-gps-source',
option('nmea-source',
type: 'boolean', value: true,
description: 'Enable network NMEA source (requires Avahi libraries)')
+option('compass',
+ type: 'boolean', value: true,
+ description: 'Enable setting heading from net.hadess.SensorProxy compass')
option('enable-backend',
type: 'boolean', value: true,
description: 'Enable backend (the geoclue service)')
diff --git a/src/gclue-location-source.c b/src/gclue-location-source.c
index 6ca59b8..5d7347d 100644
--- a/src/gclue-location-source.c
+++ b/src/gclue-location-source.c
@@ -20,9 +20,13 @@
*/
#include <glib.h>
+#include <config.h>
#include "gclue-location-source.h"
+
+#if GCLUE_USE_COMPASS
#include "gclue-compass.h"
#include "gclue-config.h"
+#endif
/**
* SECTION:gclue-location-source
@@ -49,7 +53,9 @@ struct _GClueLocationSourcePrivate
gboolean compute_movement;
gboolean scramble_location;
+#if GCLUE_USE_COMPASS
GClueCompass *compass;
+#endif
guint heading_changed_id;
};
@@ -73,6 +79,7 @@ enum
static GParamSpec *gParamSpecs[LAST_PROP];
+#if GCLUE_USE_COMPASS
static gboolean
set_heading_from_compass (GClueLocationSource *source,
GClueLocation *location)
@@ -113,6 +120,7 @@ on_compass_heading_changed (GObject *gobject,
if (set_heading_from_compass (source, source->priv->location))
g_object_notify (G_OBJECT (source), "location");
}
+#endif /* GCLUE_USE_COMPASS */
static void
gclue_location_source_get_property (GObject *object,
@@ -293,6 +301,7 @@ start_source (GClueLocationSource *source)
return GCLUE_LOCATION_SOURCE_START_RESULT_ALREADY_STARTED;
}
+#if GCLUE_USE_COMPASS
if (source->priv->compute_movement) {
GClueConfig *config = gclue_config_get_singleton ();
@@ -308,6 +317,7 @@ start_source (GClueLocationSource *source)
g_debug ("Compass is disabled in config");
}
}
+#endif
g_object_notify (G_OBJECT (source), "active");
g_debug ("%s now active", G_OBJECT_TYPE_NAME (source));
@@ -330,11 +340,13 @@ stop_source (GClueLocationSource *source)
return GCLUE_LOCATION_SOURCE_STOP_RESULT_STILL_USED;
}
+#if GCLUE_USE_COMPASS
if (source->priv->compass) {
g_signal_handler_disconnect (source->priv->compass,
source->priv->heading_changed_id);
g_clear_object (&source->priv->compass);
}
+#endif
g_object_notify (G_OBJECT (source), "active");
g_debug ("%s now inactive", G_OBJECT_TYPE_NAME (source));
@@ -447,7 +459,9 @@ gclue_location_source_set_location (GClueLocationSource *source,
gclue_location_set_speed (priv->location, speed);
}
+#if GCLUE_USE_COMPASS
set_heading_from_compass (source, location);
+#endif
heading = gclue_location_get_heading (location);
if (heading == GCLUE_LOCATION_HEADING_UNKNOWN) {
if (cur_location != NULL && priv->compute_movement)
diff --git a/src/meson.build b/src/meson.build
index 20e740d..13eb1ba 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -3,8 +3,7 @@ geoclue_deps = base_deps + [ dependency('json-glib-1.0', version: '>= 0.14.0'),
sources = [ libgeoclue_public_api_gen_sources[1],
geoclue_iface_sources,
- wpa_supplicant_sources,
- compass_iface_sources ]
+ wpa_supplicant_sources ]
sources += gnome.genmarshal('gclue-marshal',
prefix: 'gclue_marshal',
@@ -17,7 +16,6 @@ include_dirs = [ configinc,
sources += [ 'gclue-main.c',
'gclue-3g-tower.h',
'gclue-client-info.h', 'gclue-client-info.c',
- 'gclue-compass.h', 'gclue-compass.c',
'gclue-config.h', 'gclue-config.c',
'gclue-error.h', 'gclue-error.c',
'gclue-location-source.h', 'gclue-location-source.c',
@@ -58,6 +56,10 @@ if get_option('nmea-source')
sources += [ 'gclue-nmea-source.h', 'gclue-nmea-source.c' ]
endif
+if get_option('compass')
+ sources += [ compass_iface_sources , 'gclue-compass.h', 'gclue-compass.c' ]
+endif
+
c_args = [ '-DG_LOG_DOMAIN="Geoclue"' ]
link_with = [ libgeoclue_public_api ]
executable('geoclue',