[PATCH] Fix compilation against fwupd 2.0 API
authorMario Limonciello <superm1@debian.org>
Sun, 28 Jun 2026 00:03:00 +0000 (19:03 -0500)
committerMario Limonciello <superm1@debian.org>
Sat, 27 Jun 2026 18:29:28 +0000 (13:29 -0500)
Gbp-Pq: Name fwupd-2.0-compatibility-fixes

libdiscover/backends/FwupdBackend/FwupdBackend.cpp
libdiscover/backends/FwupdBackend/FwupdResource.cpp
libdiscover/backends/FwupdBackend/FwupdResource.h
libdiscover/backends/FwupdBackend/FwupdSourcesBackend.cpp
libdiscover/backends/FwupdBackend/FwupdTransaction.cpp

index 408e02dc312208cde8c7c1f0393df8c69a78c721..2e38c2bc0368dbefb51c1e1d019a252791456bd4 100644 (file)
@@ -198,7 +198,8 @@ FwupdResource *FwupdBackend::createApp(FwupdDevice *device)
         return nullptr;
     }
 
-    const QUrl update_uri(QString::fromUtf8(fwupd_release_get_uri(release)));
+    GPtrArray *locations = fwupd_release_get_locations(release);
+    const QUrl update_uri(locations && locations->len > 0 ? QString::fromUtf8((const gchar *)g_ptr_array_index(locations, 0)) : QString());
     if (!update_uri.isValid()) {
         qWarning() << "Fwupd Error: No Update URI available for" << app->name() << "[" << app->id() << "]";
         return nullptr;
@@ -323,13 +324,13 @@ void FwupdBackend::setRemotes(GPtrArray *remotes)
 {
     for (uint i = 0; remotes && i < remotes->len; i++) {
         FwupdRemote *remote = (FwupdRemote *)g_ptr_array_index(remotes, i);
-        if (!fwupd_remote_get_enabled(remote))
+        if (!fwupd_remote_has_flag(remote, FWUPD_REMOTE_FLAG_ENABLED))
             continue;
 
         if (fwupd_remote_get_kind(remote) == FWUPD_REMOTE_KIND_LOCAL)
             continue;
 
-        fwupd_client_refresh_remote_async(client, remote, m_cancellable, fwupd_client_refresh_remote_cb, this);
+        fwupd_client_refresh_remote_async(client, remote, FWUPD_CLIENT_DOWNLOAD_FLAG_NONE, m_cancellable, fwupd_client_refresh_remote_cb, this);
     }
 }
 
index c7fffec1e6cb55e29cd835c6c6a45a40ef97ba94..303481269167d28b1b73404555cdac0d9d2be7d0 100644 (file)
@@ -161,13 +161,15 @@ void FwupdResource::setReleaseDetails(FwupdRelease *release)
     m_description = QString::fromUtf8((fwupd_release_get_description(release)));
     m_homepage = QUrl(QString::fromUtf8(fwupd_release_get_homepage(release)));
     m_license = QString::fromUtf8(fwupd_release_get_license(release));
-    m_updateURI = QString::fromUtf8(fwupd_release_get_uri(release));
+    GPtrArray *locations = fwupd_release_get_locations(release);
+    if (locations != nullptr && locations->len > 0) {
+        m_updateURI = QString::fromUtf8((const gchar *)g_ptr_array_index(locations, 0));
+    }
 }
 
 void FwupdResource::setDeviceDetails(FwupdDevice *dev)
 {
     m_isLiveUpdatable = fwupd_device_has_flag(dev, FWUPD_DEVICE_FLAG_UPDATABLE);
-    m_isOnlyOffline = fwupd_device_has_flag(dev, FWUPD_DEVICE_FLAG_ONLY_OFFLINE);
     m_needsReboot = fwupd_device_has_flag(dev, FWUPD_DEVICE_FLAG_NEEDS_REBOOT);
 
     if (fwupd_device_get_name(dev)) {
@@ -182,7 +184,6 @@ void FwupdResource::setDeviceDetails(FwupdDevice *dev)
     m_vendor = QString::fromUtf8(fwupd_device_get_vendor(dev));
     m_releaseDate = QDateTime::fromSecsSinceEpoch(fwupd_device_get_created(dev)).date();
     m_availableVersion = QString::fromUtf8(fwupd_device_get_version(dev));
-    m_description = QString::fromUtf8((fwupd_device_get_description(dev)));
 
     if (fwupd_device_get_icons(dev)->len >= 1)
         m_iconName = QString::fromUtf8((const gchar *)g_ptr_array_index(fwupd_device_get_icons(dev), 0)); // Check whether given icon exists or not!
index db25328ac16414ca98bf8ce2a1daaa880fe4e8a2..98dde62122c80bd926b72697e0a80f807f1af274 100644 (file)
@@ -102,11 +102,6 @@ public:
         return m_isDeviceLocked;
     }
 
-    bool isOnlyOffline() const
-    {
-        return m_isOnlyOffline;
-    }
-
     bool isLiveUpdatable() const
     {
         return m_isLiveUpdatable;
@@ -146,7 +141,6 @@ private:
 
     QString m_updateURI;
     bool m_isDeviceLocked = false; // True if device is locked!
-    bool m_isOnlyOffline = false; // True if only offline updates
     bool m_isLiveUpdatable = false; // True if device is live updatable
     bool m_needsReboot = false; // True if device needs Reboot
     QString m_origin;
index 449c4bc47052e588aee69995ab91457baa79ad1e..a9b4615e57e8589df80cbe3c890c05824d359fd6 100644 (file)
@@ -34,7 +34,7 @@ public:
         case Qt::CheckStateRole: {
             if (value == Qt::Checked) {
                 m_backend->m_currentItem = item;
-                if (fwupd_remote_get_approval_required(remote)) {
+                if (fwupd_remote_has_flag(remote, FWUPD_REMOTE_FLAG_APPROVAL_REQUIRED)) {
                     QString eulaText = i18n("The remote %1 require that you accept their license:\n %2",
                                             QString::fromUtf8(fwupd_remote_get_title(remote)),
                                             QString::fromUtf8(fwupd_remote_get_agreement(remote)));
@@ -88,7 +88,7 @@ void FwupdSourcesBackend::populateSources()
         it->setData(id, AbstractSourcesBackend::IdRole);
         it->setData(QVariant(QString::fromUtf8(fwupd_remote_get_title(remote))), Qt::ToolTipRole);
         it->setCheckable(true);
-        it->setCheckState(fwupd_remote_get_enabled(remote) ? Qt::Checked : Qt::Unchecked);
+        it->setCheckState(fwupd_remote_has_flag(remote, FWUPD_REMOTE_FLAG_ENABLED) ? Qt::Checked : Qt::Unchecked);
         m_sources->appendRow(it);
     }
 }
@@ -121,7 +121,7 @@ void FwupdSourcesBackend::cancel()
 {
     FwupdRemote *remote =
         fwupd_client_get_remote_by_id(backend->client, m_currentItem->data(AbstractSourcesBackend::IdRole).toString().toUtf8().constData(), nullptr, nullptr);
-    m_currentItem->setCheckState(fwupd_remote_get_enabled(remote) ? Qt::Checked : Qt::Unchecked);
+    m_currentItem->setCheckState(fwupd_remote_has_flag(remote, FWUPD_REMOTE_FLAG_ENABLED) ? Qt::Checked : Qt::Unchecked);
 
     m_currentItem = nullptr;
 }
index cd7d6cb7c858b803a1af028d464ad9a0b3ed29d7..9875bdd760401c802ea903ae81ee71a785343eff 100644 (file)
@@ -82,10 +82,6 @@ void FwupdTransaction::fwupdInstall(const QString &file)
     FwupdInstallFlags install_flags = FWUPD_INSTALL_FLAG_NONE;
     g_autoptr(GError) error = nullptr;
 
-    /* only offline supported */
-    if (m_app->isOnlyOffline())
-        install_flags = static_cast<FwupdInstallFlags>(install_flags | FWUPD_INSTALL_FLAG_OFFLINE);
-
     if (!fwupd_client_install(m_backend->client, m_app->deviceId().toUtf8().constData(), file.toUtf8().constData(), install_flags, nullptr, &error)) {
         m_backend->handleError(error);
         setStatus(DoneWithErrorStatus);
@@ -110,7 +106,7 @@ void FwupdTransaction::cancel()
 
 void FwupdTransaction::finishTransaction()
 {
-    AbstractResource::State newState;
+    AbstractResource::State newState = AbstractResource::None;
     switch (role()) {
     case InstallRole:
     case ChangeAddonsRole: