diff options
author | Jon Lund Steffensen <jonlst@gmail.com> | 2017-08-30 15:35:39 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-30 15:35:39 -0700 |
commit | 2ecf92c1b27510f801bc4098ae04551cdac56968 (patch) | |
tree | ebab04733e20f90244f3acc95323245cb23be2ca | |
parent | Merge pull request #500 from jonls/continuous-location (diff) | |
parent | README: Add FAQ entry on GeoClue access denied (diff) | |
download | redshift-ng-2ecf92c1b27510f801bc4098ae04551cdac56968.tar.gz redshift-ng-2ecf92c1b27510f801bc4098ae04551cdac56968.tar.bz2 redshift-ng-2ecf92c1b27510f801bc4098ae04551cdac56968.tar.xz |
Merge pull request #504 from jonls/geoclue-update
GeoClue: better error message when access is denied
-rw-r--r-- | README.md | 16 | ||||
-rw-r--r-- | src/location-geoclue2.c | 34 |
2 files changed, 43 insertions, 7 deletions
@@ -25,7 +25,9 @@ FAQ **How do I install Redshift?** -Use the packages provided by your distribution, e.g. for Ubuntu: `apt-get install redshift` or `apt-get install redshift-gtk`. For developers, please see _Building from source_ and _Latest builds from master branch_ below. +Use the packages provided by your distribution, e.g. for Ubuntu: +`apt-get install redshift` or `apt-get install redshift-gtk`. For developers, +please see _Building from source_ and _Latest builds from master branch_ below. **How do I setup a configuration file?** @@ -48,6 +50,18 @@ example clicking anywhere on Google Maps will bring up a box with the coordinates. Remember that longitudes in the western hemisphere (e.g. the Americas) must be provided to Redshift as negative numbers. +**Why does GeoClue fail with access denied error?** + +It is possible that the location services have been disabled completely. The +check for this case varies by desktop environment. For example, in GNOME the +location services can be toggled in Settings > Privacy > Location Services. + +If this is not the case, it is possible that Redshift has been improperly +installed or not been given the required permissions to obtain location +updates from a system administrator. See +https://github.com/jonls/redshift/issues/318 for further discussion on this +issue. + **Why doesn't Redshift work on my Chromebook/Raspberry Pi?** Certain video drivers do not support adjustable gamma ramps. In some cases diff --git a/src/location-geoclue2.c b/src/location-geoclue2.c index 9641507..6ebedb4 100644 --- a/src/location-geoclue2.c +++ b/src/location-geoclue2.c @@ -35,6 +35,20 @@ # define _(s) s #endif +#define DBUS_ACCESS_ERROR "org.freedesktop.DBus.Error.AccessDenied" + + +/* Print the message explaining denial from GeoClue. */ +static void +print_denial_message() +{ + g_printerr(_( + "Access to the current location was denied by GeoClue!\n" + "Make sure that location services are enabled and that" + " Redshift is permitted\nto use location services." + " See https://github.com/jonls/redshift#faq for more\n" + "information.\n")); +} /* Indicate an unrecoverable error during GeoClue2 communication. */ static void @@ -68,8 +82,8 @@ geoclue_client_signal_cb(GDBusProxy *client, gchar *sender_name, /* Obtain location */ GError *error = NULL; - GDBusProxy *location = g_dbus_proxy_new_for_bus_sync( - G_BUS_TYPE_SYSTEM, + GDBusProxy *location = g_dbus_proxy_new_sync( + g_dbus_proxy_get_connection(client), G_DBUS_PROXY_FLAGS_NONE, NULL, "org.freedesktop.GeoClue2", @@ -111,8 +125,8 @@ on_name_appeared(GDBusConnection *conn, const gchar *name, /* Obtain GeoClue Manager */ GError *error = NULL; - GDBusProxy *geoclue_manager = g_dbus_proxy_new_for_bus_sync( - G_BUS_TYPE_SYSTEM, + GDBusProxy *geoclue_manager = g_dbus_proxy_new_sync( + conn, G_DBUS_PROXY_FLAGS_NONE, NULL, "org.freedesktop.GeoClue2", @@ -149,8 +163,8 @@ on_name_appeared(GDBusConnection *conn, const gchar *name, /* Obtain GeoClue client */ error = NULL; - GDBusProxy *geoclue_client = g_dbus_proxy_new_for_bus_sync( - G_BUS_TYPE_SYSTEM, + GDBusProxy *geoclue_client = g_dbus_proxy_new_sync( + conn, G_DBUS_PROXY_FLAGS_NONE, NULL, "org.freedesktop.GeoClue2", @@ -225,6 +239,14 @@ on_name_appeared(GDBusConnection *conn, const gchar *name, if (ret_v == NULL) { g_printerr(_("Unable to start GeoClue client: %s.\n"), error->message); + if (g_dbus_error_is_remote_error(error)) { + gchar *dbus_error = g_dbus_error_get_remote_error( + error); + if (g_strcmp0(dbus_error, DBUS_ACCESS_ERROR) == 0) { + print_denial_message(); + } + g_free(dbus_error); + } g_error_free(error); g_object_unref(geoclue_client); g_object_unref(geoclue_manager); |