InstalledStatus.h (2584B)
1 // Copyright (c) Microsoft Corporation. 2 // Licensed under the MIT License. 3 #pragma once 4 #include <AppInstallerStrings.h> 5 #include <winget/Manifest.h> 6 #include <winget/RepositorySearch.h> 7 8 #include <memory> 9 #include <vector> 10 11 12 namespace AppInstaller::Repository 13 { 14 // Defines the installed status check type. 15 enum class InstalledStatusType : uint32_t 16 { 17 // None is checked. 18 None = 0x0, 19 // Check Apps and Features entry. 20 AppsAndFeaturesEntry = 0x0001, 21 // Check Apps and Features entry install location if applicable. 22 AppsAndFeaturesEntryInstallLocation = 0x0002, 23 // Check Apps and Features entry install location with installed files if applicable. 24 AppsAndFeaturesEntryInstallLocationFile = 0x0004, 25 // Check default install location if applicable. 26 DefaultInstallLocation = 0x0008, 27 // Check default install location with installed files if applicable. 28 DefaultInstallLocationFile = 0x0010, 29 30 // Below are helper values for calling CheckInstalledStatus as input. 31 // AppsAndFeaturesEntry related checks 32 AllAppsAndFeaturesEntryChecks = AppsAndFeaturesEntry | AppsAndFeaturesEntryInstallLocation | AppsAndFeaturesEntryInstallLocationFile, 33 // DefaultInstallLocation related checks 34 AllDefaultInstallLocationChecks = DefaultInstallLocation | DefaultInstallLocationFile, 35 // All checks 36 AllChecks = AllAppsAndFeaturesEntryChecks | AllDefaultInstallLocationChecks, 37 }; 38 39 DEFINE_ENUM_FLAG_OPERATORS(InstalledStatusType); 40 41 // Struct representing an individual installed status. 42 struct InstalledStatus 43 { 44 // The installed status type. 45 InstalledStatusType Type = InstalledStatusType::None; 46 // The installed status path. 47 Utility::NormalizedString Path; 48 // The installed status result. 49 HRESULT Status; 50 51 InstalledStatus(InstalledStatusType type, Utility::NormalizedString path, HRESULT status) : 52 Type(type), Path(std::move(path)), Status(status) {} 53 }; 54 55 // Struct representing installed status from an installer. 56 struct InstallerInstalledStatus 57 { 58 Manifest::ManifestInstaller Installer; 59 std::vector<InstalledStatus> Status; 60 }; 61 62 // Checks installed status of a package. 63 std::vector<InstallerInstalledStatus> CheckPackageInstalledStatus(const std::shared_ptr<ICompositePackage>& package, InstalledStatusType checkTypes = InstalledStatusType::AllChecks); 64 }