ExtensionCatalog.h (1753B)
1 // Copyright (c) Microsoft Corporation. 2 // Licensed under the MIT License. 3 #pragma once 4 #include <AppInstallerProgress.h> 5 6 #include <winrt/Windows.ApplicationModel.h> 7 #include <winrt/Windows.ApplicationModel.AppExtensions.h> 8 9 #include <filesystem> 10 #include <string_view> 11 #include <optional> 12 13 namespace AppInstaller::Deployment 14 { 15 using namespace std::string_view_literals; 16 constexpr std::wstring_view SourceExtensionName = L"com.microsoft.winget.source"sv; 17 18 constexpr std::wstring_view IndexDBId = L"IndexDB"sv; 19 20 // Wraps an AppExtension. 21 struct Extension 22 { 23 Extension(winrt::Windows::ApplicationModel::AppExtensions::AppExtension extension); 24 25 // Gets the location of the package root. 26 std::filesystem::path GetPackagePath() const; 27 28 // Gets the location of the directory shared by the extension. 29 std::filesystem::path GetPublicFolderPath() const; 30 31 // Get the version of the package. 32 winrt::Windows::ApplicationModel::PackageVersion GetPackageVersion() const; 33 34 // Verifies the integrity of the extension. 35 bool VerifyContentIntegrity(IProgressCallback& progress); 36 37 private: 38 winrt::Windows::ApplicationModel::AppExtensions::AppExtension m_extension; 39 }; 40 41 // Wraps an AppExtensionCatalog. 42 struct ExtensionCatalog 43 { 44 ExtensionCatalog(std::wstring_view extensionName); 45 46 // Finds an extension by its package family name and id. 47 std::optional<Extension> FindByPackageFamilyAndId(std::string_view packageFamilyName, std::wstring_view id) const; 48 49 private: 50 winrt::Windows::ApplicationModel::AppExtensions::AppExtensionCatalog m_catalog = nullptr; 51 }; 52 }