geoclue2: Show explanation of access denied error

This commit is contained in:
Jon Lund Steffensen
2017-08-19 17:39:05 -07:00
parent 52d9a73d36
commit c4e0f3aa5a
+22
View File
@@ -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);