Merge branch 'wip/tolerate-no-accountsservice' into 'master'

manager: Return MCT_MANAGER_ERROR_DISABLED if no accountsservice

Closes #27

See merge request pwithnall/malcontent!89
This commit is contained in:
Philip Withnall 2020-10-15 13:52:45 +00:00
commit ba5dccfde0
1 changed files with 9 additions and 1 deletions

View File

@ -280,12 +280,20 @@ bus_error_to_manager_error (const GError *bus_error,
if (g_error_matches (bus_error, G_DBUS_ERROR, G_DBUS_ERROR_ACCESS_DENIED) ||
bus_remote_error_matches (bus_error, "org.freedesktop.Accounts.Error.PermissionDenied"))
return g_error_new (MCT_MANAGER_ERROR, MCT_MANAGER_ERROR_PERMISSION_DENIED,
_("Not allowed to query app filter data for user %u"),
_("Not allowed to query parental controls data for user %u"),
(guint) user_id);
else if (g_error_matches (bus_error, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD) ||
bus_remote_error_matches (bus_error, "org.freedesktop.Accounts.Error.Failed"))
return g_error_new (MCT_MANAGER_ERROR, MCT_MANAGER_ERROR_INVALID_USER,
_("User %u does not exist"), (guint) user_id);
else if (g_error_matches (bus_error, G_DBUS_ERROR, G_DBUS_ERROR_SERVICE_UNKNOWN) ||
g_error_matches (bus_error, G_DBUS_ERROR, G_DBUS_ERROR_NAME_HAS_NO_OWNER))
/* If accountsservice is not available on the system bus, then the
* com.endlessm.ParentalControls.AppFilter extension interface
* certainly can't be available. */
return g_error_new_literal (MCT_MANAGER_ERROR,
MCT_MANAGER_ERROR_DISABLED,
_("System accounts service not available"));
else
return g_error_copy (bus_error);
}