PackageVersionSelection.h (2515B)
1 // Copyright (c) Microsoft Corporation. 2 // Licensed under the MIT License. 3 #pragma once 4 #include <winget/RepositorySearch.h> 5 #include <winget/ManifestComparator.h> 6 7 8 namespace AppInstaller::Repository 9 { 10 // Gets an IPackageVersionCollection that represents the available package versions for the installed version. 11 // If we have tracking data, will remove packages not from the tracked source. Will also remove versions that do not correspond to the tracked channel. 12 // This function uses the latest installed version as a temporary convenience until side-by-side is implemented. 13 std::shared_ptr<IPackageVersionCollection> GetAvailableVersionsForInstalledVersion(const std::shared_ptr<ICompositePackage>& composite); 14 15 // Gets an IPackageVersionCollection that represents the available package versions for the given installed version. 16 std::shared_ptr<IPackageVersionCollection> GetAvailableVersionsForInstalledVersion( 17 const std::shared_ptr<ICompositePackage>& composite, 18 const std::shared_ptr<IPackageVersion>& installedVersion); 19 20 // Equivalent to `GetAvailableVersionsForInstalledVersion(composite, nullptr)` to make the intent more clear that the caller wants to ignore any installed 21 // package information. 22 std::shared_ptr<IPackageVersionCollection> GetAllAvailableVersions(const std::shared_ptr<ICompositePackage>& composite); 23 24 // Gets the installed version, or a null if there isn't one. 25 std::shared_ptr<IPackageVersion> GetInstalledVersion(const std::shared_ptr<ICompositePackage>& composite); 26 27 // Gets the available IPackage corresponding to the given source identifier. 28 std::shared_ptr<IPackage> GetAvailablePackageFromSource(const std::shared_ptr<ICompositePackage>& composite, const std::string_view sourceIdentifier); 29 30 struct LatestApplicableVersionData 31 { 32 std::shared_ptr<AppInstaller::Repository::IPackageVersion> LatestApplicableVersion; 33 bool UpdateAvailable = false; 34 }; 35 36 // Determines the default install version and whether an update is available. 37 LatestApplicableVersionData GetLatestApplicableVersion(const std::shared_ptr<ICompositePackage>& composite); 38 39 // Fills the options from the given metadata, optionally including the allowed architectures. 40 void GetManifestComparatorOptionsFromMetadata(AppInstaller::Manifest::ManifestComparator::Options& options, const IPackageVersion::Metadata& metadata, bool includeAllowedArchitectures = true); 41 }