[gnome-software] Add gs_app_add_provide()
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Add gs_app_add_provide()
- Date: Fri, 2 Sep 2016 18:23:10 +0000 (UTC)
commit f25a9f9a335edb507475186227c215eb69054146
Author: Richard Hughes <richard hughsie com>
Date: Fri Sep 2 18:16:46 2016 +0100
Add gs_app_add_provide()
src/gs-app.c | 39 +++++++++++++++++++++++++++++++++++++++
src/gs-app.h | 3 +++
src/plugins/gs-appstream.c | 20 ++++++++++++++++++++
3 files changed, 62 insertions(+), 0 deletions(-)
---
diff --git a/src/gs-app.c b/src/gs-app.c
index 7376ea5..af59c34 100644
--- a/src/gs-app.c
+++ b/src/gs-app.c
@@ -97,6 +97,7 @@ struct _GsApp
gint rating;
GArray *review_ratings;
GPtrArray *reviews; /* of AsReview */
+ GPtrArray *provides; /* of AsProvide */
guint64 size_installed;
guint64 size_download;
AsAppKind kind;
@@ -411,6 +412,8 @@ gs_app_to_string (GsApp *app)
}
if (app->reviews != NULL)
gs_app_kv_printf (str, "reviews", "%u", app->reviews->len);
+ if (app->provides != NULL)
+ gs_app_kv_printf (str, "provides", "%u", app->provides->len);
if (app->install_date != 0) {
gs_app_kv_printf (str, "install-date", "%"
G_GUINT64_FORMAT "",
@@ -2369,6 +2372,40 @@ gs_app_remove_review (GsApp *app, AsReview *review)
}
/**
+ * gs_app_get_provides:
+ * @app: a #GsApp
+ *
+ * Gets all the provides for the application.
+ *
+ * Returns: (element-type AsProvide) (transfer none): the list of provides
+ *
+ * Since: 3.22
+ **/
+GPtrArray *
+gs_app_get_provides (GsApp *app)
+{
+ g_return_val_if_fail (GS_IS_APP (app), NULL);
+ return app->provides;
+}
+
+/**
+ * gs_app_add_provide:
+ * @app: a #GsApp
+ * @provide: a #AsProvide
+ *
+ * Adds a provide to the application.
+ *
+ * Since: 3.22
+ **/
+void
+gs_app_add_provide (GsApp *app, AsProvide *provide)
+{
+ g_return_if_fail (GS_IS_APP (app));
+ g_return_if_fail (AS_IS_PROVIDE (provide));
+ g_ptr_array_add (app->provides, g_object_ref (provide));
+}
+
+/**
* gs_app_get_size_download:
* @app: A #GsApp
*
@@ -3287,6 +3324,7 @@ gs_app_dispose (GObject *object)
g_clear_pointer (&app->related, g_ptr_array_unref);
g_clear_pointer (&app->screenshots, g_ptr_array_unref);
g_clear_pointer (&app->reviews, g_ptr_array_unref);
+ g_clear_pointer (&app->provides, g_ptr_array_unref);
g_clear_pointer (&app->icons, g_ptr_array_unref);
G_OBJECT_CLASS (gs_app_parent_class)->dispose (object);
@@ -3448,6 +3486,7 @@ gs_app_init (GsApp *app)
app->history = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
app->screenshots = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
app->reviews = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
+ app->provides = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
app->icons = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
app->metadata = g_hash_table_new_full (g_str_hash,
g_str_equal,
diff --git a/src/gs-app.h b/src/gs-app.h
index 129ac49..a19d766 100644
--- a/src/gs-app.h
+++ b/src/gs-app.h
@@ -228,6 +228,9 @@ void gs_app_add_review (GsApp *app,
AsReview *review);
void gs_app_remove_review (GsApp *app,
AsReview *review);
+GPtrArray *gs_app_get_provides (GsApp *app);
+void gs_app_add_provide (GsApp *app,
+ AsProvide *provide);
guint64 gs_app_get_size_installed (GsApp *app);
void gs_app_set_size_installed (GsApp *app,
guint64 size_installed);
diff --git a/src/plugins/gs-appstream.c b/src/plugins/gs-appstream.c
index da61b48..8ff1629 100644
--- a/src/plugins/gs-appstream.c
+++ b/src/plugins/gs-appstream.c
@@ -178,6 +178,23 @@ gs_appstream_refine_add_reviews (GsApp *app, AsApp *item)
}
}
+static void
+gs_appstream_refine_add_provides (GsApp *app, AsApp *item)
+{
+ AsProvide *provide;
+ GPtrArray *provides;
+ guint i;
+
+ /* do we have any to add */
+ if (gs_app_get_provides(app)->len > 0)
+ return;
+ provides = as_app_get_provides (item);
+ for (i = 0; i < provides->len; i++) {
+ provide = g_ptr_array_index (provides, i);
+ gs_app_add_provide (app, provide);
+ }
+}
+
static gboolean
gs_appstream_is_recent_release (AsApp *app)
{
@@ -640,6 +657,9 @@ gs_appstream_refine_app (GsPlugin *plugin,
/* set reviews */
gs_appstream_refine_add_reviews (app, item);
+ /* set provides */
+ gs_appstream_refine_add_provides (app, item);
+
/* are the screenshots perfect */
if (gs_appstream_are_screenshots_perfect (item))
gs_app_add_kudo (app, GS_APP_KUDO_PERFECT_SCREENSHOTS);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]