[gnome-software: 6/72] malcontent: Make refine asynchronous
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software: 6/72] malcontent: Make refine asynchronous
- Date: Wed, 15 Dec 2021 13:00:54 +0000 (UTC)
commit 775042ec32cb1aed9933eae3aa0b807c083bc036
Author: Philip Withnall <pwithnall endlessos org>
Date: Wed Nov 24 16:27:21 2021 +0000
malcontent: Make refine asynchronous
Signed-off-by: Philip Withnall <pwithnall endlessos org>
Helps: #1472
plugins/malcontent/gs-plugin-malcontent.c | 36 +++++++++++++++++++++++--------
1 file changed, 27 insertions(+), 9 deletions(-)
---
diff --git a/plugins/malcontent/gs-plugin-malcontent.c b/plugins/malcontent/gs-plugin-malcontent.c
index 5692eb5ba..ed94aad73 100644
--- a/plugins/malcontent/gs-plugin-malcontent.c
+++ b/plugins/malcontent/gs-plugin-malcontent.c
@@ -360,23 +360,39 @@ refine_app_locked (GsPluginMalcontent *self,
return TRUE;
}
-gboolean
-gs_plugin_refine (GsPlugin *plugin,
- GsAppList *list,
- GsPluginRefineFlags flags,
- GCancellable *cancellable,
- GError **error)
+static void
+gs_plugin_malcontent_refine_async (GsPlugin *plugin,
+ GsAppList *list,
+ GsPluginRefineFlags flags,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
{
GsPluginMalcontent *self = GS_PLUGIN_MALCONTENT (plugin);
+ g_autoptr(GTask) task = NULL;
g_autoptr(GMutexLocker) locker = g_mutex_locker_new (&self->mutex);
+ g_autoptr(GError) local_error = NULL;
+
+ task = g_task_new (plugin, cancellable, callback, user_data);
+ g_task_set_source_tag (task, gs_plugin_malcontent_refine_async);
for (guint i = 0; i < gs_app_list_length (list); i++) {
GsApp *app = gs_app_list_index (list, i);
- if (!refine_app_locked (self, app, flags, cancellable, error))
- return FALSE;
+ if (!refine_app_locked (self, app, flags, cancellable, &local_error)) {
+ g_task_return_error (task, g_steal_pointer (&local_error));
+ return;
+ }
}
- return TRUE;
+ g_task_return_boolean (task, TRUE);
+}
+
+static gboolean
+gs_plugin_malcontent_refine_finish (GsPlugin *plugin,
+ GAsyncResult *result,
+ GError **error)
+{
+ return g_task_propagate_boolean (G_TASK (result), error);
}
gboolean
@@ -416,6 +432,8 @@ gs_plugin_malcontent_class_init (GsPluginMalcontentClass *klass)
plugin_class->setup_async = gs_plugin_malcontent_setup_async;
plugin_class->setup_finish = gs_plugin_malcontent_setup_finish;
+ plugin_class->refine_async = gs_plugin_malcontent_refine_async;
+ plugin_class->refine_finish = gs_plugin_malcontent_refine_finish;
}
GType
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]