From 52d9a73d365b8b7f37847c15a03124b472a77b16 Mon Sep 17 00:00:00 2001 From: Jon Lund Steffensen Date: Sat, 19 Aug 2017 17:37:46 -0700 Subject: geoclue2: Use existing connection object Use existing connection object when creating proxies. --- src/location-geoclue2.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/location-geoclue2.c b/src/location-geoclue2.c index 9641507..94a536e 100644 --- a/src/location-geoclue2.c +++ b/src/location-geoclue2.c @@ -68,8 +68,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 +111,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 +149,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", -- cgit v1.2.3-70-g09d2 From c4e0f3aa5a798ca2f2dae6b9355b3d9fc052502f Mon Sep 17 00:00:00 2001 From: Jon Lund Steffensen Date: Sat, 19 Aug 2017 17:38:58 -0700 Subject: geoclue2: Show explanation of access denied error --- src/location-geoclue2.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/location-geoclue2.c b/src/location-geoclue2.c index 94a536e..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 @@ -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); -- cgit v1.2.3-70-g09d2 From 3000d0ad64ee7bbe2ed03340d15b411a39229daf Mon Sep 17 00:00:00 2001 From: Jon Lund Steffensen Date: Sat, 19 Aug 2017 17:52:47 -0700 Subject: README: Add FAQ entry on GeoClue access denied --- README.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 890732d..65899e3 100644 --- a/README.md +++ b/README.md @@ -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 -- cgit v1.2.3-70-g09d2