[gnome-software] trivial: Add a sync version of the auth_action method



commit 5fa984c1a96b636845afeb0cacd5028960449621
Author: Richard Hughes <richard hughsie com>
Date:   Fri Jun 10 15:47:04 2016 +0100

    trivial: Add a sync version of the auth_action method

 src/gs-plugin-loader-sync.c |   50 +++++++++++++++++++++++++++++++++++++++++++
 src/gs-plugin-loader-sync.h |    5 ++++
 2 files changed, 55 insertions(+), 0 deletions(-)
---
diff --git a/src/gs-plugin-loader-sync.c b/src/gs-plugin-loader-sync.c
index f723a78..857c2e0 100644
--- a/src/gs-plugin-loader-sync.c
+++ b/src/gs-plugin-loader-sync.c
@@ -617,6 +617,56 @@ gs_plugin_loader_review_action (GsPluginLoader *plugin_loader,
 }
 
 /**
+ * gs_plugin_loader_auth_action_finish_sync:
+ **/
+static void
+gs_plugin_loader_auth_action_finish_sync (GsPluginLoader *plugin_loader,
+                                         GAsyncResult *res,
+                                         GsPluginLoaderHelper *helper)
+{
+       helper->ret = gs_plugin_loader_auth_action_finish (plugin_loader,
+                                                          res,
+                                                          helper->error);
+       g_main_loop_quit (helper->loop);
+}
+
+/**
+ * gs_plugin_loader_auth_action:
+ **/
+gboolean
+gs_plugin_loader_auth_action (GsPluginLoader *plugin_loader,
+                             GsAuth *auth,
+                             GsAuthAction 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_auth_action_async (plugin_loader,
+                                           auth,
+                                           action,
+                                           cancellable,
+                                           (GAsyncReadyCallback) gs_plugin_loader_auth_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 dfcb282..7a28845 100644
--- a/src/gs-plugin-loader-sync.h
+++ b/src/gs-plugin-loader-sync.h
@@ -82,6 +82,11 @@ gboolean      gs_plugin_loader_review_action         (GsPluginLoader *plugin_loader,
                                                         GsReviewAction  action,
                                                         GCancellable   *cancellable,
                                                         GError         **error);
+gboolean        gs_plugin_loader_auth_action           (GsPluginLoader *plugin_loader,
+                                                        GsAuth         *auth,
+                                                        GsAuthAction    action,
+                                                        GCancellable   *cancellable,
+                                                        GError         **error);
 gboolean        gs_plugin_loader_refresh               (GsPluginLoader *plugin_loader,
                                                         guint           cache_age,
                                                         GsPluginRefreshFlags flags,


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