winget-cli

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

CatalogPackageMetadata.cpp (6303B)


      1 // Copyright (c) Microsoft Corporation.
      2 // Licensed under the MIT License.
      3 #include "pch.h"
      4 #include <winget/RepositorySource.h>
      5 #include "CatalogPackageMetadata.h"
      6 #include "CatalogPackageMetadata.g.cpp"
      7 #include <wil\cppwinrt_wrl.h>
      8 
      9 namespace winrt::Microsoft::Management::Deployment::implementation
     10 {
     11     using Localization = ::AppInstaller::Manifest::Localization;
     12 
     13     void CatalogPackageMetadata::Initialize(::AppInstaller::Manifest::ManifestLocalization manifestLocalization)
     14     {
     15         m_manifestLocalization = std::move(manifestLocalization);
     16     }
     17 
     18     hstring CatalogPackageMetadata::Locale()
     19     {
     20         return winrt::to_hstring(m_manifestLocalization.Locale);
     21     }
     22     hstring CatalogPackageMetadata::Publisher()
     23     {
     24         return winrt::to_hstring(m_manifestLocalization.Get<Localization::Publisher>());
     25     }
     26     hstring CatalogPackageMetadata::PublisherUrl()
     27     {
     28         return winrt::to_hstring(m_manifestLocalization.Get<Localization::PublisherUrl>());
     29     }
     30     hstring CatalogPackageMetadata::PublisherSupportUrl()
     31     {
     32         return winrt::to_hstring(m_manifestLocalization.Get<Localization::PublisherSupportUrl>());
     33     }
     34     hstring CatalogPackageMetadata::PrivacyUrl()
     35     {
     36         return winrt::to_hstring(m_manifestLocalization.Get<Localization::PrivacyUrl>());
     37     }
     38     hstring CatalogPackageMetadata::Author()
     39     {
     40         return winrt::to_hstring(m_manifestLocalization.Get<Localization::Author>());
     41     }
     42     hstring CatalogPackageMetadata::PackageName()
     43     {
     44         return winrt::to_hstring(m_manifestLocalization.Get<Localization::PackageName>());
     45     }
     46     hstring CatalogPackageMetadata::PackageUrl()
     47     {
     48         return winrt::to_hstring(m_manifestLocalization.Get<Localization::PackageUrl>());
     49     }
     50     hstring CatalogPackageMetadata::License()
     51     {
     52         return winrt::to_hstring(m_manifestLocalization.Get<Localization::License>());
     53     }
     54     hstring CatalogPackageMetadata::LicenseUrl()
     55     {
     56         return winrt::to_hstring(m_manifestLocalization.Get<Localization::LicenseUrl>());
     57     }
     58     hstring CatalogPackageMetadata::Copyright()
     59     {
     60         return winrt::to_hstring(m_manifestLocalization.Get<Localization::Copyright>());
     61     }
     62     hstring CatalogPackageMetadata::CopyrightUrl()
     63     {
     64         return winrt::to_hstring(m_manifestLocalization.Get<Localization::CopyrightUrl>());
     65     }
     66     hstring CatalogPackageMetadata::ShortDescription()
     67     {
     68         return winrt::to_hstring(m_manifestLocalization.Get<Localization::ShortDescription>());
     69     }
     70     hstring CatalogPackageMetadata::Description()
     71     {
     72         return winrt::to_hstring(m_manifestLocalization.Get<Localization::Description>());
     73     }
     74     hstring CatalogPackageMetadata::ReleaseNotes()
     75     {
     76         return winrt::to_hstring(m_manifestLocalization.Get<Localization::ReleaseNotes>());
     77     }
     78     hstring CatalogPackageMetadata::ReleaseNotesUrl()
     79     {
     80         return winrt::to_hstring(m_manifestLocalization.Get<Localization::ReleaseNotesUrl>());
     81     }
     82     hstring CatalogPackageMetadata::PurchaseUrl()
     83     {
     84         return winrt::to_hstring(m_manifestLocalization.Get<Localization::PurchaseUrl>());
     85     }
     86     hstring CatalogPackageMetadata::InstallationNotes()
     87     {
     88         return winrt::to_hstring(m_manifestLocalization.Get<Localization::InstallationNotes>());
     89     }
     90     winrt::Windows::Foundation::Collections::IVectorView<winrt::Microsoft::Management::Deployment::PackageAgreement> CatalogPackageMetadata::Agreements()
     91     {
     92         if (!m_packageAgreements)
     93         {
     94             auto agreements = winrt::single_threaded_vector<winrt::Microsoft::Management::Deployment::PackageAgreement>();
     95             for (auto const& agreement : m_manifestLocalization.Get<AppInstaller::Manifest::Localization::Agreements>())
     96             {
     97                 auto packageAgreement = winrt::make_self<wil::details::module_count_wrapper<winrt::Microsoft::Management::Deployment::implementation::PackageAgreement>>();
     98                 packageAgreement->Initialize(agreement);
     99                 agreements.Append(*packageAgreement);
    100             }
    101             m_packageAgreements = agreements;
    102         }
    103 
    104         return m_packageAgreements.GetView();
    105     }
    106     winrt::Windows::Foundation::Collections::IVectorView<hstring> CatalogPackageMetadata::Tags()
    107     {
    108         if (!m_tags)
    109         {
    110             // Vector hasn't been created yet, create and populate it.
    111             auto tags = winrt::single_threaded_vector<hstring>();
    112             for (auto&& tag : m_manifestLocalization.Get<Localization::Tags>())
    113             {
    114                 tags.Append(winrt::to_hstring(tag));
    115             }
    116             m_tags = tags;
    117         }
    118 
    119         return m_tags.GetView();
    120     }
    121     winrt::Windows::Foundation::Collections::IVectorView<winrt::Microsoft::Management::Deployment::Documentation> CatalogPackageMetadata::Documentations()
    122     {
    123         if (!m_documentations)
    124         {
    125             auto documentations = winrt::single_threaded_vector<winrt::Microsoft::Management::Deployment::Documentation>();
    126             for (auto const& documentation : m_manifestLocalization.Get<AppInstaller::Manifest::Localization::Documentations>())
    127             {
    128                 auto documentationImpl = winrt::make_self<wil::details::module_count_wrapper<winrt::Microsoft::Management::Deployment::implementation::Documentation>>();
    129                 documentationImpl->Initialize(documentation);
    130                 documentations.Append(*documentationImpl);
    131             }
    132             m_documentations = documentations;
    133         }
    134 
    135         return m_documentations.GetView();
    136     }
    137     winrt::Windows::Foundation::Collections::IVectorView<winrt::Microsoft::Management::Deployment::Icon> CatalogPackageMetadata::Icons()
    138     {
    139         if (!m_icons)
    140         {
    141             auto icons = winrt::single_threaded_vector<winrt::Microsoft::Management::Deployment::Icon>();
    142             for (auto const& icon : m_manifestLocalization.Get<AppInstaller::Manifest::Localization::Icons>())
    143             {
    144                 auto iconImpl = winrt::make_self<wil::details::module_count_wrapper<winrt::Microsoft::Management::Deployment::implementation::Icon>>();
    145                 iconImpl->Initialize(icon);
    146                 icons.Append(*iconImpl);
    147             }
    148             m_icons = icons;
    149         }
    150 
    151         return m_icons.GetView();
    152     }
    153 }