[gnome-software: 2/38] gs-plugin-helpers: Add helpers for refresh_metadata




commit fa28b9e7ad206720bad6e87908abdc30262697de
Author: Philip Withnall <pwithnall endlessos org>
Date:   Thu Jan 27 18:49:32 2022 +0000

    gs-plugin-helpers: Add helpers for refresh_metadata
    
    These will be used in upcoming commits.
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>
    
    Helps: #1472

 lib/gs-plugin-helpers.c | 35 +++++++++++++++++++++++++++++++++++
 lib/gs-plugin-helpers.h | 10 ++++++++++
 2 files changed, 45 insertions(+)
---
diff --git a/lib/gs-plugin-helpers.c b/lib/gs-plugin-helpers.c
index e8817a68f..ab409ec3f 100644
--- a/lib/gs-plugin-helpers.c
+++ b/lib/gs-plugin-helpers.c
@@ -95,3 +95,38 @@ gs_plugin_refine_data_free (GsPluginRefineData *data)
        g_clear_object (&data->list);
        g_free (data);
 }
+
+/**
+ * gs_plugin_refresh_metadata_data_new:
+ * @cache_age_secs: maximum allowed age of the cache in order for it to remain valid, in seconds
+ * @flags: refresh metadata flags
+ *
+ * Context data for a call to #GsPluginClass.refresh_metadata_async.
+ *
+ * Returns: (transfer full): context data structure
+ * Since: 42
+ */
+GsPluginRefreshMetadataData *
+gs_plugin_refresh_metadata_data_new (guint64                      cache_age_secs,
+                                     GsPluginRefreshMetadataFlags flags)
+{
+       g_autoptr(GsPluginRefreshMetadataData) data = g_new0 (GsPluginRefreshMetadataData, 1);
+       data->cache_age_secs = cache_age_secs;
+       data->flags = flags;
+
+       return g_steal_pointer (&data);
+}
+
+/**
+ * gs_plugin_refresh_metadata_data_free:
+ * @data: (transfer full): a #GsPluginRefreshMetadataData
+ *
+ * Free the given @data.
+ *
+ * Since: 42
+ */
+void
+gs_plugin_refresh_metadata_data_free (GsPluginRefreshMetadataData *data)
+{
+       g_free (data);
+}
diff --git a/lib/gs-plugin-helpers.h b/lib/gs-plugin-helpers.h
index 3edab86c8..c061ee198 100644
--- a/lib/gs-plugin-helpers.h
+++ b/lib/gs-plugin-helpers.h
@@ -34,4 +34,14 @@ GTask *gs_plugin_refine_data_new_task (gpointer             source_object,
 void gs_plugin_refine_data_free (GsPluginRefineData *data);
 G_DEFINE_AUTOPTR_CLEANUP_FUNC (GsPluginRefineData, gs_plugin_refine_data_free)
 
+typedef struct {
+       guint64 cache_age_secs;
+       GsPluginRefreshMetadataFlags flags;
+} GsPluginRefreshMetadataData;
+
+GsPluginRefreshMetadataData *gs_plugin_refresh_metadata_data_new (guint64                      
cache_age_secs,
+                                                                  GsPluginRefreshMetadataFlags flags);
+void gs_plugin_refresh_metadata_data_free (GsPluginRefreshMetadataData *data);
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (GsPluginRefreshMetadataData, gs_plugin_refresh_metadata_data_free)
+
 G_END_DECLS


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