Merge pull request #497 from jonls/remove-geoclue-1

Remove deprecated GeoClue 1 location provider
This commit is contained in:
Jon Lund Steffensen
2017-08-16 20:57:25 -07:00
committed by GitHub
11 changed files with 61 additions and 359 deletions
+37 -14
View File
@@ -1,15 +1,38 @@
dist: trusty
sudo: required
language: c
before_install:
- sed -i -e 's|AC_PREREQ(\[2.69\])|AC_PREREQ([2.68])|' configure.ac
- sudo apt-get update -qq
install:
- sudo apt-get install -qq autopoint intltool
- sudo apt-get install -qq libdrm-dev
- sudo apt-get install -qq libxcb1-dev libxcb-randr0-dev
- sudo apt-get install -qq libx11-dev libxxf86vm-dev
- sudo apt-get install -qq libgeoclue-dev
- sudo apt-get install -qq libglib2.0-dev
- sudo apt-get install -qq python3
script: ./bootstrap && ./configure --enable-drm --enable-vidmode --enable-randr --enable-geoclue --enable-geoclue2 --enable-gui && make -j2 distcheck
matrix:
include:
- os: linux
compiler: gcc
dist: trusty
sudo: false
# - os: osx
# compiler: clang
addons:
apt:
packages:
- autopoint
- intltool
# DRM
- libdrm-dev
# RANDR
- libxcb1-dev
- libxcb-randr0-dev
# VidMode
- libx11-dev
- libxxf86vm-dev
# GeoClue2
- libglib2.0-dev
# GUI
- python3
install: |
if [ "$TRAVIS_OS_NAME" == "osx" ]; then
brew install gettext
brew install intltool
fi
script: |
./bootstrap && ./configure --enable-drm --enable-vidmode --enable-randr --enable-geoclue2 --enable-gui && make -j2 distcheck
+3 -3
View File
@@ -52,7 +52,7 @@ Dependencies
* libdrm (Optional, for DRM support)
* libxcb, libxcb-randr (Optional, for RandR support)
* libX11, libXxf86vm (Optional, for VidMode support)
* geoclue (Optional, for geoclue support)
* Glib 2 (Optional, for GeoClue2 support)
* python3, pygobject, pyxdg (Optional, for GUI support)
* appindicator (Optional, for Ubuntu-style GUI status icon)
@@ -158,8 +158,8 @@ Install MinGW and run `configure` using the following command line. Use
``` shell
$ ./configure --disable-drm --disable-randr --disable-vidmode --enable-wingdi \
--disable-geoclue --disable-gui --disable-ubuntu \
--host=x86_64-w64-mingw32
--disable-quartz --disable-geoclue2 --disable-corelocation --disable-gui \
--disable-ubuntu --host=x86_64-w64-mingw32
```
+2 -2
View File
@@ -64,8 +64,8 @@ of gamma ramps, which is what Redshift uses to change the screen color
temperature. There's also "wingdi" which is for the Windows version,
and "drm" which allows manipulation of gamma ramps in a TTY in Linux.
Then there are location providers: "manual", "gnome-clock" and
"geoclue". Some time ago there was only one way to specify the
Then there are location providers: "manual", "geoclue2" and "corelocation".
Some time ago there was only one way to specify the
location which had to be done manually with the argument "-l LAT:LON".
Then later, automatic "location providers" were added and the syntax
had to be changed to "-l PROVIDER:OPTIONS" where OPTIONS are arguments
+1 -1
View File
@@ -17,7 +17,7 @@ build_script:
$env:MSYSTEM = "MINGW32"
}
$env:CONFIGURE_FLAGS = "--disable-drm --disable-randr --disable-vidmode --enable-wingdi --disable-quartz --disable-geoclue --disable-geoclue2 --disable-corelocation --disable-gui --disable-ubuntu --disable-nls --host=$env:arch-w64-mingw32"
$env:CONFIGURE_FLAGS = "--disable-drm --disable-randr --disable-vidmode --enable-wingdi --disable-quartz --disable-geoclue2 --disable-corelocation --disable-gui --disable-ubuntu --disable-nls --host=$env:arch-w64-mingw32"
- ps: md (Join-Path $env:APPVEYOR_BUILD_FOLDER root)
- C:\msys64\usr\bin\bash -lc "cd $APPVEYOR_BUILD_FOLDER && ./bootstrap"
+9 -35
View File
@@ -13,7 +13,7 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
# Checks for programs.
AC_PROG_CC_C99
AC_PROG_LIBTOOL
AC_PROG_OBJC # For OSX support modules
AC_PROG_OBJC # For macOS support modules
AC_LANG([C])
AC_PROG_INTLTOOL([0.50])
@@ -69,10 +69,9 @@ PKG_CHECK_MODULES([XCB_RANDR], [xcb-randr],
[have_xcb_randr=yes], [have_xcb_randr=no])
PKG_CHECK_MODULES([GLIB], [glib-2.0 gobject-2.0], [have_glib=yes], [have_glib=no])
PKG_CHECK_MODULES([GEOCLUE], [geoclue], [have_geoclue=yes], [have_geoclue=no])
PKG_CHECK_MODULES([GEOCLUE2], [glib-2.0 gio-2.0 >= 2.26], [have_geoclue2=yes], [have_geoclue2=no])
# OSX headers
# macOS headers
AC_CHECK_HEADER([ApplicationServices/ApplicationServices.h], [have_appserv_h=yes], [have_appserv_h=no])
# CoreLocation.h is an Objective C header. Only test if
@@ -173,10 +172,10 @@ AS_IF([test "x$enable_vidmode" != xno], [
])
AM_CONDITIONAL([ENABLE_VIDMODE], [test "x$enable_vidmode" = xyes])
# Check Quartz (OSX) method
# Check Quartz (macOS) method
AC_MSG_CHECKING([whether to enable Quartz method])
AC_ARG_ENABLE([quartz], [AC_HELP_STRING([--enable-quartz],
[enable Quartz (OSX) method])],
[enable Quartz (macOS) method])],
[enable_quartz=$enableval],[enable_quartz=maybe])
AS_IF([test "x$enable_quartz" != xno], [
AS_IF([test $have_appserv_h = yes], [
@@ -226,30 +225,6 @@ AS_IF([test "x$enable_wingdi" != xno], [
AM_CONDITIONAL([ENABLE_WINGDI], [test "x$enable_wingdi" = xyes])
# Check Geoclue location provider
AC_MSG_CHECKING([whether to enable Geoclue location provider])
AC_ARG_ENABLE([geoclue], [AC_HELP_STRING([--enable-geoclue],
[enable Geoclue location provider])],
[enable_geoclue=$enableval],[enable_geoclue=maybe])
AS_IF([test "x$enable_geoclue" != xno], [
AS_IF([test "x$have_geoclue" = xyes -a "x$have_glib" = xyes], [
AC_DEFINE([ENABLE_GEOCLUE], 1,
[Define to 1 to enable Geoclue location provider])
AC_MSG_RESULT([yes])
enable_geoclue=yes
], [
AC_MSG_RESULT([missing dependencies])
AS_IF([test "x$enable_geoclue" = xyes], [
AC_MSG_ERROR([missing dependencies for Geoclue location provider])
])
enable_geoclue=no
])
], [
AC_MSG_RESULT([no])
enable_geoclue=no
])
AM_CONDITIONAL([ENABLE_GEOCLUE], [test "x$enable_geoclue" = xyes])
# Check Geoclue2 location provider
AC_MSG_CHECKING([whether to enable Geoclue2 location provider])
AC_ARG_ENABLE([geoclue2], [AC_HELP_STRING([--enable-geoclue2],
@@ -274,10 +249,10 @@ AS_IF([test "x$enable_geoclue2" != xno], [
])
AM_CONDITIONAL([ENABLE_GEOCLUE2], [test "x$enable_geoclue2" = xyes])
# Check CoreLocation (OSX) provider
# Check CoreLocation (macOS) provider
AC_MSG_CHECKING([whether to enable CoreLocation method])
AC_ARG_ENABLE([corelocation], [AC_HELP_STRING([--enable-corelocation],
[enable CoreLocation (OSX) provider])],
[enable CoreLocation (macOS) provider])],
[enable_corelocation=$enableval],[enable_corelocation=maybe])
AS_IF([test "x$enable_corelocation" != xno], [
AS_IF([test "x$have_corelocation_h" = xyes], [
@@ -388,13 +363,12 @@ echo "
DRM: ${enable_drm}
RANDR: ${enable_randr}
VidMode: ${enable_vidmode}
Quartz (OSX): ${enable_quartz}
Quartz (macOS): ${enable_quartz}
WinGDI (Windows): ${enable_wingdi}
Location providers:
Geoclue: ${enable_geoclue}
Geoclue2: ${enable_geoclue2}
CoreLocation (OSX) ${enable_corelocation}
Geoclue2: ${enable_geoclue2}
CoreLocation (macOS): ${enable_corelocation}
GUI: ${enable_gui}
Ubuntu icons: ${enable_ubuntu}
-1
View File
@@ -15,7 +15,6 @@ src/gamma-quartz.c
src/gamma-w32gdi.c
src/gamma-dummy.c
src/location-geoclue.c
src/location-geoclue2.c
src/location-corelocation.m
src/location-manual.c
+1 -1
View File
@@ -24,7 +24,7 @@ gamma=0.8
;gamma-day=0.8:0.7:0.8
;gamma-night=0.6
; Set the location-provider: 'geoclue', 'geoclue2', 'manual'
; Set the location-provider: 'geoclue2', 'manual'
; type 'redshift -l list' to see possible values.
; The location provider settings are in a different section.
location-provider=manual
+8 -17
View File
@@ -9,15 +9,15 @@ AM_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\"
bin_PROGRAMS = redshift
redshift_SOURCES = \
redshift.c redshift.h \
signals.c signals.h \
colorramp.c colorramp.h \
config-ini.c config-ini.h \
location-manual.c location-manual.h \
solar.c solar.h \
systemtime.c systemtime.h \
gamma-dummy.c gamma-dummy.h \
hooks.c hooks.h \
gamma-dummy.c gamma-dummy.h
location-manual.c location-manual.h \
redshift.c redshift.h \
signals.c signals.h \
solar.c solar.h \
systemtime.c systemtime.h
EXTRA_redshift_SOURCES = \
gamma-drm.c gamma-drm.h \
@@ -25,7 +25,8 @@ EXTRA_redshift_SOURCES = \
gamma-vidmode.c gamma-vidmode.h \
gamma-quartz.c gamma-quartz.h \
gamma-w32gdi.c gamma-w32gdi.h \
location-geoclue.c location-geoclue.h \
location-geoclue2.c location-geoclue2.h \
location-corelocation.m location-corelocation.h \
windows/appicon.rc \
windows/versioninfo.rc
@@ -69,16 +70,6 @@ redshift_LDADD += -lgdi32
endif
if ENABLE_GEOCLUE
redshift_SOURCES += location-geoclue.c location-geoclue.h
AM_CFLAGS += \
$(GEOCLUE_CFLAGS) $(GEOCLUE_LIBS) \
$(GLIB_CFLAGS) $(GLIB_LIBS)
redshift_LDADD += \
$(GEOCLUE_LIBS) $(GEOCLUE_CFLAGS)
$(GLIB_LIBS) $(GLIB_CFLAGS)
endif
if ENABLE_GEOCLUE2
redshift_SOURCES += location-geoclue2.c location-geoclue2.h
AM_CFLAGS += \
-218
View File
@@ -1,218 +0,0 @@
/* location-geoclue.c -- Geoclue location provider source
This file is part of Redshift.
Redshift is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Redshift is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Redshift. If not, see <http://www.gnu.org/licenses/>.
Copyright (c) 2010 Mathieu Trudel-Lapierre <mathieu-tl@ubuntu.com>
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <geoclue/geoclue-master.h>
#include <geoclue/geoclue-position.h>
#include <glib.h>
#include <glib-object.h>
#include "location-geoclue.h"
#include "redshift.h"
#ifdef ENABLE_NLS
# include <libintl.h>
# define _(s) gettext(s)
#else
# define _(s) s
#endif
#define DEFAULT_PROVIDER "org.freedesktop.Geoclue.Providers.UbuntuGeoIP"
#define DEFAULT_PROVIDER_PATH "/org/freedesktop/Geoclue/Providers/UbuntuGeoIP"
int
location_geoclue_init(location_geoclue_state_t *state)
{
#if !GLIB_CHECK_VERSION(2, 35, 0)
g_type_init();
#endif
state->position = NULL;
state->provider = NULL;
state->provider_path = NULL;
return 0;
}
int
location_geoclue_start(location_geoclue_state_t *state)
{
if (state->provider && state->provider_path) {
state->position = geoclue_position_new(state->provider,
state->provider_path);
} else {
if (getenv("DISPLAY") == NULL || *getenv("DISPLAY") == '\0') {
/* TODO This (hack) should be removed when GeoClue has been patched. */
putenv("DISPLAY=:0");
}
GError *error = NULL;
GeoclueMaster *master = geoclue_master_get_default();
GeoclueMasterClient *client = geoclue_master_create_client(master,
NULL, &error);
g_object_unref(master);
if (client == NULL) {
if (error != NULL) {
g_printerr(_("Unable to obtain master client: %s\n"),
error->message);
g_error_free(error);
} else {
g_printerr(_("Unable to obtain master client\n"));
}
return -1;
}
if (!geoclue_master_client_set_requirements(client,
GEOCLUE_ACCURACY_LEVEL_REGION,
0, FALSE,
GEOCLUE_RESOURCE_NETWORK,
&error)) {
if (error != NULL) {
g_printerr(_("Can't set requirements for master: %s\n"),
error->message);
g_error_free(error);
} else {
g_printerr(_("Can't set requirements for master\n"));
}
g_object_unref(client);
return -1;
}
state->position = geoclue_master_client_create_position(client, NULL);
g_object_unref(client);
}
gchar *name = NULL;
if (geoclue_provider_get_provider_info(GEOCLUE_PROVIDER(state->position),
&name, NULL, NULL)) {
fprintf(stdout, _("Started Geoclue provider `%s'.\n"), name);
g_free(name);
} else {
fputs(_("Could not find a usable Geoclue provider.\n"), stderr);
fputs(_("Try setting name and path to specify which to use.\n"), stderr);
return -1;
}
return 0;
}
void
location_geoclue_free(location_geoclue_state_t *state)
{
if (state->position != NULL) g_object_unref(state->position);
free(state->provider);
free(state->provider_path);
}
void
location_geoclue_print_help(FILE *f)
{
fputs(_("Use the location as discovered by a Geoclue provider.\n"), f);
fputs("\n", f);
/* TRANSLATORS: Geoclue help output
left column must not be translated */
fputs(_(" name=N\tName of Geoclue provider (or `default')\n"
" path=N\tPath of Geoclue provider (or `default')\n"), f);
fputs("\n", f);
fprintf(f, _("NOTE: currently Redshift doesn't recheck %s once started,\n"
"which means it has to be restarted to take notice after travel.\n"),
"GeoClue");
fputs("\n", f);
}
int
location_geoclue_set_option(location_geoclue_state_t *state,
const char *key, const char *value)
{
const char *provider = NULL;
const char *path = NULL;
/* Parse string value */
if (strcasecmp(key, "name") == 0) {
if (strcasecmp(value, "default") == 0) {
provider = DEFAULT_PROVIDER;
} else {
provider = value;
}
state->provider = strdup(provider);
if (state->provider == NULL) {
perror("strdup");
return -1;
}
} else if (strcasecmp(key, "path") == 0) {
if (value != NULL && strcasecmp(value, "default") == 0) {
path = DEFAULT_PROVIDER_PATH;
} else {
path = value;
}
state->provider_path = strdup(path);
if (state->provider_path == NULL) {
perror("strdup");
return -1;
}
} else {
fprintf(stderr, _("Unknown method parameter: `%s'.\n"), key);
return -1;
}
return 0;
}
int
location_geoclue_get_location(location_geoclue_state_t *state,
location_t *location)
{
GeocluePositionFields fields;
GError *error = NULL;
double latitude = 0, longitude = 0;
fields = geoclue_position_get_position(state->position, NULL,
&latitude, &longitude, NULL,
NULL, &error);
if (error) {
g_printerr(_("Could not get location: %s.\n"), error->message);
g_error_free(error);
return -1;
}
if (fields & GEOCLUE_POSITION_FIELDS_LATITUDE &&
fields & GEOCLUE_POSITION_FIELDS_LONGITUDE) {
fprintf(stdout, _("According to the geoclue provider"
" we're at: %.2f, %.2f\n"),
latitude, longitude);
} else {
g_warning(_("Provider does not have a valid location available."));
return -1;
}
location->lat = latitude;
location->lon = longitude;
return 0;
}
-46
View File
@@ -1,46 +0,0 @@
/* location-geoclue.h -- Geoclue location provider header
This file is part of Redshift.
Redshift is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Redshift is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Redshift. If not, see <http://www.gnu.org/licenses/>.
Copyright (c) 2010 Mathieu Trudel-Lapierre <mathieu-tl@ubuntu.com>
*/
#ifndef REDSHIFT_LOCATION_GEOCLUE_H
#define REDSHIFT_LOCATION_GEOCLUE_H
#include <stdio.h>
#include <geoclue/geoclue-position.h>
#include "redshift.h"
typedef struct {
GeocluePosition *position; /* main geoclue object */
char *provider; /* name of a geoclue provider */
char *provider_path; /* path of the geoclue provider */
} location_geoclue_state_t;
int location_geoclue_init(location_geoclue_state_t *state);
int location_geoclue_start(location_geoclue_state_t *state);
void location_geoclue_free(location_geoclue_state_t *state);
void location_geoclue_print_help(FILE *f);
int location_geoclue_set_option(location_geoclue_state_t *state,
const char *key, const char *value);
int location_geoclue_get_location(location_geoclue_state_t *state,
location_t *loc);
#endif /* ! REDSHIFT_LOCATION_GEOCLUE_H */
-21
View File
@@ -81,10 +81,6 @@
#include "location-manual.h"
#ifdef ENABLE_GEOCLUE
# include "location-geoclue.h"
#endif
#ifdef ENABLE_GEOCLUE2
# include "location-geoclue2.h"
#endif
@@ -195,28 +191,11 @@ static const gamma_method_t gamma_methods[] = {
/* Union of state data for location providers */
typedef union {
location_manual_state_t manual;
#ifdef ENABLE_GEOCLUE
location_geoclue_state_t geoclue;
#endif
} location_state_t;
/* Location provider method structs */
static const location_provider_t location_providers[] = {
#ifdef ENABLE_GEOCLUE
{
"geoclue",
(location_provider_init_func *)location_geoclue_init,
(location_provider_start_func *)location_geoclue_start,
(location_provider_free_func *)location_geoclue_free,
(location_provider_print_help_func *)
location_geoclue_print_help,
(location_provider_set_option_func *)
location_geoclue_set_option,
(location_provider_get_location_func *)
location_geoclue_get_location
},
#endif
#ifdef ENABLE_GEOCLUE2
{
"geoclue2",