[gnome-software/wip/kalev/gnome-3-22: 53/96] Set the origin from the AppStream file if set



commit 44ef7218a57027e6805141f1cfe8b916dc12678f
Author: Richard Hughes <richard hughsie com>
Date:   Thu Feb 16 16:39:19 2017 +0000

    Set the origin from the AppStream file if set
    
    This allows us to work out the provenance without doing a constly call to
    PackageKit for each application result. In the details shell we'll be doing
    this anyway, but for search results we want the results to be fast.

 src/plugins/gs-appstream.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
---
diff --git a/src/plugins/gs-appstream.c b/src/plugins/gs-appstream.c
index d461ca6..ea24748 100644
--- a/src/plugins/gs-appstream.c
+++ b/src/plugins/gs-appstream.c
@@ -509,6 +509,16 @@ gs_appstream_get_bundle_kind (AsApp *item)
        return AS_BUNDLE_KIND_UNKNOWN;
 }
 
+static gboolean
+gs_appstream_origin_valid (const gchar *origin)
+{
+       if (origin == NULL)
+               return FALSE;
+       if (g_strcmp0 (origin, "") == 0)
+               return FALSE;
+       return TRUE;
+}
+
 gboolean
 gs_appstream_refine_app (GsPlugin *plugin,
                         GsApp *app,
@@ -765,6 +775,11 @@ gs_appstream_refine_app (GsPlugin *plugin,
        if (tmp != NULL && gs_app_get_origin_hostname (app) == NULL)
                gs_app_set_origin_hostname (app, tmp);
 
+       /* we have an origin in the XML */
+       if (gs_app_get_origin (app) == NULL &&
+           gs_appstream_origin_valid (as_app_get_origin (item)))
+               gs_app_set_origin (app, as_app_get_origin (item));
+
        /* is there any update information */
        if (!gs_appstream_refine_app_updates (plugin, app, item, error))
                return FALSE;


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