winget-cli

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

AppInstallerDeployment.h (3321B)


      1 // Copyright (c) Microsoft Corporation.
      2 // Licensed under the MIT License.
      3 #pragma once
      4 #include <AppInstallerProgress.h>
      5 #include <winrt/Windows.Foundation.h>
      6 #include <winrt/Windows.Management.Deployment.h>
      7 
      8 namespace AppInstaller::Deployment
      9 {
     10     // A set of optional values useful across many of the deployment functions.
     11     struct Options
     12     {
     13         Options() = default;
     14         explicit Options(bool skipReputationCheck) : SkipReputationCheck(skipReputationCheck) {}
     15 
     16         // Avoid using APIs that make a reputation check.
     17         bool SkipReputationCheck = false;
     18 
     19         // The pairs of URI+Digest to enforce.
     20         std::vector<std::pair<std::string, std::wstring>> ExpectedDigests;
     21     };
     22 
     23     // Calls winrt::Windows::Management::Deployment::PackageManager::AddPackageAsync if skipSmartScreen is true,
     24     // Otherwise, calls winrt::Windows::Management::Deployment::PackageManager::RequestAddPackageAsync
     25     void AddPackage(
     26         const winrt::Windows::Foundation::Uri& uri,
     27         const Options& options,
     28         IProgressCallback& callback);
     29 
     30     // Calls winrt::Windows::Management::Deployment::PackageManager::AddPackageAsync if skipSmartScreen is true,
     31     // Otherwise, calls winrt::Windows::Management::Deployment::PackageManager::RequestAddPackageAsync.
     32     // If the Add function fails due to the package being in use, we fall back to stage and register, which allows
     33     // a deferred registration.
     34     // Returns true if the registration was deferred; false if not.
     35     bool AddPackageWithDeferredFallback(
     36         std::string_view uri,
     37         const Options& options,
     38         IProgressCallback& callback);
     39 
     40     // Calls winrt::Windows::Management::Deployment::PackageManager::RemovePackageAsync
     41     void RemovePackage(
     42         std::string_view packageFullName,
     43         winrt::Windows::Management::Deployment::RemovalOptions options,
     44         IProgressCallback& callback);
     45 
     46     // Calls winrt::Windows::Management::Deployment::PackageManager::StagePackageAsync
     47     //       winrt::Windows::Management::Deployment::PackageManager::ProvisionPackageForAllUsersAsync
     48     //       winrt::Windows::Management::Deployment::PackageManager::RegisterPackageByFullNameAsync if not running as system
     49     bool AddPackageMachineScope(
     50         std::string_view uri,
     51         const Options& options,
     52         IProgressCallback& callback);
     53 
     54     // Calls winrt::Windows::Management::Deployment::PackageManager::DeprovisionPackageForAllUsersAsync
     55     //       winrt::Windows::Management::Deployment::PackageManager::RemovePackageAsync with RemoveForAllUsers
     56     void RemovePackageMachineScope(
     57         std::string_view packageFamilyName,
     58         std::string_view packageFullName,
     59         IProgressCallback& callback);
     60 
     61     // Calls winrt::Windows::Management::Deployment::PackageManager::FindPackagesForUser
     62     bool IsRegistered(std::string_view packageFamilyName);
     63 
     64     // Calls winrt::Windows::Management::Deployment::PackageManager::RegisterPackageByFamilyNameAsync
     65     void RegisterPackage(
     66         std::string_view packageFamilyName,
     67         IProgressCallback& callback);
     68 
     69     // Determines if the ExpectedDigests property (and thus feture) is supported on the current version of Windows.
     70     bool IsExpectedDigestsSupported();
     71 }