diff options
author | Jon Lund Steffensen <jonlst@gmail.com> | 2017-08-19 17:38:58 -0700 |
---|---|---|
committer | Jon Lund Steffensen <jonlst@gmail.com> | 2017-08-19 17:39:05 -0700 |
commit | c4e0f3aa5a798ca2f2dae6b9355b3d9fc052502f (patch) | |
tree | 8cba4a46570796cb775c71429a255996f5c00941 /src | |
parent | geoclue2: Use existing connection object (diff) | |
download | redshift-ng-c4e0f3aa5a798ca2f2dae6b9355b3d9fc052502f.tar.gz redshift-ng-c4e0f3aa5a798ca2f2dae6b9355b3d9fc052502f.tar.bz2 redshift-ng-c4e0f3aa5a798ca2f2dae6b9355b3d9fc052502f.tar.xz |
geoclue2: Show explanation of access denied error
Diffstat (limited to 'src')
-rw-r--r-- | src/location-geoclue2.c | 22 |
1 files changed, 22 insertions, 0 deletions
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); |