Commit c94e9cc8 authored by Allison Lortie's avatar Allison Lortie Committed by Zeeshan Ali

Add support for disabling some sources

Introduce configure options --disable-wifi-source, --disable-3g-source
and --disable-modem-gps-source to allow disabling of backends that
depend on NetworkManager and ModemManager (since these components are
not widely ported).

There is no "auto detect" -- the options must be explicitly specified in
order to disable the feature.  This prevents a quiet reduction in
functionality just because the right headers didn't happen to be
installed at configure time, which should help prevent packaging
mistakes.

https://bugs.freedesktop.org/show_bug.cgi?id=73961
parent 8c43cf63
......@@ -56,8 +56,6 @@ PKG_CHECK_MODULES(GEOCLUE, [
gio-unix-2.0 >= $GLIB_MIN_VERSION
json-glib-1.0 >= $JSON_GLIB_MIN_VERSION
libsoup-2.4
libnm-glib >= $LIBNM_GLIB_MIN_VERSION
mm-glib >= $LIBMM_GLIB_MIN_VERSION
libxml-2.0 >= $LIBXML_MIN_VERSION
])
......@@ -104,6 +102,58 @@ else
fi
AM_CONDITIONAL([BUILD_GEOIP_SERVER], [test "x$build_geoip_server" = "xyes"])
# 3G source
AC_ARG_ENABLE(3g-source,
AS_HELP_STRING([--disable-3g-source], [Disable 3G backend (requires ModemManager)]),
[build_3g_source=$enableval], [build_3g_source=yes])
if test "$build_3g_source" = "yes"; then
build_modem_source=yes
AC_DEFINE([GCLUE_USE_3G_SOURCE], [1], [Build 3G source?])
else
AC_DEFINE([GCLUE_USE_3G_SOURCE], [0], [Build 3G source?])
fi
AM_CONDITIONAL([BUILD_3G_SOURCE], [test "$build_3g_source" = "yes"])
# GPS source
AC_ARG_ENABLE(modem-gps-source,
AS_HELP_STRING([--disable-gps-source], [Disable GPS backend (requires ModemManager)]),
[build_modem_gps_source=$enableval], [build_modem_gps_source=yes])
if test "$build_modem_gps_source" = "yes"; then
build_modem_source=yes
AC_DEFINE([GCLUE_USE_MODEM_GPS_SOURCE], [1], [Build GPS source?])
else
AC_DEFINE([GCLUE_USE_MODEM_GPS_SOURCE], [0], [Build GPS source?])
fi
AM_CONDITIONAL([BUILD_MODEM_GPS_SOURCE], [test "$build_modem_gps_source" = "yes"])
# Wifi source
AC_ARG_ENABLE(wifi-source,
AS_HELP_STRING([--disable-wifi-source], [Disable Wifi backend (requires ModemManager)]),
[build_wifi_source=$enableval], [build_wifi_source=yes])
if test "$build_wifi_source" = "yes"; then
require_networkmanager=yes
AC_DEFINE([GCLUE_USE_WIFI_SOURCE], [1], [Build Wifi source?])
else
AC_DEFINE([GCLUE_USE_WIFI_SOURCE], [0], [Build Wifi source?])
fi
AM_CONDITIONAL([BUILD_WIFI_SOURCE], [test "$build_wifi_source" = "yes"])
# Modem source is used in common by GPS and 3G sources
if test "$build_modem_source" = "yes"; then
require_modemmanager=yes
fi
AM_CONDITIONAL([BUILD_MODEM_SOURCE], [test "$build_modem_source" = "yes"])
# Check for ModemManager if one of the sources requires it
if test "$require_modemmanager" = "yes"; then
PKG_CHECK_MODULES(ModemManager, mm-glib >= $LIBMM_GLIB_MIN_VERSION)
fi
# Check for NetworkManager if one of the sources requires it
if test "$require_networkmanager" = "yes"; then
PKG_CHECK_MODULES(NetworkManager, libnm-glib >= $LIBNM_GLIB_MIN_VERSION)
fi
# Demo agent
AC_ARG_ENABLE(demo-agent,
AS_HELP_STRING([--enable-demo-agent=yes|no],
......@@ -201,4 +251,8 @@ AC_MSG_NOTICE([
prefix: ${prefix}
c compiler: ${CC} ${CFLAGS}
systemdsystemunitdir: ${systemdsystemunitdir}
3G source: ${build_3g_source}
Wifi source: ${build_wifi_source}
Modem GPS source: ${build_modem_gps_source}
])
......@@ -28,6 +28,8 @@ BUILT_SOURCES = \
noinst_LTLIBRARIES = libgeoclue.la
AM_CPPFLAGS = $(GEOCLUE_CFLAGS) \
$(ModemManager_CFLAGS) \
$(NetworkManager_CFLAGS) \
$(WARN_CFLAGS) \
-DLOCALEDIR="\"$(datadir)/locale\"" \
-DG_LOG_DOMAIN=\""Geoclue"\" \
......@@ -49,24 +51,38 @@ libgeoclue_la_SOURCES = \
gclue-location-source.c \
gclue-locator.h \
gclue-locator.c \
gclue-modem-source.c \
gclue-modem-source.h \
gclue-modem-gps.c \
gclue-modem-gps.h \
gclue-service-manager.h \
gclue-service-manager.c \
gclue-service-client.h \
gclue-service-client.c \
gclue-service-location.h \
gclue-service-location.c \
gclue-wifi.h \
gclue-wifi.c \
gclue-web-source.c \
gclue-web-source.h \
gclue-3g.c \
gclue-3g.h \
$(NULL)
libgeoclue_la_LIBADD = $(GEOCLUE_LIBS) $(LIBS)
if BUILD_WIFI_SOURCE
libgeoclue_la_SOURCES += gclue-wifi.h gclue-wifi.c
endif
if BUILD_MODEM_SOURCE
libgeoclue_la_SOURCES += gclue-modem-source.c gclue-modem-source.h
endif
if BUILD_3G_SOURCE
libgeoclue_la_SOURCES += gclue-3g.c gclue-3g.h
endif
if BUILD_MODEM_GPS_SOURCE
libgeoclue_la_SOURCES += gclue-modem-gps.c gclue-modem-gps.h
endif
libgeoclue_la_LIBADD = \
$(GEOCLUE_LIBS) \
$(NetworkManager_LIBS) \
$(ModemManager_LIBS) \
$(LIBS) \
$(NULL)
geoclue_SOURCES = \
gclue-main.c \
......
......@@ -20,14 +20,25 @@
* Authors: Zeeshan Ali (Khattak) <zeeshanak@gnome.org>
*/
#include "config.h"
#include <glib/gi18n.h>
#include "gclue-locator.h"
#include "gclue-ipclient.h"
#include "public-api/gclue-enum-types.h"
#if GCLUE_USE_WIFI_SOURCE
#include "gclue-wifi.h"
#endif
#if GCLUE_USE_3G_SOURCE
#include "gclue-3g.h"
#endif
#if GCLUE_USE_MODEM_GPS_SOURCE
#include "gclue-modem-gps.h"
#include "public-api/gclue-enum-types.h"
#endif
/* This class is like a master location source that hides all individual
* location sources from rest of the code
......@@ -133,7 +144,7 @@ static void
gclue_locator_constructed (GObject *object)
{
GClueLocator *locator = GCLUE_LOCATOR (object);
GClueModemGPS *gps = NULL;
GClueLocationSource *submit_source = NULL;
GList *node;
if (locator->priv->accuracy_level >= GCLUE_IPCLIENT_ACCURACY_LEVEL) {
......@@ -141,21 +152,28 @@ gclue_locator_constructed (GObject *object)
locator->priv->sources = g_list_append (locator->priv->sources,
ipclient);
}
#if GCLUE_USE_3G_SOURCE
if (locator->priv->accuracy_level >= GCLUE_3G_ACCURACY_LEVEL) {
GClue3G *source = gclue_3g_get_singleton ();
locator->priv->sources = g_list_append (locator->priv->sources,
source);
}
#endif
#if GCLUE_USE_WIFI_SOURCE
if (locator->priv->accuracy_level >= GCLUE_WIFI_ACCURACY_LEVEL) {
GClueWifi *wifi = gclue_wifi_get_singleton ();
locator->priv->sources = g_list_append (locator->priv->sources,
wifi);
}
#endif
#if GCLUE_USE_MODEM_GPS_SOURCE
if (locator->priv->accuracy_level >= GCLUE_MODEM_GPS_ACCURACY_LEVEL) {
gps = gclue_modem_gps_get_singleton ();
GClueModemGPS *gps = gclue_modem_gps_get_singleton ();
locator->priv->sources = g_list_append (locator->priv->sources,
gps);
submit_source = GCLUE_LOCATION_SOURCE (gps);
}
#endif
for (node = locator->priv->sources; node != NULL; node = node->next) {
GClueLocationSource *src = GCLUE_LOCATION_SOURCE (node->data);
......@@ -171,10 +189,10 @@ gclue_locator_constructed (GObject *object)
G_CALLBACK (on_location_changed),
locator);
if (gps != NULL && GCLUE_IS_WEB_SOURCE (src))
if (submit_source != NULL && GCLUE_IS_WEB_SOURCE (src))
gclue_web_source_set_submit_source
(GCLUE_WEB_SOURCE (src),
GCLUE_LOCATION_SOURCE (gps));
submit_source);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment