[gnome-software] Convert GsPlugin to be a GObject
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Convert GsPlugin to be a GObject
- Date: Thu, 21 Apr 2016 18:00:35 +0000 (UTC)
commit 3a586a86a2257cc462899a6d010b94fb0160fa08
Author: Richard Hughes <richard hughsie com>
Date: Thu Apr 21 09:56:27 2016 +0100
Convert GsPlugin to be a GObject
This completes our sealing effort and means we can have a stable plugin API
in the near future. I still don't think out-of-tree plugins are a good idea
but at least we have more of a "enterprise" story for 3-22.
src/gs-plugin-loader.c | 127 ++++++++------
src/gs-plugin-private.h | 1 -
src/gs-plugin.c | 217 +++++++++++++++++------
src/gs-plugin.h | 35 ++---
src/plugins/gs-plugin-dpkg.c | 2 +-
src/plugins/gs-plugin-dummy.c | 36 +++--
src/plugins/gs-plugin-epiphany.c | 18 ++-
src/plugins/gs-plugin-fedora-distro-upgrades.c | 6 +-
src/plugins/gs-plugin-fedora-tagger-usage.c | 4 +-
src/plugins/gs-plugin-fwupd.c | 10 +-
src/plugins/gs-plugin-limba.c | 9 +-
src/plugins/gs-plugin-ostree.c | 2 +-
src/plugins/gs-plugin-packagekit.c | 11 +-
src/plugins/gs-plugin-shell-extensions.c | 14 +-
src/plugins/gs-plugin-steam.c | 11 +-
src/plugins/gs-plugin-ubuntu-reviews.c | 2 +-
src/plugins/gs-plugin-xdg-app.c | 21 ++-
17 files changed, 335 insertions(+), 191 deletions(-)
---
diff --git a/src/gs-plugin-loader.c b/src/gs-plugin-loader.c
index 1dbc0f5..8b3639e 100644
--- a/src/gs-plugin-loader.c
+++ b/src/gs-plugin-loader.c
@@ -234,7 +234,8 @@ gs_plugin_loader_run_adopt (GsPluginLoader *plugin_loader, GList *list)
adopt_app_func (plugin, app);
gs_plugin_loader_action_stop (plugin_loader, plugin);
if (gs_app_get_management_plugin (app) != NULL) {
- g_debug ("%s adopted %s", plugin->name,
+ g_debug ("%s adopted %s",
+ gs_plugin_get_name (plugin),
gs_app_get_id (app));
}
}
@@ -298,12 +299,12 @@ gs_plugin_loader_run_refine (GsPluginLoader *plugin_loader,
if (function_name_parent == NULL) {
ptask = as_profile_start (priv->profile,
"GsPlugin::%s(%s)",
- plugin->name,
+ gs_plugin_get_name (plugin),
function_name);
} else {
ptask = as_profile_start (priv->profile,
"GsPlugin::%s(%s;%s)",
- plugin->name,
+ gs_plugin_get_name (plugin),
function_name_parent,
function_name);
}
@@ -317,7 +318,8 @@ gs_plugin_loader_run_refine (GsPluginLoader *plugin_loader,
gs_plugin_loader_action_stop (plugin_loader, plugin);
if (!ret) {
g_warning ("failed to call %s on %s: %s",
- function_name, plugin->name,
+ function_name,
+ gs_plugin_get_name (plugin),
error_local->message);
continue;
}
@@ -332,7 +334,8 @@ gs_plugin_loader_run_refine (GsPluginLoader *plugin_loader,
gs_plugin_loader_action_stop (plugin_loader, plugin);
if (!ret) {
g_warning ("failed to call %s on %s: %s",
- function_name_app, plugin->name,
+ function_name_app,
+ gs_plugin_get_name (plugin),
error_local->message);
continue;
}
@@ -462,13 +465,15 @@ gs_plugin_loader_run_results (GsPluginLoader *plugin_loader,
/* run function */
ptask2 = as_profile_start (priv->profile,
"GsPlugin::%s(%s)",
- plugin->name, function_name);
+ gs_plugin_get_name (plugin),
+ function_name);
gs_plugin_loader_action_start (plugin_loader, plugin, FALSE);
ret = plugin_func (plugin, &list, cancellable, &error_local);
gs_plugin_loader_action_stop (plugin_loader, plugin);
if (!ret) {
g_warning ("failed to call %s on %s: %s",
- function_name, plugin->name,
+ function_name,
+ gs_plugin_get_name (plugin),
error_local->message);
continue;
}
@@ -773,14 +778,15 @@ gs_plugin_loader_run_action (GsPluginLoader *plugin_loader,
continue;
ptask = as_profile_start (priv->profile,
"GsPlugin::%s(%s)",
- plugin->name,
+ gs_plugin_get_name (plugin),
function_name);
gs_plugin_loader_action_start (plugin_loader, plugin, FALSE);
ret = plugin_func (plugin, app, cancellable, &error_local);
gs_plugin_loader_action_stop (plugin_loader, plugin);
if (!ret) {
g_warning ("failed to call %s on %s: %s",
- function_name, plugin->name,
+ function_name,
+ gs_plugin_get_name (plugin),
error_local->message);
gs_plugin_loader_set_app_error (app, error_local);
continue;
@@ -1670,7 +1676,7 @@ gs_plugin_loader_search_thread_cb (GTask *task,
continue;
ptask = as_profile_start (priv->profile,
"GsPlugin::%s(%s)",
- plugin->name,
+ gs_plugin_get_name (plugin),
function_name);
gs_plugin_loader_action_start (plugin_loader, plugin, FALSE);
ret = plugin_func (plugin, values, &state->list,
@@ -1678,7 +1684,8 @@ gs_plugin_loader_search_thread_cb (GTask *task,
gs_plugin_loader_action_stop (plugin_loader, plugin);
if (!ret) {
g_warning ("failed to call %s on %s: %s",
- function_name, plugin->name,
+ function_name,
+ gs_plugin_get_name (plugin),
error_local->message);
continue;
}
@@ -1831,7 +1838,7 @@ gs_plugin_loader_search_files_thread_cb (GTask *task,
continue;
ptask = as_profile_start (priv->profile,
"GsPlugin::%s(%s)",
- plugin->name,
+ gs_plugin_get_name (plugin),
function_name);
gs_plugin_loader_action_start (plugin_loader, plugin, FALSE);
ret = plugin_func (plugin, values, &state->list,
@@ -1839,7 +1846,8 @@ gs_plugin_loader_search_files_thread_cb (GTask *task,
gs_plugin_loader_action_stop (plugin_loader, plugin);
if (!ret) {
g_warning ("failed to call %s on %s: %s",
- function_name, plugin->name,
+ function_name,
+ gs_plugin_get_name (plugin),
error_local->message);
continue;
}
@@ -1993,7 +2001,7 @@ gs_plugin_loader_search_what_provides_thread_cb (GTask *task,
continue;
ptask = as_profile_start (priv->profile,
"GsPlugin::%s(%s)",
- plugin->name,
+ gs_plugin_get_name (plugin),
function_name);
gs_plugin_loader_action_start (plugin_loader, plugin, FALSE);
ret = plugin_func (plugin, values, &state->list,
@@ -2001,7 +2009,8 @@ gs_plugin_loader_search_what_provides_thread_cb (GTask *task,
gs_plugin_loader_action_stop (plugin_loader, plugin);
if (!ret) {
g_warning ("failed to call %s on %s: %s",
- function_name, plugin->name,
+ function_name,
+ gs_plugin_get_name (plugin),
error_local->message);
continue;
}
@@ -2161,7 +2170,7 @@ gs_plugin_loader_get_categories_thread_cb (GTask *task,
continue;
ptask = as_profile_start (priv->profile,
"GsPlugin::%s(%s)",
- plugin->name,
+ gs_plugin_get_name (plugin),
function_name);
gs_plugin_loader_action_start (plugin_loader, plugin, FALSE);
ret = plugin_func (plugin, &state->list,
@@ -2169,7 +2178,8 @@ gs_plugin_loader_get_categories_thread_cb (GTask *task,
gs_plugin_loader_action_stop (plugin_loader, plugin);
if (!ret) {
g_warning ("failed to call %s on %s: %s",
- function_name, plugin->name,
+ function_name,
+ gs_plugin_get_name (plugin),
error_local->message);
continue;
}
@@ -2301,7 +2311,7 @@ gs_plugin_loader_get_category_apps_thread_cb (GTask *task,
continue;
ptask = as_profile_start (priv->profile,
"GsPlugin::%s(%s)",
- plugin->name,
+ gs_plugin_get_name (plugin),
function_name);
gs_plugin_loader_action_start (plugin_loader, plugin, FALSE);
ret = plugin_func (plugin, state->category, &state->list,
@@ -2309,7 +2319,8 @@ gs_plugin_loader_get_category_apps_thread_cb (GTask *task,
gs_plugin_loader_action_stop (plugin_loader, plugin);
if (!ret) {
g_warning ("failed to call %s on %s: %s",
- function_name, plugin->name,
+ function_name,
+ gs_plugin_get_name (plugin),
error_local->message);
continue;
}
@@ -2625,7 +2636,7 @@ gs_plugin_loader_review_action_thread_cb (GTask *task,
continue;
ptask = as_profile_start (priv->profile,
"GsPlugin::%s(%s)",
- plugin->name,
+ gs_plugin_get_name (plugin),
state->function_name);
gs_plugin_loader_action_start (plugin_loader, plugin, FALSE);
ret = plugin_func (plugin, state->app, state->review,
@@ -2633,7 +2644,8 @@ gs_plugin_loader_review_action_thread_cb (GTask *task,
gs_plugin_loader_action_stop (plugin_loader, plugin);
if (!ret) {
g_warning ("failed to call %s on %s: %s",
- state->function_name, plugin->name,
+ state->function_name,
+ gs_plugin_get_name (plugin),
error_local->message);
continue;
}
@@ -3023,7 +3035,7 @@ gs_plugin_loader_run (GsPluginLoader *plugin_loader, const gchar *function_name)
continue;
ptask = as_profile_start (priv->profile,
"GsPlugin::%s(%s)",
- plugin->name,
+ gs_plugin_get_name (plugin),
function_name);
gs_plugin_loader_action_start (plugin_loader, plugin, FALSE);
plugin_func (plugin);
@@ -3045,7 +3057,7 @@ gs_plugin_loader_find_plugin (GsPluginLoader *plugin_loader,
for (i = 0; i < priv->plugins->len; i++) {
plugin = g_ptr_array_index (priv->plugins, i);
- if (g_strcmp0 (plugin->name, plugin_name) == 0)
+ if (g_strcmp0 (gs_plugin_get_name (plugin), plugin_name) == 0)
return plugin;
}
return NULL;
@@ -3066,15 +3078,14 @@ gs_plugin_loader_get_enabled (GsPluginLoader *plugin_loader,
}
/**
- * gs_plugin_loader_status_update_cb:
+ * gs_plugin_loader_status_changed_cb:
*/
static void
-gs_plugin_loader_status_update_cb (GsPlugin *plugin,
- GsApp *app,
- GsPluginStatus status,
- gpointer user_data)
+gs_plugin_loader_status_changed_cb (GsPlugin *plugin,
+ GsApp *app,
+ GsPluginStatus status,
+ GsPluginLoader *plugin_loader)
{
- GsPluginLoader *plugin_loader = GS_PLUGIN_LOADER (user_data);
GsPluginLoaderPrivate *priv = gs_plugin_loader_get_instance_private (plugin_loader);
/* same as last time */
@@ -3113,9 +3124,9 @@ gs_plugin_loader_updates_changed_delay_cb (gpointer user_data)
* gs_plugin_loader_updates_changed_cb:
*/
static void
-gs_plugin_loader_updates_changed_cb (GsPlugin *plugin, gpointer user_data)
+gs_plugin_loader_updates_changed_cb (GsPlugin *plugin,
+ GsPluginLoader *plugin_loader)
{
- GsPluginLoader *plugin_loader = GS_PLUGIN_LOADER (user_data);
GsPluginLoaderPrivate *priv = gs_plugin_loader_get_instance_private (plugin_loader);
if (priv->updates_changed_id != 0)
return;
@@ -3142,15 +3153,17 @@ gs_plugin_loader_open_plugin (GsPluginLoader *plugin_loader,
g_warning ("Failed to load %s: %s", filename, error->message);
return;
}
- plugin->status_update_fn = gs_plugin_loader_status_update_cb;
- plugin->status_update_user_data = plugin_loader;
- plugin->updates_changed_fn = gs_plugin_loader_updates_changed_cb;
- plugin->updates_changed_user_data = plugin_loader;
+ g_signal_connect (plugin, "updates-changed",
+ G_CALLBACK (gs_plugin_loader_updates_changed_cb),
+ plugin_loader);
+ g_signal_connect (plugin, "status-changed",
+ G_CALLBACK (gs_plugin_loader_status_changed_cb),
+ plugin_loader);
gs_plugin_set_soup_session (plugin, priv->soup_session);
gs_plugin_set_profile (plugin, priv->profile);
gs_plugin_set_locale (plugin, priv->locale);
gs_plugin_set_scale (plugin, gs_plugin_loader_get_scale (plugin_loader));
- g_debug ("opened plugin %s: %s", filename, plugin->name);
+ g_debug ("opened plugin %s: %s", filename, gs_plugin_get_name (plugin));
/* add to array */
g_ptr_array_add (priv->plugins, plugin);
@@ -3272,7 +3285,7 @@ gs_plugin_loader_setup (GsPluginLoader *plugin_loader,
if (!gs_plugin_get_enabled (plugin))
continue;
ret = g_strv_contains ((const gchar * const *) whitelist,
- plugin->name);
+ gs_plugin_get_name (plugin));
gs_plugin_set_enabled (plugin, ret);
}
}
@@ -3298,9 +3311,9 @@ gs_plugin_loader_setup (GsPluginLoader *plugin_loader,
if (gs_plugin_get_priority (plugin) <= gs_plugin_get_priority (dep)) {
g_debug ("%s [%i] to be ordered after %s [%i] "
"so promoting to [%i]",
- plugin->name,
+ gs_plugin_get_name (plugin),
gs_plugin_get_priority (plugin),
- dep->name,
+ gs_plugin_get_name (dep),
gs_plugin_get_priority (dep),
gs_plugin_get_priority (dep) + 1);
gs_plugin_set_priority (plugin, gs_plugin_get_priority (dep) + 1);
@@ -3326,9 +3339,9 @@ gs_plugin_loader_setup (GsPluginLoader *plugin_loader,
if (gs_plugin_get_priority (plugin) <= gs_plugin_get_priority (dep)) {
g_debug ("%s [%i] to be ordered before %s [%i] "
"so promoting to [%i]",
- plugin->name,
+ gs_plugin_get_name (plugin),
gs_plugin_get_priority (plugin),
- dep->name,
+ gs_plugin_get_name (dep),
gs_plugin_get_priority (dep),
gs_plugin_get_priority (dep) + 1);
gs_plugin_set_priority (dep, gs_plugin_get_priority (plugin) + 1);
@@ -3370,7 +3383,8 @@ gs_plugin_loader_setup (GsPluginLoader *plugin_loader,
if (!gs_plugin_get_enabled (dep))
continue;
g_debug ("disabling %s as conflicts with %s",
- dep->name, plugin->name);
+ gs_plugin_get_name (dep),
+ gs_plugin_get_name (plugin));
gs_plugin_set_enabled (dep, FALSE);
}
}
@@ -3394,14 +3408,15 @@ gs_plugin_loader_setup (GsPluginLoader *plugin_loader,
continue;
ptask2 = as_profile_start (priv->profile,
"GsPlugin::%s(%s)",
- plugin->name,
+ gs_plugin_get_name (plugin),
function_name);
gs_plugin_loader_action_start (plugin_loader, plugin, TRUE);
ret = plugin_func (plugin, NULL, &error_local);
gs_plugin_loader_action_stop (plugin_loader, plugin);
if (!ret) {
g_debug ("disabling %s as setup failed: %s",
- plugin->name, error_local->message);
+ gs_plugin_get_name (plugin),
+ error_local->message);
gs_plugin_set_enabled (plugin, FALSE);
}
}
@@ -3428,7 +3443,7 @@ gs_plugin_loader_dump_state (GsPluginLoader *plugin_loader)
g_debug ("[%s]\t%i\t->\t%s",
gs_plugin_get_enabled (plugin) ? "enabled" : "disabld",
gs_plugin_get_priority (plugin),
- plugin->name);
+ gs_plugin_get_name (plugin));
}
}
@@ -3521,7 +3536,7 @@ gs_plugin_loader_init (GsPluginLoader *plugin_loader)
guint i;
priv->scale = 1;
- priv->plugins = g_ptr_array_new_with_free_func ((GDestroyNotify) gs_plugin_free);
+ priv->plugins = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
priv->status_last = GS_PLUGIN_STATUS_LAST;
priv->pending_apps = g_ptr_array_new_with_free_func ((GFreeFunc) g_object_unref);
priv->profile = as_profile_new ();
@@ -3680,14 +3695,15 @@ gs_plugin_loader_run_refresh (GsPluginLoader *plugin_loader,
continue;
ptask = as_profile_start (priv->profile,
"GsPlugin::%s(%s)",
- plugin->name,
+ gs_plugin_get_name (plugin),
function_name);
gs_plugin_loader_action_start (plugin_loader, plugin, TRUE);
ret = plugin_func (plugin, cache_age, flags, cancellable, &error_local);
gs_plugin_loader_action_stop (plugin_loader, plugin);
if (!ret) {
g_warning ("failed to call %s on %s: %s",
- function_name, plugin->name,
+ function_name,
+ gs_plugin_get_name (plugin),
error_local->message);
continue;
}
@@ -3822,7 +3838,7 @@ gs_plugin_loader_filename_to_app_thread_cb (GTask *task,
continue;
ptask = as_profile_start (priv->profile,
"GsPlugin::%s(%s)",
- plugin->name,
+ gs_plugin_get_name (plugin),
function_name);
gs_plugin_loader_action_start (plugin_loader, plugin, FALSE);
ret = plugin_func (plugin, &state->list, state->filename,
@@ -3830,7 +3846,8 @@ gs_plugin_loader_filename_to_app_thread_cb (GTask *task,
gs_plugin_loader_action_stop (plugin_loader, plugin);
if (!ret) {
g_warning ("failed to call %s on %s: %s",
- function_name, plugin->name,
+ function_name,
+ gs_plugin_get_name (plugin),
error_local->message);
continue;
}
@@ -3965,14 +3982,15 @@ gs_plugin_loader_update_thread_cb (GTask *task,
continue;
ptask = as_profile_start (priv->profile,
"GsPlugin::%s(%s)",
- plugin->name,
+ gs_plugin_get_name (plugin),
function_name);
gs_plugin_loader_action_start (plugin_loader, plugin, FALSE);
ret = plugin_func (plugin, state->list, cancellable, &error_local);
gs_plugin_loader_action_stop (plugin_loader, plugin);
if (!ret) {
g_warning ("failed to call %s on %s: %s",
- function_name, plugin->name,
+ function_name,
+ gs_plugin_get_name (plugin),
error_local->message);
continue;
}
@@ -4004,7 +4022,7 @@ gs_plugin_loader_update_thread_cb (GTask *task,
ptask = as_profile_start (priv->profile,
"GsPlugin::%s(%s){%s}",
- plugin->name,
+ gs_plugin_get_name (plugin),
function_name,
gs_app_get_id (app));
gs_plugin_loader_action_start (plugin_loader, plugin, FALSE);
@@ -4014,7 +4032,8 @@ gs_plugin_loader_update_thread_cb (GTask *task,
gs_plugin_loader_action_stop (plugin_loader, plugin);
if (!ret) {
g_warning ("failed to call %s on %s: %s",
- function_name, plugin->name,
+ function_name,
+ gs_plugin_get_name (plugin),
error_local->message);
gs_plugin_loader_set_app_error (app, error_local);
continue;
diff --git a/src/gs-plugin-private.h b/src/gs-plugin-private.h
index 44fbb2d..e081b5b 100644
--- a/src/gs-plugin-private.h
+++ b/src/gs-plugin-private.h
@@ -35,7 +35,6 @@ GsPlugin *gs_plugin_new (void);
GsPlugin *gs_plugin_create (const gchar *filename,
GError **error);
-void gs_plugin_free (GsPlugin *plugin);
void gs_plugin_action_start (GsPlugin *plugin,
gboolean exclusive);
void gs_plugin_action_stop (GsPlugin *plugin);
diff --git a/src/gs-plugin.c b/src/gs-plugin.c
index 4dcfb37..6f97ca3 100644
--- a/src/gs-plugin.c
+++ b/src/gs-plugin.c
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
- * Copyright (C) 2013-2014 Richard Hughes <richard hughsie com>
+ * Copyright (C) 2013-2016 Richard Hughes <richard hughsie com>
*
* Licensed under the GNU General Public License Version 2
*
@@ -39,13 +39,15 @@
#include "config.h"
-#include <glib.h>
#include <gio/gdesktopappinfo.h>
+#include <gdk/gdk.h>
-#include "gs-plugin-private.h"
#include "gs-os-release.h"
+#include "gs-plugin-private.h"
+#include "gs-plugin.h"
-struct GsPluginPrivate {
+typedef struct
+{
AsProfile *profile;
GHashTable *cache;
GModule *module;
@@ -58,14 +60,29 @@ struct GsPluginPrivate {
const gchar **order_before; /* allow-none */
gboolean enabled;
gchar *locale; /* allow-none */
+ gchar *name;
gint scale;
guint priority;
guint timer_id;
+} GsPluginPrivate;
+
+G_DEFINE_TYPE_WITH_PRIVATE (GsPlugin, gs_plugin, G_TYPE_OBJECT)
+
+enum {
+ PROP_0,
+ PROP_FLAGS,
+ PROP_LAST
};
-typedef const gchar **(*GsPluginGetDepsFunc) (GsPlugin *plugin);
+enum {
+ SIGNAL_UPDATES_CHANGED,
+ SIGNAL_STATUS_CHANGED,
+ SIGNAL_LAST
+};
-#define gs_plugin_get_instance_private(p) (p->priv);
+static guint signals [SIGNAL_LAST] = { 0 };
+
+typedef const gchar **(*GsPluginGetDepsFunc) (GsPlugin *plugin);
/**
* gs_plugin_status_to_string:
@@ -89,27 +106,6 @@ gs_plugin_status_to_string (GsPluginStatus status)
return "removing";
return "unknown";
}
-
-/**
- * gs_plugin_new:
- **/
-GsPlugin *
-gs_plugin_new (void)
-{
- GsPlugin *plugin = g_slice_new0 (GsPlugin);
- plugin->priv = g_new0 (GsPluginPrivate, 1);
- plugin->priv->enabled = TRUE;
- plugin->priv->priority = 0.f;
- plugin->priv->scale = 1;
- plugin->priv->profile = as_profile_new ();
- plugin->priv->cache = g_hash_table_new_full (g_str_hash,
- g_str_equal,
- g_free,
- (GDestroyNotify) g_object_unref);
- g_rw_lock_init (&plugin->priv->rwlock);
- return plugin;
-}
-
/**
* gs_plugin_create:
**/
@@ -121,6 +117,7 @@ gs_plugin_create (const gchar *filename, GError **error)
GsPluginGetDepsFunc order_before = NULL;
GsPluginGetDepsFunc plugin_conflicts = NULL;
GsPlugin *plugin = NULL;
+ GsPluginPrivate *priv;
g_autofree gchar *basename = NULL;
module = g_module_open (filename, 0);
@@ -158,24 +155,27 @@ gs_plugin_create (const gchar *filename, GError **error)
/* create new plugin */
plugin = gs_plugin_new ();
- plugin->priv->module = module;
- plugin->priv->order_after = order_after != NULL ? order_after (plugin) : NULL;
- plugin->priv->order_before = order_before != NULL ? order_before (plugin) : NULL;
- plugin->priv->conflicts = plugin_conflicts != NULL ? plugin_conflicts (plugin) : NULL;
- plugin->name = g_strdup (basename + 13);
+ priv = gs_plugin_get_instance_private (plugin);
+ priv->module = module;
+ priv->order_after = order_after != NULL ? order_after (plugin) : NULL;
+ priv->order_before = order_before != NULL ? order_before (plugin) : NULL;
+ priv->conflicts = plugin_conflicts != NULL ? plugin_conflicts (plugin) : NULL;
+ priv->name = g_strdup (basename + 13);
return plugin;
}
/**
- * gs_plugin_free:
+ * gs_plugin_finalize:
**/
-void
-gs_plugin_free (GsPlugin *plugin)
+static void
+gs_plugin_finalize (GObject *object)
{
+ GsPlugin *plugin = GS_PLUGIN (object);
GsPluginPrivate *priv = gs_plugin_get_instance_private (plugin);
+
if (priv->timer_id > 0)
g_source_remove (priv->timer_id);
- g_free (plugin->name);
+ g_free (priv->name);
g_free (priv->data);
g_free (priv->locale);
g_rw_lock_clear (&priv->rwlock);
@@ -183,8 +183,6 @@ gs_plugin_free (GsPlugin *plugin)
g_object_unref (priv->soup_session);
g_hash_table_unref (priv->cache);
g_module_close (priv->module);
- g_free (priv);
- g_slice_free (GsPlugin, plugin);
}
/**
@@ -241,7 +239,7 @@ gs_plugin_action_delay_cb (gpointer user_data)
GsPlugin *plugin = GS_PLUGIN (user_data);
GsPluginPrivate *priv = gs_plugin_get_instance_private (plugin);
- g_debug ("plugin no longer recently active: %s", plugin->name);
+ g_debug ("plugin no longer recently active: %s", priv->name);
priv->flags &= ~GS_PLUGIN_FLAGS_RECENT;
priv->timer_id = 0;
return FALSE;
@@ -310,6 +308,16 @@ gs_plugin_set_enabled (GsPlugin *plugin, gboolean enabled)
}
/**
+ * gs_plugin_set_enabled:
+ **/
+const gchar *
+gs_plugin_get_name (GsPlugin *plugin)
+{
+ GsPluginPrivate *priv = gs_plugin_get_instance_private (plugin);
+ return priv->name;
+}
+
+/**
* gs_plugin_get_scale:
**/
guint
@@ -497,14 +505,11 @@ static gboolean
gs_plugin_status_update_cb (gpointer user_data)
{
GsPluginStatusHelper *helper = (GsPluginStatusHelper *) user_data;
-
- /* call back into the loader */
- helper->plugin->status_update_fn (helper->plugin,
- helper->app,
- helper->status,
- helper->plugin->status_update_user_data);
- if (helper->app != NULL)
- g_object_unref (helper->app);
+ g_signal_emit (helper->plugin,
+ signals[SIGNAL_STATUS_CHANGED], 0,
+ helper->app,
+ helper->status);
+ g_object_unref (helper->app);
g_slice_free (GsPluginStatusHelper, helper);
return FALSE;
}
@@ -516,11 +521,12 @@ void
gs_plugin_status_update (GsPlugin *plugin, GsApp *app, GsPluginStatus status)
{
GsPluginStatusHelper *helper;
-
helper = g_slice_new0 (GsPluginStatusHelper);
helper->plugin = plugin;
helper->status = status;
- if (app != NULL)
+ if (app == NULL)
+ helper->app = gs_app_new (NULL);
+ else
helper->app = g_object_ref (app);
g_idle_add (gs_plugin_status_update_cb, helper);
}
@@ -585,7 +591,7 @@ static gboolean
gs_plugin_updates_changed_cb (gpointer user_data)
{
GsPlugin *plugin = GS_PLUGIN (user_data);
- plugin->updates_changed_fn (plugin, plugin->updates_changed_user_data);
+ g_signal_emit (plugin, signals[SIGNAL_UPDATES_CHANGED], 0);
return FALSE;
}
@@ -611,6 +617,7 @@ static void
gs_plugin_download_chunk_cb (SoupMessage *msg, SoupBuffer *chunk,
GsPluginDownloadHelper *helper)
{
+ GsPluginPrivate *priv = gs_plugin_get_instance_private (helper->plugin);
guint percentage;
goffset header_size;
goffset body_length;
@@ -619,7 +626,7 @@ gs_plugin_download_chunk_cb (SoupMessage *msg, SoupBuffer *chunk,
if (g_cancellable_is_cancelled (helper->cancellable)) {
g_debug ("cancelling download of %s",
gs_app_get_id (helper->app));
- soup_session_cancel_message (helper->plugin->priv->soup_session,
+ soup_session_cancel_message (priv->soup_session,
msg,
SOUP_STATUS_CANCELLED);
return;
@@ -659,12 +666,12 @@ gs_plugin_download_data (GsPlugin *plugin,
GCancellable *cancellable,
GError **error)
{
+ GsPluginPrivate *priv = gs_plugin_get_instance_private (plugin);
GsPluginDownloadHelper helper;
guint status_code;
g_autoptr(SoupMessage) msg = NULL;
- GsPluginPrivate *priv = gs_plugin_get_instance_private (plugin);
- g_debug ("downloading %s from %s", uri, plugin->name);
+ g_debug ("downloading %s from %s", uri, priv->name);
msg = soup_message_new (SOUP_METHOD_GET, uri);
if (app != NULL) {
helper.plugin = plugin;
@@ -698,13 +705,13 @@ gs_plugin_download_file (GsPlugin *plugin,
GCancellable *cancellable,
GError **error)
{
+ GsPluginPrivate *priv = gs_plugin_get_instance_private (plugin);
GsPluginDownloadHelper helper;
guint status_code;
g_autoptr(GError) error_local = NULL;
g_autoptr(SoupMessage) msg = NULL;
- GsPluginPrivate *priv = gs_plugin_get_instance_private (plugin);
- g_debug ("downloading %s to %s from %s", uri, filename, plugin->name);
+ g_debug ("downloading %s to %s from %s", uri, filename, priv->name);
msg = soup_message_new (SOUP_METHOD_GET, uri);
if (app != NULL) {
helper.plugin = plugin;
@@ -743,9 +750,8 @@ gs_plugin_download_file (GsPlugin *plugin,
GsApp *
gs_plugin_cache_lookup (GsPlugin *plugin, const gchar *key)
{
- GsApp *app;
GsPluginPrivate *priv = gs_plugin_get_instance_private (plugin);
- app = g_hash_table_lookup (priv->cache, key);
+ GsApp *app = g_hash_table_lookup (priv->cache, key);
if (app == NULL)
return NULL;
return g_object_ref (app);
@@ -763,4 +769,101 @@ gs_plugin_cache_add (GsPlugin *plugin, const gchar *key, GsApp *app)
g_hash_table_insert (priv->cache, g_strdup (key), g_object_ref (app));
}
+/**
+ * gs_plugin_set_property:
+ */
+static void
+gs_plugin_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+{
+ GsPlugin *plugin = GS_PLUGIN (object);
+ GsPluginPrivate *priv = gs_plugin_get_instance_private (plugin);
+ switch (prop_id) {
+ case PROP_FLAGS:
+ priv->flags = g_value_get_uint64 (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+/**
+ * gs_plugin_get_property:
+ */
+static void
+gs_plugin_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+{
+ GsPlugin *plugin = GS_PLUGIN (object);
+ GsPluginPrivate *priv = gs_plugin_get_instance_private (plugin);
+ switch (prop_id) {
+ case PROP_FLAGS:
+ g_value_set_uint64 (value, priv->flags);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+/**
+ * gs_plugin_class_init:
+ */
+static void
+gs_plugin_class_init (GsPluginClass *klass)
+{
+ GParamSpec *pspec;
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->set_property = gs_plugin_set_property;
+ object_class->get_property = gs_plugin_get_property;
+ object_class->finalize = gs_plugin_finalize;
+
+ pspec = g_param_spec_uint64 ("flags", NULL, NULL,
+ 0, G_MAXUINT64, 0, G_PARAM_READWRITE);
+ g_object_class_install_property (object_class, PROP_FLAGS, pspec);
+
+ signals [SIGNAL_UPDATES_CHANGED] =
+ g_signal_new ("updates-changed",
+ G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GsPluginClass, updates_changed),
+ NULL, NULL, g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ signals [SIGNAL_STATUS_CHANGED] =
+ g_signal_new ("status-changed",
+ G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GsPluginClass, status_changed),
+ NULL, NULL, g_cclosure_marshal_generic,
+ G_TYPE_NONE, 2, GS_TYPE_APP, G_TYPE_UINT);
+}
+
+/**
+ * gs_plugin_init:
+ */
+static void
+gs_plugin_init (GsPlugin *plugin)
+{
+ GsPluginPrivate *priv = gs_plugin_get_instance_private (plugin);
+ priv->enabled = TRUE;
+ priv->priority = 0.f;
+ priv->scale = 1;
+ priv->profile = as_profile_new ();
+ priv->cache = g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ g_free,
+ (GDestroyNotify) g_object_unref);
+ g_rw_lock_init (&priv->rwlock);
+}
+
+/**
+ * gs_plugin_new:
+ */
+GsPlugin *
+gs_plugin_new (void)
+{
+ GsPlugin *plugin;
+ plugin = g_object_new (GS_TYPE_PLUGIN, NULL);
+ return plugin;
+}
+
/* vim: set noexpandtab: */
diff --git a/src/gs-plugin.h b/src/gs-plugin.h
index c43d236..fe6ada7 100644
--- a/src/gs-plugin.h
+++ b/src/gs-plugin.h
@@ -26,7 +26,6 @@
#include <glib-object.h>
#include <gmodule.h>
#include <gio/gio.h>
-#include <gtk/gtk.h>
#include <libsoup/soup.h>
#include "gs-app.h"
@@ -35,9 +34,21 @@
G_BEGIN_DECLS
+#define GS_TYPE_PLUGIN (gs_plugin_get_type ())
+
+G_DECLARE_DERIVABLE_TYPE (GsPlugin, gs_plugin, GS, PLUGIN, GObject)
+
+struct _GsPluginClass
+{
+ GObjectClass parent_class;
+ void (*updates_changed) (GsPlugin *plugin);
+ void (*status_changed) (GsPlugin *plugin,
+ GsApp *app,
+ guint status);
+ gpointer padding[29];
+};
+
typedef struct GsPluginData GsPluginData;
-typedef struct GsPluginPrivate GsPluginPrivate;
-typedef struct GsPlugin GsPlugin;
typedef enum {
GS_PLUGIN_STATUS_UNKNOWN,
@@ -51,13 +62,6 @@ typedef enum {
GS_PLUGIN_STATUS_LAST
} GsPluginStatus;
-typedef void (*GsPluginStatusUpdate) (GsPlugin *plugin,
- GsApp *app,
- GsPluginStatus status,
- gpointer user_data);
-typedef void (*GsPluginUpdatesChanged) (GsPlugin *plugin,
- gpointer user_data);
-
typedef enum {
GS_PLUGIN_FLAGS_NONE = 0,
GS_PLUGIN_FLAGS_RUNNING_SELF = 1 << 0,
@@ -67,15 +71,6 @@ typedef enum {
GS_PLUGIN_FLAGS_LAST
} GsPluginFlags;
-struct GsPlugin {
- gchar *name;
- GsPluginPrivate *priv;
- GsPluginStatusUpdate status_update_fn;
- gpointer status_update_user_data;
- GsPluginUpdatesChanged updates_changed_fn;
- gpointer updates_changed_user_data;
-};
-
typedef enum {
GS_PLUGIN_ERROR_FAILED,
GS_PLUGIN_ERROR_NOT_SUPPORTED,
@@ -137,12 +132,12 @@ typedef enum {
/* helpers */
#define GS_PLUGIN_ERROR 1
-#define GS_PLUGIN(x) ((GsPlugin *) x)
/* public getters and setters */
GsPluginData *gs_plugin_alloc_data (GsPlugin *plugin,
gsize sz);
GsPluginData *gs_plugin_get_data (GsPlugin *plugin);
+const gchar *gs_plugin_get_name (GsPlugin *plugin);
gboolean gs_plugin_get_enabled (GsPlugin *plugin);
void gs_plugin_set_enabled (GsPlugin *plugin,
gboolean enabled);
diff --git a/src/plugins/gs-plugin-dpkg.c b/src/plugins/gs-plugin-dpkg.c
index f2108a3..6bc58b3 100644
--- a/src/plugins/gs-plugin-dpkg.c
+++ b/src/plugins/gs-plugin-dpkg.c
@@ -36,7 +36,7 @@ gs_plugin_initialize (GsPlugin *plugin)
{
if (!g_file_test (DPKG_DEB_BINARY, G_FILE_TEST_EXISTS)) {
g_debug ("disabling '%s' as no %s available",
- plugin->name, DPKG_DEB_BINARY);
+ gs_plugin_get_name (plugin), DPKG_DEB_BINARY);
gs_plugin_set_enabled (plugin, FALSE);
}
}
diff --git a/src/plugins/gs-plugin-dummy.c b/src/plugins/gs-plugin-dummy.c
index 3115100..2199b25 100644
--- a/src/plugins/gs-plugin-dummy.c
+++ b/src/plugins/gs-plugin-dummy.c
@@ -51,7 +51,8 @@ gs_plugin_initialize (GsPlugin *plugin)
{
gs_plugin_alloc_data (plugin, sizeof(GsPluginData));
if (g_getenv ("GS_SELF_TEST_DUMMY_ENABLE") == NULL) {
- g_debug ("disabling '%s' as not in self test", plugin->name);
+ g_debug ("disabling '%s' as not in self test",
+ gs_plugin_get_name (plugin));
gs_plugin_set_enabled (plugin, FALSE);
}
}
@@ -77,7 +78,7 @@ gs_plugin_adopt_app (GsPlugin *plugin, GsApp *app)
g_strcmp0 (gs_app_get_id (app), "chiron.desktop") == 0 ||
g_strcmp0 (gs_app_get_id (app), "zeus.desktop") == 0 ||
g_strcmp0 (gs_app_get_id (app), "zeus-spell.addon") == 0)
- gs_app_set_management_plugin (app, plugin->name);
+ gs_app_set_management_plugin (app, gs_plugin_get_name (plugin));
}
typedef struct {
@@ -233,7 +234,7 @@ gs_plugin_add_search (GsPlugin *plugin,
gs_app_set_size (app, 42 * 1024 * 1024);
gs_app_set_kind (app, AS_APP_KIND_DESKTOP);
gs_app_set_state (app, AS_APP_STATE_INSTALLED);
- gs_app_set_management_plugin (app, plugin->name);
+ gs_app_set_management_plugin (app, gs_plugin_get_name (plugin));
gs_app_list_add (list, app);
/* add to cache so it can be found by the flashing callback */
@@ -275,7 +276,7 @@ gs_plugin_add_updates (GsPlugin *plugin,
gs_app_set_icon (app, ic);
gs_app_set_kind (app, AS_APP_KIND_DESKTOP);
gs_app_set_state (app, AS_APP_STATE_UPDATABLE_LIVE);
- gs_app_set_management_plugin (app, plugin->name);
+ gs_app_set_management_plugin (app, gs_plugin_get_name (plugin));
gs_app_list_add (list, app);
g_object_unref (app);
@@ -289,7 +290,7 @@ gs_plugin_add_updates (GsPlugin *plugin,
gs_app_set_state (app, AS_APP_STATE_UPDATABLE);
gs_app_add_source (app, "libvirt-glib-devel");
gs_app_add_source_id (app, "libvirt-glib-devel;0.0.1;noarch;fedora");
- gs_app_set_management_plugin (app, plugin->name);
+ gs_app_set_management_plugin (app, gs_plugin_get_name (plugin));
gs_app_list_add (list, app);
g_object_unref (app);
@@ -303,7 +304,7 @@ gs_plugin_add_updates (GsPlugin *plugin,
gs_app_set_state (app, AS_APP_STATE_UPDATABLE_LIVE);
gs_app_add_source (app, "chiron-libs");
gs_app_add_source_id (app, "chiron-libs;0.0.1;i386;updates-testing");
- gs_app_set_management_plugin (app, plugin->name);
+ gs_app_set_management_plugin (app, gs_plugin_get_name (plugin));
gs_app_list_add (list, app);
g_object_unref (app);
@@ -330,7 +331,7 @@ gs_plugin_add_installed (GsPlugin *plugin,
gs_app_set_state (app, AS_APP_STATE_INSTALLED);
gs_app_set_kind (app, AS_APP_KIND_GENERIC);
gs_app_set_origin (app, "london-west");
- gs_app_set_management_plugin (app, plugin->name);
+ gs_app_set_management_plugin (app, gs_plugin_get_name (plugin));
gs_app_list_add (list, app);
}
@@ -339,7 +340,7 @@ gs_plugin_add_installed (GsPlugin *plugin,
g_autoptr(GsApp) app = gs_app_new (app_ids[i]);
gs_app_set_state (app, AS_APP_STATE_INSTALLED);
gs_app_set_kind (app, AS_APP_KIND_DESKTOP);
- gs_app_set_management_plugin (app, plugin->name);
+ gs_app_set_management_plugin (app, gs_plugin_get_name (plugin));
gs_app_list_add (list, app);
}
@@ -356,7 +357,8 @@ gs_plugin_app_remove (GsPlugin *plugin,
GError **error)
{
/* only process this app if was created by this plugin */
- if (g_strcmp0 (gs_app_get_management_plugin (app), plugin->name) != 0)
+ if (g_strcmp0 (gs_app_get_management_plugin (app),
+ gs_plugin_get_name (plugin)) != 0)
return TRUE;
/* remove app */
@@ -381,7 +383,8 @@ gs_plugin_app_install (GsPlugin *plugin,
GError **error)
{
/* only process this app if was created by this plugin */
- if (g_strcmp0 (gs_app_get_management_plugin (app), plugin->name) != 0)
+ if (g_strcmp0 (gs_app_get_management_plugin (app),
+ gs_plugin_get_name (plugin)) != 0)
return TRUE;
/* install app */
@@ -406,7 +409,8 @@ gs_plugin_update_app (GsPlugin *plugin,
GError **error)
{
/* only process this app if was created by this plugin */
- if (g_strcmp0 (gs_app_get_management_plugin (app), plugin->name) != 0)
+ if (g_strcmp0 (gs_app_get_management_plugin (app),
+ gs_plugin_get_name (plugin)) != 0)
return TRUE;
/* always fail */
@@ -523,7 +527,7 @@ gs_plugin_add_category_apps (GsPlugin *plugin,
gs_app_set_state (app, AS_APP_STATE_AVAILABLE);
gs_app_set_pixbuf (app, gdk_pixbuf_new_from_file
("/usr/share/icons/hicolor/48x48/apps/chiron.desktop.png", NULL));
gs_app_set_kind (app, AS_APP_KIND_DESKTOP);
- gs_app_set_management_plugin (app, plugin->name);
+ gs_app_set_management_plugin (app, gs_plugin_get_name (plugin));
gs_app_list_add (list, app);
return TRUE;
}
@@ -566,7 +570,7 @@ gs_plugin_add_distro_upgrades (GsPlugin *plugin,
gs_app_set_size (app, 1024 * 1024 * 1024);
gs_app_set_license (app, GS_APP_QUALITY_LOWEST, "LicenseRef-free");
gs_app_set_origin_ui (app, "Dummy");
- gs_app_set_management_plugin (app, plugin->name);
+ gs_app_set_management_plugin (app, gs_plugin_get_name (plugin));
gs_app_set_metadata (app, "GnomeSoftware::UpgradeBanner-css",
"background: url('" DATADIR "/gnome-software/upgrade-bg.png');"
"background-size: 100% 100%;");
@@ -606,7 +610,8 @@ gs_plugin_app_upgrade_download (GsPlugin *plugin, GsApp *app,
GCancellable *cancellable, GError **error)
{
/* only process this app if was created by this plugin */
- if (g_strcmp0 (gs_app_get_management_plugin (app), plugin->name) != 0)
+ if (g_strcmp0 (gs_app_get_management_plugin (app),
+ gs_plugin_get_name (plugin)) != 0)
return TRUE;
g_debug ("starting download");
@@ -625,7 +630,8 @@ gs_plugin_app_upgrade_trigger (GsPlugin *plugin, GsApp *app,
GCancellable *cancellable, GError **error)
{
/* only process this app if was created by this plugin */
- if (g_strcmp0 (gs_app_get_management_plugin (app), plugin->name) != 0)
+ if (g_strcmp0 (gs_app_get_management_plugin (app),
+ gs_plugin_get_name (plugin)) != 0)
return TRUE;
/* NOP */
diff --git a/src/plugins/gs-plugin-epiphany.c b/src/plugins/gs-plugin-epiphany.c
index fca73e2..6aba229 100644
--- a/src/plugins/gs-plugin-epiphany.c
+++ b/src/plugins/gs-plugin-epiphany.c
@@ -62,7 +62,7 @@ gs_plugin_initialize (GsPlugin *plugin)
if (epiphany == NULL) {
gs_plugin_set_enabled (plugin, FALSE);
g_debug ("disabling '%s' as epiphany does not exist",
- plugin->name);
+ gs_plugin_get_name (plugin));
}
}
@@ -73,7 +73,7 @@ void
gs_plugin_adopt_app (GsPlugin *plugin, GsApp *app)
{
if (gs_app_get_kind (app) == AS_APP_KIND_WEB_APP)
- gs_app_set_management_plugin (app, plugin->name);
+ gs_app_set_management_plugin (app, gs_plugin_get_name (plugin));
}
/**
@@ -117,7 +117,8 @@ gs_plugin_app_install (GsPlugin *plugin, GsApp *app,
g_autoptr(GFile) symlink_icon = NULL;
/* only process this app if was created by this plugin */
- if (g_strcmp0 (gs_app_get_management_plugin (app), plugin->name) != 0)
+ if (g_strcmp0 (gs_app_get_management_plugin (app),
+ gs_plugin_get_name (plugin)) != 0)
return TRUE;
/* create the correct directory */
@@ -235,7 +236,8 @@ gs_plugin_app_remove (GsPlugin *plugin, GsApp *app,
g_autoptr(GFile) file_app = NULL;
/* only process this app if was created by this plugin */
- if (g_strcmp0 (gs_app_get_management_plugin (app), plugin->name) != 0)
+ if (g_strcmp0 (gs_app_get_management_plugin (app),
+ gs_plugin_get_name (plugin)) != 0)
return TRUE;
/* remove the epi 'config' file */
@@ -274,7 +276,8 @@ gs_plugin_refine_app (GsPlugin *plugin,
g_autofree gchar *id_nonfull = NULL;
/* only process this app if was created by this plugin */
- if (g_strcmp0 (gs_app_get_management_plugin (app), plugin->name) != 0)
+ if (g_strcmp0 (gs_app_get_management_plugin (app),
+ gs_plugin_get_name (plugin)) != 0)
return TRUE;
gs_app_set_size (app, 4096);
@@ -299,7 +302,7 @@ gs_plugin_refine_app (GsPlugin *plugin,
if (g_file_test (fn, G_FILE_TEST_EXISTS)) {
gs_app_set_state (app, AS_APP_STATE_INSTALLED);
gs_app_add_source_id (app, fn);
- gs_app_set_management_plugin (app, plugin->name);
+ gs_app_set_management_plugin (app, gs_plugin_get_name (plugin));
return TRUE;
}
gs_app_set_state (app, AS_APP_STATE_AVAILABLE);
@@ -316,7 +319,8 @@ gs_plugin_launch (GsPlugin *plugin,
GError **error)
{
/* only process this app if was created by this plugin */
- if (g_strcmp0 (gs_app_get_management_plugin (app), plugin->name) != 0)
+ if (g_strcmp0 (gs_app_get_management_plugin (app),
+ gs_plugin_get_name (plugin)) != 0)
return TRUE;
return gs_plugin_app_launch (plugin, app, error);
}
diff --git a/src/plugins/gs-plugin-fedora-distro-upgrades.c b/src/plugins/gs-plugin-fedora-distro-upgrades.c
index aacb099..bde6cc4 100644
--- a/src/plugins/gs-plugin-fedora-distro-upgrades.c
+++ b/src/plugins/gs-plugin-fedora-distro-upgrades.c
@@ -46,7 +46,7 @@ gs_plugin_initialize (GsPlugin *plugin)
/* check that we are running on Fedora */
if (!gs_plugin_check_distro_id (plugin, "fedora")) {
gs_plugin_set_enabled (plugin, FALSE);
- g_debug ("disabling '%s' as we're not Fedora", plugin->name);
+ g_debug ("disabling '%s' as we're not Fedora", gs_plugin_get_name (plugin));
return;
}
}
@@ -79,11 +79,11 @@ gs_plugin_fedora_distro_upgrades_changed_cb (GFileMonitor *monitor,
/* only reload the update list if the plugin is NOT running itself
* and the time since it ran is greater than 5 seconds (inotify FTW) */
if (gs_plugin_has_flags (plugin, GS_PLUGIN_FLAGS_RUNNING_SELF)) {
- g_debug ("no notify as plugin %s active", plugin->name);
+ g_debug ("no notify as plugin %s active", gs_plugin_get_name (plugin));
return;
}
if (gs_plugin_has_flags (plugin, GS_PLUGIN_FLAGS_RECENT)) {
- g_debug ("no notify as plugin %s recently active", plugin->name);
+ g_debug ("no notify as plugin %s recently active", gs_plugin_get_name (plugin));
return;
}
g_debug ("cache file changed, so reloading upgrades list");
diff --git a/src/plugins/gs-plugin-fedora-tagger-usage.c b/src/plugins/gs-plugin-fedora-tagger-usage.c
index 64c1db5..7a96f9f 100644
--- a/src/plugins/gs-plugin-fedora-tagger-usage.c
+++ b/src/plugins/gs-plugin-fedora-tagger-usage.c
@@ -50,14 +50,14 @@ gs_plugin_initialize (GsPlugin *plugin)
if (!g_settings_get_boolean (settings, "send-software-usage-stats")) {
gs_plugin_set_enabled (plugin, FALSE);
g_debug ("disabling '%s' as 'send-software-usage-stats' "
- "disabled in GSettings", plugin->name);
+ "disabled in GSettings", gs_plugin_get_name (plugin));
return;
}
/* check that we are running on Fedora */
if (!gs_plugin_check_distro_id (plugin, "fedora")) {
gs_plugin_set_enabled (plugin, FALSE);
- g_debug ("disabling '%s' as we're not Fedora", plugin->name);
+ g_debug ("disabling '%s' as we're not Fedora", gs_plugin_get_name (plugin));
return;
}
}
diff --git a/src/plugins/gs-plugin-fwupd.c b/src/plugins/gs-plugin-fwupd.c
index 3baca15..3e0a0db 100644
--- a/src/plugins/gs-plugin-fwupd.c
+++ b/src/plugins/gs-plugin-fwupd.c
@@ -94,7 +94,7 @@ void
gs_plugin_adopt_app (GsPlugin *plugin, GsApp *app)
{
if (gs_app_get_kind (app) == AS_APP_KIND_FIRMWARE)
- gs_app_set_management_plugin (app, plugin->name);
+ gs_app_set_management_plugin (app, gs_plugin_get_name (plugin));
}
/**
@@ -471,7 +471,7 @@ gs_plugin_fwupd_check_lvfs_metadata (GsPlugin *plugin,
g_autofree gchar *url_sig = NULL;
g_autoptr(GBytes) data = NULL;
g_autoptr(GKeyFile) config = NULL;
- g_autoptr(GsApp) app_dl = gs_app_new (plugin->name);
+ g_autoptr(GsApp) app_dl = gs_app_new (gs_plugin_get_name (plugin));
/* read config file */
config = g_key_file_new ();
@@ -680,7 +680,8 @@ gs_plugin_app_install (GsPlugin *plugin,
GError **error)
{
/* only process this app if was created by this plugin */
- if (g_strcmp0 (gs_app_get_management_plugin (app), plugin->name) != 0)
+ if (g_strcmp0 (gs_app_get_management_plugin (app),
+ gs_plugin_get_name (plugin)) != 0)
return TRUE;
return gs_plugin_fwupd_install (plugin, app, cancellable, error);
@@ -699,7 +700,8 @@ gs_plugin_update_app (GsPlugin *plugin,
{
GsPluginData *priv = gs_plugin_get_data (plugin);
/* only process this app if was created by this plugin */
- if (g_strcmp0 (gs_app_get_management_plugin (app), plugin->name) != 0)
+ if (g_strcmp0 (gs_app_get_management_plugin (app),
+ gs_plugin_get_name (plugin)) != 0)
return TRUE;
/* locked devices need unlocking, rather than installing */
diff --git a/src/plugins/gs-plugin-limba.c b/src/plugins/gs-plugin-limba.c
index 56a572f..816fa3e 100644
--- a/src/plugins/gs-plugin-limba.c
+++ b/src/plugins/gs-plugin-limba.c
@@ -83,7 +83,8 @@ gs_plugin_refine_app (GsPlugin *plugin,
g_autoptr(AsProfileTask) ptask = NULL;
/* not us */
- if (g_strcmp0 (gs_app_get_management_plugin (app), plugin->name) != 0)
+ if (g_strcmp0 (gs_app_get_management_plugin (app),
+ gs_plugin_get_name (plugin)) != 0)
return TRUE;
/* profile */
@@ -177,7 +178,8 @@ gs_plugin_app_remove (GsPlugin *plugin,
g_autoptr(GError) error_local = NULL;
/* not us */
- if (g_strcmp0 (gs_app_get_management_plugin (app), plugin->name) != 0)
+ if (g_strcmp0 (gs_app_get_management_plugin (app),
+ gs_plugin_get_name (plugin)) != 0)
return TRUE;
mgr = li_manager_new ();
@@ -223,7 +225,8 @@ gs_plugin_app_install (GsPlugin *plugin,
g_autoptr(GError) error_local = NULL;
/* not us */
- if (g_strcmp0 (gs_app_get_management_plugin (app), plugin->name) != 0)
+ if (g_strcmp0 (gs_app_get_management_plugin (app),
+ gs_plugin_get_name (plugin)) != 0)
return TRUE;
/* create new installer and select remote package */
diff --git a/src/plugins/gs-plugin-ostree.c b/src/plugins/gs-plugin-ostree.c
index 2270165..8bd4523 100644
--- a/src/plugins/gs-plugin-ostree.c
+++ b/src/plugins/gs-plugin-ostree.c
@@ -125,7 +125,7 @@ gs_plugin_add_sources (GsPlugin *plugin,
/* create app */
app = gs_app_new (names[i]);
- gs_app_set_management_plugin (app, plugin->name);
+ gs_app_set_management_plugin (app, gs_plugin_get_name (plugin));
gs_app_set_kind (app, AS_APP_KIND_SOURCE);
gs_app_set_state (app, AS_APP_STATE_INSTALLED);
gs_app_set_url (app, AS_URL_KIND_HOMEPAGE, url);
diff --git a/src/plugins/gs-plugin-packagekit.c b/src/plugins/gs-plugin-packagekit.c
index e2b4ac4..ed97a3b 100644
--- a/src/plugins/gs-plugin-packagekit.c
+++ b/src/plugins/gs-plugin-packagekit.c
@@ -260,7 +260,7 @@ gs_plugin_add_sources (GsPlugin *plugin,
rd = g_ptr_array_index (array, i);
id = pk_repo_detail_get_id (rd);
app = gs_app_new (id);
- gs_app_set_management_plugin (app, plugin->name);
+ gs_app_set_management_plugin (app, gs_plugin_get_name (plugin));
gs_app_set_kind (app, AS_APP_KIND_SOURCE);
gs_app_set_state (app, AS_APP_STATE_INSTALLED);
gs_app_set_name (app,
@@ -337,7 +337,8 @@ gs_plugin_app_install (GsPlugin *plugin,
data.ptask = NULL;
/* only process this app if was created by this plugin */
- if (g_strcmp0 (gs_app_get_management_plugin (app), plugin->name) != 0)
+ if (g_strcmp0 (gs_app_get_management_plugin (app),
+ gs_plugin_get_name (plugin)) != 0)
return TRUE;
/* high priority foreground operation */
@@ -589,7 +590,8 @@ gs_plugin_app_remove (GsPlugin *plugin,
data.ptask = NULL;
/* only process this app if was created by this plugin */
- if (g_strcmp0 (gs_app_get_management_plugin (app), plugin->name) != 0)
+ if (g_strcmp0 (gs_app_get_management_plugin (app),
+ gs_plugin_get_name (plugin)) != 0)
return TRUE;
/* remove repo and all apps in it */
@@ -786,7 +788,8 @@ gs_plugin_launch (GsPlugin *plugin,
GError **error)
{
/* only process this app if was created by this plugin */
- if (g_strcmp0 (gs_app_get_management_plugin (app), plugin->name) != 0)
+ if (g_strcmp0 (gs_app_get_management_plugin (app),
+ gs_plugin_get_name (plugin)) != 0)
return TRUE;
return gs_plugin_app_launch (plugin, app, error);
}
diff --git a/src/plugins/gs-plugin-shell-extensions.c b/src/plugins/gs-plugin-shell-extensions.c
index e6edd00..f1af60b 100644
--- a/src/plugins/gs-plugin-shell-extensions.c
+++ b/src/plugins/gs-plugin-shell-extensions.c
@@ -92,7 +92,7 @@ void
gs_plugin_adopt_app (GsPlugin *plugin, GsApp *app)
{
if (gs_app_get_kind (app) == AS_APP_KIND_SHELL_EXTENSION)
- gs_app_set_management_plugin (app, plugin->name);
+ gs_app_set_management_plugin (app, gs_plugin_get_name (plugin));
}
/**
@@ -312,7 +312,7 @@ gs_plugin_refine_app (GsPlugin *plugin,
/* adopt any here */
if (gs_app_get_management_plugin (app) == NULL)
- gs_app_set_management_plugin (app, plugin->name);
+ gs_app_set_management_plugin (app, gs_plugin_get_name (plugin));
/* assume apps are available if they exist in AppStream metadata */
if (gs_app_get_state (app) == AS_APP_STATE_UNKNOWN)
@@ -478,7 +478,7 @@ gs_plugin_shell_extensions_parse_app (GsPlugin *plugin,
/* we have no data :/ */
as_app_set_comment (app, NULL, "GNOME Shell Extension");
- as_app_add_metadata (app, "GnomeSoftware::Plugin", plugin->name);
+ as_app_add_metadata (app, "GnomeSoftware::Plugin", gs_plugin_get_name (plugin));
return app;
}
@@ -589,7 +589,7 @@ gs_plugin_shell_extensions_get_apps (GsPlugin *plugin,
g_autofree gchar *uri = NULL;
g_autoptr(GFile) cachefn_file = NULL;
g_autoptr(GBytes) data = NULL;
- g_autoptr(GsApp) dummy = gs_app_new (plugin->name);
+ g_autoptr(GsApp) dummy = gs_app_new (gs_plugin_get_name (plugin));
/* look in the cache */
cachedir = gs_utils_get_cachedir ("extensions", error);
@@ -722,7 +722,8 @@ gs_plugin_app_remove (GsPlugin *plugin,
g_autoptr(GVariant) retval = NULL;
/* only process this app if was created by this plugin */
- if (g_strcmp0 (gs_app_get_management_plugin (app), plugin->name) != 0)
+ if (g_strcmp0 (gs_app_get_management_plugin (app),
+ gs_plugin_get_name (plugin)) != 0)
return TRUE;
/* remove */
@@ -773,7 +774,8 @@ gs_plugin_app_install (GsPlugin *plugin,
g_autoptr(GVariant) retval = NULL;
/* only process this app if was created by this plugin */
- if (g_strcmp0 (gs_app_get_management_plugin (app), plugin->name) != 0)
+ if (g_strcmp0 (gs_app_get_management_plugin (app),
+ gs_plugin_get_name (plugin)) != 0)
return TRUE;
/* install */
diff --git a/src/plugins/gs-plugin-steam.c b/src/plugins/gs-plugin-steam.c
index 984a91c..1a1e3f0 100644
--- a/src/plugins/gs-plugin-steam.c
+++ b/src/plugins/gs-plugin-steam.c
@@ -615,7 +615,7 @@ gs_plugin_steam_update_store_app (GsPlugin *plugin,
return FALSE;
cache_fn = g_build_filename (cachedir, cache_basename, NULL);
if (!g_file_test (cache_fn, G_FILE_TEST_EXISTS)) {
- g_autoptr(GsApp) app_dl = gs_app_new (plugin->name);
+ g_autoptr(GsApp) app_dl = gs_app_new (gs_plugin_get_name (plugin));
uri = g_strdup_printf ("http://store.steampowered.com/app/%s/", gameid_str);
if (!gs_plugin_download_file (plugin,
app_dl,
@@ -916,7 +916,8 @@ gs_plugin_app_install (GsPlugin *plugin, GsApp *app,
g_autofree gchar *cmdline = NULL;
/* only process this app if was created by this plugin */
- if (g_strcmp0 (gs_app_get_management_plugin (app), plugin->name) != 0)
+ if (g_strcmp0 (gs_app_get_management_plugin (app),
+ gs_plugin_get_name (plugin)) != 0)
return TRUE;
/* this is async as steam is a different process: FIXME: use D-Bus */
@@ -937,7 +938,8 @@ gs_plugin_app_remove (GsPlugin *plugin, GsApp *app,
g_autofree gchar *cmdline = NULL;
/* only process this app if was created by this plugin */
- if (g_strcmp0 (gs_app_get_management_plugin (app), plugin->name) != 0)
+ if (g_strcmp0 (gs_app_get_management_plugin (app),
+ gs_plugin_get_name (plugin)) != 0)
return TRUE;
/* this is async as steam is a different process: FIXME: use D-Bus */
@@ -958,7 +960,8 @@ gs_plugin_launch (GsPlugin *plugin, GsApp *app,
g_autofree gchar *cmdline = NULL;
/* only process this app if was created by this plugin */
- if (g_strcmp0 (gs_app_get_management_plugin (app), plugin->name) != 0)
+ if (g_strcmp0 (gs_app_get_management_plugin (app),
+ gs_plugin_get_name (plugin)) != 0)
return TRUE;
/* this is async as steam is a different process: FIXME: use D-Bus */
diff --git a/src/plugins/gs-plugin-ubuntu-reviews.c b/src/plugins/gs-plugin-ubuntu-reviews.c
index 8133dd2..ce0d916 100644
--- a/src/plugins/gs-plugin-ubuntu-reviews.c
+++ b/src/plugins/gs-plugin-ubuntu-reviews.c
@@ -60,7 +60,7 @@ gs_plugin_initialize (GsPlugin *plugin)
/* check that we are running on Ubuntu */
if (!gs_plugin_check_distro_id (plugin, "ubuntu")) {
gs_plugin_set_enabled (plugin, FALSE);
- g_debug ("disabling '%s' as we're not Ubuntu", plugin->name);
+ g_debug ("disabling '%s' as we're not Ubuntu", gs_plugin_get_name (plugin));
return;
}
diff --git a/src/plugins/gs-plugin-xdg-app.c b/src/plugins/gs-plugin-xdg-app.c
index 8188bec..43d89e9 100644
--- a/src/plugins/gs-plugin-xdg-app.c
+++ b/src/plugins/gs-plugin-xdg-app.c
@@ -91,7 +91,7 @@ gs_plugin_adopt_app (GsPlugin *plugin, GsApp *app)
{
if (g_str_has_prefix (gs_app_get_id (app), "user-xdgapp:") ||
g_str_has_prefix (gs_app_get_id (app), "xdgapp:")) {
- gs_app_set_management_plugin (app, plugin->name);
+ gs_app_set_management_plugin (app, gs_plugin_get_name (plugin));
}
}
@@ -519,7 +519,7 @@ gs_plugin_add_sources (GsPlugin *plugin,
continue;
app = gs_app_new (xdg_app_remote_get_name (xremote));
- gs_app_set_management_plugin (app, plugin->name);
+ gs_app_set_management_plugin (app, gs_plugin_get_name (plugin));
gs_app_set_kind (app, AS_APP_KIND_SOURCE);
gs_app_set_state (app, AS_APP_STATE_INSTALLED);
gs_app_set_name (app,
@@ -835,7 +835,7 @@ gs_plugin_refine_item_metadata (GsPlugin *plugin,
/* AppStream sets the source to appname/arch/branch, if this isn't set
* we can't break out the fields */
if (gs_app_get_source_default (app) == NULL) {
- g_warning ("no source set by appstream for %s", plugin->name);
+ g_warning ("no source set by appstream for %s", gs_plugin_get_name (plugin));
return TRUE;
}
@@ -1117,7 +1117,8 @@ gs_plugin_xdg_app_refine_app (GsPlugin *plugin,
g_autoptr(AsProfileTask) ptask = NULL;
/* only process this app if was created by this plugin */
- if (g_strcmp0 (gs_app_get_management_plugin (app), plugin->name) != 0)
+ if (g_strcmp0 (gs_app_get_management_plugin (app),
+ gs_plugin_get_name (plugin)) != 0)
return TRUE;
/* profile */
@@ -1182,7 +1183,8 @@ gs_plugin_launch (GsPlugin *plugin,
const gchar *branch = NULL;
/* only process this app if was created by this plugin */
- if (g_strcmp0 (gs_app_get_management_plugin (app), plugin->name) != 0)
+ if (g_strcmp0 (gs_app_get_management_plugin (app),
+ gs_plugin_get_name (plugin)) != 0)
return TRUE;
branch = gs_app_get_xdgapp_branch (app);
@@ -1209,7 +1211,8 @@ gs_plugin_app_remove (GsPlugin *plugin,
GsPluginData *priv = gs_plugin_get_data (plugin);
/* only process this app if was created by this plugin */
- if (g_strcmp0 (gs_app_get_management_plugin (app), plugin->name) != 0)
+ if (g_strcmp0 (gs_app_get_management_plugin (app),
+ gs_plugin_get_name (plugin)) != 0)
return TRUE;
/* remove */
@@ -1243,7 +1246,8 @@ gs_plugin_app_install (GsPlugin *plugin,
g_autoptr(XdgAppInstalledRef) xref = NULL;
/* only process this app if was created by this plugin */
- if (g_strcmp0 (gs_app_get_management_plugin (app), plugin->name) != 0)
+ if (g_strcmp0 (gs_app_get_management_plugin (app),
+ gs_plugin_get_name (plugin)) != 0)
return TRUE;
/* ensure we have metadata and state */
@@ -1341,7 +1345,8 @@ gs_plugin_update_app (GsPlugin *plugin,
g_autoptr(XdgAppInstalledRef) xref = NULL;
/* only process this app if was created by this plugin */
- if (g_strcmp0 (gs_app_get_management_plugin (app), plugin->name) != 0)
+ if (g_strcmp0 (gs_app_get_management_plugin (app),
+ gs_plugin_get_name (plugin)) != 0)
return TRUE;
/* install */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]