[gnome-software: 5/72] generic-updates: Make refine asynchronous
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software: 5/72] generic-updates: Make refine asynchronous
- Date: Wed, 15 Dec 2021 13:00:54 +0000 (UTC)
commit ff035c6bcdb5044b76e5370e65a642edad0581fb
Author: Philip Withnall <pwithnall endlessos org>
Date: Wed Nov 24 16:26:57 2021 +0000
generic-updates: Make refine asynchronous
Signed-off-by: Philip Withnall <pwithnall endlessos org>
Helps: #1472
plugins/core/gs-plugin-generic-updates.c | 44 ++++++++++++++++++++++++--------
1 file changed, 33 insertions(+), 11 deletions(-)
---
diff --git a/plugins/core/gs-plugin-generic-updates.c b/plugins/core/gs-plugin-generic-updates.c
index bef94d77c..06a16f141 100644
--- a/plugins/core/gs-plugin-generic-updates.c
+++ b/plugins/core/gs-plugin-generic-updates.c
@@ -78,19 +78,26 @@ gs_plugin_generic_updates_get_os_update (GsPlugin *plugin)
return app;
}
-gboolean
-gs_plugin_refine (GsPlugin *plugin,
- GsAppList *list,
- GsPluginRefineFlags flags,
- GCancellable *cancellable,
- GError **error)
+static void
+gs_plugin_generic_updates_refine_async (GsPlugin *plugin,
+ GsAppList *list,
+ GsPluginRefineFlags flags,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
{
+ g_autoptr(GTask) task = NULL;
g_autoptr(GsApp) app = NULL;
g_autoptr(GsAppList) os_updates = gs_app_list_new ();
+ task = g_task_new (plugin, cancellable, callback, user_data);
+ g_task_set_source_tag (task, gs_plugin_generic_updates_refine_async);
+
/* not from get_updates() */
- if ((flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_UPDATE_DETAILS) == 0)
- return TRUE;
+ if ((flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_UPDATE_DETAILS) == 0) {
+ g_task_return_boolean (task, TRUE);
+ return;
+ }
/* do we have any packages left that are not apps? */
for (guint i = 0; i < gs_app_list_length (list); i++) {
@@ -100,8 +107,10 @@ gs_plugin_refine (GsPlugin *plugin,
if (gs_plugin_generic_updates_merge_os_update (app_tmp))
gs_app_list_add (os_updates, app_tmp);
}
- if (gs_app_list_length (os_updates) == 0)
- return TRUE;
+ if (gs_app_list_length (os_updates) == 0) {
+ g_task_return_boolean (task, TRUE);
+ return;
+ }
/* create new meta object */
app = gs_plugin_generic_updates_get_os_update (plugin);
@@ -111,12 +120,25 @@ gs_plugin_refine (GsPlugin *plugin,
gs_app_list_remove (list, app_tmp);
}
gs_app_list_add (list, app);
- return TRUE;
+
+ g_task_return_boolean (task, TRUE);
+}
+
+static gboolean
+gs_plugin_generic_updates_refine_finish (GsPlugin *plugin,
+ GAsyncResult *result,
+ GError **error)
+{
+ return g_task_propagate_boolean (G_TASK (result), error);
}
static void
gs_plugin_generic_updates_class_init (GsPluginGenericUpdatesClass *klass)
{
+ GsPluginClass *plugin_class = GS_PLUGIN_CLASS (klass);
+
+ plugin_class->refine_async = gs_plugin_generic_updates_refine_async;
+ plugin_class->refine_finish = gs_plugin_generic_updates_refine_finish;
}
GType
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]