[gnome-software: 18/24] gs-cmd: Use GsPluginJobListApps rather than ACTION_GET_RECENT




commit 2ef0350758ba28569fc33a3b4696a54325de9dcc
Author: Philip Withnall <pwithnall endlessos org>
Date:   Wed Apr 13 23:41:11 2022 +0100

    gs-cmd: Use GsPluginJobListApps rather than ACTION_GET_RECENT
    
    This is one step towards removing `ACTION_GET_RECENT` and allowing
    plugins to consolidate their vfuncs which list apps.
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>
    
    Helps: #1472

 lib/gs-cmd.c | 26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)
---
diff --git a/lib/gs-cmd.c b/lib/gs-cmd.c
index 2068414ab..039e2b646 100644
--- a/lib/gs-cmd.c
+++ b/lib/gs-cmd.c
@@ -632,15 +632,27 @@ main (int argc, char **argv)
                        cache_age_secs = 60 * 60 * 24 * 60;
                for (i = 0; i < repeat; i++) {
                        g_autoptr(GsPluginJob) plugin_job = NULL;
+                       g_autoptr(GDateTime) now = NULL;
+                       g_autoptr(GDateTime) released_since = NULL;
+                       g_autoptr(GsAppQuery) query = NULL;
+                       GsPluginListAppsFlags flags = GS_PLUGIN_LIST_APPS_FLAGS_NONE;
+
                        if (list != NULL)
                                g_object_unref (list);
-                       plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_GET_RECENT,
-                                                        "age", cache_age_secs,
-                                                        "refine-flags", self->refine_flags,
-                                                        "max-results", self->max_results,
-                                                        "interactive", self->interactive,
-                                                        NULL);
-                       gs_plugin_job_set_sort_func (plugin_job, app_sort_kind_cb, NULL);
+
+                       now = g_date_time_new_now_local ();
+                       released_since = g_date_time_add_seconds (now, -cache_age_secs);
+                       query = gs_app_query_new ("released-since", released_since,
+                                                 "refine-flags", self->refine_flags,
+                                                 "dedupe-flags", GS_APP_LIST_FILTER_FLAG_KEY_ID,
+                                                 "max-results", self->max_results,
+                                                 "sort-func", app_sort_kind_cb,
+                                                 NULL);
+
+                       if (self->interactive)
+                               flags |= GS_PLUGIN_LIST_APPS_FLAGS_INTERACTIVE;
+
+                       plugin_job = gs_plugin_job_list_apps_new (query, flags);
                        list = gs_plugin_loader_job_process (self->plugin_loader, plugin_job,
                                                             NULL, &error);
                        if (list == NULL) {


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