[gnome-software/603-gnome-software-reports-unknown-error-when-there-is-a-signing-issue: 188/191] 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: 188/191] packagekit: Recognize when the user declined an operation
- Date: Tue, 10 Aug 2021 12:43:09 +0000 (UTC)
commit 223a32144baa0e262c3b629bfe55ad258a5027ef
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 | 13 +++++++++++++
2 files changed, 17 insertions(+)
---
diff --git a/meson.build b/meson.build
index b4a26ae3b..a61797a67 100644
--- a/meson.build
+++ b/meson.build
@@ -201,6 +201,10 @@ if get_option('packagekit')
if meson.get_compiler('c').has_function('pk_details_get_download_size', prefix: '#include
<packagekit-glib2/packagekit.h>', dependencies: packagekit)
conf.set('HAVE_PK_DETAILS_GET_DOWNLOAD_SIZE', '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 c644ff993..c953a4008 100644
--- a/plugins/packagekit/packagekit-common.c
+++ b/plugins/packagekit/packagekit-common.c
@@ -102,6 +102,19 @@ 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
*/
+ 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]