Skip to content

Commit

Permalink
build: Fix build with fwupd 2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bobby285271 committed Nov 7, 2024
1 parent 67cbe8b commit f081779
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
6 changes: 5 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ datadir = join_paths(prefix, get_option('datadir'))
libdir = join_paths(prefix, get_option('libdir'))

glib_dep = dependency('glib-2.0', version: '>=2.64.0')

fwupd_dep = dependency('fwupd')
appstream_dep = dependency ('appstream', version: '>=0.12.10')

add_project_arguments(
Expand All @@ -31,6 +31,10 @@ if glib_dep.version().version_compare ('>=2.73.0')
vala_flags += ['--define', 'HAS_GLIB_2_73']
endif

if fwupd_dep.version().version_compare ('>=2.0.0')
vala_flags += ['--define', 'HAS_FWUPD_2_0']
endif

if appstream_dep.version().version_compare('>=1.0')
vala_flags += ['--define', 'HAS_APPSTREAM_1_0']
endif
Expand Down
4 changes: 4 additions & 0 deletions src/Views/FirmwareReleaseView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,11 @@ public class About.FirmwareReleaseView : Gtk.Box {
stack.visible_child = scrolled_window;

var release_version = release.get_version ();
#if HAS_FWUPD_2_0
if (release.get_flags () == Fwupd.ReleaseFlags.IS_UPGRADE && release_version != device.get_version ()) {
#else
if (release.get_flags () == Fwupd.RELEASE_FLAG_IS_UPGRADE && release_version != device.get_version ()) {
#endif
update_button.label = _("Update");
update_button.sensitive = true;
} else {
Expand Down
21 changes: 21 additions & 0 deletions src/Views/FirmwareView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,11 @@ public class About.FirmwareView : Switchboard.SettingsPage {
}

private void add_device (Fwupd.Device device) {
#if HAS_FWUPD_2_0
if (device.has_flag (Fwupd.DeviceFlags.UPDATABLE)) {
#else
if (device.has_flag (Fwupd.DEVICE_FLAG_UPDATABLE)) {
#endif
FirmwareClient.get_upgrades.begin (fwupd_client, device.get_id (), (obj, res) => {
Fwupd.Release? release = null;

Expand Down Expand Up @@ -253,18 +257,35 @@ public class About.FirmwareView : Switchboard.SettingsPage {
}

private async void continue_update (Fwupd.Device device, Fwupd.Release release) {
#if HAS_FWUPD_2_0
var locations = release.get_locations ();
// Typically the first URI will be the main HTTP mirror,
// it's unlikely that we'll be using IPFS/IPNS URLs anyway.
var path = yield download_file (device, locations.length > 0 ? locations[0] : "");
#else
var path = yield download_file (device, release.get_uri ());
#endif

try {
var install_flags = Fwupd.InstallFlags.NONE;
#if !HAS_FWUPD_2_0
if (device.has_flag (Fwupd.DEVICE_FLAG_ONLY_OFFLINE)) {
install_flags = Fwupd.InstallFlags.OFFLINE;
}
#endif

if (yield FirmwareClient.install (fwupd_client, device.get_id (), path, install_flags)) {
#if HAS_FWUPD_2_0
if (device.has_flag (Fwupd.DeviceFlags.NEEDS_REBOOT)) {
#else
if (device.has_flag (Fwupd.DEVICE_FLAG_NEEDS_REBOOT)) {
#endif
show_reboot_dialog ();
#if HAS_FWUPD_2_0
} else if (device.has_flag (Fwupd.DeviceFlags.NEEDS_SHUTDOWN)) {
#else
} else if (device.has_flag (Fwupd.DEVICE_FLAG_NEEDS_SHUTDOWN)) {
#endif
show_shutdown_dialog ();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ shared_module(
config_vala,
css_gresource,
dependencies: [
dependency('fwupd'),
fwupd_dep,
glib_dep,
dependency('gio-2.0'),
dependency('gobject-2.0'),
Expand Down

0 comments on commit f081779

Please sign in to comment.