[gnome-shell/mcatanzaro/#2276] Fix prompt for updates on end session dialog
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/mcatanzaro/#2276] Fix prompt for updates on end session dialog
- Date: Wed, 25 Mar 2020 22:24:49 +0000 (UTC)
commit a34d149a8fa10adcb6ee49451c2f6e4cd628273d
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Tue Mar 17 20:56:33 2020 -0500
Fix prompt for updates on end session dialog
Since PackageKit 1.11.1, the prompt to install updates on the end
session dialog has been (mostly) broken. The problem is that it only
works if PackageKit is running at the time the end session dialog is
opened; otherwise, our GDBusProxy has invalidated all of its properties,
which we read to see if update is possible. We need to autostart
PackageKit before reading its properties to fix this problem. That would
be easy if we were calling a method to see if an update or distro
upgrade were available, but since we're just checking a property,
there's not really an obvious non-hackish way to do it. So I came up
with this yucky hack: we can ping PackageKit, which will autostart it,
then wait for it to update its properties. (The properties are not
updated before we receive the reply to its ping.)
The timeout is created to ensure that we don't fail to show the dialog
if PackageKit responds to the ping but fails to update its properties in
a reasonable amount of time. It's yucky, but we should be robust to that
possibility.
Fixes https://gitlab.gnome.org/GNOME/gnome-shell/issues/2276
js/ui/endSessionDialog.js | 49 ++++++++++++++++++++++++++++++++++++++---------
1 file changed, 40 insertions(+), 9 deletions(-)
---
diff --git a/js/ui/endSessionDialog.js b/js/ui/endSessionDialog.js
index 42ae0d3f26..ec7dbdcc87 100644
--- a/js/ui/endSessionDialog.js
+++ b/js/ui/endSessionDialog.js
@@ -29,6 +29,8 @@ const UserWidget = imports.ui.userWidget;
const { loadInterfaceXML } = imports.misc.fileUtils;
+Gio._promisify(Gio.DBusConnection.prototype, 'call', 'call_finish');
+
const _ITEM_ICON_SIZE = 64;
const EndSessionDialogIface = loadInterfaceXML('org.gnome.SessionManager.EndSessionDialog');
@@ -346,9 +348,9 @@ class EndSessionDialog extends ModalDialog.ModalDialog {
// Use a different description when we are installing a system upgrade
// if the PackageKit proxy is available (i.e. PackageKit is available).
- if (this._pkOfflineProxy && dialogContent.upgradeDescription) {
- let name = this._pkOfflineProxy.PreparedUpgrade['name'].deep_unpack();
- let version = this._pkOfflineProxy.PreparedUpgrade['version'].deep_unpack();
+ if (this._updateInfo && dialogContent.upgradeDescription) {
+ let name = this._updateInfo.PreparedUpgrade['name'].deep_unpack();
+ let version = this._updateInfo.PreparedUpgrade['version'].deep_unpack();
if (name != null && version != null)
description = dialogContent.upgradeDescription(name, version);
@@ -608,16 +610,46 @@ class EndSessionDialog extends ModalDialog.ModalDialog {
});
}
- OpenAsync(parameters, invocation) {
+ async _getUpdateInfo() {
+ const connection = this._pkOfflineProxy.get_connection();
+ const reply = await connection.call(
+ this._pkOfflineProxy.g_name,
+ this._pkOfflineProxy.g_object_path,
+ 'org.freedesktop.DBus.Properties',
+ 'GetAll',
+ new GLib.Variant('(s)', [this._pkOfflineProxy.g_interface_name]),
+ null,
+ Gio.DBusCallFlags.NONE,
+ -1,
+ null);
+ const [info] = reply.recursiveUnpack();
+ return info;
+ }
+
+ async OpenAsync(parameters, invocation) {
let [type, timestamp, totalSecondsToStayOpen, inhibitorObjectPaths] = parameters;
this._totalSecondsToStayOpen = totalSecondsToStayOpen;
this._type = type;
+ try {
+ this._updateInfo = await this._getUpdateInfo();
+ } catch (e) {
+ if (this._pkOfflineProxy !== null)
+ log('Failed to get update info from PackageKit: %s'.format(e.message));
+
+ this._updateInfo = {
+ UpdateTriggered: false,
+ UpdatePrepared: false,
+ UpgradeTriggered: false,
+ PreparedUpgrade: {},
+ }
+ }
+
// Only consider updates and upgrades if PackageKit is available.
if (this._pkOfflineProxy && this._type == DialogType.RESTART) {
- if (this._pkOfflineProxy.UpdateTriggered)
+ if (this._updateInfo.UpdateTriggered)
this._type = DialogType.UPDATE_RESTART;
- else if (this._pkOfflineProxy.UpgradeTriggered)
+ else if (this._updateInfo.UpgradeTriggered)
this._type = DialogType.UPGRADE_RESTART;
}
@@ -646,9 +678,8 @@ class EndSessionDialog extends ModalDialog.ModalDialog {
if (dialogContent.showOtherSessions)
this._loadSessions();
- // Only consider updates and upgrades if PackageKit is available.
- let updateTriggered = this._pkOfflineProxy ? this._pkOfflineProxy.UpdateTriggered : false;
- let updatePrepared = this._pkOfflineProxy ? this._pkOfflineProxy.UpdatePrepared : false;
+ let updateTriggered = this._updateInfo.UpdateTriggered;
+ let updatePrepared = this._updateInfo.UpdatePrepared;
let updatesAllowed = this._updatesPermission && this._updatesPermission.allowed;
_setCheckBoxLabel(this._checkBox, dialogContent.checkBoxText || '');
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]