[gnome-software/603-gnome-software-reports-unknown-error-when-there-is-a-signing-issue: 207/207] packagekit: Ask the user what to do when there's a package signing issue




commit 7c8f63ec206c4b3757b1fed3092f0dc87132c3fb
Author: Milan Crha <mcrha redhat com>
Date:   Mon Sep 20 14:22:32 2021 +0200

    packagekit: Ask the user what to do when there's a package signing issue
    
    Ask the user what to do, rather than error out with a cryptic error
    message "could not do untrusted question as no klass support".
    
    Closes https://gitlab.gnome.org/GNOME/gnome-software/-/issues/603

 plugins/packagekit/gs-packagekit-task.c           | 229 ++++++++++++++++++++++
 plugins/packagekit/gs-packagekit-task.h           |  32 +++
 plugins/packagekit/gs-plugin-packagekit-refresh.c |   7 +-
 plugins/packagekit/gs-plugin-packagekit.c         |  35 ++--
 plugins/packagekit/meson.build                    |   2 +
 po/POTFILES.in                                    |   1 +
 6 files changed, 286 insertions(+), 20 deletions(-)
---
diff --git a/plugins/packagekit/gs-packagekit-task.c b/plugins/packagekit/gs-packagekit-task.c
new file mode 100644
index 000000000..e003f6a70
--- /dev/null
+++ b/plugins/packagekit/gs-packagekit-task.c
@@ -0,0 +1,229 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ * vi:set noexpandtab tabstop=8 shiftwidth=8:
+ *
+ * Copyright (C) 2021 Red Hat <www.redhat.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include "config.h"
+
+#include <glib/gi18n-lib.h>
+
+#include "gs-packagekit-task.h"
+
+typedef struct _GsPackageKitTaskPrivate {
+       GWeakRef plugin_weakref; /* GsPlugin * */
+       GsPluginAction action;
+} GsPackageKitTaskPrivate;
+
+G_DEFINE_TYPE_WITH_PRIVATE (GsPackageKitTask, gs_packagekit_task, PK_TYPE_TASK)
+
+static gboolean
+gs_packagekit_task_user_accepted (PkTask *task,
+                                 const gchar *title,
+                                 const gchar *msg,
+                                 const gchar *details,
+                                 const gchar *accept_label)
+{
+       GsPackageKitTask *gs_task = GS_PACKAGEKIT_TASK (task);
+       GsPackageKitTaskPrivate *priv = gs_packagekit_task_get_instance_private (gs_task);
+       g_autoptr(GsPlugin) plugin = NULL;
+       gboolean accepts = FALSE;
+
+       plugin = g_weak_ref_get (&priv->plugin_weakref);
+       if (plugin)
+               accepts = gs_plugin_ask_user_accepts (plugin, title, msg, details, accept_label);
+
+       return accepts;
+}
+
+typedef struct _QuestionData {
+       GWeakRef task_weakref;
+       guint request;
+       gchar *title;
+       gchar *msg;
+       gchar *details;
+       gchar *accept_label;
+} QuestionData;
+
+static QuestionData *
+question_data_new (GsPackageKitTask *task,
+                  guint request,
+                  const gchar *title,
+                  const gchar *msg,
+                  const gchar *details,
+                  const gchar *accept_label)
+{
+       QuestionData *qd;
+
+       qd = g_slice_new0 (QuestionData);
+       g_weak_ref_init (&qd->task_weakref, task);
+       qd->request = request;
+       qd->title = g_strdup (title);
+       qd->msg = g_strdup (msg);
+       qd->details = g_strdup (details);
+       qd->accept_label = g_strdup (accept_label);
+
+       return qd;
+}
+
+static void
+question_data_free (gpointer ptr)
+{
+       QuestionData *qd = ptr;
+
+       if (qd) {
+               g_weak_ref_clear (&qd->task_weakref);
+               g_free (qd->title);
+               g_free (qd->msg);
+               g_free (qd->details);
+               g_free (qd->accept_label);
+               g_slice_free (QuestionData, qd);
+       }
+}
+
+static gboolean
+gs_packagekit_task_question_idle_cb (gpointer user_data)
+{
+       QuestionData *qd = user_data;
+       g_autoptr(PkTask) task = NULL;
+
+       task = g_weak_ref_get (&qd->task_weakref);
+       if (task) {
+               if (gs_packagekit_task_user_accepted (task, qd->title, qd->msg, qd->details, 
qd->accept_label))
+                       pk_task_user_accepted (task, qd->request);
+               else
+                       pk_task_user_declined (task, qd->request);
+       }
+
+       return G_SOURCE_REMOVE;
+}
+
+static void
+gs_packagekit_task_schedule_question (GsPackageKitTask *task,
+                                     guint request,
+                                     const gchar *title,
+                                     const gchar *msg,
+                                     const gchar *details,
+                                     const gchar *accept_label)
+{
+       QuestionData *qd;
+
+       qd = question_data_new (task, request, title, msg, details, accept_label);
+       g_idle_add_full (G_PRIORITY_HIGH_IDLE, gs_packagekit_task_question_idle_cb, qd, question_data_free);
+}
+
+static void
+gs_packagekit_task_untrusted_question (PkTask *task,
+                                      guint request,
+                                      PkResults *results)
+{
+       GsPackageKitTask *gs_task = GS_PACKAGEKIT_TASK (task);
+       GsPackageKitTaskPrivate *priv = gs_packagekit_task_get_instance_private (gs_task);
+       g_autoptr(PkError) error = NULL;
+       const gchar *title;
+       const gchar *msg;
+       const gchar *details;
+       const gchar *accept_label;
+
+       switch (priv->action) {
+       case GS_PLUGIN_ACTION_INSTALL:
+               title = _("Install Unsigned Software?");
+               msg = _("Software that is to be installed is not signed. It will not be possible to verify 
the origin of updates to this software, or whether updates have been tampered with.");
+               accept_label = _("_Install");
+               break;
+       case GS_PLUGIN_ACTION_DOWNLOAD:
+               title = _("Download Unsigned Software?");
+               msg = _("Unsigned updates are available. Without a signature, it is not possible to verify 
the origin of the update, or whether it has been tampered with.");
+               accept_label = _("_Download");
+               break;
+       case GS_PLUGIN_ACTION_UPDATE:
+               title = _("Update Unsigned Software?");
+               msg = _("Unsigned updates are available. Without a signature, it is not possible to verify 
the origin of the update, or whether it has been tampered with. Software updates will be disabled until 
unsigned updates are either removed or updated.");
+               accept_label = _("_Update");
+               break;
+       default:
+               pk_task_user_declined (task, request);
+               return;
+       }
+
+       error = pk_results_get_error_code (results);
+       if (error)
+               details = pk_error_get_details (error);
+       else
+               details = NULL;
+
+       gs_packagekit_task_schedule_question (gs_task, request, title, msg, details, accept_label);
+}
+
+static void
+gs_packagekit_task_finalize (GObject *object)
+{
+       GsPackageKitTask *task = GS_PACKAGEKIT_TASK (object);
+       GsPackageKitTaskPrivate *priv = gs_packagekit_task_get_instance_private (task);
+
+       g_weak_ref_clear (&priv->plugin_weakref);
+
+       G_OBJECT_CLASS (gs_packagekit_task_parent_class)->finalize (object);
+}
+
+static void
+gs_packagekit_task_class_init (GsPackageKitTaskClass *klass)
+{
+       GObjectClass *object_class;
+       PkTaskClass *task_class;
+
+       task_class = PK_TASK_CLASS (klass);
+       task_class->untrusted_question = gs_packagekit_task_untrusted_question;
+
+       object_class = G_OBJECT_CLASS (klass);
+       object_class->finalize = gs_packagekit_task_finalize;
+}
+
+static void
+gs_packagekit_task_init (GsPackageKitTask *task)
+{
+       GsPackageKitTaskPrivate *priv = gs_packagekit_task_get_instance_private (task);
+
+       g_weak_ref_init (&priv->plugin_weakref, NULL);
+}
+
+PkTask *
+gs_packagekit_task_new (GsPlugin *plugin)
+{
+       GsPackageKitTask *task;
+       GsPackageKitTaskPrivate *priv;
+
+       g_return_val_if_fail (GS_IS_PLUGIN (plugin), NULL);
+
+       task = g_object_new (GS_TYPE_PACKAGEKIT_TASK, NULL);
+       priv = gs_packagekit_task_get_instance_private (task);
+
+       g_weak_ref_set (&priv->plugin_weakref, plugin);
+
+       return PK_TASK (task);
+}
+
+void
+gs_packagekit_task_setup (GsPackageKitTask *task,
+                         GsPluginAction action,
+                         gboolean interactive)
+{
+       GsPackageKitTaskPrivate *priv = gs_packagekit_task_get_instance_private (task);
+
+       g_return_if_fail (GS_IS_PACKAGEKIT_TASK (task));
+
+       priv->action = action;
+       pk_client_set_interactive (PK_CLIENT (task), interactive);
+}
+
+GsPluginAction
+gs_packagekit_task_get_action (GsPackageKitTask *task)
+{
+       GsPackageKitTaskPrivate *priv = gs_packagekit_task_get_instance_private (task);
+
+       g_return_val_if_fail (GS_IS_PACKAGEKIT_TASK (task), GS_PLUGIN_ACTION_UNKNOWN);
+
+       return priv->action;
+}
diff --git a/plugins/packagekit/gs-packagekit-task.h b/plugins/packagekit/gs-packagekit-task.h
new file mode 100644
index 000000000..ff8ef42e3
--- /dev/null
+++ b/plugins/packagekit/gs-packagekit-task.h
@@ -0,0 +1,32 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ * vi:set noexpandtab tabstop=8 shiftwidth=8:
+ *
+ * Copyright (C) 2021 Red Hat <www.redhat.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#pragma once
+
+#include <glib-object.h>
+#include <gnome-software.h>
+#include <packagekit-glib2/packagekit.h>
+
+G_BEGIN_DECLS
+
+#define GS_TYPE_PACKAGEKIT_TASK (gs_packagekit_task_get_type ())
+
+G_DECLARE_DERIVABLE_TYPE (GsPackageKitTask, gs_packagekit_task, GS, PACKAGEKIT_TASK, PkTask)
+
+struct _GsPackageKitTaskClass
+{
+       PkTaskClass parent_class;
+};
+
+PkTask         *gs_packagekit_task_new         (GsPlugin               *plugin);
+void            gs_packagekit_task_setup       (GsPackageKitTask       *task,
+                                                GsPluginAction          action,
+                                                gboolean                interactive);
+GsPluginAction  gs_packagekit_task_get_action  (GsPackageKitTask       *task);
+
+G_END_DECLS
diff --git a/plugins/packagekit/gs-plugin-packagekit-refresh.c 
b/plugins/packagekit/gs-plugin-packagekit-refresh.c
index ef06bcd23..348a6168a 100644
--- a/plugins/packagekit/gs-plugin-packagekit-refresh.c
+++ b/plugins/packagekit/gs-plugin-packagekit-refresh.c
@@ -14,6 +14,7 @@
 
 #include "gs-metered.h"
 #include "gs-packagekit-helper.h"
+#include "gs-packagekit-task.h"
 #include "packagekit-common.h"
 
 /*
@@ -33,7 +34,7 @@ gs_plugin_initialize (GsPlugin *plugin)
        GsPluginData *priv = gs_plugin_alloc_data (plugin, sizeof(GsPluginData));
 
        g_mutex_init (&priv->task_mutex);
-       priv->task = pk_task_new ();
+       priv->task = gs_packagekit_task_new (plugin);
        pk_task_set_only_download (priv->task, TRUE);
        pk_client_set_background (PK_CLIENT (priv->task), TRUE);
        pk_client_set_interactive (PK_CLIENT (priv->task), gs_plugin_has_flags (plugin, 
GS_PLUGIN_FLAGS_INTERACTIVE));
@@ -69,7 +70,7 @@ _download_only (GsPlugin *plugin, GsAppList *list,
         * we end up downloading a different set of packages than what was
         * shown to the user */
        pk_client_set_cache_age (PK_CLIENT (priv->task), G_MAXUINT);
-       pk_client_set_interactive (PK_CLIENT (priv->task), gs_plugin_has_flags (plugin, 
GS_PLUGIN_FLAGS_INTERACTIVE));
+       gs_packagekit_task_setup (GS_PACKAGEKIT_TASK (priv->task), GS_PLUGIN_ACTION_DOWNLOAD, 
gs_plugin_has_flags (plugin, GS_PLUGIN_FLAGS_INTERACTIVE));
        results = pk_client_get_updates (PK_CLIENT (priv->task),
                                         pk_bitfield_value (PK_FILTER_ENUM_NONE),
                                         cancellable,
@@ -180,7 +181,7 @@ gs_plugin_refresh (GsPlugin *plugin,
        g_mutex_lock (&priv->task_mutex);
        /* cache age of 1 is user-initiated */
        pk_client_set_background (PK_CLIENT (priv->task), cache_age > 1);
-       pk_client_set_interactive (PK_CLIENT (priv->task), gs_plugin_has_flags (plugin, 
GS_PLUGIN_FLAGS_INTERACTIVE));
+       gs_packagekit_task_setup (GS_PACKAGEKIT_TASK (priv->task), GS_PLUGIN_ACTION_REFRESH, 
gs_plugin_has_flags (plugin, GS_PLUGIN_FLAGS_INTERACTIVE));
        pk_client_set_cache_age (PK_CLIENT (priv->task), cache_age);
        /* refresh the metadata */
        results = pk_client_refresh_cache (PK_CLIENT (priv->task),
diff --git a/plugins/packagekit/gs-plugin-packagekit.c b/plugins/packagekit/gs-plugin-packagekit.c
index 720dc1a49..d2af31e1e 100644
--- a/plugins/packagekit/gs-plugin-packagekit.c
+++ b/plugins/packagekit/gs-plugin-packagekit.c
@@ -20,6 +20,7 @@
 #include "packagekit-common.h"
 #include "gs-markdown.h"
 #include "gs-packagekit-helper.h"
+#include "gs-packagekit-task.h"
 
 /*
  * SECTION:
@@ -80,7 +81,7 @@ gs_plugin_initialize (GsPlugin *plugin)
 
        /* core */
        g_mutex_init (&priv->task_mutex);
-       priv->task = pk_task_new ();
+       priv->task = gs_packagekit_task_new (plugin);
        pk_client_set_background (PK_CLIENT (priv->task), FALSE);
        pk_client_set_cache_age (PK_CLIENT (priv->task), G_MAXUINT);
        pk_client_set_interactive (PK_CLIENT (priv->task), gs_plugin_has_flags (plugin, 
GS_PLUGIN_FLAGS_INTERACTIVE));
@@ -99,7 +100,7 @@ gs_plugin_initialize (GsPlugin *plugin)
 
        /* local */
        g_mutex_init (&priv->task_mutex_local);
-       priv->task_local = pk_task_new ();
+       priv->task_local = gs_packagekit_task_new (plugin);
        pk_client_set_background (PK_CLIENT (priv->task_local), FALSE);
        pk_client_set_interactive (PK_CLIENT (priv->task_local), gs_plugin_has_flags (plugin, 
GS_PLUGIN_FLAGS_INTERACTIVE));
 
@@ -132,7 +133,7 @@ gs_plugin_initialize (GsPlugin *plugin)
 
        /* upgrade */
        g_mutex_init (&priv->task_mutex_upgrade);
-       priv->task_upgrade = pk_task_new ();
+       priv->task_upgrade = gs_packagekit_task_new (plugin);
        pk_task_set_only_download (priv->task_upgrade, TRUE);
        pk_client_set_background (PK_CLIENT (priv->task_upgrade), TRUE);
        pk_client_set_cache_age (PK_CLIENT (priv->task_upgrade), 60 * 60 * 24);
@@ -204,7 +205,7 @@ gs_plugin_add_sources_related (GsPlugin *plugin,
                                         PK_FILTER_ENUM_NOT_COLLECTIONS,
                                         -1);
        g_mutex_lock (&priv->task_mutex);
-       pk_client_set_interactive (PK_CLIENT (priv->task), gs_plugin_has_flags (plugin, 
GS_PLUGIN_FLAGS_INTERACTIVE));
+       gs_packagekit_task_setup (GS_PACKAGEKIT_TASK (priv->task), GS_PLUGIN_ACTION_GET_SOURCES, 
gs_plugin_has_flags (plugin, GS_PLUGIN_FLAGS_INTERACTIVE));
        results = pk_client_get_packages (PK_CLIENT(priv->task),
                                           filter,
                                           cancellable,
@@ -267,7 +268,7 @@ gs_plugin_add_sources (GsPlugin *plugin,
                                         PK_FILTER_ENUM_NOT_DEVELOPMENT,
                                         -1);
        g_mutex_lock (&priv->task_mutex);
-       pk_client_set_interactive (PK_CLIENT (priv->task), gs_plugin_has_flags (plugin, 
GS_PLUGIN_FLAGS_INTERACTIVE));
+       gs_packagekit_task_setup (GS_PACKAGEKIT_TASK (priv->task), GS_PLUGIN_ACTION_GET_SOURCES, 
gs_plugin_has_flags (plugin, GS_PLUGIN_FLAGS_INTERACTIVE));
        results = pk_client_get_repo_list (PK_CLIENT(priv->task),
                                           filter,
                                           cancellable,
@@ -335,7 +336,7 @@ gs_plugin_app_origin_repo_enable (GsPlugin *plugin,
        /* do sync call */
        gs_plugin_status_update (plugin, app, GS_PLUGIN_STATUS_WAITING);
        g_mutex_lock (&priv->task_mutex);
-       pk_client_set_interactive (PK_CLIENT (priv->task), gs_plugin_has_flags (plugin, 
GS_PLUGIN_FLAGS_INTERACTIVE));
+       gs_packagekit_task_setup (GS_PACKAGEKIT_TASK (priv->task), GS_PLUGIN_ACTION_INSTALL, 
gs_plugin_has_flags (plugin, GS_PLUGIN_FLAGS_INTERACTIVE));
        results = pk_client_repo_enable (PK_CLIENT (priv->task),
                                         repo_id,
                                         TRUE,
@@ -424,7 +425,7 @@ gs_plugin_app_install (GsPlugin *plugin,
                /* actually install the package */
                gs_packagekit_helper_add_app (helper, app);
                g_mutex_lock (&priv->task_mutex);
-               pk_client_set_interactive (PK_CLIENT (priv->task), gs_plugin_has_flags (plugin, 
GS_PLUGIN_FLAGS_INTERACTIVE));
+               gs_packagekit_task_setup (GS_PACKAGEKIT_TASK (priv->task), GS_PLUGIN_ACTION_INSTALL, 
gs_plugin_has_flags (plugin, GS_PLUGIN_FLAGS_INTERACTIVE));
                results = pk_task_install_packages_sync (priv->task,
                                                         package_ids,
                                                         cancellable,
@@ -502,7 +503,7 @@ gs_plugin_app_install (GsPlugin *plugin,
                }
                gs_packagekit_helper_add_app (helper, app);
                g_mutex_lock (&priv->task_mutex);
-               pk_client_set_interactive (PK_CLIENT (priv->task), gs_plugin_has_flags (plugin, 
GS_PLUGIN_FLAGS_INTERACTIVE));
+               gs_packagekit_task_setup (GS_PACKAGEKIT_TASK (priv->task), GS_PLUGIN_ACTION_INSTALL, 
gs_plugin_has_flags (plugin, GS_PLUGIN_FLAGS_INTERACTIVE));
                results = pk_task_install_packages_sync (priv->task,
                                                         (gchar **) array_package_ids->pdata,
                                                         cancellable,
@@ -544,7 +545,7 @@ gs_plugin_app_install (GsPlugin *plugin,
                gs_app_set_state (app, GS_APP_STATE_INSTALLING);
                gs_packagekit_helper_add_app (helper, app);
                g_mutex_lock (&priv->task_mutex);
-               pk_client_set_interactive (PK_CLIENT (priv->task), gs_plugin_has_flags (plugin, 
GS_PLUGIN_FLAGS_INTERACTIVE));
+               gs_packagekit_task_setup (GS_PACKAGEKIT_TASK (priv->task), GS_PLUGIN_ACTION_INSTALL, 
gs_plugin_has_flags (plugin, GS_PLUGIN_FLAGS_INTERACTIVE));
                results = pk_task_install_files_sync (priv->task,
                                                      package_ids,
                                                      cancellable,
@@ -630,7 +631,7 @@ gs_plugin_app_remove (GsPlugin *plugin,
        gs_app_set_state (app, GS_APP_STATE_REMOVING);
        gs_packagekit_helper_add_app (helper, app);
        g_mutex_lock (&priv->task_mutex);
-       pk_client_set_interactive (PK_CLIENT (priv->task), gs_plugin_has_flags (plugin, 
GS_PLUGIN_FLAGS_INTERACTIVE));
+       gs_packagekit_task_setup (GS_PACKAGEKIT_TASK (priv->task), GS_PLUGIN_ACTION_REMOVE, 
gs_plugin_has_flags (plugin, GS_PLUGIN_FLAGS_INTERACTIVE));
        results = pk_task_remove_packages_sync (priv->task,
                                                package_ids,
                                                TRUE, GS_PACKAGEKIT_AUTOREMOVE,
@@ -702,7 +703,7 @@ gs_plugin_add_updates (GsPlugin *plugin,
        /* do sync call */
        gs_plugin_status_update (plugin, NULL, GS_PLUGIN_STATUS_WAITING);
        g_mutex_lock (&priv->task_mutex);
-       pk_client_set_interactive (PK_CLIENT (priv->task), gs_plugin_has_flags (plugin, 
GS_PLUGIN_FLAGS_INTERACTIVE));
+       gs_packagekit_task_setup (GS_PACKAGEKIT_TASK (priv->task), GS_PLUGIN_ACTION_GET_UPDATES, 
gs_plugin_has_flags (plugin, GS_PLUGIN_FLAGS_INTERACTIVE));
        results = pk_client_get_updates (PK_CLIENT (priv->task),
                                         pk_bitfield_value (PK_FILTER_ENUM_NONE),
                                         cancellable,
@@ -741,7 +742,7 @@ gs_plugin_add_search_files (GsPlugin *plugin,
                                         PK_FILTER_ENUM_ARCH,
                                         -1);
        g_mutex_lock (&priv->task_mutex);
-       pk_client_set_interactive (PK_CLIENT (priv->task), gs_plugin_has_flags (plugin, 
GS_PLUGIN_FLAGS_INTERACTIVE));
+       gs_packagekit_task_setup (GS_PACKAGEKIT_TASK (priv->task), GS_PLUGIN_ACTION_SEARCH_FILES, 
gs_plugin_has_flags (plugin, GS_PLUGIN_FLAGS_INTERACTIVE));
        results = pk_client_search_files (PK_CLIENT (priv->task),
                                          filter,
                                          search,
@@ -774,7 +775,7 @@ gs_plugin_add_search_what_provides (GsPlugin *plugin,
                                         PK_FILTER_ENUM_ARCH,
                                         -1);
        g_mutex_lock (&priv->task_mutex);
-       pk_client_set_interactive (PK_CLIENT (priv->task), gs_plugin_has_flags (plugin, 
GS_PLUGIN_FLAGS_INTERACTIVE));
+       gs_packagekit_task_setup (GS_PACKAGEKIT_TASK (priv->task), GS_PLUGIN_ACTION_SEARCH_PROVIDES, 
gs_plugin_has_flags (plugin, GS_PLUGIN_FLAGS_INTERACTIVE));
        results = pk_client_what_provides (PK_CLIENT (priv->task),
                                           filter,
                                           search,
@@ -1365,7 +1366,7 @@ gs_plugin_packagekit_refine_distro_upgrade (GsPlugin *plugin,
        g_mutex_lock (&priv->client_mutex_refine);
        cache_age_save = pk_client_get_cache_age (priv->client_refine);
        pk_client_set_cache_age (priv->client_refine, 60 * 60 * 24 * 7); /* once per week */
-       pk_client_set_interactive (priv->client_refine, gs_plugin_has_flags (plugin, 
GS_PLUGIN_FLAGS_INTERACTIVE));
+       gs_packagekit_task_setup (GS_PACKAGEKIT_TASK (priv->client_refine), GS_PLUGIN_ACTION_REFINE, 
gs_plugin_has_flags (plugin, GS_PLUGIN_FLAGS_INTERACTIVE));
        results = pk_client_upgrade_system (priv->client_refine,
                                            pk_bitfield_from_enums (PK_TRANSACTION_FLAG_ENUM_SIMULATE, -1),
                                            gs_app_get_version (app),
@@ -1959,7 +1960,7 @@ gs_plugin_file_to_app (GsPlugin *plugin,
        files = g_strsplit (filename, "\t", -1);
        g_mutex_lock (&priv->task_mutex_local);
        pk_client_set_cache_age (PK_CLIENT (priv->task_local), G_MAXUINT);
-       pk_client_set_interactive (PK_CLIENT (priv->task_local), gs_plugin_has_flags (plugin, 
GS_PLUGIN_FLAGS_INTERACTIVE));
+       gs_packagekit_task_setup (GS_PACKAGEKIT_TASK (priv->task_local), GS_PLUGIN_ACTION_FILE_TO_APP, 
gs_plugin_has_flags (plugin, GS_PLUGIN_FLAGS_INTERACTIVE));
        results = pk_client_get_details_local (PK_CLIENT (priv->task_local),
                                               files,
                                               cancellable,
@@ -2250,7 +2251,7 @@ gs_plugin_url_to_app (GsPlugin *plugin,
        package_ids[0] = g_strdup (path);
 
        g_mutex_lock (&priv->client_mutex_url_to_app);
-       pk_client_set_interactive (priv->client_url_to_app, gs_plugin_has_flags (plugin, 
GS_PLUGIN_FLAGS_INTERACTIVE));
+       gs_packagekit_task_setup (GS_PACKAGEKIT_TASK (priv->client_url_to_app), GS_PLUGIN_ACTION_URL_TO_APP, 
gs_plugin_has_flags (plugin, GS_PLUGIN_FLAGS_INTERACTIVE));
        results = pk_client_resolve (priv->client_url_to_app,
                                     pk_bitfield_from_enums (PK_FILTER_ENUM_NEWEST, PK_FILTER_ENUM_ARCH, -1),
                                     package_ids,
@@ -2554,7 +2555,7 @@ gs_plugin_app_upgrade_download (GsPlugin *plugin,
        gs_app_set_state (app, GS_APP_STATE_INSTALLING);
        gs_packagekit_helper_set_progress_app (helper, app);
        g_mutex_lock (&priv->task_mutex_upgrade);
-       pk_client_set_interactive (PK_CLIENT (priv->task_upgrade), gs_plugin_has_flags (plugin, 
GS_PLUGIN_FLAGS_INTERACTIVE));
+       gs_packagekit_task_setup (GS_PACKAGEKIT_TASK (priv->task_upgrade), GS_PLUGIN_ACTION_UPGRADE_DOWNLOAD, 
gs_plugin_has_flags (plugin, GS_PLUGIN_FLAGS_INTERACTIVE));
        results = pk_task_upgrade_system_sync (priv->task_upgrade,
                                               gs_app_get_version (app),
                                               PK_UPGRADE_KIND_ENUM_COMPLETE,
diff --git a/plugins/packagekit/meson.build b/plugins/packagekit/meson.build
index a7cfcd7d4..07f570c12 100644
--- a/plugins/packagekit/meson.build
+++ b/plugins/packagekit/meson.build
@@ -31,6 +31,7 @@ shared_module(
   sources : [
     'gs-plugin-packagekit.c',
     'gs-packagekit-helper.c',
+    'gs-packagekit-task.c',
     'packagekit-common.c',
     'gs-markdown.c',
   ],
@@ -65,6 +66,7 @@ shared_module(
   'gs_plugin_packagekit-refresh',
   sources : [
     'gs-plugin-packagekit-refresh.c',
+    'gs-packagekit-task.c',
     'gs-packagekit-helper.c',
     'packagekit-common.c',
   ],
diff --git a/po/POTFILES.in b/po/POTFILES.in
index d9105d846..5e139f15b 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -111,6 +111,7 @@ plugins/flatpak/gs-plugin-flatpak.c
 plugins/fwupd/gs-fwupd-app.c
 plugins/fwupd/gs-plugin-fwupd.c
 plugins/fwupd/org.gnome.Software.Plugin.Fwupd.metainfo.xml.in
+plugins/packagekit/gs-packagekit-task.c
 plugins/packagekit/gs-plugin-packagekit.c
 plugins/rpm-ostree/gs-plugin-rpm-ostree.c
 plugins/snap/gs-plugin-snap.c


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]