/** * gs_plugin_refine: */ gboolean gs_plugin_refine (GsPlugin *plugin, GList **list, GsPluginRefineFlags flags, GCancellable *cancellable, GError **error) { GsApp *app; GList *l; /* add reviews if possible */ if (flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_REVIEWS) { for (l = *list; l != NULL; l = l->next) { g_autoptr(GError) error_local = NULL; app = GS_APP (l->data); if (gs_app_get_reviews(app)->len > 0) continue; if (gs_app_get_id_no_prefix (app) == NULL) continue; if (gs_app_get_id_kind (app) == AS_ID_KIND_ADDON) continue; if (!gs_plugin_refine_reviews (plugin, app, cancellable, &error_local)) { g_warning ("Failed to get reviews: %s", error_local->message); } } } /* add ratings if possible */ if (flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_REVIEW_RATINGS) { for (l = *list; l != NULL; l = l->next) { g_autoptr(GError) error_local = NULL; app = GS_APP (l->data); if (gs_app_get_review_ratings(app) != NULL) continue; if (gs_app_get_id_no_prefix (app) == NULL) continue; if (gs_app_get_id_kind (app) == AS_ID_KIND_ADDON) continue; if (!gs_plugin_refine_ratings (plugin, app, cancellable, &error_local)) { g_warning ("Failed to get ratings: %s", error_local->message); } } } return TRUE; }
/** * gs_plugin_refine: */ gboolean gs_plugin_refine (GsPlugin *plugin, GList **list, GsPluginRefineFlags flags, GCancellable *cancellable, GError **error) { GList *l; GPtrArray *sources; GsApp *app; const gchar *pkgname; gboolean ret; gint rating; gint confidence; guint i; /* nothing to do here */ if ((flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_RATING) == 0) return TRUE; /* already loaded */ if (g_once_init_enter (&plugin->priv->loaded)) { ret = gs_plugin_fedora_tagger_load_db (plugin, error); g_once_init_leave (&plugin->priv->loaded, TRUE); if (!ret) return FALSE; } /* add any missing ratings data */ for (l = *list; l != NULL; l = l->next) { app = GS_APP (l->data); if (gs_app_get_rating (app) != -1) continue; sources = gs_app_get_sources (app); for (i = 0; i < sources->len; i++) { pkgname = g_ptr_array_index (sources, i); ret = gs_plugin_resolve_app (plugin, pkgname, &rating, &confidence, error); if (!ret) return FALSE; if (rating != -1) { g_debug ("fedora-tagger setting rating on %s to %i%% [%i]", pkgname, rating, confidence); gs_app_set_rating (app, rating); gs_app_set_rating_confidence (app, confidence); gs_app_set_rating_kind (app, GS_APP_RATING_KIND_SYSTEM); if (confidence > 50 && rating > 80) { g_debug ("%s is popular [confidence %i]", gs_app_get_source_default (app), confidence); gs_app_add_kudo (app, GS_APP_KUDO_POPULAR); } } } } return TRUE; }
/** * gs_plugin_refine: */ gboolean gs_plugin_refine (GsPlugin *plugin, GList **list, GsPluginRefineFlags flags, GCancellable *cancellable, GError **error) { GList *l; GsApp *app; g_autoptr(AsProfileTask) ptask = NULL; ptask = as_profile_start_literal (plugin->profile, "limba::refine"); for (l = *list; l != NULL; l = l->next) { app = GS_APP (l->data); /* not us */ if (g_strcmp0 (gs_app_get_management_plugin (app), "Limba") != 0) continue; if (!gs_plugin_refine_app (plugin, app, error)) return FALSE; } /* sucess */ return TRUE; }
/** * gs_plugin_refine: */ gboolean gs_plugin_refine (GsPlugin *plugin, GList **list, GsPluginRefineFlags flags, GCancellable *cancellable, GError **error) { GList *l; GsApp *app; const gchar *EMPTY[] = { "", NULL }; /* nothing to do here */ if ((flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_MENU_PATH) == 0) return TRUE; for (l = *list; l != NULL; l = l->next) { app = GS_APP (l->data); if (gs_app_get_menu_path (app) == NULL) { if (!gs_plugin_refine_app (plugin, app)) { /* don't keep searching for this */ gs_app_set_menu_path (app, (gchar **) EMPTY); } } } return TRUE; }
/** * gs_utils_error_add_unique_id: * @error: a #GError * @app: a #GsApp * * Adds a unique ID prefix to the error. * * Since: 3.22 **/ void gs_utils_error_add_unique_id (GError **error, GsApp *app) { g_return_if_fail (GS_APP (app)); if (error == NULL || *error == NULL) return; g_prefix_error (error, "[%s] ", gs_app_get_unique_id (app)); }
/** * gs_plugin_xdg_app_progress_cb: */ static void gs_plugin_xdg_app_progress_cb (const gchar *status, guint progress, gboolean estimating, gpointer user_data) { GsApp *app = GS_APP (user_data); gs_app_set_progress (app, progress); }
static void gs_shell_overview_get_popular_rotating_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) { LoadData *load_data = (LoadData *) user_data; GsShellOverview *self = load_data->self; GsShellOverviewPrivate *priv = gs_shell_overview_get_instance_private (self); GsPluginLoader *plugin_loader = GS_PLUGIN_LOADER (source_object); GList *l; GsApp *app; gint i; GtkWidget *tile; g_autoptr(GError) error = NULL; g_autoptr(GsAppList) list = NULL; /* get popular apps */ list = gs_plugin_loader_get_category_apps_finish (plugin_loader, res, &error); if (list == NULL) { if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) g_warning ("failed to get recommended applications: %s", error->message); gtk_widget_hide (priv->popular_rotating_heading); gtk_widget_hide (priv->box_popular_rotating); goto out; } else if (g_list_length (list) < N_TILES) { g_warning ("hiding recommended applications: found only %d to show, need at least %d", g_list_length (list), N_TILES); gtk_widget_hide (priv->popular_rotating_heading); gtk_widget_hide (priv->box_popular_rotating); goto out; } gs_plugin_list_randomize (&list); gtk_widget_show (priv->popular_rotating_heading); gtk_widget_show (priv->box_popular_rotating); gs_container_remove_all (GTK_CONTAINER (priv->box_popular_rotating)); for (l = list, i = 0; l != NULL && i < N_TILES; l = l->next, i++) { app = GS_APP (l->data); tile = gs_popular_tile_new (app); g_signal_connect (tile, "clicked", G_CALLBACK (popular_tile_clicked), self); gtk_container_add (GTK_CONTAINER (priv->box_popular_rotating), tile); } priv->empty = FALSE; out: load_data_free (load_data); priv->loading_popular_rotating = FALSE; priv->refresh_count--; if (priv->refresh_count == 0) { priv->cache_valid = TRUE; g_signal_emit (self, signals[SIGNAL_REFRESHED], 0); } }
/** * gs_cmd_show_results_apps: **/ static void gs_cmd_show_results_apps (GList *list) { GList *l; GPtrArray *related; GsApp *app; GsApp *app_rel; guint i; for (l = list; l != NULL; l = l->next) { _cleanup_free_ gchar *tmp = NULL; app = GS_APP (l->data); tmp = gs_app_to_string (app); g_print ("%s\n", tmp); related = gs_app_get_related (app); for (i = 0; i < related->len; i++) { _cleanup_free_ gchar *tmp_rel = NULL; app_rel = GS_APP (g_ptr_array_index (related, i)); tmp_rel = gs_app_to_string (app_rel); g_print ("\t%s\n", tmp_rel); } } }
static void gs_shell_overview_get_featured_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) { GsShellOverview *self = GS_SHELL_OVERVIEW (user_data); GsShellOverviewPrivate *priv = gs_shell_overview_get_instance_private (self); GsPluginLoader *plugin_loader = GS_PLUGIN_LOADER (source_object); GtkWidget *tile; GsApp *app; g_autoptr(GError) error = NULL; g_autoptr(GsAppList) list = NULL; list = gs_plugin_loader_get_featured_finish (plugin_loader, res, &error); if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) goto out; if (g_getenv ("GNOME_SOFTWARE_FEATURED") == NULL) { /* Don't show apps from the category that's currently featured as the category of the day */ gs_plugin_list_filter (&list, filter_category, priv->category_of_day); gs_plugin_list_randomize (&list); } gs_container_remove_all (GTK_CONTAINER (priv->bin_featured)); gtk_widget_set_visible (priv->featured_heading, list != NULL); if (list == NULL) { g_warning ("failed to get featured apps: %s", error ? error->message : "no apps to show"); goto out; } /* at the moment, we only care about the first app */ app = GS_APP (list->data); tile = gs_feature_tile_new (app); g_signal_connect (tile, "clicked", G_CALLBACK (feature_tile_clicked), self); gtk_container_add (GTK_CONTAINER (priv->bin_featured), tile); priv->empty = FALSE; out: priv->loading_featured = FALSE; priv->refresh_count--; if (priv->refresh_count == 0) { priv->cache_valid = TRUE; g_signal_emit (self, signals[SIGNAL_REFRESHED], 0); } }
/** * gs_shell_overview_get_popular_cb: **/ static void gs_shell_overview_get_popular_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) { GsShellOverview *self = GS_SHELL_OVERVIEW (user_data); GsShellOverviewPrivate *priv = gs_shell_overview_get_instance_private (self); GsPluginLoader *plugin_loader = GS_PLUGIN_LOADER (source_object); GList *l; GsApp *app; gint i; GtkWidget *tile; g_autoptr(GError) error = NULL; g_autoptr(GsAppList) list = NULL; /* get popular apps */ list = gs_plugin_loader_get_popular_finish (plugin_loader, res, &error); gtk_widget_set_visible (priv->box_popular, list != NULL); gtk_widget_set_visible (priv->popular_heading, list != NULL); if (list == NULL) { if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) g_warning ("failed to get popular apps: %s", error->message); goto out; } /* Don't show apps from the category that's currently featured as the category of the day */ gs_plugin_list_filter (&list, filter_category, priv->category_of_day); gs_plugin_list_randomize (&list); gs_container_remove_all (GTK_CONTAINER (priv->box_popular)); for (l = list, i = 0; l != NULL && i < N_TILES; l = l->next, i++) { app = GS_APP (l->data); tile = gs_popular_tile_new (app); g_signal_connect (tile, "clicked", G_CALLBACK (popular_tile_clicked), self); gtk_container_add (GTK_CONTAINER (priv->box_popular), tile); } priv->empty = FALSE; out: priv->loading_popular = FALSE; priv->refresh_count--; if (priv->refresh_count == 0) { priv->cache_valid = TRUE; g_signal_emit (self, signals[SIGNAL_REFRESHED], 0); } }
/** * gs_plugin_refine: */ gboolean gs_plugin_refine (GsPlugin *plugin, GList **list, GsPluginRefineFlags flags, GCancellable *cancellable, GError **error) { GList *l; GsApp *app; g_autoptr(AsProfileTask) ptask = NULL; /* are any of the packages on the blacklist? */ ptask = as_profile_start_literal (plugin->profile, "hardcoded-blacklist"); for (l = *list; l != NULL; l = l->next) { app = GS_APP (l->data); if (!gs_plugin_refine_app (plugin, app, error)) return FALSE; } return TRUE; }
/** * gs_shell_category_get_apps_cb: **/ static void gs_shell_category_get_apps_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) { gint i = 0; GList *l; GList *list; GsApp *app; GtkWidget *tile; GsShellCategory *shell = GS_SHELL_CATEGORY (user_data); GsShellCategoryPrivate *priv = shell->priv; GsPluginLoader *plugin_loader = GS_PLUGIN_LOADER (source_object); _cleanup_error_free_ GError *error = NULL; list = gs_plugin_loader_get_category_apps_finish (plugin_loader, res, &error); if (list == NULL) { if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) g_warning ("failed to get apps for category apps: %s", error->message); goto out; } gtk_grid_remove_column (GTK_GRID (priv->category_detail_grid), 1); gtk_grid_remove_column (GTK_GRID (priv->category_detail_grid), 0); for (l = list, i = 0; l != NULL; l = l->next, i++) { app = GS_APP (l->data); tile = gs_app_tile_new (app); g_signal_connect (tile, "clicked", G_CALLBACK (app_tile_clicked), shell); gtk_grid_attach (GTK_GRID (priv->category_detail_grid), tile, (i % 2), i / 2, 1, 1); } if (i == 1) gtk_grid_attach (GTK_GRID (priv->category_detail_grid), priv->col1_placeholder, 1, 0, 1, 1); out: gs_plugin_list_free (list); }
/** * gs_plugin_refine: */ gboolean gs_plugin_refine (GsPlugin *plugin, GList **list, GsPluginRefineFlags flags, GCancellable *cancellable, GError **error) { GsApp *app; GList *l; for (l = *list; l != NULL; l = l->next) { app = GS_APP (l->data); if (gs_app_get_name (app) == NULL) { if (g_strcmp0 (gs_app_get_id (app), "gnome-boxes") == 0) { gs_app_set_name (app, GS_APP_QUALITY_NORMAL, "Boxes"); gs_app_set_summary (app, GS_APP_QUALITY_NORMAL, "A simple GNOME 3 application to access remote or virtual systems"); } } } return TRUE; }
static void gs_cmd_show_results_apps (GsAppList *list) { GPtrArray *related; GsApp *app; GsApp *app_rel; guint i; guint j; for (j = 0; j < gs_app_list_length (list); j++) { g_autofree gchar *tmp = NULL; app = gs_app_list_index (list, j); tmp = gs_app_to_string (app); g_print ("%s\n", tmp); related = gs_app_get_related (app); for (i = 0; i < related->len; i++) { g_autofree gchar *tmp_rel = NULL; app_rel = GS_APP (g_ptr_array_index (related, i)); tmp_rel = gs_app_to_string (app_rel); g_print ("\t%s\n", tmp_rel); } } }
/** * gs_plugin_refine: */ gboolean gs_plugin_refine (GsPlugin *plugin, GList **list, GsPluginRefineFlags flags, GCancellable *cancellable, GError **error) { GList *l; GsApp *app; const gchar *tmp; for (l = *list; l != NULL; l = l->next) { app = GS_APP (l->data); if (gs_app_get_id_kind (app) != AS_ID_KIND_WEB_APP) continue; gs_app_set_size (app, 4096); tmp = gs_app_get_source_id_default (app); if (tmp != NULL) continue; if (!gs_plugin_refine_app (plugin, app, error)) return FALSE; } return TRUE; }