[gnome-software/603-gnome-software-reports-unknown-error-when-there-is-a-signing-issue: 44/48] packagekit: Recognize when the user declined an operation
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/603-gnome-software-reports-unknown-error-when-there-is-a-signing-issue: 44/48] packagekit: Recognize when the user declined an operation
- Date: Thu, 14 Oct 2021 15:02:37 +0000 (UTC)
commit 2f2e2123b6cec9ac4a16cf96478ca2909c765ee2
Author: Milan Crha <mcrha redhat com>
Date: Fri Jul 9 12:37:35 2021 +0200
packagekit: Recognize when the user declined an operation
An old PackageKit returns a generic PK_CLIENT_ERROR_FAILED error with
a non-localized text "user declined interaction" in such case, thus
catch it and convert the error into GS_PLUGIN_ERROR_CANCELLED,
thus the user doesn't see a notification about declined interaction
when he/she did it.
A new PackageKit defines a specific error code for the declined interaction,
thus use that, if available.
meson.build | 4 ++++
plugins/packagekit/packagekit-common.c | 15 +++++++++++++++
2 files changed, 19 insertions(+)
---
diff --git a/meson.build b/meson.build
index bb39e8304..04530fb4e 100644
--- a/meson.build
+++ b/meson.build
@@ -200,6 +200,10 @@ if get_option('packagekit')
meson.get_compiler('c').has_function('pk_offline_trigger_upgrade_with_flags', prefix: '#include
<packagekit-glib2/packagekit.h>', dependencies: packagekit)
conf.set('HAVE_PK_OFFLINE_WITH_FLAGS', '1')
endif
+ if meson.get_compiler('c').links('''#include <packagekit-glib2/packagekit.h>
+ int main(void) { PkClientError err = PK_CLIENT_ERROR_DECLINED_INTERACTION; return 0; }''',
dependencies: packagekit, name: 'PK_CLIENT_ERROR_DECLINED_INTERACTION')
+ conf.set('HAVE_PK_CLIENT_ERROR_DECLINED_INTERACTION', '1')
+ endif
endif
if get_option('eos_updater')
diff --git a/plugins/packagekit/packagekit-common.c b/plugins/packagekit/packagekit-common.c
index dc79c2f62..64d064a84 100644
--- a/plugins/packagekit/packagekit-common.c
+++ b/plugins/packagekit/packagekit-common.c
@@ -105,6 +105,21 @@ gs_plugin_packagekit_error_convert (GError **error)
case PK_CLIENT_ERROR_NOT_SUPPORTED:
error_tmp->code = GS_PLUGIN_ERROR_NOT_SUPPORTED;
break;
+ #ifdef HAVE_PK_CLIENT_ERROR_DECLINED_INTERACTION
+ case PK_CLIENT_ERROR_DECLINED_INTERACTION:
+ error_tmp->code = GS_PLUGIN_ERROR_CANCELLED;
+ break;
+ #else
+ case PK_CLIENT_ERROR_FAILED:
+ /* The text is not localized on the PackageKit side and it uses a generic error code
+ * FIXME: This can be dropped when we depend on a
+ * PackageKit version which includes
https://github.com/PackageKit/PackageKit/pull/497 */
+ if (g_strcmp0 (error_tmp->message, "user declined interaction") == 0)
+ error_tmp->code = GS_PLUGIN_ERROR_CANCELLED;
+ else
+ error_tmp->code = GS_PLUGIN_ERROR_FAILED;
+ break;
+ #endif
/* this is working around a bug in libpackagekit-glib */
case PK_ERROR_ENUM_TRANSACTION_CANCELLED:
error_tmp->code = GS_PLUGIN_ERROR_CANCELLED;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]