[gnome-software: 30/72] dummy: Make refine asynchronous
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software: 30/72] dummy: Make refine asynchronous
- Date: Wed, 15 Dec 2021 13:00:55 +0000 (UTC)
commit b52c13a8a12553eeac39835d453a2a35ef3ca7c7
Author: Philip Withnall <pwithnall endlessos org>
Date: Wed Nov 24 17:13:08 2021 +0000
dummy: Make refine asynchronous
Signed-off-by: Philip Withnall <pwithnall endlessos org>
Helps: #1472
plugins/dummy/gs-plugin-dummy.c | 36 +++++++++++++++++++++++++++---------
1 file changed, 27 insertions(+), 9 deletions(-)
---
diff --git a/plugins/dummy/gs-plugin-dummy.c b/plugins/dummy/gs-plugin-dummy.c
index 0c95fa921..12395325e 100644
--- a/plugins/dummy/gs-plugin-dummy.c
+++ b/plugins/dummy/gs-plugin-dummy.c
@@ -730,23 +730,39 @@ refine_app (GsPluginDummy *self,
return TRUE;
}
-gboolean
-gs_plugin_refine (GsPlugin *plugin,
- GsAppList *list,
- GsPluginRefineFlags flags,
- GCancellable *cancellable,
- GError **error)
+static void
+gs_plugin_dummy_refine_async (GsPlugin *plugin,
+ GsAppList *list,
+ GsPluginRefineFlags flags,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
{
GsPluginDummy *self = GS_PLUGIN_DUMMY (plugin);
+ g_autoptr(GTask) task = NULL;
+ g_autoptr(GError) local_error = NULL;
+
+ task = g_task_new (plugin, cancellable, callback, user_data);
+ g_task_set_source_tag (task, gs_plugin_dummy_refine_async);
for (guint i = 0; i < gs_app_list_length (list); i++) {
GsApp *app = gs_app_list_index (list, i);
- if (!refine_app (self, app, flags, cancellable, error))
- return FALSE;
+ if (!refine_app (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_dummy_refine_finish (GsPlugin *plugin,
+ GAsyncResult *result,
+ GError **error)
+{
+ return g_task_propagate_boolean (G_TASK (result), error);
}
gboolean
@@ -906,6 +922,8 @@ gs_plugin_dummy_class_init (GsPluginDummyClass *klass)
plugin_class->setup_async = gs_plugin_dummy_setup_async;
plugin_class->setup_finish = gs_plugin_dummy_setup_finish;
+ plugin_class->refine_async = gs_plugin_dummy_refine_async;
+ plugin_class->refine_finish = gs_plugin_dummy_refine_finish;
}
GType
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]