[gnome-software/1364-implement-other-apps-by-author-section-in-app-details-page: 30/38] gs-plugin: Add GS_PLUGIN_ACTION_SEARCH_OTHER_APPS




commit 1b8f1ca73e12010330994a4fd04598e82b03a752
Author: Milan Crha <mcrha redhat com>
Date:   Tue Mar 15 18:13:06 2022 +0100

    gs-plugin: Add GS_PLUGIN_ACTION_SEARCH_OTHER_APPS
    
    Will be used to search for other apps of a given developer or project group.

 lib/gs-plugin-loader.c |  6 ++++++
 lib/gs-plugin-types.h  |  2 ++
 lib/gs-plugin-vfuncs.h | 21 +++++++++++++++++++++
 lib/gs-plugin.c        |  6 ++++++
 4 files changed, 35 insertions(+)
---
diff --git a/lib/gs-plugin-loader.c b/lib/gs-plugin-loader.c
index 6c72bb022..c40db1294 100644
--- a/lib/gs-plugin-loader.c
+++ b/lib/gs-plugin-loader.c
@@ -679,6 +679,7 @@ gs_plugin_loader_call_vfunc (GsPluginLoaderHelper *helper,
                break;
        case GS_PLUGIN_ACTION_SEARCH_FILES:
        case GS_PLUGIN_ACTION_SEARCH_PROVIDES:
+       case GS_PLUGIN_ACTION_SEARCH_OTHER_APPS:
                {
                        GsPluginSearchFunc plugin_func = func;
                        const gchar *search[2] = { gs_plugin_job_get_search (helper->plugin_job), NULL };
@@ -3202,6 +3203,7 @@ gs_plugin_loader_process_thread_cb (GTask *task,
        case GS_PLUGIN_ACTION_LAUNCH:
        case GS_PLUGIN_ACTION_REMOVE:
        case GS_PLUGIN_ACTION_SEARCH:
+       case GS_PLUGIN_ACTION_SEARCH_OTHER_APPS:
        case GS_PLUGIN_ACTION_UPDATE:
        case GS_PLUGIN_ACTION_INSTALL_REPO:
        case GS_PLUGIN_ACTION_REMOVE_REPO:
@@ -3383,6 +3385,7 @@ gs_plugin_loader_process_thread_cb (GTask *task,
                gs_app_list_filter (list, gs_plugin_loader_app_is_valid_updatable, helper);
                break;
        case GS_PLUGIN_ACTION_GET_RECENT:
+       case GS_PLUGIN_ACTION_SEARCH_OTHER_APPS:
                gs_app_list_filter (list, gs_plugin_loader_app_is_non_compulsory, NULL);
                gs_app_list_filter (list, gs_plugin_loader_app_is_desktop, NULL);
                gs_app_list_filter (list, gs_plugin_loader_app_is_valid_filter, helper);
@@ -3779,6 +3782,7 @@ gs_plugin_loader_job_process_async (GsPluginLoader *plugin_loader,
        case GS_PLUGIN_ACTION_SEARCH:
        case GS_PLUGIN_ACTION_SEARCH_FILES:
        case GS_PLUGIN_ACTION_SEARCH_PROVIDES:
+       case GS_PLUGIN_ACTION_SEARCH_OTHER_APPS:
        case GS_PLUGIN_ACTION_URL_TO_APP:
                if (gs_plugin_job_get_search (plugin_job) == NULL) {
                        g_task_return_new_error (task,
@@ -3795,6 +3799,7 @@ gs_plugin_loader_job_process_async (GsPluginLoader *plugin_loader,
        /* sorting fallbacks */
        switch (action) {
        case GS_PLUGIN_ACTION_SEARCH:
+       case GS_PLUGIN_ACTION_SEARCH_OTHER_APPS:
                if (gs_plugin_job_get_sort_func (plugin_job, NULL) == NULL) {
                        gs_plugin_job_set_sort_func (plugin_job,
                                                     gs_plugin_loader_app_sort_match_value_cb, NULL);
@@ -3868,6 +3873,7 @@ gs_plugin_loader_job_process_async (GsPluginLoader *plugin_loader,
        case GS_PLUGIN_ACTION_SEARCH:
        case GS_PLUGIN_ACTION_SEARCH_FILES:
        case GS_PLUGIN_ACTION_SEARCH_PROVIDES:
+       case GS_PLUGIN_ACTION_SEARCH_OTHER_APPS:
                if (gs_plugin_job_get_timeout (plugin_job) > 0) {
                        helper->timeout_id =
                                g_timeout_add_seconds (gs_plugin_job_get_timeout (plugin_job),
diff --git a/lib/gs-plugin-types.h b/lib/gs-plugin-types.h
index 5723dec72..10debd1b4 100644
--- a/lib/gs-plugin-types.h
+++ b/lib/gs-plugin-types.h
@@ -261,6 +261,7 @@ typedef enum {
  * @GS_PLUGIN_ACTION_REMOVE_REPO:              Remove a repository (Since: 41)
  * @GS_PLUGIN_ACTION_ENABLE_REPO:              Enable a repository (Since: 41)
  * @GS_PLUGIN_ACTION_DISABLE_REPO:             Disable a repository (Since: 41)
+ * @GS_PLUGIN_ACTION_SEARCH_OTHER_APPS:                Get the search results for a developer (Since: 43)
  *
  * The plugin action.
  **/
@@ -293,6 +294,7 @@ typedef enum {
        GS_PLUGIN_ACTION_REMOVE_REPO,
        GS_PLUGIN_ACTION_ENABLE_REPO,
        GS_PLUGIN_ACTION_DISABLE_REPO,
+       GS_PLUGIN_ACTION_SEARCH_OTHER_APPS,
        GS_PLUGIN_ACTION_LAST  /*< skip >*/
 } GsPluginAction;
 
diff --git a/lib/gs-plugin-vfuncs.h b/lib/gs-plugin-vfuncs.h
index 83364376c..9f38d6145 100644
--- a/lib/gs-plugin-vfuncs.h
+++ b/lib/gs-plugin-vfuncs.h
@@ -125,6 +125,27 @@ gboolean    gs_plugin_add_search_what_provides     (GsPlugin       *plugin,
                                                         GCancellable   *cancellable,
                                                         GError         **error);
 
+/**
+ * gs_plugin_add_search_other_apps:
+ * @plugin: a #GsPlugin
+ * @values: a NULL terminated list of search terms, e.g. [ "gnome" ]
+ * @list: a #GsAppList
+ * @cancellable: a #GCancellable, or %NULL
+ * @error: a #GError, or %NULL
+ *
+ * Called when searching for applications provided by certain developer.
+ *
+ * Plugins are expected to add new apps using gs_app_list_add().
+ *
+ * Returns: %TRUE for success or if not relevant
+ *
+ * Since: 43
+ **/
+gboolean        gs_plugin_add_search_other_apps        (GsPlugin       *plugin,
+                                                        gchar          **values,
+                                                        GsAppList      *list,
+                                                        GCancellable   *cancellable,
+                                                        GError         **error);
 /**
  * gs_plugin_add_alternates
  * @plugin: a #GsPlugin
diff --git a/lib/gs-plugin.c b/lib/gs-plugin.c
index b34bbd8dc..92e39bdc7 100644
--- a/lib/gs-plugin.c
+++ b/lib/gs-plugin.c
@@ -1444,6 +1444,8 @@ gs_plugin_action_to_function_name (GsPluginAction action)
                return "gs_plugin_add_search_files";
        if (action == GS_PLUGIN_ACTION_SEARCH_PROVIDES)
                return "gs_plugin_add_search_what_provides";
+       if (action == GS_PLUGIN_ACTION_SEARCH_OTHER_APPS)
+               return "gs_plugin_add_search_other_apps";
        if (action == GS_PLUGIN_ACTION_GET_CATEGORY_APPS)
                return "gs_plugin_add_category_apps";
        if (action == GS_PLUGIN_ACTION_GET_CATEGORIES)
@@ -1506,6 +1508,8 @@ gs_plugin_action_to_string (GsPluginAction action)
                return "search-files";
        if (action == GS_PLUGIN_ACTION_SEARCH_PROVIDES)
                return "search-provides";
+       if (action == GS_PLUGIN_ACTION_SEARCH_OTHER_APPS)
+               return "search-other-apps";
        if (action == GS_PLUGIN_ACTION_GET_CATEGORIES)
                return "get-categories";
        if (action == GS_PLUGIN_ACTION_GET_CATEGORY_APPS)
@@ -1576,6 +1580,8 @@ gs_plugin_action_from_string (const gchar *action)
                return GS_PLUGIN_ACTION_SEARCH_FILES;
        if (g_strcmp0 (action, "search-provides") == 0)
                return GS_PLUGIN_ACTION_SEARCH_PROVIDES;
+       if (g_strcmp0 (action, "search-other-apps") == 0)
+               return GS_PLUGIN_ACTION_SEARCH_OTHER_APPS;
        if (g_strcmp0 (action, "get-categories") == 0)
                return GS_PLUGIN_ACTION_GET_CATEGORIES;
        if (g_strcmp0 (action, "get-category-apps") == 0)


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