[gnome-software/603-gnome-software-reports-unknown-error-when-there-is-a-signing-issue] Apply 10 suggestion(s) to 3 file(s)



commit 8d251b45a2136ae502ac00735a168c8c1c6fc199
Author: Philip Withnall <philip tecnocode co uk>
Date:   Mon Nov 29 10:24:53 2021 +0000

    Apply 10 suggestion(s) to 3 file(s)

 lib/gs-plugin-loader.c                  |  2 +-
 plugins/packagekit/gs-packagekit-task.c | 27 ++++++++++++++++++++++-----
 src/gs-common.c                         |  1 +
 3 files changed, 24 insertions(+), 6 deletions(-)
---
diff --git a/lib/gs-plugin-loader.c b/lib/gs-plugin-loader.c
index 633ddefee..b53ca9b04 100644
--- a/lib/gs-plugin-loader.c
+++ b/lib/gs-plugin-loader.c
@@ -2187,7 +2187,7 @@ gs_plugin_loader_ask_untrusted_cb (GsPlugin *plugin,
                                   GsPluginLoader *plugin_loader)
 {
        gboolean accepts = FALSE;
-       g_debug ("emitting ask-untrusted title:'%s', msg:'%s' details:'%s' aaccept-label:'%s'", title, msg, 
details, accept_label);
+       g_debug ("emitting ask-untrusted title:'%s', msg:'%s' details:'%s' accept-label:'%s'", title, msg, 
details, accept_label);
        g_signal_emit (plugin_loader,
                       signals[SIGNAL_ASK_UNTRUSTED], 0,
                       title, msg, details, accept_label, &accepts);
diff --git a/plugins/packagekit/gs-packagekit-task.c b/plugins/packagekit/gs-packagekit-task.c
index a2aee0bf0..ea002c414 100644
--- a/plugins/packagekit/gs-packagekit-task.c
+++ b/plugins/packagekit/gs-packagekit-task.c
@@ -12,12 +12,26 @@
 
 #include "gs-packagekit-task.h"
 
-typedef struct _GsPackageKitTaskPrivate {
+/**
+ * SECTION:gs-packagekit-task
+ * @short_description: PkTask subclass which implements vfuncs for user interaction during a task
+ *
+ * #GsPackagekitTask is a subclass of #PkTask which represents a single
+ * operation on PacakgeKit.
+ *
+ * By subclassing #PkTask, it can implement vfuncs which allow decisions
+ * to be made about the task while it’s running. For example, to decide
+ * what to do if an untrusted package needs to be installed.
+ *
+ * Since: 42
+ */
+
+typedef struct {
        GWeakRef plugin_weakref; /* GsPlugin * */
        GsPluginAction action;
 } GsPackageKitTaskPrivate;
 
-G_DEFINE_TYPE_WITH_PRIVATE (GsPackageKitTask, gs_packagekit_task, PK_TYPE_TASK)
+G_DEFINE_TYPE_WITH_PRIVATE (GsPackagekitTask, gs_packagekit_task, PK_TYPE_TASK)
 
 static gboolean
 gs_packagekit_task_user_accepted (PkTask *task,
@@ -38,7 +52,7 @@ gs_packagekit_task_user_accepted (PkTask *task,
        return accepts;
 }
 
-typedef struct _QuestionData {
+typedef struct {
        GWeakRef task_weakref;
        guint request;
        gchar *title;
@@ -83,6 +97,8 @@ question_data_free (gpointer ptr)
        }
 }
 
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (QuestionData, question_data_free)
+
 static gboolean
 gs_packagekit_task_question_idle_cb (gpointer user_data)
 {
@@ -108,12 +124,13 @@ gs_packagekit_task_schedule_question (GsPackageKitTask *task,
                                      const gchar *details,
                                      const gchar *accept_label)
 {
-       QuestionData *qd;
+       g_autoptr(QuestionData) qd = NULL;
 
        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);
+       g_idle_add_full (G_PRIORITY_HIGH_IDLE, gs_packagekit_task_question_idle_cb, g_steal_pointer (&qd), 
question_data_free);
 }
 
+/* This may be called in a PackageKit worker thread. */
 static void
 gs_packagekit_task_untrusted_question (PkTask *task,
                                       guint request,
diff --git a/src/gs-common.c b/src/gs-common.c
index f91708573..a2b3eb70b 100644
--- a/src/gs-common.c
+++ b/src/gs-common.c
@@ -644,6 +644,7 @@ gs_utils_ask_user_accepts (GtkWindow *parent,
        GtkWidget *dialog;
        RunInfo run_info;
 
+       g_return_val_if_fail (parent == NULL || GTK_IS_WINDOW (parent), FALSE);
        g_return_val_if_fail (title != NULL, FALSE);
        g_return_val_if_fail (msg != NULL, FALSE);
 


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