js: Use async D-Bus wrappers

After porting the more complex cases - in particular those that
affect a module's API - we are left with straight-forward D-Bus
method calls that can be moved to promise-based wrappers in one
go.

For consistency, this also switches from Remote to Async where
the call result is ignored.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2344>
This commit is contained in:
Florian Müllner
2022-06-23 14:53:29 +02:00
committed by Marge Bot
parent a3db909383
commit 637ee7386e
23 changed files with 462 additions and 496 deletions

View File

@@ -32,39 +32,39 @@ var ScreenSaverService = class extends ServiceImplementation {
() => this._dbusImpl.emit_signal('WakeUpScreen', null));
}
LockAsync(params, invocation) {
this._proxy.LockRemote(...params, (res, error) => {
if (this._handleError(invocation, error))
return;
async LockAsync(params, invocation) {
try {
await this._proxy.LockAsync(...params);
invocation.return_value(null);
});
} catch (error) {
this._handleError(invocation, error);
}
}
GetActiveAsync(params, invocation) {
this._proxy.GetActiveRemote(...params, (res, error) => {
if (this._handleError(invocation, error))
return;
async GetActiveAsync(params, invocation) {
try {
const res = await this._proxy.GetActiveAsync(...params);
invocation.return_value(new GLib.Variant('(b)', res));
});
} catch (error) {
this._handleError(invocation, error);
}
}
SetActiveAsync(params, invocation) {
this._proxy.SetActiveRemote(...params, (res, error) => {
if (this._handleError(invocation, error))
return;
async SetActiveAsync(params, invocation) {
try {
await this._proxy.SetActiveAsync(...params);
invocation.return_value(null);
});
} catch (error) {
this._handleError(invocation, error);
}
}
GetActiveTimeAsync(params, invocation) {
this._proxy.GetActiveTimeRemote(...params, (res, error) => {
if (this._handleError(invocation, error))
return;
async GetActiveTimeAsync(params, invocation) {
try {
const res = await this._proxy.GetActiveTimeAsync(...params);
invocation.return_value(new GLib.Variant('(u)', res));
});
} catch (error) {
this._handleError(invocation, error);
}
}
};