[gnome-software] trivial: Add gs_plugin_cache_remove()
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] trivial: Add gs_plugin_cache_remove()
- Date: Mon, 31 Oct 2016 16:50:57 +0000 (UTC)
commit 781a28dc3d53581725af6bb4218d24f129c4d837
Author: Richard Hughes <richard hughsie com>
Date: Mon Oct 31 14:42:33 2016 +0000
trivial: Add gs_plugin_cache_remove()
This allows plugins to remove items from the cache.
src/gs-plugin.c | 33 +++++++++++++++++++++++++++++++++
src/gs-plugin.h | 2 ++
2 files changed, 35 insertions(+), 0 deletions(-)
---
diff --git a/src/gs-plugin.c b/src/gs-plugin.c
index 3b70808..3f034b0 100644
--- a/src/gs-plugin.c
+++ b/src/gs-plugin.c
@@ -47,6 +47,7 @@
#include <gio/gdesktopappinfo.h>
#include <gdk/gdk.h>
+#include "gs-app-list-private.h"
#include "gs-os-release.h"
#include "gs-plugin-private.h"
#include "gs-plugin.h"
@@ -1210,6 +1211,38 @@ gs_plugin_cache_lookup (GsPlugin *plugin, const gchar *key)
}
/**
+ * gs_plugin_cache_remove:
+ * @plugin: a #GsPlugin
+ * @key: a key which matches
+ *
+ * Removes an application from the per-plugin cache.
+ *
+ * Since: 3.24
+ **/
+void
+gs_plugin_cache_remove (GsPlugin *plugin, const gchar *key)
+{
+ GsPluginPrivate *priv = gs_plugin_get_instance_private (plugin);
+
+ g_return_if_fail (GS_IS_PLUGIN (plugin));
+ g_return_if_fail (key != NULL);
+
+ /* global, so using internal unique_id */
+ if (gs_plugin_has_flags (plugin, GS_PLUGIN_FLAGS_GLOBAL_CACHE)) {
+ GsApp *app_tmp;
+ if (!as_utils_unique_id_valid (key)) {
+ g_critical ("key %s is not a unique_id", key);
+ return;
+ }
+ app_tmp = gs_app_list_lookup (priv->global_cache, key);
+ if (app_tmp != NULL)
+ gs_app_list_remove (priv->global_cache, app_tmp);
+ return;
+ }
+ g_hash_table_remove (priv->cache, key);
+}
+
+/**
* gs_plugin_cache_add:
* @plugin: a #GsPlugin
* @key: a string, or %NULL if the unique ID should be used
diff --git a/src/gs-plugin.h b/src/gs-plugin.h
index b4977dd..648bfcd 100644
--- a/src/gs-plugin.h
+++ b/src/gs-plugin.h
@@ -109,6 +109,8 @@ GsApp *gs_plugin_cache_lookup (GsPlugin *plugin,
void gs_plugin_cache_add (GsPlugin *plugin,
const gchar *key,
GsApp *app);
+void gs_plugin_cache_remove (GsPlugin *plugin,
+ const gchar *key);
void gs_plugin_cache_invalidate (GsPlugin *plugin);
void gs_plugin_status_update (GsPlugin *plugin,
GsApp *app,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]