[gnome-software/wip/temp/ubuntu-xenial-rebased: 13/326] Add an ability for plugins to request authorization for posting reviews
- From: Iain Lane <iainl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/temp/ubuntu-xenial-rebased: 13/326] Add an ability for plugins to request authorization for posting reviews
- Date: Fri, 29 Apr 2016 09:48:24 +0000 (UTC)
commit ddf57c760138395af2cae181e826cb93bd545471
Author: Robert Ancell <robert ancell canonical com>
Date: Thu Jan 14 22:41:11 2016 +1300
Add an ability for plugins to request authorization for posting reviews
src/gs-plugin-loader.c | 18 ++++++++++++++++--
src/gs-plugin.h | 1 +
2 files changed, 17 insertions(+), 2 deletions(-)
---
diff --git a/src/gs-plugin-loader.c b/src/gs-plugin-loader.c
index a18f56b..0ac74ff 100644
--- a/src/gs-plugin-loader.c
+++ b/src/gs-plugin-loader.c
@@ -50,6 +50,8 @@ typedef struct
guint updates_changed_id;
gboolean online;
+
+ gchar **review_auths;
} GsPluginLoaderPrivate;
G_DEFINE_TYPE_WITH_PRIVATE (GsPluginLoader, gs_plugin_loader, G_TYPE_OBJECT)
@@ -2906,7 +2908,8 @@ gs_plugin_loader_updates_changed_cb (GsPlugin *plugin, gpointer user_data)
*/
static GsPlugin *
gs_plugin_loader_open_plugin (GsPluginLoader *plugin_loader,
- const gchar *filename)
+ const gchar *filename,
+ GPtrArray *review_auths)
{
GsPluginLoaderPrivate *priv = gs_plugin_loader_get_instance_private (plugin_loader);
gboolean ret;
@@ -2945,6 +2948,14 @@ gs_plugin_loader_open_plugin (GsPluginLoader *plugin_loader,
"gs_plugin_get_conflicts",
(gpointer *) &plugin_conflicts);
+ /* Check if this module requires any authorization for reviews */
+ (void) g_module_symbol (module,
+ "gs_plugin_get_review_auth",
+ (gpointer *) &plugin_review_auth);
+ review_auth = plugin_review_auth != NULL ? plugin_review_auth (plugin) : NULL;
+ if (review_auth)
+ g_ptr_array_add (review_auths, g_strdup (review_auth));
+
/* print what we know */
plugin = g_slice_new0 (GsPlugin);
plugin->enabled = TRUE;
@@ -3057,6 +3068,7 @@ gs_plugin_loader_setup (GsPluginLoader *plugin_loader,
guint j;
g_autoptr(GDir) dir = NULL;
g_autoptr(AsProfileTask) ptask = NULL;
+ GPtrArray *review_auths;
g_return_val_if_fail (priv->location != NULL, FALSE);
@@ -3068,6 +3080,7 @@ gs_plugin_loader_setup (GsPluginLoader *plugin_loader,
/* try to open each plugin */
g_debug ("searching for plugins in %s", priv->location);
+ review_auths = g_ptr_array_new ();
do {
g_autofree gchar *filename_plugin = NULL;
filename_tmp = g_dir_read_name (dir);
@@ -3078,7 +3091,7 @@ gs_plugin_loader_setup (GsPluginLoader *plugin_loader,
filename_plugin = g_build_filename (priv->location,
filename_tmp,
NULL);
- gs_plugin_loader_open_plugin (plugin_loader, filename_plugin);
+ gs_plugin_loader_open_plugin (plugin_loader, filename_plugin, review_auths);
} while (TRUE);
/* optional whitelist */
@@ -3294,6 +3307,7 @@ gs_plugin_loader_finalize (GObject *object)
g_strfreev (priv->compatible_projects);
g_free (priv->location);
g_free (priv->locale);
+ g_strfreev (priv->review_auths);
g_mutex_clear (&priv->pending_apps_mutex);
diff --git a/src/gs-plugin.h b/src/gs-plugin.h
index c1862e1..e4cc0b8 100644
--- a/src/gs-plugin.h
+++ b/src/gs-plugin.h
@@ -148,6 +148,7 @@ typedef enum {
typedef const gchar *(*GsPluginGetNameFunc) (void);
typedef const gchar **(*GsPluginGetDepsFunc) (GsPlugin *plugin);
+typedef const gchar *(*GsPluginGetReviewAuthFunc) (GsPlugin *plugin);
typedef void (*GsPluginFunc) (GsPlugin *plugin);
typedef gboolean (*GsPluginSetupFunc) (GsPlugin *plugin,
GCancellable *cancellable,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]