Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deprecations for AppStream 0.16 #2015

Merged
merged 3 commits into from
Apr 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions src/Core/FlatpakBackend.vala
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,19 @@ public class AppCenterCore.FlatpakBackend : Backend, Object {
construct {
worker_thread = new Thread<bool> ("flatpak-worker", worker_func);
user_appstream_pool = new AppStream.Pool ();
#if HAS_APPSTREAM_0_15
#if HAS_APPSTREAM_0_16
user_appstream_pool.set_flags (AppStream.PoolFlags.LOAD_OS_CATALOG);
#elif HAS_APPSTREAM_0_15
user_appstream_pool.set_flags (AppStream.PoolFlags.LOAD_OS_COLLECTION);
#else
user_appstream_pool.set_flags (AppStream.PoolFlags.READ_COLLECTION);
user_appstream_pool.set_cache_flags (AppStream.CacheFlags.NONE);
#endif

system_appstream_pool = new AppStream.Pool ();
#if HAS_APPSTREAM_0_15
#if HAS_APPSTREAM_0_16
system_appstream_pool.set_flags (AppStream.PoolFlags.LOAD_OS_CATALOG);
#elif HAS_APPSTREAM_0_15
system_appstream_pool.set_flags (AppStream.PoolFlags.LOAD_OS_COLLECTION);
#else
system_appstream_pool.set_flags (AppStream.PoolFlags.READ_COLLECTION);
Expand Down Expand Up @@ -1039,7 +1043,10 @@ public class AppCenterCore.FlatpakBackend : Backend, Object {
private void reload_appstream_pool () {
var new_package_list = new Gee.HashMap<string, Package> ();

#if HAS_APPSTREAM_0_15
#if HAS_APPSTREAM_0_16
user_appstream_pool.reset_extra_data_locations ();
user_appstream_pool.add_extra_data_location (user_metadata_path, AppStream.FormatStyle.CATALOG);
#elif HAS_APPSTREAM_0_15
user_appstream_pool.reset_extra_data_locations ();
user_appstream_pool.add_extra_data_location (user_metadata_path, AppStream.FormatStyle.COLLECTION);
#else
Expand Down Expand Up @@ -1074,7 +1081,10 @@ public class AppCenterCore.FlatpakBackend : Backend, Object {
});
}

#if HAS_APPSTREAM_0_15
#if HAS_APPSTREAM_0_16
system_appstream_pool.reset_extra_data_locations ();
system_appstream_pool.add_extra_data_location (system_metadata_path, AppStream.FormatStyle.CATALOG);
#elif HAS_APPSTREAM_0_15
system_appstream_pool.reset_extra_data_locations ();
system_appstream_pool.add_extra_data_location (system_metadata_path, AppStream.FormatStyle.COLLECTION);
#else
Expand Down
7 changes: 6 additions & 1 deletion src/Core/PackageKitBackend.vala
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,12 @@ public class AppCenterCore.PackageKitBackend : Backend, Object {
// Clear out the default set of metadata locations and only use the folder that gets populated
// with elementary's AppStream data.
#if HIDE_UPSTREAM_DISTRO_APPS
#if HAS_APPSTREAM_0_15
#if HAS_APPSTREAM_0_16
// Don't load Ubuntu components
appstream_pool.set_load_std_data_locations (false);
appstream_pool.reset_extra_data_locations ();
appstream_pool.add_extra_data_location ("/usr/share/app-info", AppStream.FormatStyle.CATALOG);
#elif HAS_APPSTREAM_0_15
// Don't load Ubuntu components
appstream_pool.set_load_std_data_locations (false);
appstream_pool.reset_extra_data_locations ();
Expand Down
4 changes: 4 additions & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ if appstream.version().version_compare('>=0.15')
args += '--define=HAS_APPSTREAM_0_15'
endif

if appstream.version().version_compare('>=0.16')
args += '--define=HAS_APPSTREAM_0_16'
endif

executable(
meson.project_name(),
appcenter_files,
Expand Down