mirror of
https://github.com/edu4rdshl/gnome-shell.git
synced 2026-07-17 23:24:51 +00:00
parentalControlsManager: Don't log error when disabled
We currently special-case the DISABLED error when initializing
filtering, but not on app filter changes.
While it seems reasonable that Malcontent.Manager wouldn't emit
the signal while disabled, that's not actually true: It is emitted
when any user account information tracked by AccountsServices
changes.
Even if the signal were limited to changes of the ParentalControls
extension, it would still get emitted when app filtering *becomes*
disabled.
So regardless of potential improvements in libmalcontent itself,
we should filter out the DISABLED consistently, both when creating
the initial filter and when updating it.
https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/6749
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2796>
(cherry picked from commit 593f659a73)
This commit is contained in:
parent
bbb5478a0a
commit
199b556b5d
1 changed files with 23 additions and 15 deletions
|
|
@ -74,18 +74,10 @@ var ParentalControlsManager = GObject.registerClass({
|
||||||
try {
|
try {
|
||||||
const connection = await Gio.DBus.get(Gio.BusType.SYSTEM, null);
|
const connection = await Gio.DBus.get(Gio.BusType.SYSTEM, null);
|
||||||
this._manager = new Malcontent.Manager({ connection });
|
this._manager = new Malcontent.Manager({ connection });
|
||||||
this._appFilter = await this._manager.get_app_filter_async(
|
this._appFilter = await this._getAppFilter();
|
||||||
Shell.util_get_uid(),
|
|
||||||
Malcontent.ManagerGetValueFlags.NONE,
|
|
||||||
null);
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e.matches(Malcontent.ManagerError, Malcontent.ManagerError.DISABLED)) {
|
logError(e, 'Failed to get parental controls settings');
|
||||||
console.debug('Parental controls globally disabled');
|
return;
|
||||||
this._disabled = true;
|
|
||||||
} else {
|
|
||||||
logError(e, 'Failed to get parental controls settings');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this._manager.connect('app-filter-changed', this._onAppFilterChanged.bind(this));
|
this._manager.connect('app-filter-changed', this._onAppFilterChanged.bind(this));
|
||||||
|
|
@ -95,6 +87,25 @@ var ParentalControlsManager = GObject.registerClass({
|
||||||
this.emit('app-filter-changed');
|
this.emit('app-filter-changed');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async _getAppFilter() {
|
||||||
|
let appFilter = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
appFilter = await this._manager.get_app_filter_async(
|
||||||
|
Shell.util_get_uid(),
|
||||||
|
Malcontent.ManagerGetValueFlags.NONE,
|
||||||
|
null);
|
||||||
|
} catch (e) {
|
||||||
|
if (!e.matches(Malcontent.ManagerError, Malcontent.ManagerError.DISABLED))
|
||||||
|
throw e;
|
||||||
|
|
||||||
|
console.debug('Parental controls globally disabled');
|
||||||
|
this._disabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return appFilter;
|
||||||
|
}
|
||||||
|
|
||||||
async _onAppFilterChanged(manager, uid) {
|
async _onAppFilterChanged(manager, uid) {
|
||||||
// Emit 'changed' signal only if app-filter is changed for currently logged-in user.
|
// Emit 'changed' signal only if app-filter is changed for currently logged-in user.
|
||||||
let currentUid = Shell.util_get_uid();
|
let currentUid = Shell.util_get_uid();
|
||||||
|
|
@ -102,10 +113,7 @@ var ParentalControlsManager = GObject.registerClass({
|
||||||
return;
|
return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this._appFilter = await this._manager.get_app_filter_async(
|
this._appFilter = await this._getAppFilter();
|
||||||
currentUid,
|
|
||||||
Malcontent.ManagerGetValueFlags.NONE,
|
|
||||||
null);
|
|
||||||
this.emit('app-filter-changed');
|
this.emit('app-filter-changed');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Log an error and keep the old app filter.
|
// Log an error and keep the old app filter.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue