[gnome-software] trivial: Add a sync version of the review action functionality
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] trivial: Add a sync version of the review action functionality
- Date: Fri, 10 Jun 2016 14:04:40 +0000 (UTC)
commit adc02e85461210b7faf6dae2d7a8ddaf73035d3d
Author: Richard Hughes <richard hughsie com>
Date: Fri Jun 10 14:27:28 2016 +0100
trivial: Add a sync version of the review action functionality
src/gs-plugin-loader-sync.c | 52 +++++++++++++++++++++++++++++++++++++++++++
src/gs-plugin-loader-sync.h | 6 +++++
src/gs-plugin-loader.c | 16 +++++++++++++
src/gs-plugin-loader.h | 3 ++
4 files changed, 77 insertions(+), 0 deletions(-)
---
diff --git a/src/gs-plugin-loader-sync.c b/src/gs-plugin-loader-sync.c
index c1a6d79..f723a78 100644
--- a/src/gs-plugin-loader-sync.c
+++ b/src/gs-plugin-loader-sync.c
@@ -565,6 +565,58 @@ gs_plugin_loader_app_action (GsPluginLoader *plugin_loader,
}
/**
+ * gs_plugin_loader_review_action_finish_sync:
+ **/
+static void
+gs_plugin_loader_review_action_finish_sync (GsPluginLoader *plugin_loader,
+ GAsyncResult *res,
+ GsPluginLoaderHelper *helper)
+{
+ helper->ret = gs_plugin_loader_review_action_finish (plugin_loader,
+ res,
+ helper->error);
+ g_main_loop_quit (helper->loop);
+}
+
+/**
+ * gs_plugin_loader_review_action:
+ **/
+gboolean
+gs_plugin_loader_review_action (GsPluginLoader *plugin_loader,
+ GsApp *app,
+ GsReview *review,
+ GsReviewAction action,
+ GCancellable *cancellable,
+ GError **error)
+{
+ GsPluginLoaderHelper helper;
+
+ /* create temp object */
+ helper.context = g_main_context_new ();
+ helper.loop = g_main_loop_new (helper.context, FALSE);
+ helper.error = error;
+
+ g_main_context_push_thread_default (helper.context);
+
+ /* run async method */
+ gs_plugin_loader_review_action_async (plugin_loader,
+ app,
+ review,
+ action,
+ cancellable,
+ (GAsyncReadyCallback)
gs_plugin_loader_review_action_finish_sync,
+ &helper);
+ g_main_loop_run (helper.loop);
+
+ g_main_context_pop_thread_default (helper.context);
+
+ g_main_loop_unref (helper.loop);
+ g_main_context_unref (helper.context);
+
+ return helper.ret;
+}
+
+/**
* gs_plugin_loader_refresh_finish_sync:
**/
static void
diff --git a/src/gs-plugin-loader-sync.h b/src/gs-plugin-loader-sync.h
index e643957..dfcb282 100644
--- a/src/gs-plugin-loader-sync.h
+++ b/src/gs-plugin-loader-sync.h
@@ -76,6 +76,12 @@ gboolean gs_plugin_loader_app_action (GsPluginLoader *plugin_loader,
GsPluginLoaderAction action,
GCancellable *cancellable,
GError **error);
+gboolean gs_plugin_loader_review_action (GsPluginLoader *plugin_loader,
+ GsApp *app,
+ GsReview *review,
+ GsReviewAction action,
+ GCancellable *cancellable,
+ GError **error);
gboolean gs_plugin_loader_refresh (GsPluginLoader *plugin_loader,
guint cache_age,
GsPluginRefreshFlags flags,
diff --git a/src/gs-plugin-loader.c b/src/gs-plugin-loader.c
index 25e9c12..935e8db 100644
--- a/src/gs-plugin-loader.c
+++ b/src/gs-plugin-loader.c
@@ -3077,6 +3077,22 @@ gs_plugin_loader_review_action_async (GsPluginLoader *plugin_loader,
}
/**
+ * gs_plugin_loader_review_action_finish:
+ **/
+gboolean
+gs_plugin_loader_review_action_finish (GsPluginLoader *plugin_loader,
+ GAsyncResult *res,
+ GError **error)
+{
+ g_return_val_if_fail (GS_IS_PLUGIN_LOADER (plugin_loader), FALSE);
+ g_return_val_if_fail (G_IS_TASK (res), FALSE);
+ g_return_val_if_fail (g_task_is_valid (res, plugin_loader), FALSE);
+ g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+
+ return g_task_propagate_boolean (G_TASK (res), error);
+}
+
+/**
* gs_plugin_loader_app_action_finish:
*
* Return value: success
diff --git a/src/gs-plugin-loader.h b/src/gs-plugin-loader.h
index 572416c..6e2bbdb 100644
--- a/src/gs-plugin-loader.h
+++ b/src/gs-plugin-loader.h
@@ -211,6 +211,9 @@ void gs_plugin_loader_app_action_async (GsPluginLoader
*plugin_loader,
gboolean gs_plugin_loader_app_action_finish (GsPluginLoader *plugin_loader,
GAsyncResult *res,
GError **error);
+gboolean gs_plugin_loader_review_action_finish (GsPluginLoader *plugin_loader,
+ GAsyncResult *res,
+ GError **error);
void gs_plugin_loader_review_action_async (GsPluginLoader *plugin_loader,
GsApp *app,
GsReview *review,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]