[gnome-software/1409-add-available-for-fedora-section-to-the-explore-page: 1239/1241] flatpak: Implement search for deployment-featured apps




commit 3f7622b9da6959dbbcb620c30a622974c923dad0
Author: Milan Crha <mcrha redhat com>
Date:   Fri May 6 12:08:52 2022 +0200

    flatpak: Implement search for deployment-featured apps

 plugins/flatpak/gs-flatpak.c        | 17 +++++++++++++++++
 plugins/flatpak/gs-flatpak.h        |  7 +++++++
 plugins/flatpak/gs-plugin-flatpak.c | 16 +++++++++++++---
 3 files changed, 37 insertions(+), 3 deletions(-)
---
diff --git a/plugins/flatpak/gs-flatpak.c b/plugins/flatpak/gs-flatpak.c
index c1185413f..049610adf 100644
--- a/plugins/flatpak/gs-flatpak.c
+++ b/plugins/flatpak/gs-flatpak.c
@@ -4094,6 +4094,23 @@ gs_flatpak_add_featured (GsFlatpak *self,
        return TRUE;
 }
 
+gboolean
+gs_flatpak_add_deployment_featured (GsFlatpak *self,
+                                   GsAppList *list,
+                                   gboolean interactive,
+                                   const gchar *const *deployments,
+                                   GCancellable *cancellable,
+                                   GError **error)
+{
+       g_autoptr(GRWLockReaderLocker) locker = NULL;
+
+       if (!gs_flatpak_rescan_app_data (self, interactive, cancellable, error))
+               return FALSE;
+
+       locker = g_rw_lock_reader_locker_new (&self->silo_lock);
+       return gs_appstream_add_deployment_featured (self->silo, deployments, list, cancellable, error);
+}
+
 gboolean
 gs_flatpak_add_alternates (GsFlatpak *self,
                           GsApp *app,
diff --git a/plugins/flatpak/gs-flatpak.h b/plugins/flatpak/gs-flatpak.h
index 3c4724897..a704e3b40 100644
--- a/plugins/flatpak/gs-flatpak.h
+++ b/plugins/flatpak/gs-flatpak.h
@@ -146,6 +146,13 @@ gboolean   gs_flatpak_add_featured         (GsFlatpak              *self,
                                                 gboolean                interactive,
                                                 GCancellable           *cancellable,
                                                 GError                 **error);
+gboolean       gs_flatpak_add_deployment_featured
+                                               (GsFlatpak              *self,
+                                                GsAppList              *list,
+                                                gboolean                interactive,
+                                                const gchar *const     *deployments,
+                                                GCancellable           *cancellable,
+                                                GError                 **error);
 gboolean       gs_flatpak_add_alternates       (GsFlatpak              *self,
                                                 GsApp                  *app,
                                                 GsAppList              *list,
diff --git a/plugins/flatpak/gs-plugin-flatpak.c b/plugins/flatpak/gs-plugin-flatpak.c
index c8c994b6c..7c554868d 100644
--- a/plugins/flatpak/gs-plugin-flatpak.c
+++ b/plugins/flatpak/gs-plugin-flatpak.c
@@ -1953,19 +1953,22 @@ list_apps_thread_cb (GTask        *task,
        gboolean interactive = (data->flags & GS_PLUGIN_LIST_APPS_FLAGS_INTERACTIVE);
        GDateTime *released_since = NULL;
        guint64 age_secs = 0;
+       const gchar * const *deployment_featured = NULL;
        g_autoptr(GError) local_error = NULL;
 
        assert_in_worker (self);
 
-       if (data->query != NULL)
+       if (data->query != NULL) {
                released_since = gs_app_query_get_released_since (data->query);
+               deployment_featured = gs_app_query_get_deployment_featured (data->query);
+       }
        if (released_since != NULL) {
                g_autoptr(GDateTime) now = g_date_time_new_now_local ();
                age_secs = g_date_time_difference (now, released_since) / G_TIME_SPAN_SECOND;
        }
 
        /* Currently only support released-since queries. */
-       if (released_since == NULL) {
+       if (released_since == NULL && deployment_featured == NULL) {
                g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
                                         "Unsupported query");
                return;
@@ -1974,7 +1977,14 @@ list_apps_thread_cb (GTask        *task,
        for (guint i = 0; i < self->installations->len; i++) {
                GsFlatpak *flatpak = g_ptr_array_index (self->installations, i);
 
-               if (!gs_flatpak_add_recent (flatpak, list, age_secs, interactive, cancellable, &local_error)) 
{
+               if (released_since != NULL &&
+                   !gs_flatpak_add_recent (flatpak, list, age_secs, interactive, cancellable, &local_error)) 
{
+                       g_task_return_error (task, g_steal_pointer (&local_error));
+                       return;
+               }
+
+               if (deployment_featured != NULL &&
+                   !gs_flatpak_add_deployment_featured (flatpak, list, interactive, deployment_featured, 
cancellable, &local_error)) {
                        g_task_return_error (task, g_steal_pointer (&local_error));
                        return;
                }


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