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:
parent
a3db909383
commit
637ee7386e
@ -43,87 +43,82 @@ var ExtensionsService = class extends ServiceImplementation {
|
|||||||
this._proxy.UserExtensionsEnabled = enable;
|
this._proxy.UserExtensionsEnabled = enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
ListExtensionsAsync(params, invocation) {
|
async ListExtensionsAsync(params, invocation) {
|
||||||
this._proxy.ListExtensionsRemote(...params, (res, error) => {
|
try {
|
||||||
if (this._handleError(invocation, error))
|
const res = await this._proxy.ListExtensionsAsync(...params);
|
||||||
return;
|
|
||||||
|
|
||||||
invocation.return_value(new GLib.Variant('(a{sa{sv}})', res));
|
invocation.return_value(new GLib.Variant('(a{sa{sv}})', res));
|
||||||
});
|
} catch (error) {
|
||||||
|
this._handleError(invocation, error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GetExtensionInfoAsync(params, invocation) {
|
async GetExtensionInfoAsync(params, invocation) {
|
||||||
this._proxy.GetExtensionInfoRemote(...params, (res, error) => {
|
try {
|
||||||
if (this._handleError(invocation, error))
|
const res = await this._proxy.GetExtensionInfoAsync(...params);
|
||||||
return;
|
|
||||||
|
|
||||||
invocation.return_value(new GLib.Variant('(a{sv})', res));
|
invocation.return_value(new GLib.Variant('(a{sv})', res));
|
||||||
});
|
} catch (error) {
|
||||||
|
this._handleError(invocation, error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GetExtensionErrorsAsync(params, invocation) {
|
async GetExtensionErrorsAsync(params, invocation) {
|
||||||
this._proxy.GetExtensionErrorsRemote(...params, (res, error) => {
|
try {
|
||||||
if (this._handleError(invocation, error))
|
const res = await this._proxy.GetExtensionErrorsAsync(...params);
|
||||||
return;
|
|
||||||
|
|
||||||
invocation.return_value(new GLib.Variant('(as)', res));
|
invocation.return_value(new GLib.Variant('(as)', res));
|
||||||
});
|
} catch (error) {
|
||||||
|
this._handleError(invocation, error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
InstallRemoteExtensionAsync(params, invocation) {
|
async InstallRemoteExtensionAsync(params, invocation) {
|
||||||
this._proxy.InstallRemoteExtensionRemote(...params, (res, error) => {
|
try {
|
||||||
if (this._handleError(invocation, error))
|
const res = await this._proxy.InstallRemoteExtensionAsync(...params);
|
||||||
return;
|
|
||||||
|
|
||||||
invocation.return_value(new GLib.Variant('(s)', res));
|
invocation.return_value(new GLib.Variant('(s)', res));
|
||||||
});
|
} catch (error) {
|
||||||
|
this._handleError(invocation, error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UninstallExtensionAsync(params, invocation) {
|
async UninstallExtensionAsync(params, invocation) {
|
||||||
this._proxy.UninstallExtensionRemote(...params, (res, error) => {
|
try {
|
||||||
if (this._handleError(invocation, error))
|
const res = await this._proxy.UninstallExtensionAsync(...params);
|
||||||
return;
|
|
||||||
|
|
||||||
invocation.return_value(new GLib.Variant('(b)', res));
|
invocation.return_value(new GLib.Variant('(b)', res));
|
||||||
});
|
} catch (error) {
|
||||||
|
this._handleError(invocation, error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EnableExtensionAsync(params, invocation) {
|
async EnableExtensionAsync(params, invocation) {
|
||||||
this._proxy.EnableExtensionRemote(...params, (res, error) => {
|
try {
|
||||||
if (this._handleError(invocation, error))
|
const res = await this._proxy.EnableExtensionAsync(...params);
|
||||||
return;
|
|
||||||
|
|
||||||
invocation.return_value(new GLib.Variant('(b)', res));
|
invocation.return_value(new GLib.Variant('(b)', res));
|
||||||
});
|
} catch (error) {
|
||||||
|
this._handleError(invocation, error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DisableExtensionAsync(params, invocation) {
|
async DisableExtensionAsync(params, invocation) {
|
||||||
this._proxy.DisableExtensionRemote(...params, (res, error) => {
|
try {
|
||||||
if (this._handleError(invocation, error))
|
const res = await this._proxy.DisableExtensionAsync(...params);
|
||||||
return;
|
|
||||||
|
|
||||||
invocation.return_value(new GLib.Variant('(b)', res));
|
invocation.return_value(new GLib.Variant('(b)', res));
|
||||||
});
|
} catch (error) {
|
||||||
|
this._handleError(invocation, error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LaunchExtensionPrefsAsync([uuid], invocation) {
|
LaunchExtensionPrefsAsync([uuid], invocation) {
|
||||||
this.OpenExtensionPrefsAsync([uuid, '', {}], invocation);
|
this.OpenExtensionPrefsAsync([uuid, '', {}], invocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
OpenExtensionPrefsAsync(params, invocation) {
|
async OpenExtensionPrefsAsync(params, invocation) {
|
||||||
const [uuid, parentWindow, options] = params;
|
const [uuid, parentWindow, options] = params;
|
||||||
|
|
||||||
this._proxy.GetExtensionInfoRemote(uuid, (res, error) => {
|
try {
|
||||||
if (this._handleError(invocation, error))
|
const [serialized] = await this._proxy.GetExtensionInfoAsync(uuid);
|
||||||
return;
|
|
||||||
|
|
||||||
if (this._prefsDialog) {
|
if (this._prefsDialog)
|
||||||
this._handleError(invocation,
|
throw new Error('Already showing a prefs dialog');
|
||||||
new Error('Already showing a prefs dialog'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const [serialized] = res;
|
|
||||||
const extension = ExtensionUtils.deserializeExtension(serialized);
|
const extension = ExtensionUtils.deserializeExtension(serialized);
|
||||||
|
|
||||||
this._prefsDialog = new ExtensionPrefsDialog(extension);
|
this._prefsDialog = new ExtensionPrefsDialog(extension);
|
||||||
@ -150,15 +145,17 @@ var ExtensionsService = class extends ServiceImplementation {
|
|||||||
this._prefsDialog.show();
|
this._prefsDialog.show();
|
||||||
|
|
||||||
invocation.return_value(null);
|
invocation.return_value(null);
|
||||||
});
|
} catch (error) {
|
||||||
|
this._handleError(invocation, error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CheckForUpdatesAsync(params, invocation) {
|
async CheckForUpdatesAsync(params, invocation) {
|
||||||
this._proxy.CheckForUpdatesRemote(...params, (res, error) => {
|
try {
|
||||||
if (this._handleError(invocation, error))
|
await this._proxy.CheckForUpdatesAsync(...params);
|
||||||
return;
|
|
||||||
|
|
||||||
invocation.return_value(null);
|
invocation.return_value(null);
|
||||||
});
|
} catch (error) {
|
||||||
|
this._handleError(invocation, error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -103,45 +103,44 @@ var NotificationDaemon = class extends ServiceImplementation {
|
|||||||
'sender-pid': new GLib.Variant('u', pid),
|
'sender-pid': new GLib.Variant('u', pid),
|
||||||
};
|
};
|
||||||
|
|
||||||
this._proxy.NotifyRemote(...params, (res, error) => {
|
try {
|
||||||
if (this._handleError(invocation, error))
|
const [id] = await this._proxy.NotifyAsync(...params);
|
||||||
return;
|
|
||||||
|
|
||||||
const [id] = res;
|
|
||||||
this._activeNotifications.set(id, sender);
|
this._activeNotifications.set(id, sender);
|
||||||
invocation.return_value(new GLib.Variant('(u)', res));
|
invocation.return_value(new GLib.Variant('(u)', [id]));
|
||||||
});
|
} catch (error) {
|
||||||
|
this._handleError(invocation, error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CloseNotificationAsync(params, invocation) {
|
async CloseNotificationAsync(params, invocation) {
|
||||||
const [id] = params;
|
const [id] = params;
|
||||||
if (!this._checkNotificationId(invocation, id))
|
if (!this._checkNotificationId(invocation, id))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this._proxy.CloseNotificationRemote(...params, (res, error) => {
|
try {
|
||||||
if (this._handleError(invocation, error))
|
await this._proxy.CloseNotificationAsync(...params);
|
||||||
return;
|
|
||||||
|
|
||||||
invocation.return_value(null);
|
invocation.return_value(null);
|
||||||
});
|
} catch (error) {
|
||||||
|
this._handleError(invocation, error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GetCapabilitiesAsync(params, invocation) {
|
async GetCapabilitiesAsync(params, invocation) {
|
||||||
this._proxy.GetCapabilitiesRemote(...params, (res, error) => {
|
try {
|
||||||
if (this._handleError(invocation, error))
|
const res = await this._proxy.GetCapabilitiesAsync(...params);
|
||||||
return;
|
|
||||||
|
|
||||||
invocation.return_value(new GLib.Variant('(as)', res));
|
invocation.return_value(new GLib.Variant('(as)', res));
|
||||||
});
|
} catch (error) {
|
||||||
|
this._handleError(invocation, error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GetServerInformationAsync(params, invocation) {
|
async GetServerInformationAsync(params, invocation) {
|
||||||
this._proxy.GetServerInformationRemote(...params, (res, error) => {
|
try {
|
||||||
if (this._handleError(invocation, error))
|
const res = await this._proxy.GetServerInformationAsync(...params);
|
||||||
return;
|
|
||||||
|
|
||||||
invocation.return_value(new GLib.Variant('(ssss)', res));
|
invocation.return_value(new GLib.Variant('(ssss)', res));
|
||||||
});
|
} catch (error) {
|
||||||
|
this._handleError(invocation, error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async _getSenderPid(sender) {
|
async _getSenderPid(sender) {
|
||||||
|
@ -32,39 +32,39 @@ var ScreenSaverService = class extends ServiceImplementation {
|
|||||||
() => this._dbusImpl.emit_signal('WakeUpScreen', null));
|
() => this._dbusImpl.emit_signal('WakeUpScreen', null));
|
||||||
}
|
}
|
||||||
|
|
||||||
LockAsync(params, invocation) {
|
async LockAsync(params, invocation) {
|
||||||
this._proxy.LockRemote(...params, (res, error) => {
|
try {
|
||||||
if (this._handleError(invocation, error))
|
await this._proxy.LockAsync(...params);
|
||||||
return;
|
|
||||||
|
|
||||||
invocation.return_value(null);
|
invocation.return_value(null);
|
||||||
});
|
} catch (error) {
|
||||||
|
this._handleError(invocation, error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GetActiveAsync(params, invocation) {
|
async GetActiveAsync(params, invocation) {
|
||||||
this._proxy.GetActiveRemote(...params, (res, error) => {
|
try {
|
||||||
if (this._handleError(invocation, error))
|
const res = await this._proxy.GetActiveAsync(...params);
|
||||||
return;
|
|
||||||
|
|
||||||
invocation.return_value(new GLib.Variant('(b)', res));
|
invocation.return_value(new GLib.Variant('(b)', res));
|
||||||
});
|
} catch (error) {
|
||||||
|
this._handleError(invocation, error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SetActiveAsync(params, invocation) {
|
async SetActiveAsync(params, invocation) {
|
||||||
this._proxy.SetActiveRemote(...params, (res, error) => {
|
try {
|
||||||
if (this._handleError(invocation, error))
|
await this._proxy.SetActiveAsync(...params);
|
||||||
return;
|
|
||||||
|
|
||||||
invocation.return_value(null);
|
invocation.return_value(null);
|
||||||
});
|
} catch (error) {
|
||||||
|
this._handleError(invocation, error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GetActiveTimeAsync(params, invocation) {
|
async GetActiveTimeAsync(params, invocation) {
|
||||||
this._proxy.GetActiveTimeRemote(...params, (res, error) => {
|
try {
|
||||||
if (this._handleError(invocation, error))
|
const res = await this._proxy.GetActiveTimeAsync(...params);
|
||||||
return;
|
|
||||||
|
|
||||||
invocation.return_value(new GLib.Variant('(u)', res));
|
invocation.return_value(new GLib.Variant('(u)', res));
|
||||||
});
|
} catch (error) {
|
||||||
|
this._handleError(invocation, error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -100,9 +100,9 @@ var Manager = class extends Signals.EventEmitter {
|
|||||||
|
|
||||||
release() {
|
release() {
|
||||||
Service(Gio.DBus.system,
|
Service(Gio.DBus.system,
|
||||||
'org.freedesktop.realmd',
|
'org.freedesktop.realmd',
|
||||||
'/org/freedesktop/realmd',
|
'/org/freedesktop/realmd',
|
||||||
service => service.ReleaseRemote());
|
service => service.ReleaseAsync().catch(logError));
|
||||||
this._aggregateProvider.disconnectObject(this);
|
this._aggregateProvider.disconnectObject(this);
|
||||||
this._realms = { };
|
this._realms = { };
|
||||||
this._updateLoginFormat();
|
this._updateLoginFormat();
|
||||||
|
@ -376,7 +376,7 @@ var ShellUserVerifier = class extends Signals.EventEmitter {
|
|||||||
this.emit('show-message', null, null, MessageType.NONE);
|
this.emit('show-message', null, null, MessageType.NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
_checkForFingerprintReader() {
|
async _checkForFingerprintReader() {
|
||||||
this._fingerprintReaderType = FingerprintReaderType.NONE;
|
this._fingerprintReaderType = FingerprintReaderType.NONE;
|
||||||
|
|
||||||
if (!this._settings.get_boolean(FINGERPRINT_AUTHENTICATION_KEY) ||
|
if (!this._settings.get_boolean(FINGERPRINT_AUTHENTICATION_KEY) ||
|
||||||
@ -385,21 +385,19 @@ var ShellUserVerifier = class extends Signals.EventEmitter {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this._fprintManager.GetDefaultDeviceRemote(Gio.DBusCallFlags.NONE, this._cancellable,
|
try {
|
||||||
(params, error) => {
|
const [device] = await this._fprintManager.GetDefaultDeviceAsync(
|
||||||
if (!error && params) {
|
Gio.DBusCallFlags.NONE, this._cancellable);
|
||||||
const [device] = params;
|
const fprintDeviceProxy = new FprintDeviceProxy(Gio.DBus.system,
|
||||||
const fprintDeviceProxy = new FprintDeviceProxy(Gio.DBus.system,
|
'net.reactivated.Fprint',
|
||||||
'net.reactivated.Fprint',
|
device);
|
||||||
device);
|
const fprintDeviceType = fprintDeviceProxy['scan-type'];
|
||||||
const fprintDeviceType = fprintDeviceProxy['scan-type'];
|
|
||||||
|
|
||||||
this._fingerprintReaderType = fprintDeviceType === 'swipe'
|
this._fingerprintReaderType = fprintDeviceType === 'swipe'
|
||||||
? FingerprintReaderType.SWIPE
|
? FingerprintReaderType.SWIPE
|
||||||
: FingerprintReaderType.PRESS;
|
: FingerprintReaderType.PRESS;
|
||||||
this._updateDefaultService();
|
this._updateDefaultService();
|
||||||
}
|
} catch (e) {}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_onCredentialManagerAuthenticated(credentialManager, _token) {
|
_onCredentialManagerAuthenticated(credentialManager, _token) {
|
||||||
|
@ -153,24 +153,24 @@ class ModemGsm extends ModemBase {
|
|||||||
this._proxy.connectSignal('RegistrationInfo', (proxy, sender, [_status, code, name]) => {
|
this._proxy.connectSignal('RegistrationInfo', (proxy, sender, [_status, code, name]) => {
|
||||||
this._setOperatorName(_findProviderForMccMnc(name, code));
|
this._setOperatorName(_findProviderForMccMnc(name, code));
|
||||||
});
|
});
|
||||||
this._proxy.GetRegistrationInfoRemote(([result], err) => {
|
this._getInitialState();
|
||||||
if (err) {
|
}
|
||||||
log(err);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let [status_, code, name] = result;
|
async _getInitialState() {
|
||||||
|
try {
|
||||||
|
const [
|
||||||
|
[status_, code, name],
|
||||||
|
[quality],
|
||||||
|
] = await Promise.all([
|
||||||
|
this._proxy.GetRegistrationInfoAsync(),
|
||||||
|
this._proxy.GetSignalQualityAsync(),
|
||||||
|
]);
|
||||||
this._setOperatorName(_findProviderForMccMnc(name, code));
|
this._setOperatorName(_findProviderForMccMnc(name, code));
|
||||||
});
|
this._setSignalQuality(quality);
|
||||||
this._proxy.GetSignalQualityRemote((result, err) => {
|
} catch (err) {
|
||||||
if (err) {
|
// it will return an error if the device is not connected
|
||||||
// it will return an error if the device is not connected
|
this._setSignalQuality(0);
|
||||||
this._setSignalQuality(0);
|
}
|
||||||
} else {
|
|
||||||
let [quality] = result;
|
|
||||||
this._setSignalQuality(quality);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -188,27 +188,28 @@ class ModemCdma extends ModemBase {
|
|||||||
if (this.operator_name == null)
|
if (this.operator_name == null)
|
||||||
this._refreshServingSystem();
|
this._refreshServingSystem();
|
||||||
});
|
});
|
||||||
this._proxy.GetSignalQualityRemote((result, err) => {
|
this._getSignalQuality();
|
||||||
if (err) {
|
|
||||||
// it will return an error if the device is not connected
|
|
||||||
this._setSignalQuality(0);
|
|
||||||
} else {
|
|
||||||
let [quality] = result;
|
|
||||||
this._setSignalQuality(quality);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_refreshServingSystem() {
|
async _getSignalQuality() {
|
||||||
this._proxy.GetServingSystemRemote(([result], err) => {
|
try {
|
||||||
if (err) {
|
const [quality] = await this._proxy.GetSignalQualityAsync();
|
||||||
// it will return an error if the device is not connected
|
this._setSignalQuality(quality);
|
||||||
this._setOperatorName(null);
|
} catch (err) {
|
||||||
} else {
|
// it will return an error if the device is not connected
|
||||||
let [bandClass_, band_, sid] = result;
|
this._setSignalQuality(0);
|
||||||
this._setOperatorName(_findProviderForSid(sid));
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
async _refreshServingSystem() {
|
||||||
|
try {
|
||||||
|
const [bandClass_, band_, sid] =
|
||||||
|
await this._proxy.GetServingSystemAsync();
|
||||||
|
this._setOperatorName(_findProviderForSid(sid));
|
||||||
|
} catch (err) {
|
||||||
|
// it will return an error if the device is not connected
|
||||||
|
this._setOperatorName(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -329,11 +329,14 @@ const SystemActions = GObject.registerClass({
|
|||||||
this.notify('can-lock-screen');
|
this.notify('can-lock-screen');
|
||||||
}
|
}
|
||||||
|
|
||||||
_updateHaveShutdown() {
|
async _updateHaveShutdown() {
|
||||||
this._session.CanShutdownRemote((result, error) => {
|
try {
|
||||||
this._canHavePowerOff = error ? false : result[0];
|
const [canShutdown] = await this._session.CanShutdownAsync();
|
||||||
this._updatePowerOff();
|
this._canHavePowerOff = canShutdown;
|
||||||
});
|
} catch (e) {
|
||||||
|
this._canHavePowerOff = false;
|
||||||
|
}
|
||||||
|
this._updatePowerOff();
|
||||||
}
|
}
|
||||||
|
|
||||||
_updatePowerOff() {
|
_updatePowerOff() {
|
||||||
@ -431,21 +434,21 @@ const SystemActions = GObject.registerClass({
|
|||||||
throw new Error('The logout action is not available!');
|
throw new Error('The logout action is not available!');
|
||||||
|
|
||||||
Main.overview.hide();
|
Main.overview.hide();
|
||||||
this._session.LogoutRemote(0);
|
this._session.LogoutAsync(0).catch(logError);
|
||||||
}
|
}
|
||||||
|
|
||||||
activatePowerOff() {
|
activatePowerOff() {
|
||||||
if (!this._actions.get(POWER_OFF_ACTION_ID).available)
|
if (!this._actions.get(POWER_OFF_ACTION_ID).available)
|
||||||
throw new Error('The power-off action is not available!');
|
throw new Error('The power-off action is not available!');
|
||||||
|
|
||||||
this._session.ShutdownRemote(0);
|
this._session.ShutdownAsync(0).catch(logError);
|
||||||
}
|
}
|
||||||
|
|
||||||
activateRestart() {
|
activateRestart() {
|
||||||
if (!this._actions.get(RESTART_ACTION_ID).available)
|
if (!this._actions.get(RESTART_ACTION_ID).available)
|
||||||
throw new Error('The restart action is not available!');
|
throw new Error('The restart action is not available!');
|
||||||
|
|
||||||
this._session.RebootRemote();
|
this._session.RebootAsync().catch(logError);
|
||||||
}
|
}
|
||||||
|
|
||||||
activateSuspend() {
|
activateSuspend() {
|
||||||
|
@ -39,7 +39,7 @@ var WeatherClient = class extends Signals.EventEmitter {
|
|||||||
|
|
||||||
this._needsAuth = true;
|
this._needsAuth = true;
|
||||||
this._weatherAuthorized = false;
|
this._weatherAuthorized = false;
|
||||||
this._permStore = new PermissionStore.PermissionStore((proxy, error) => {
|
this._permStore = new PermissionStore.PermissionStore(async (proxy, error) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
log(`Failed to connect to permissionStore: ${error.message}`);
|
log(`Failed to connect to permissionStore: ${error.message}`);
|
||||||
return;
|
return;
|
||||||
@ -53,14 +53,15 @@ var WeatherClient = class extends Signals.EventEmitter {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this._permStore.LookupRemote('gnome', 'geolocation', (res, err) => {
|
let [perms, data] = [{}, null];
|
||||||
if (err)
|
try {
|
||||||
log(`Error looking up permission: ${err.message}`);
|
[perms, data] = await this._permStore.LookupAsync('gnome', 'geolocation');
|
||||||
|
} catch (err) {
|
||||||
|
log(`Error looking up permission: ${err.message}`);
|
||||||
|
}
|
||||||
|
|
||||||
let [perms, data] = err ? [{}, null] : res;
|
const params = ['gnome', 'geolocation', false, data, perms];
|
||||||
let params = ['gnome', 'geolocation', false, data, perms];
|
this._onPermStoreChanged(this._permStore, '', params);
|
||||||
this._onPermStoreChanged(this._permStore, '', params);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
this._permStore.connectSignal('Changed',
|
this._permStore.connectSignal('Changed',
|
||||||
this._onPermStoreChanged.bind(this));
|
this._onPermStoreChanged.bind(this));
|
||||||
|
@ -337,11 +337,11 @@ class DBusEventSource extends EventSourceBase {
|
|||||||
this._events.clear();
|
this._events.clear();
|
||||||
this.emit('changed');
|
this.emit('changed');
|
||||||
}
|
}
|
||||||
this._dbusProxy.SetTimeRangeRemote(
|
this._dbusProxy.SetTimeRangeAsync(
|
||||||
this._curRequestBegin.getTime() / 1000,
|
this._curRequestBegin.getTime() / 1000,
|
||||||
this._curRequestEnd.getTime() / 1000,
|
this._curRequestEnd.getTime() / 1000,
|
||||||
forceReload,
|
forceReload,
|
||||||
Gio.DBusCallFlags.NONE);
|
Gio.DBusCallFlags.NONE).catch(logError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,12 +51,12 @@ var AutomountManager = class {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_InhibitorsChanged(_object, _senderName, [_inhibitor]) {
|
async _InhibitorsChanged(_object, _senderName, [_inhibitor]) {
|
||||||
this._session.IsInhibitedRemote(GNOME_SESSION_AUTOMOUNT_INHIBIT,
|
try {
|
||||||
(result, error) => {
|
const [inhibited] =
|
||||||
if (!error)
|
await this._session.IsInhibitedAsync(GNOME_SESSION_AUTOMOUNT_INHIBIT);
|
||||||
this._inhibited = result[0];
|
this._inhibited = inhibited;
|
||||||
});
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
_startupMountAll() {
|
_startupMountAll() {
|
||||||
|
@ -504,89 +504,73 @@ class EndSessionDialog extends ModalDialog.ModalDialog {
|
|||||||
this._confirm('ConfirmedReboot');
|
this._confirm('ConfirmedReboot');
|
||||||
}
|
}
|
||||||
|
|
||||||
_confirm(signal) {
|
async _confirm(signal) {
|
||||||
let callback = () => {
|
if (this._checkBox.visible) {
|
||||||
this._fadeOutDialog();
|
// Trigger the offline update as requested
|
||||||
this._stopTimer();
|
if (this._checkBox.checked) {
|
||||||
this._stopAltCapture();
|
switch (signal) {
|
||||||
this._dbusImpl.emit_signal(signal, null);
|
case 'ConfirmedReboot':
|
||||||
};
|
await this._triggerOfflineUpdateReboot();
|
||||||
|
break;
|
||||||
// Offline update not available; just emit the signal
|
case 'ConfirmedShutdown':
|
||||||
if (!this._checkBox.visible) {
|
// To actually trigger the offline update, we need to
|
||||||
callback();
|
// reboot to do the upgrade. When the upgrade is complete,
|
||||||
return;
|
// the computer will shut down automatically.
|
||||||
}
|
signal = 'ConfirmedReboot';
|
||||||
|
await this._triggerOfflineUpdateShutdown();
|
||||||
// Trigger the offline update as requested
|
break;
|
||||||
if (this._checkBox.checked) {
|
default:
|
||||||
switch (signal) {
|
break;
|
||||||
case "ConfirmedReboot":
|
}
|
||||||
this._triggerOfflineUpdateReboot(callback);
|
} else {
|
||||||
break;
|
await this._triggerOfflineUpdateCancel();
|
||||||
case "ConfirmedShutdown":
|
|
||||||
// To actually trigger the offline update, we need to
|
|
||||||
// reboot to do the upgrade. When the upgrade is complete,
|
|
||||||
// the computer will shut down automatically.
|
|
||||||
signal = "ConfirmedReboot";
|
|
||||||
this._triggerOfflineUpdateShutdown(callback);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
callback();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
this._triggerOfflineUpdateCancel(callback);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this._fadeOutDialog();
|
||||||
|
this._stopTimer();
|
||||||
|
this._stopAltCapture();
|
||||||
|
this._dbusImpl.emit_signal(signal, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
_onOpened() {
|
_onOpened() {
|
||||||
this._sync();
|
this._sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
_triggerOfflineUpdateReboot(callback) {
|
async _triggerOfflineUpdateReboot() {
|
||||||
// Handle this gracefully if PackageKit is not available.
|
// Handle this gracefully if PackageKit is not available.
|
||||||
if (!this._pkOfflineProxy) {
|
if (!this._pkOfflineProxy)
|
||||||
callback();
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
await this._pkOfflineProxy.TriggerAsync('reboot');
|
||||||
|
} catch (error) {
|
||||||
|
log(error.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
this._pkOfflineProxy.TriggerRemote('reboot', (result, error) => {
|
|
||||||
if (error)
|
|
||||||
log(error.message);
|
|
||||||
|
|
||||||
callback();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_triggerOfflineUpdateShutdown(callback) {
|
async _triggerOfflineUpdateShutdown() {
|
||||||
// Handle this gracefully if PackageKit is not available.
|
// Handle this gracefully if PackageKit is not available.
|
||||||
if (!this._pkOfflineProxy) {
|
if (!this._pkOfflineProxy)
|
||||||
callback();
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
await this._pkOfflineProxy.TriggerAsync('power-off');
|
||||||
|
} catch (error) {
|
||||||
|
log(error.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
this._pkOfflineProxy.TriggerRemote('power-off', (result, error) => {
|
|
||||||
if (error)
|
|
||||||
log(error.message);
|
|
||||||
|
|
||||||
callback();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_triggerOfflineUpdateCancel(callback) {
|
async _triggerOfflineUpdateCancel() {
|
||||||
// Handle this gracefully if PackageKit is not available.
|
// Handle this gracefully if PackageKit is not available.
|
||||||
if (!this._pkOfflineProxy) {
|
if (!this._pkOfflineProxy)
|
||||||
callback();
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
await this._pkOfflineProxy.CancelAsync();
|
||||||
|
} catch (error) {
|
||||||
|
log(error.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
this._pkOfflineProxy.CancelRemote((result, error) => {
|
|
||||||
if (error)
|
|
||||||
log(error.message);
|
|
||||||
|
|
||||||
callback();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_startTimer() {
|
_startTimer() {
|
||||||
|
@ -53,7 +53,7 @@ var InhibitShortcutsDialog = GObject.registerClass({
|
|||||||
return this._app && !this._app.is_window_backed();
|
return this._app && !this._app.is_window_backed();
|
||||||
}
|
}
|
||||||
|
|
||||||
_saveToPermissionStore(grant) {
|
async _saveToPermissionStore(grant) {
|
||||||
if (!this._shouldUsePermStore() || this._permStore == null)
|
if (!this._shouldUsePermStore() || this._permStore == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -61,15 +61,15 @@ var InhibitShortcutsDialog = GObject.registerClass({
|
|||||||
permissions[this._app.get_id()] = [grant];
|
permissions[this._app.get_id()] = [grant];
|
||||||
let data = GLib.Variant.new('av', {});
|
let data = GLib.Variant.new('av', {});
|
||||||
|
|
||||||
this._permStore.SetRemote(APP_PERMISSIONS_TABLE,
|
try {
|
||||||
true,
|
await this._permStore.SetAsync(APP_PERMISSIONS_TABLE,
|
||||||
APP_PERMISSIONS_ID,
|
true,
|
||||||
permissions,
|
APP_PERMISSIONS_ID,
|
||||||
data,
|
permissions,
|
||||||
(result, error) => {
|
data);
|
||||||
if (error != null)
|
} catch (error) {
|
||||||
log(error.message);
|
log(error.message);
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_buildLayout() {
|
_buildLayout() {
|
||||||
@ -134,30 +134,27 @@ var InhibitShortcutsDialog = GObject.registerClass({
|
|||||||
|
|
||||||
/* Check with the permission store */
|
/* Check with the permission store */
|
||||||
let appId = this._app.get_id();
|
let appId = this._app.get_id();
|
||||||
this._permStore = new PermissionStore.PermissionStore((proxy, error) => {
|
this._permStore = new PermissionStore.PermissionStore(async (proxy, error) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
log(error.message);
|
log(error.message);
|
||||||
this._dialog.open();
|
this._dialog.open();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this._permStore.LookupRemote(APP_PERMISSIONS_TABLE,
|
try {
|
||||||
APP_PERMISSIONS_ID,
|
const [permissions] = await this._permStore.LookupAsync(
|
||||||
(res, err) => {
|
APP_PERMISSIONS_TABLE, APP_PERMISSIONS_ID);
|
||||||
if (err) {
|
|
||||||
this._dialog.open();
|
|
||||||
log(err.message);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let [permissions] = res;
|
if (permissions[appId] === undefined) // Not found
|
||||||
if (permissions[appId] === undefined) // Not found
|
this._dialog.open();
|
||||||
this._dialog.open();
|
else if (permissions[appId] === GRANTED)
|
||||||
else if (permissions[appId] == GRANTED)
|
this._emitResponse(DialogResponse.ALLOW);
|
||||||
this._emitResponse(DialogResponse.ALLOW);
|
else
|
||||||
else
|
this._emitResponse(DialogResponse.DENY);
|
||||||
this._emitResponse(DialogResponse.DENY);
|
} catch (err) {
|
||||||
});
|
this._dialog.open();
|
||||||
|
log(err.message);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ var MprisPlayer = class MprisPlayer extends Signals.EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
playPause() {
|
playPause() {
|
||||||
this._playerProxy.PlayPauseRemote();
|
this._playerProxy.PlayPauseAsync().catch(logError);
|
||||||
}
|
}
|
||||||
|
|
||||||
get canGoNext() {
|
get canGoNext() {
|
||||||
@ -129,7 +129,7 @@ var MprisPlayer = class MprisPlayer extends Signals.EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
next() {
|
next() {
|
||||||
this._playerProxy.NextRemote();
|
this._playerProxy.NextAsync().catch(logError);
|
||||||
}
|
}
|
||||||
|
|
||||||
get canGoPrevious() {
|
get canGoPrevious() {
|
||||||
@ -137,7 +137,7 @@ var MprisPlayer = class MprisPlayer extends Signals.EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
previous() {
|
previous() {
|
||||||
this._playerProxy.PreviousRemote();
|
this._playerProxy.PreviousAsync().catch(logError);
|
||||||
}
|
}
|
||||||
|
|
||||||
raise() {
|
raise() {
|
||||||
@ -152,7 +152,7 @@ var MprisPlayer = class MprisPlayer extends Signals.EventEmitter {
|
|||||||
if (app)
|
if (app)
|
||||||
app.activate();
|
app.activate();
|
||||||
else if (this._mprisProxy.CanRaise)
|
else if (this._mprisProxy.CanRaise)
|
||||||
this._mprisProxy.RaiseRemote();
|
this._mprisProxy.RaiseAsync().catch(logError);
|
||||||
}
|
}
|
||||||
|
|
||||||
_close() {
|
_close() {
|
||||||
@ -275,14 +275,13 @@ class MediaSection extends MessageList.MessageListSection {
|
|||||||
this._players.set(busName, player);
|
this._players.set(busName, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
_onProxyReady() {
|
async _onProxyReady() {
|
||||||
this._proxy.ListNamesRemote(([names]) => {
|
const [names] = await this._proxy.ListNamesAsync();
|
||||||
names.forEach(name => {
|
names.forEach(name => {
|
||||||
if (!name.startsWith(MPRIS_PLAYER_PREFIX))
|
if (!name.startsWith(MPRIS_PLAYER_PREFIX))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this._addPlayer(name);
|
this._addPlayer(name);
|
||||||
});
|
|
||||||
});
|
});
|
||||||
this._proxy.connectSignal('NameOwnerChanged',
|
this._proxy.connectSignal('NameOwnerChanged',
|
||||||
this._onNameOwnerChanged.bind(this));
|
this._onNameOwnerChanged.bind(this));
|
||||||
|
@ -575,32 +575,41 @@ class GtkNotificationDaemonAppSource extends MessageTray.Source {
|
|||||||
return new MessageTray.NotificationApplicationPolicy(this._appId);
|
return new MessageTray.NotificationApplicationPolicy(this._appId);
|
||||||
}
|
}
|
||||||
|
|
||||||
_createApp(callback) {
|
_createApp() {
|
||||||
return new FdoApplicationProxy(Gio.DBus.session, this._appId, this._objectPath, callback);
|
return new Promise((resolve, reject) => {
|
||||||
|
new FdoApplicationProxy(Gio.DBus.session,
|
||||||
|
this._appId, this._objectPath, (proxy, err) => {
|
||||||
|
if (err)
|
||||||
|
reject(err);
|
||||||
|
else
|
||||||
|
resolve(proxy);
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
_createNotification(params) {
|
_createNotification(params) {
|
||||||
return new GtkNotificationDaemonNotification(this, params);
|
return new GtkNotificationDaemonNotification(this, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
activateAction(actionId, target) {
|
async activateAction(actionId, target) {
|
||||||
this._createApp((app, error) => {
|
try {
|
||||||
if (error == null)
|
const app = await this._createApp();
|
||||||
app.ActivateActionRemote(actionId, target ? [target] : [], getPlatformData());
|
const params = target ? [target] : [];
|
||||||
else
|
app.ActivateActionAsync(actionId, params, getPlatformData());
|
||||||
logError(error, 'Failed to activate application proxy');
|
} catch (error) {
|
||||||
});
|
logError(error, 'Failed to activate application proxy');
|
||||||
|
}
|
||||||
Main.overview.hide();
|
Main.overview.hide();
|
||||||
Main.panel.closeCalendar();
|
Main.panel.closeCalendar();
|
||||||
}
|
}
|
||||||
|
|
||||||
open() {
|
async open() {
|
||||||
this._createApp((app, error) => {
|
try {
|
||||||
if (error == null)
|
const app = await this._createApp();
|
||||||
app.ActivateRemote(getPlatformData());
|
app.ActivateAsync(getPlatformData());
|
||||||
else
|
} catch (error) {
|
||||||
logError(error, 'Failed to open application proxy');
|
logError(error, 'Failed to open application proxy');
|
||||||
});
|
}
|
||||||
Main.overview.hide();
|
Main.overview.hide();
|
||||||
Main.panel.closeCalendar();
|
Main.panel.closeCalendar();
|
||||||
}
|
}
|
||||||
|
@ -302,7 +302,7 @@ var RemoteSearchProvider = class {
|
|||||||
}
|
}
|
||||||
|
|
||||||
activateResult(id) {
|
activateResult(id) {
|
||||||
this.proxy.ActivateResultRemote(id);
|
this.proxy.ActivateResultAsync(id).catch(logError);
|
||||||
}
|
}
|
||||||
|
|
||||||
launchSearch(_terms) {
|
launchSearch(_terms) {
|
||||||
@ -321,10 +321,12 @@ var RemoteSearchProvider2 = class extends RemoteSearchProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
activateResult(id, terms) {
|
activateResult(id, terms) {
|
||||||
this.proxy.ActivateResultRemote(id, terms, global.get_current_time());
|
this.proxy.ActivateResultAsync(
|
||||||
|
id, terms, global.get_current_time()).catch(logError);
|
||||||
}
|
}
|
||||||
|
|
||||||
launchSearch(terms) {
|
launchSearch(terms) {
|
||||||
this.proxy.LaunchSearchRemote(terms, global.get_current_time());
|
this.proxy.LaunchSearchAsync(
|
||||||
|
terms, global.get_current_time()).catch(logError);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -173,7 +173,7 @@ var ScreenShield = class extends Signals.EventEmitter {
|
|||||||
this.emit('locked-changed');
|
this.emit('locked-changed');
|
||||||
|
|
||||||
if (this._loginSession)
|
if (this._loginSession)
|
||||||
this._loginSession.SetLockedHintRemote(locked);
|
this._loginSession.SetLockedHintAsync(locked).catch(logError);
|
||||||
}
|
}
|
||||||
|
|
||||||
_activateDialog() {
|
_activateDialog() {
|
||||||
|
@ -1824,42 +1824,38 @@ var ScreenshotUI = GObject.registerClass({
|
|||||||
this.close(true);
|
this.close(true);
|
||||||
|
|
||||||
// This is a bit awkward because creating a proxy synchronously hangs Shell.
|
// This is a bit awkward because creating a proxy synchronously hangs Shell.
|
||||||
const doStartScreencast = () => {
|
const doStartScreencast = async () => {
|
||||||
let method =
|
let method =
|
||||||
this._screencastProxy.ScreencastRemote.bind(this._screencastProxy);
|
this._screencastProxy.ScreencastAsync.bind(this._screencastProxy);
|
||||||
if (w !== -1) {
|
if (w !== -1) {
|
||||||
method = this._screencastProxy.ScreencastAreaRemote.bind(
|
method = this._screencastProxy.ScreencastAreaAsync.bind(
|
||||||
this._screencastProxy, x, y, w, h);
|
this._screencastProxy, x, y, w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
method(
|
try {
|
||||||
GLib.build_filenamev([
|
const [success, path] = await method(
|
||||||
/* Translators: this is the folder where recorded
|
GLib.build_filenamev([
|
||||||
screencasts are stored. */
|
/* Translators: this is the folder where recorded
|
||||||
_('Screencasts'),
|
screencasts are stored. */
|
||||||
/* Translators: this is a filename used for screencast
|
_('Screencasts'),
|
||||||
* recording, where "%d" and "%t" date and time, e.g.
|
/* Translators: this is a filename used for screencast
|
||||||
* "Screencast from 07-17-2013 10:00:46 PM.webm" */
|
* recording, where "%d" and "%t" date and time, e.g.
|
||||||
/* xgettext:no-c-format */
|
* "Screencast from 07-17-2013 10:00:46 PM.webm" */
|
||||||
_('Screencast from %d %t.webm'),
|
/* xgettext:no-c-format */
|
||||||
]),
|
_('Screencast from %d %t.webm'),
|
||||||
{ 'draw-cursor': new GLib.Variant('b', drawCursor) },
|
]),
|
||||||
([success, path], error) => {
|
{'draw-cursor': new GLib.Variant('b', drawCursor)});
|
||||||
if (error !== null) {
|
if (!success)
|
||||||
this._setScreencastInProgress(false);
|
throw new Error();
|
||||||
log(`Error starting screencast: ${error.message}`);
|
this._screencastPath = path;
|
||||||
return;
|
} catch (error) {
|
||||||
}
|
this._setScreencastInProgress(false);
|
||||||
|
const {message} = error;
|
||||||
if (!success) {
|
if (message)
|
||||||
this._setScreencastInProgress(false);
|
log(`Error starting screencast: ${message}`);
|
||||||
log('Error starting screencast');
|
else
|
||||||
return;
|
log('Error starting screencast');
|
||||||
}
|
}
|
||||||
|
|
||||||
this._screencastPath = path;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Set this before calling the method as the screen recording indicator
|
// Set this before calling the method as the screen recording indicator
|
||||||
@ -1886,7 +1882,7 @@ var ScreenshotUI = GObject.registerClass({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stopScreencast() {
|
async stopScreencast() {
|
||||||
if (!this._screencastInProgress)
|
if (!this._screencastInProgress)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -1894,58 +1890,59 @@ var ScreenshotUI = GObject.registerClass({
|
|||||||
// will check it before the success callback fires.
|
// will check it before the success callback fires.
|
||||||
this._setScreencastInProgress(false);
|
this._setScreencastInProgress(false);
|
||||||
|
|
||||||
this._screencastProxy.StopScreencastRemote((success, error) => {
|
try {
|
||||||
if (error !== null) {
|
const [success] = await this._screencastProxy.StopScreencastAsync();
|
||||||
log(`Error stopping screencast: ${error.message}`);
|
if (!success)
|
||||||
return;
|
throw new Error();
|
||||||
}
|
} catch (error) {
|
||||||
|
const {message} = error;
|
||||||
if (!success) {
|
if (message)
|
||||||
|
log(`Error stopping screencast: ${message}`);
|
||||||
|
else
|
||||||
log('Error stopping screencast');
|
log('Error stopping screencast');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show a notification.
|
||||||
|
const file = Gio.file_new_for_path(this._screencastPath);
|
||||||
|
|
||||||
|
const source = new MessageTray.Source(
|
||||||
|
// Translators: notification source name.
|
||||||
|
_('Screenshot'),
|
||||||
|
'screencast-recorded-symbolic'
|
||||||
|
);
|
||||||
|
const notification = new MessageTray.Notification(
|
||||||
|
source,
|
||||||
|
// Translators: notification title.
|
||||||
|
_('Screencast recorded'),
|
||||||
|
// Translators: notification body when a screencast was recorded.
|
||||||
|
_('Click here to view the video.')
|
||||||
|
);
|
||||||
|
// Translators: button on the screencast notification.
|
||||||
|
notification.addAction(_('Show in Files'), () => {
|
||||||
|
const app =
|
||||||
|
Gio.app_info_get_default_for_type('inode/directory', false);
|
||||||
|
|
||||||
|
if (app === null) {
|
||||||
|
// It may be null e.g. in a toolbox without nautilus.
|
||||||
|
log('Error showing in files: no default app set for inode/directory');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show a notification.
|
app.launch([file], global.create_app_launch_context(0, -1));
|
||||||
const file = Gio.file_new_for_path(this._screencastPath);
|
|
||||||
|
|
||||||
const source = new MessageTray.Source(
|
|
||||||
// Translators: notification source name.
|
|
||||||
_('Screenshot'),
|
|
||||||
'screencast-recorded-symbolic'
|
|
||||||
);
|
|
||||||
const notification = new MessageTray.Notification(
|
|
||||||
source,
|
|
||||||
// Translators: notification title.
|
|
||||||
_('Screencast recorded'),
|
|
||||||
// Translators: notification body when a screencast was recorded.
|
|
||||||
_('Click here to view the video.')
|
|
||||||
);
|
|
||||||
// Translators: button on the screencast notification.
|
|
||||||
notification.addAction(_('Show in Files'), () => {
|
|
||||||
const app =
|
|
||||||
Gio.app_info_get_default_for_type('inode/directory', false);
|
|
||||||
|
|
||||||
if (app === null) {
|
|
||||||
// It may be null e.g. in a toolbox without nautilus.
|
|
||||||
log('Error showing in files: no default app set for inode/directory');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
app.launch([file], global.create_app_launch_context(0, -1));
|
|
||||||
});
|
|
||||||
notification.connect('activated', () => {
|
|
||||||
try {
|
|
||||||
Gio.app_info_launch_default_for_uri(
|
|
||||||
file.get_uri(), global.create_app_launch_context(0, -1));
|
|
||||||
} catch (err) {
|
|
||||||
logError(err, 'Error opening screencast');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
notification.setTransient(true);
|
|
||||||
|
|
||||||
Main.messageTray.add(source);
|
|
||||||
source.showNotification(notification);
|
|
||||||
});
|
});
|
||||||
|
notification.connect('activated', () => {
|
||||||
|
try {
|
||||||
|
Gio.app_info_launch_default_for_uri(
|
||||||
|
file.get_uri(), global.create_app_launch_context(0, -1));
|
||||||
|
} catch (err) {
|
||||||
|
logError(err, 'Error opening screencast');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
notification.setTransient(true);
|
||||||
|
|
||||||
|
Main.messageTray.add(source);
|
||||||
|
source.showNotification(notification);
|
||||||
}
|
}
|
||||||
|
|
||||||
get screencast_in_progress() {
|
get screencast_in_progress() {
|
||||||
|
@ -82,19 +82,6 @@ function _spawnPerfHelper() {
|
|||||||
Util.trySpawnCommandLine(command);
|
Util.trySpawnCommandLine(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
function _callRemote(obj, method, ...args) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
args.push((result, excp) => {
|
|
||||||
if (excp)
|
|
||||||
reject(excp);
|
|
||||||
else
|
|
||||||
resolve();
|
|
||||||
});
|
|
||||||
|
|
||||||
method.apply(obj, args);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* createTestWindow:
|
* createTestWindow:
|
||||||
* @param {Object} params: options for window creation.
|
* @param {Object} params: options for window creation.
|
||||||
@ -121,9 +108,9 @@ function createTestWindow(params) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
let perfHelper = _getPerfHelper();
|
let perfHelper = _getPerfHelper();
|
||||||
return _callRemote(perfHelper, perfHelper.CreateWindowRemote,
|
perfHelper.CreateWindowAsync(
|
||||||
params.width, params.height,
|
params.width, params.height,
|
||||||
params.alpha, params.maximized, params.redraws);
|
params.alpha, params.maximized, params.redraws).catch(logError);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -135,7 +122,7 @@ function createTestWindow(params) {
|
|||||||
*/
|
*/
|
||||||
function waitTestWindows() {
|
function waitTestWindows() {
|
||||||
let perfHelper = _getPerfHelper();
|
let perfHelper = _getPerfHelper();
|
||||||
return _callRemote(perfHelper, perfHelper.WaitWindowsRemote);
|
perfHelper.WaitWindowsAsync().catch(logError);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -150,7 +137,7 @@ function waitTestWindows() {
|
|||||||
*/
|
*/
|
||||||
function destroyTestWindows() {
|
function destroyTestWindows() {
|
||||||
let perfHelper = _getPerfHelper();
|
let perfHelper = _getPerfHelper();
|
||||||
return _callRemote(perfHelper, perfHelper.DestroyWindowsRemote);
|
perfHelper.DestroyWindowsAsync().catch(logError);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -137,7 +137,7 @@ var GeoclueAgent = GObject.registerClass({
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
_onManagerProxyReady(proxy, error) {
|
async _onManagerProxyReady(proxy, error) {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
log(error.message);
|
log(error.message);
|
||||||
this._connecting = false;
|
this._connecting = false;
|
||||||
@ -150,15 +150,13 @@ var GeoclueAgent = GObject.registerClass({
|
|||||||
|
|
||||||
this.notify('in-use');
|
this.notify('in-use');
|
||||||
|
|
||||||
this._managerProxy.AddAgentRemote('gnome-shell', this._onAgentRegistered.bind(this));
|
try {
|
||||||
}
|
await this._managerProxy.AddAgentAsync('gnome-shell');
|
||||||
|
this._connecting = false;
|
||||||
_onAgentRegistered(result, error) {
|
this._notifyMaxAccuracyLevel();
|
||||||
this._connecting = false;
|
} catch (e) {
|
||||||
this._notifyMaxAccuracyLevel();
|
log(e.message);
|
||||||
|
}
|
||||||
if (error != null)
|
|
||||||
log(error.message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_onGeoclueVanished() {
|
_onGeoclueVanished() {
|
||||||
@ -298,7 +296,7 @@ var AppAuthorizer = class {
|
|||||||
return this._accuracyLevel;
|
return this._accuracyLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
_saveToPermissionStore() {
|
async _saveToPermissionStore() {
|
||||||
if (this._permStoreProxy == null)
|
if (this._permStoreProxy == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -308,15 +306,16 @@ var AppAuthorizer = class {
|
|||||||
|
|
||||||
let data = GLib.Variant.new('av', {});
|
let data = GLib.Variant.new('av', {});
|
||||||
|
|
||||||
this._permStoreProxy.SetRemote(APP_PERMISSIONS_TABLE,
|
try {
|
||||||
true,
|
await this._permStoreProxy.SetAsync(
|
||||||
APP_PERMISSIONS_ID,
|
APP_PERMISSIONS_TABLE,
|
||||||
this._permissions,
|
true,
|
||||||
data,
|
APP_PERMISSIONS_ID,
|
||||||
(result, error) => {
|
this._permissions,
|
||||||
if (error != null)
|
data);
|
||||||
log(error.message);
|
} catch (error) {
|
||||||
});
|
log(error.message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ var PortalHelperResult = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const PortalHelperIface = loadInterfaceXML('org.gnome.Shell.PortalHelper');
|
const PortalHelperIface = loadInterfaceXML('org.gnome.Shell.PortalHelper');
|
||||||
const PortalHelperProxy = Gio.DBusProxy.makeProxyWrapper(PortalHelperIface);
|
const PortalHelperInfo = Gio.DBusInterfaceInfo.new_for_xml(PortalHelperIface);
|
||||||
|
|
||||||
function signalToIcon(value) {
|
function signalToIcon(value) {
|
||||||
if (value < 20)
|
if (value < 20)
|
||||||
@ -2090,7 +2090,7 @@ class Indicator extends PanelMenu.SystemIndicator {
|
|||||||
_flushConnectivityQueue() {
|
_flushConnectivityQueue() {
|
||||||
if (this._portalHelperProxy) {
|
if (this._portalHelperProxy) {
|
||||||
for (let item of this._connectivityQueue)
|
for (let item of this._connectivityQueue)
|
||||||
this._portalHelperProxy.CloseRemote(item);
|
this._portalHelperProxy.CloseAsync(item).catch(logError);
|
||||||
}
|
}
|
||||||
|
|
||||||
this._connectivityQueue = [];
|
this._connectivityQueue = [];
|
||||||
@ -2101,7 +2101,7 @@ class Indicator extends PanelMenu.SystemIndicator {
|
|||||||
|
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
if (this._portalHelperProxy)
|
if (this._portalHelperProxy)
|
||||||
this._portalHelperProxy.CloseRemote(path);
|
this._portalHelperProxy.CloseAsync(path).catch(logError);
|
||||||
|
|
||||||
this._connectivityQueue.splice(index, 1);
|
this._connectivityQueue.splice(index, 1);
|
||||||
}
|
}
|
||||||
@ -2128,7 +2128,7 @@ class Indicator extends PanelMenu.SystemIndicator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_syncConnectivity() {
|
async _syncConnectivity() {
|
||||||
if (this._mainConnection == null ||
|
if (this._mainConnection == null ||
|
||||||
this._mainConnection.state != NM.ActiveConnectionState.ACTIVATED) {
|
this._mainConnection.state != NM.ActiveConnectionState.ACTIVATED) {
|
||||||
this._flushConnectivityQueue();
|
this._flushConnectivityQueue();
|
||||||
@ -2153,25 +2153,27 @@ class Indicator extends PanelMenu.SystemIndicator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let timestamp = global.get_current_time();
|
let timestamp = global.get_current_time();
|
||||||
if (this._portalHelperProxy) {
|
if (!this._portalHelperProxy) {
|
||||||
this._portalHelperProxy.AuthenticateRemote(path, '', timestamp);
|
this._portalHelperProxy = new Gio.DBusProxy({
|
||||||
} else {
|
g_connection: Gio.DBus.session,
|
||||||
new PortalHelperProxy(Gio.DBus.session,
|
g_name: 'org.gnome.Shell.PortalHelper',
|
||||||
'org.gnome.Shell.PortalHelper',
|
g_object_path: '/org/gnome/Shell/PortalHelper',
|
||||||
'/org/gnome/Shell/PortalHelper',
|
g_interface_name: PortalHelperInfo.name,
|
||||||
(proxy, error) => {
|
g_interface_info: PortalHelperInfo,
|
||||||
if (error) {
|
});
|
||||||
log(`Error launching the portal helper: ${error}`);
|
this._portalHelperProxy.connectSignal('Done',
|
||||||
return;
|
() => this._portalHelperDone().catch(logError));
|
||||||
}
|
|
||||||
|
|
||||||
this._portalHelperProxy = proxy;
|
try {
|
||||||
proxy.connectSignal('Done', this._portalHelperDone.bind(this));
|
await this._portalHelperProxy.init_async(
|
||||||
|
GLib.PRIORITY_DEFAULT, null);
|
||||||
proxy.AuthenticateRemote(path, '', timestamp);
|
} catch (e) {
|
||||||
});
|
console.error(`Error launching the portal helper: ${e.message}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this._portalHelperProxy?.AuthenticateAsync(path, '', timestamp).catch(logError);
|
||||||
|
|
||||||
this._connectivityQueue.push(path);
|
this._connectivityQueue.push(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,20 +109,15 @@ var Client = class extends Signals.EventEmitter {
|
|||||||
this._proxy = null;
|
this._proxy = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
enrollDevice(id, policy, callback) {
|
async enrollDevice(id, policy) {
|
||||||
this._proxy.EnrollDeviceRemote(id, policy, AuthCtrl.NONE, (res, error) => {
|
try {
|
||||||
if (error) {
|
const [path] = await this._proxy.EnrollDeviceAsync(id, policy, AuthCtrl.NONE);
|
||||||
Gio.DBusError.strip_remote_error(error);
|
const device = new BoltDeviceProxy(Gio.DBus.system, BOLT_DBUS_NAME, path);
|
||||||
callback(null, error);
|
return device;
|
||||||
return;
|
} catch (error) {
|
||||||
}
|
Gio.DBusError.strip_remote_error(error);
|
||||||
|
throw error;
|
||||||
let [path] = res;
|
}
|
||||||
let device = new BoltDeviceProxy(Gio.DBus.system,
|
|
||||||
BOLT_DBUS_NAME,
|
|
||||||
path);
|
|
||||||
callback(device, null);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get authMode() {
|
get authMode() {
|
||||||
@ -191,32 +186,29 @@ var AuthRobot = class extends Signals.EventEmitter {
|
|||||||
this._enrollDevicesIdle.bind(this));
|
this._enrollDevicesIdle.bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
_onEnrollDone(device, error) {
|
async _enrollDevicesIdle() {
|
||||||
if (error)
|
|
||||||
this.emit('enroll-failed', device, error);
|
|
||||||
|
|
||||||
/* TODO: scan the list of devices to be authorized for children
|
|
||||||
* of this device and remove them (and their children and
|
|
||||||
* their children and ....) from the device queue
|
|
||||||
*/
|
|
||||||
this._enrolling = this._devicesToEnroll.length > 0;
|
|
||||||
|
|
||||||
if (this._enrolling) {
|
|
||||||
GLib.idle_add(GLib.PRIORITY_DEFAULT,
|
|
||||||
this._enrollDevicesIdle.bind(this));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_enrollDevicesIdle() {
|
|
||||||
let devices = this._devicesToEnroll;
|
let devices = this._devicesToEnroll;
|
||||||
|
|
||||||
let dev = devices.shift();
|
let dev = devices.shift();
|
||||||
if (dev === undefined)
|
if (dev === undefined)
|
||||||
return GLib.SOURCE_REMOVE;
|
return GLib.SOURCE_REMOVE;
|
||||||
|
|
||||||
this._client.enrollDevice(dev.Uid,
|
try {
|
||||||
Policy.DEFAULT,
|
await this._client.enrollDevice(dev.Uid, Policy.DEFAULT);
|
||||||
this._onEnrollDone.bind(this));
|
|
||||||
|
/* TODO: scan the list of devices to be authorized for children
|
||||||
|
* of this device and remove them (and their children and
|
||||||
|
* their children and ....) from the device queue
|
||||||
|
*/
|
||||||
|
this._enrolling = this._devicesToEnroll.length > 0;
|
||||||
|
|
||||||
|
if (this._enrolling) {
|
||||||
|
GLib.idle_add(GLib.PRIORITY_DEFAULT,
|
||||||
|
this._enrollDevicesIdle.bind(this));
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
this.emit('enroll-failed', null, error);
|
||||||
|
}
|
||||||
return GLib.SOURCE_REMOVE;
|
return GLib.SOURCE_REMOVE;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -894,8 +894,8 @@ var WindowManager = class {
|
|||||||
labels.push(str ?? '');
|
labels.push(str ?? '');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._gsdWacomProxy)
|
this._gsdWacomProxy?.SetOLEDLabelsAsync(
|
||||||
this._gsdWacomProxy.SetOLEDLabelsRemote(pad.get_device_node(), labels);
|
pad.get_device_node(), labels).catch(logError);
|
||||||
});
|
});
|
||||||
|
|
||||||
global.display.connect('init-xserver', (display, task) => {
|
global.display.connect('init-xserver', (display, task) => {
|
||||||
|
@ -51,7 +51,7 @@ class Application extends Adw.Application {
|
|||||||
}
|
}
|
||||||
|
|
||||||
vfunc_activate() {
|
vfunc_activate() {
|
||||||
this._shellProxy.CheckForUpdatesRemote();
|
this._shellProxy.CheckForUpdatesAsync().catch(logError);
|
||||||
this._window.present();
|
this._window.present();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,7 +176,7 @@ var ExtensionsWindow = GObject.registerClass({
|
|||||||
|
|
||||||
dialog.connect('response', (dlg, response) => {
|
dialog.connect('response', (dlg, response) => {
|
||||||
if (response === Gtk.ResponseType.ACCEPT)
|
if (response === Gtk.ResponseType.ACCEPT)
|
||||||
this._shellProxy.UninstallExtensionRemote(uuid);
|
this._shellProxy.UninstallExtensionAsync(uuid).catch(logError);
|
||||||
dialog.destroy();
|
dialog.destroy();
|
||||||
});
|
});
|
||||||
dialog.present();
|
dialog.present();
|
||||||
@ -191,9 +191,9 @@ var ExtensionsWindow = GObject.registerClass({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this._shellProxy.OpenExtensionPrefsRemote(uuid,
|
this._shellProxy.OpenExtensionPrefsAsync(uuid,
|
||||||
this._exportedHandle,
|
this._exportedHandle,
|
||||||
{ modal: new GLib.Variant('b', true) });
|
{modal: new GLib.Variant('b', true)}).catch(logError);
|
||||||
}
|
}
|
||||||
|
|
||||||
_showAbout() {
|
_showAbout() {
|
||||||
@ -281,24 +281,23 @@ var ExtensionsWindow = GObject.registerClass({
|
|||||||
this._syncListVisibility();
|
this._syncListVisibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
_scanExtensions() {
|
async _scanExtensions() {
|
||||||
this._shellProxy.ListExtensionsRemote(([extensionsMap], e) => {
|
try {
|
||||||
if (e) {
|
const [extensionsMap] = await this._shellProxy.ListExtensionsAsync();
|
||||||
if (e instanceof Gio.DBusError) {
|
|
||||||
log(`Failed to connect to shell proxy: ${e}`);
|
|
||||||
this._mainStack.visible_child_name = 'noshell';
|
|
||||||
} else {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (let uuid in extensionsMap) {
|
for (let uuid in extensionsMap) {
|
||||||
let extension = ExtensionUtils.deserializeExtension(extensionsMap[uuid]);
|
let extension = ExtensionUtils.deserializeExtension(extensionsMap[uuid]);
|
||||||
this._addExtensionRow(extension);
|
this._addExtensionRow(extension);
|
||||||
}
|
}
|
||||||
this._extensionsLoaded();
|
this._extensionsLoaded();
|
||||||
});
|
} catch (e) {
|
||||||
|
if (e instanceof Gio.DBusError) {
|
||||||
|
log(`Failed to connect to shell proxy: ${e}`);
|
||||||
|
this._mainStack.visible_child_name = 'noshell';
|
||||||
|
} else {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_addExtensionRow(extension) {
|
_addExtensionRow(extension) {
|
||||||
@ -407,9 +406,9 @@ var ExtensionRow = GObject.registerClass({
|
|||||||
action.connect('activate', toggleState);
|
action.connect('activate', toggleState);
|
||||||
action.connect('change-state', (a, state) => {
|
action.connect('change-state', (a, state) => {
|
||||||
if (state.get_boolean())
|
if (state.get_boolean())
|
||||||
this._app.shellProxy.EnableExtensionRemote(this.uuid);
|
this._app.shellProxy.EnableExtensionAsync(this.uuid).catch(logError);
|
||||||
else
|
else
|
||||||
this._app.shellProxy.DisableExtensionRemote(this.uuid);
|
this._app.shellProxy.DisableExtensionAsync(this.uuid).catch(logError);
|
||||||
});
|
});
|
||||||
this._actionGroup.add_action(action);
|
this._actionGroup.add_action(action);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user