[gnome-software/wip/hughsie/fwupd-deprecated-api] fwupd: Do not use deprecated API in the plugin




commit 0488679a2de08bf15c6fb4692b00f78c2923505c
Author: Richard Hughes <richard hughsie com>
Date:   Mon Mar 22 12:34:22 2021 +0000

    fwupd: Do not use deprecated API in the plugin

 plugins/fwupd/gs-fwupd-app.c    | 13 +++++++++++++
 plugins/fwupd/gs-plugin-fwupd.c | 10 ++++++++++
 2 files changed, 23 insertions(+)
---
diff --git a/plugins/fwupd/gs-fwupd-app.c b/plugins/fwupd/gs-fwupd-app.c
index f95dff7f2..9c9d64ec9 100644
--- a/plugins/fwupd/gs-fwupd-app.c
+++ b/plugins/fwupd/gs-fwupd-app.c
@@ -191,6 +191,9 @@ gs_fwupd_release_get_name (FwupdRelease *release)
 void
 gs_fwupd_app_set_from_release (GsApp *app, FwupdRelease *rel)
 {
+#if FWUPD_CHECK_VERSION(1,5,6)
+       GPtrArray *locations = fwupd_release_get_locations (rel);
+#endif
        if (fwupd_release_get_name (rel) != NULL) {
                g_autofree gchar *tmp = gs_fwupd_release_get_name (rel);
                gs_app_set_name (app, GS_APP_QUALITY_NORMAL, tmp);
@@ -213,11 +216,21 @@ gs_fwupd_app_set_from_release (GsApp *app, FwupdRelease *rel)
                gs_app_set_license (app, GS_APP_QUALITY_NORMAL,
                                    fwupd_release_get_license (rel));
        }
+#if FWUPD_CHECK_VERSION(1,5,6)
+       if (locations->len > 0) {
+               const gchar *uri = g_ptr_array_index (locations, 0);
+               /* typically the first URI will be the main HTTP mirror, and we
+                * don't have the capability to use an IPFS/IPNS URL anyway */
+               gs_app_set_origin_hostname (app, uri);
+               gs_fwupd_app_set_update_uri (app, uri);
+       }
+#else
        if (fwupd_release_get_uri (rel) != NULL) {
                gs_app_set_origin_hostname (app,
                                            fwupd_release_get_uri (rel));
                gs_fwupd_app_set_update_uri (app, fwupd_release_get_uri (rel));
        }
+#endif
        if (fwupd_release_get_description (rel) != NULL) {
                g_autofree gchar *tmp = NULL;
                tmp = as_markup_convert_simple (fwupd_release_get_description (rel), NULL);
diff --git a/plugins/fwupd/gs-plugin-fwupd.c b/plugins/fwupd/gs-plugin-fwupd.c
index 9b3b0738f..7a9aa593b 100644
--- a/plugins/fwupd/gs-plugin-fwupd.c
+++ b/plugins/fwupd/gs-plugin-fwupd.c
@@ -375,6 +375,9 @@ gs_plugin_fwupd_new_app (GsPlugin *plugin, FwupdDevice *dev, GError **error)
 {
        FwupdRelease *rel = fwupd_device_get_release_default (dev);
        GPtrArray *checksums;
+#if FWUPD_CHECK_VERSION(1,5,6)
+       GPtrArray *locations = fwupd_release_get_locations (rel);
+#endif
        const gchar *update_uri;
        g_autofree gchar *basename = NULL;
        g_autofree gchar *filename_cache = NULL;
@@ -425,7 +428,14 @@ gs_plugin_fwupd_new_app (GsPlugin *plugin, FwupdDevice *dev, GError **error)
                             gs_app_get_update_version (app));
                return NULL;
        }
+#if FWUPD_CHECK_VERSION(1,5,6)
+       /* typically the first URI will be the main HTTP mirror, and we
+        * don't have the capability to use an IPFS/IPNS URL anyway */
+       if (locations->len > 0)
+               update_uri = g_ptr_array_index (locations, 0);
+#else
        update_uri = fwupd_release_get_uri (rel);
+#endif
        if (update_uri == NULL) {
                g_set_error (error,
                             GS_PLUGIN_ERROR,


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