diff --git a/WindowsAppRuntime.sln b/WindowsAppRuntime.sln index 7f01c0f99e..1a2c2f5781 100644 --- a/WindowsAppRuntime.sln +++ b/WindowsAppRuntime.sln @@ -243,6 +243,9 @@ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ChangeTracker", "dev\EnvironmentManager\ChangeTracker\ChangeTracker.vcxitems", "{E15C3465-9D45-495D-92CE-B91EF45E8623}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WindowsAppRuntime_MSIXInstallFromPath", "dev\WindowsAppRuntime_MSIXInstallFromPath\WindowsAppRuntime_MSIXInstallFromPath.vcxproj", "{D45D4170-E055-4926-8B03-04DAA5F02C6C}" + ProjectSection(ProjectDependencies) = postProject + {BF3FCED0-CADB-490A-93A7-4D90E1F45AB0} = {BF3FCED0-CADB-490A-93A7-4D90E1F45AB0} + EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Framework.Widgets", "test\DynamicDependency\data\Framework.Widgets\Framework.Widgets.vcxproj", "{09DDAE21-397F-4263-8561-7F2FF28127CF}" EndProject @@ -423,6 +426,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VersionInfoTests", "test\Ve EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.FrameworkUdk.PackageReference", "eng\PackageReference\FrameworkUdk\Microsoft.FrameworkUdk.PackageReference.csproj", "{FD0CC14A-ED4B-4936-B68B-F31E58372E32}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "MSIX.Package", "MSIX.Package", "{AF2F6D25-AC23-471E-B5C5-0F7BFB0315D9}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MSIXPackage", "dev\MSIX.Package\MSIX.Package.vcxitems", "{9313B570-83C2-4474-BC23-414B31EC4D15}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -1721,6 +1728,8 @@ Global {2A2D1131-273C-4E17-BCD3-8812170A4B95} = {448ED2E5-0B37-4D97-9E6B-8C10A507976A} {E3EDEC7F-A24E-4766-BB1D-6BDFBA157C51} = {2A2D1131-273C-4E17-BCD3-8812170A4B95} {442FB943-1197-48FE-B3B6-8C1BCA1E81E4} = {8630F7AA-2969-4DC9-8700-9B468C1DC21D} + {AF2F6D25-AC23-471E-B5C5-0F7BFB0315D9} = {448ED2E5-0B37-4D97-9E6B-8C10A507976A} + {9313B570-83C2-4474-BC23-414B31EC4D15} = {AF2F6D25-AC23-471E-B5C5-0F7BFB0315D9} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {4B3D7591-CFEC-4762-9A07-ABE99938FB77} @@ -1738,6 +1747,7 @@ Global dev\Common\Common.vcxitems*{8828053c-d6ec-4744-8624-f8c676c2d4df}*SharedItemsImports = 9 dev\Licensing\Licensing.vcxitems*{885a43fa-052d-4b0d-a2dc-13ee15796435}*SharedItemsImports = 9 test\inc\inc.vcxitems*{8e52d7ea-a200-4a6b-ba74-8efb49468caf}*SharedItemsImports = 4 + dev\MSIX.Package\MSIX.Package.vcxitems*{9313b570-83c2-4474-bc23-414b31ec4d15}*SharedItemsImports = 9 dev\AppNotifications\AppNotifications.vcxitems*{b4824897-88e0-4927-8fb9-e60106f01ed9}*SharedItemsImports = 9 test\inc\inc.vcxitems*{b567fe2e-3a03-48d0-b2b5-760cdec35891}*SharedItemsImports = 9 dev\Common\Common.vcxitems*{b73ad907-6164-4294-88fb-f3c9c10da1f1}*SharedItemsImports = 4 diff --git a/build/NuSpecs/AppxManifest.xml b/build/NuSpecs/AppxManifest.xml index ef35e49436..c64a4e95d2 100644 --- a/build/NuSpecs/AppxManifest.xml +++ b/build/NuSpecs/AppxManifest.xml @@ -34,6 +34,20 @@ + + + + + + + + + + + + + + diff --git a/dev/MSIX.Package/M.W.AM.FindPackageOptions.cpp b/dev/MSIX.Package/M.W.AM.FindPackageOptions.cpp new file mode 100644 index 0000000000..42f77c5f4c --- /dev/null +++ b/dev/MSIX.Package/M.W.AM.FindPackageOptions.cpp @@ -0,0 +1,124 @@ +// Copyright (c) Microsoft Corporation and Contributors. +// Licensed under the MIT License. + +#include + +#include "M.W.AM.FindPackageOptions.h" + +#include "Microsoft.Windows.ApplicationModel.FindPackageOptions.g.cpp" + +namespace winrt::Microsoft::Windows::ApplicationModel::implementation +{ + winrt::Windows::System::User FindPackageOptions::User() + { + throw hresult_not_implemented(); + } + void FindPackageOptions::User(winrt::Windows::System::User const& value) + { + throw hresult_not_implemented(); + } + hstring FindPackageOptions::PackageFullName() + { + return m_packageFullName; + } + void FindPackageOptions::PackageFullName(hstring const& value) + { + m_packageFullName = value; + } + hstring FindPackageOptions::PackageFamilyName() + { + return m_packageFamilyName; + } + void FindPackageOptions::PackageFamilyName(hstring const& value) + { + m_packageFamilyName = value; + } + hstring FindPackageOptions::PackageName() + { + return m_packageName; + } + void FindPackageOptions::PackageName(hstring const& value) + { + m_packageName = value; + } + hstring FindPackageOptions::PackagePublisher() + { + return m_packagePublisher; + } + void FindPackageOptions::PackagePublisher(hstring const& value) + { + m_packagePublisher = value; + } + hstring FindPackageOptions::PackagePublisherId() + { + return m_packagePublisherId; + } + void FindPackageOptions::PackagePublisherId(hstring const& value) + { + m_packagePublisherId = value; + } + bool FindPackageOptions::IsMain() + { + return m_isMain; + } + void FindPackageOptions::IsMain(bool value) + { + m_isMain = value; + } + bool FindPackageOptions::IsFramework() + { + return m_isFramework; + } + void FindPackageOptions::IsFramework(bool value) + { + m_isFramework = value; + } + bool FindPackageOptions::IsResource() + { + return m_isResource; + } + void FindPackageOptions::IsResource(bool value) + { + m_isResource = value; + } + bool FindPackageOptions::IsOptional() + { + return m_isOptional; + } + void FindPackageOptions::IsOptional(bool value) + { + m_isOptional = value; + } + bool FindPackageOptions::IsOptionalInRelatedSet() + { + return m_isOptionalInRelatedSet; + } + void FindPackageOptions::IsOptionalInRelatedSet(bool value) + { + m_isOptionalInRelatedSet = value; + } + bool FindPackageOptions::IsOptionalNotInRelatedSet() + { + return m_isOptionalNotInRelatedSet; + } + void FindPackageOptions::IsOptionalNotInRelatedSet(bool value) + { + m_isOptionalNotInRelatedSet = value; + } + bool FindPackageOptions::IsBundle() + { + return m_isBundle; + } + void FindPackageOptions::IsBundle(bool value) + { + m_isBundle = value; + } + bool FindPackageOptions::IsProvisioned() + { + return m_isProvisioned; + } + void FindPackageOptions::IsProvisioned(bool value) + { + m_isProvisioned = value; + } +} diff --git a/dev/MSIX.Package/M.W.AM.FindPackageOptions.h b/dev/MSIX.Package/M.W.AM.FindPackageOptions.h new file mode 100644 index 0000000000..85775346a8 --- /dev/null +++ b/dev/MSIX.Package/M.W.AM.FindPackageOptions.h @@ -0,0 +1,65 @@ +// Copyright (c) Microsoft Corporation and Contributors. +// Licensed under the MIT License. + +#pragma once + +#include "Microsoft.Windows.ApplicationModel.FindPackageOptions.g.h" + +namespace winrt::Microsoft::Windows::ApplicationModel::implementation +{ + struct FindPackageOptions : FindPackageOptionsT + { + FindPackageOptions() = default; + + winrt::Windows::System::User User(); + void User(winrt::Windows::System::User const& value); + hstring PackageFullName(); + void PackageFullName(hstring const& value); + hstring PackageFamilyName(); + void PackageFamilyName(hstring const& value); + hstring PackageName(); + void PackageName(hstring const& value); + hstring PackagePublisher(); + void PackagePublisher(hstring const& value); + hstring PackagePublisherId(); + void PackagePublisherId(hstring const& value); + bool IsMain(); + void IsMain(bool value); + bool IsFramework(); + void IsFramework(bool value); + bool IsResource(); + void IsResource(bool value); + bool IsOptional(); + void IsOptional(bool value); + bool IsOptionalInRelatedSet(); + void IsOptionalInRelatedSet(bool value); + bool IsOptionalNotInRelatedSet(); + void IsOptionalNotInRelatedSet(bool value); + bool IsBundle(); + void IsBundle(bool value); + bool IsProvisioned(); + void IsProvisioned(bool value); + + private: + //TODO winrt::Windows::System::User m_user; + hstring m_packageFullName; + hstring m_packageFamilyName; + hstring m_packageName; + hstring m_packagePublisher; + hstring m_packagePublisherId; + bool m_isMain{}; + bool m_isFramework{}; + bool m_isResource{}; + bool m_isOptional{}; + bool m_isOptionalInRelatedSet{}; + bool m_isOptionalNotInRelatedSet{}; + bool m_isBundle{}; + bool m_isProvisioned{}; + }; +} +namespace winrt::Microsoft::Windows::ApplicationModel::factory_implementation +{ + struct FindPackageOptions : FindPackageOptionsT + { + }; +} diff --git a/dev/MSIX.Package/M.W.AM.FindRelatedPackagesOptions.cpp b/dev/MSIX.Package/M.W.AM.FindRelatedPackagesOptions.cpp new file mode 100644 index 0000000000..32eb48b9b4 --- /dev/null +++ b/dev/MSIX.Package/M.W.AM.FindRelatedPackagesOptions.cpp @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation and Contributors. +// Licensed under the MIT License. + +#include + +#include "M.W.AM.FindRelatedPackagesOptions.h" + +#include "Microsoft.Windows.ApplicationModel.FindRelatedPackagesOptions.g.cpp" + +namespace winrt::Microsoft::Windows::ApplicationModel::implementation +{ + FindRelatedPackagesOptions::FindRelatedPackagesOptions(winrt::Microsoft::Windows::ApplicationModel::PackageRelationship const& Relationship) : + m_relationship(Relationship) + { + } + winrt::Microsoft::Windows::ApplicationModel::PackageRelationship FindRelatedPackagesOptions::Relationship() + { + return m_relationship; + } + void FindRelatedPackagesOptions::Relationship(winrt::Microsoft::Windows::ApplicationModel::PackageRelationship const& value) + { + m_relationship = value; + } + bool FindRelatedPackagesOptions::IncludeFrameworks() + { + return m_includeFrameworks; + } + void FindRelatedPackagesOptions::IncludeFrameworks(bool value) + { + m_includeFrameworks = value; + } + bool FindRelatedPackagesOptions::IncludeHostRuntimes() + { + return m_includeHostRuntimes; + } + void FindRelatedPackagesOptions::IncludeHostRuntimes(bool value) + { + m_includeHostRuntimes = value; + } + bool FindRelatedPackagesOptions::IncludeOptionals() + { + return m_includeOptionals; + } + void FindRelatedPackagesOptions::IncludeOptionals(bool value) + { + m_includeOptionals = value; + } + bool FindRelatedPackagesOptions::IncludeResources() + { + return m_includeResources; + } + void FindRelatedPackagesOptions::IncludeResources(bool value) + { + m_includeResources = value; + } +} diff --git a/dev/MSIX.Package/M.W.AM.FindRelatedPackagesOptions.h b/dev/MSIX.Package/M.W.AM.FindRelatedPackagesOptions.h new file mode 100644 index 0000000000..6da53166c7 --- /dev/null +++ b/dev/MSIX.Package/M.W.AM.FindRelatedPackagesOptions.h @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation and Contributors. +// Licensed under the MIT License. + +#pragma once + +#include "Microsoft.Windows.ApplicationModel.FindRelatedPackagesOptions.g.h" + +namespace winrt::Microsoft::Windows::ApplicationModel::implementation +{ + struct FindRelatedPackagesOptions : FindRelatedPackagesOptionsT + { + FindRelatedPackagesOptions() = default; + + FindRelatedPackagesOptions(winrt::Microsoft::Windows::ApplicationModel::PackageRelationship const& Relationship); + winrt::Microsoft::Windows::ApplicationModel::PackageRelationship Relationship(); + void Relationship(winrt::Microsoft::Windows::ApplicationModel::PackageRelationship const& value); + bool IncludeFrameworks(); + void IncludeFrameworks(bool value); + bool IncludeHostRuntimes(); + void IncludeHostRuntimes(bool value); + bool IncludeOptionals(); + void IncludeOptionals(bool value); + bool IncludeResources(); + void IncludeResources(bool value); + + private: + winrt::Microsoft::Windows::ApplicationModel::PackageRelationship m_relationship{ winrt::Microsoft::Windows::ApplicationModel::PackageRelationship::Dependencies }; + bool m_includeFrameworks{}; + bool m_includeHostRuntimes{}; + bool m_includeOptionals{}; + bool m_includeResources{}; + }; +} +namespace winrt::Microsoft::Windows::ApplicationModel::factory_implementation +{ + struct FindRelatedPackagesOptions : FindRelatedPackagesOptionsT + { + }; +} diff --git a/dev/MSIX.Package/M.W.AM.Package.cpp b/dev/MSIX.Package/M.W.AM.Package.cpp new file mode 100644 index 0000000000..c33d9ac812 --- /dev/null +++ b/dev/MSIX.Package/M.W.AM.Package.cpp @@ -0,0 +1,234 @@ +// Copyright (c) Microsoft Corporation and Contributors. +// Licensed under the MIT License. + +#include + +#include "M.W.AM.Package.h" + +#include "Microsoft.Windows.ApplicationModel.Package.g.cpp" + +namespace winrt::Microsoft::Windows::ApplicationModel::implementation +{ + Package::Package(winrt::Windows::ApplicationModel::Package const& package) : + m_package(package) + { + } + winrt::Microsoft::Windows::ApplicationModel::Package Package::GetCurrent() + { + return winrt::Microsoft::Windows::ApplicationModel::Package(winrt::Windows::ApplicationModel::Package::Current()); + } + winrt::Microsoft::Windows::ApplicationModel::Package Package::FindPackage(hstring const& packageFullName) + { + auto packageManager{ winrt::Windows::Management::Deployment::PackageManager() }; + auto package{ packageManager.FindPackage(packageFullName) }; + return winrt::Microsoft::Windows::ApplicationModel::Package(package); + } + winrt::Microsoft::Windows::ApplicationModel::Package Package::FindPackage(winrt::Windows::System::User const& /*user*/, hstring const& packageFullName) + { + auto packageManager{ winrt::Windows::Management::Deployment::PackageManager() }; + //TODO convert user to string + auto package{ packageManager.FindPackageForUser(/*user*/ winrt::hstring(), packageFullName) }; + return winrt::Microsoft::Windows::ApplicationModel::Package(package); + } + winrt::Windows::Foundation::Collections::IVector Package::FindPackages() + { + auto packageManager{ winrt::Windows::Management::Deployment::PackageManager() }; + auto packages{ packageManager.FindPackages() }; + return ToVector(packages); + } + winrt::Windows::Foundation::Collections::IVector Package::FindPackages(hstring const& packageFamilyName) + { + auto packageManager{ winrt::Windows::Management::Deployment::PackageManager() }; + auto packages{ packageManager.FindPackages(packageFamilyName) }; + return ToVector(packages); + } + winrt::Windows::Foundation::Collections::IVector Package::FindPackages(hstring const& packageName, hstring const& packagePublisher) + { + auto packageManager{ winrt::Windows::Management::Deployment::PackageManager() }; + auto packages{ packageManager.FindPackages(packageName, packagePublisher) }; + return ToVector(packages); + } + winrt::Windows::Foundation::Collections::IVector Package::FindPackagesForUser(winrt::Windows::System::User const& /*user*/) + { + auto packageManager{ winrt::Windows::Management::Deployment::PackageManager() }; + //TODO convert user to string + auto packages{ packageManager.FindPackagesForUser(/*user*/ winrt::hstring()) }; + return ToVector(packages); + } + winrt::Windows::Foundation::Collections::IVector Package::FindPackagesForUser(winrt::Windows::System::User const& /*user*/, hstring const& packageFamilyName) + { + auto packageManager{ winrt::Windows::Management::Deployment::PackageManager() }; + //TODO convert user to string + auto packages{ packageManager.FindPackagesForUser(/*user*/ winrt::hstring(), packageFamilyName) }; + return ToVector(packages); + } + winrt::Windows::Foundation::Collections::IVector Package::FindPackagesForUser(winrt::Windows::System::User const& /*user*/, hstring const& packageName, hstring const& packagePublisher) + { + auto packageManager{ winrt::Windows::Management::Deployment::PackageManager() }; + //TODO convert user to string + auto packages{ packageManager.FindPackagesForUser(/*user*/ winrt::hstring(), packageName, packagePublisher) }; + return ToVector(packages); + } + winrt::Windows::Foundation::Collections::IVector Package::FindPackagesForUserWithPackageTypes(winrt::Windows::System::User const& /*user*/, winrt::Windows::Management::Deployment::PackageTypes const& types) + { + auto packageManager{ winrt::Windows::Management::Deployment::PackageManager() }; + //TODO convert user to string + auto packages{ packageManager.FindPackagesForUserWithPackageTypes(/*user*/ winrt::hstring(), types) }; + return ToVector(packages); + } + winrt::Windows::Foundation::Collections::IVector Package::FindPackagesForUserWithPackageTypes(winrt::Windows::System::User const& /*user*/, hstring const& packageFamilyName, winrt::Windows::Management::Deployment::PackageTypes const& types) + { + auto packageManager{ winrt::Windows::Management::Deployment::PackageManager() }; + //TODO convert user to string + auto packages{ packageManager.FindPackagesForUserWithPackageTypes(/*user*/ winrt::hstring(), packageFamilyName, types) }; + return ToVector(packages); + } + winrt::Windows::Foundation::Collections::IVector Package::FindPackagesForUserWithPackageTypes(winrt::Windows::System::User const& /*user*/, hstring const& packageName, hstring const& packagePublisher, winrt::Windows::Management::Deployment::PackageTypes const& types) + { + auto packageManager{ winrt::Windows::Management::Deployment::PackageManager() }; + //TODO convert user to string + auto packages{ packageManager.FindPackagesForUserWithPackageTypes(/*user*/ winrt::hstring(), packageName, packagePublisher, types) }; + return ToVector(packages); + } + winrt::Windows::Foundation::Collections::IVector Package::FindProvisionedPackages() + { + throw hresult_not_implemented(); + } + winrt::Microsoft::Windows::ApplicationModel::Package Package::FindPackageWithOptions(winrt::Microsoft::Windows::ApplicationModel::FindPackageOptions const& /*options*/) + { + throw hresult_not_implemented(); + } + winrt::Windows::Foundation::Collections::IVector Package::FindPackagesWithOptions(winrt::Microsoft::Windows::ApplicationModel::FindPackageOptions const& /*options*/) + { + throw hresult_not_implemented(); + } + winrt::Microsoft::Windows::ApplicationModel::PackageDisplayInfo Package::DisplayInfo() + { + return winrt::Microsoft::Windows::ApplicationModel::PackageDisplayInfo(*this); + } + winrt::Microsoft::Windows::ApplicationModel::PackageLocation Package::Location() + { + return winrt::Microsoft::Windows::ApplicationModel::PackageLocation(*this); + } + winrt::Microsoft::Windows::ApplicationModel::PackageIdentity Package::Identity() + { + return winrt::Microsoft::Windows::ApplicationModel::PackageIdentity(*this); + } + winrt::Microsoft::Windows::ApplicationModel::PackageGraph Package::PackageGraph() + { + return winrt::Microsoft::Windows::ApplicationModel::PackageGraph(*this); + } + winrt::Microsoft::Windows::ApplicationModel::PackageInstallInfo Package::Install() + { + return winrt::Microsoft::Windows::ApplicationModel::PackageInstallInfo(*this); + } + winrt::Microsoft::Windows::ApplicationModel::PackageApplications Package::Applications() + { + return winrt::Microsoft::Windows::ApplicationModel::PackageApplications(*this); + } + winrt::Microsoft::Windows::ApplicationModel::PackageContentGroups Package::ContentGroups() + { + return winrt::Microsoft::Windows::ApplicationModel::PackageContentGroups(*this); + } + winrt::Windows::Management::Deployment::PackageTypes Package::PackageType() + { + if (IsFramework()) + { + return winrt::Windows::Management::Deployment::PackageTypes::Framework; + } + else if (IsResource()) + { + return winrt::Windows::Management::Deployment::PackageTypes::Resource; + } + else if (IsOptional()) + { + return winrt::Windows::Management::Deployment::PackageTypes::Optional; + } + else if (IsBundle()) + { + return winrt::Windows::Management::Deployment::PackageTypes::Bundle; + } + else + { + return winrt::Windows::Management::Deployment::PackageTypes::Main; + } + } + bool Package::IsMain() + { + return PackageType() == winrt::Windows::Management::Deployment::PackageTypes::Main; + } + bool Package::IsFramework() + { + return m_package.IsFramework(); + } + bool Package::IsResource() + { + return m_package.IsResourcePackage(); + } + bool Package::IsOptional() + { + return m_package.IsOptional(); + } + bool Package::IsOptionalInRelatedSet() + { + throw hresult_not_implemented(); + } + bool Package::IsBundle() + { + return m_package.IsBundle(); + } + bool Package::IsDevelopmentMode() + { + return m_package.IsDevelopmentMode(); + } + bool Package::IsStub() + { + //? winrt::com_ptr ptr{ m_package.as() }; + throw hresult_not_implemented(); + } + bool Package::IsSigned() + { + return SignatureKind() != winrt::Microsoft::Windows::ApplicationModel::PackageSignatureKind::None; + } + winrt::Microsoft::Windows::ApplicationModel::PackageSignatureKind Package::SignatureKind() + { + return static_cast(m_package.SignatureKind()); + } + winrt::Microsoft::Windows::ApplicationModel::PackageStatus Package::Status() + { + return winrt::Microsoft::Windows::ApplicationModel::PackageStatus{ m_package.Status() }; + } + winrt::Windows::Foundation::IAsyncOperation Package::CheckUpdateAvailabilityAsync() + { + return m_package.CheckUpdateAvailabilityAsync(); + } + winrt::Windows::Foundation::IAsyncOperation Package::SetInUseAsync(bool inUse) + { + return m_package.SetInUseAsync(inUse); + } + winrt::Windows::Foundation::IAsyncOperation Package::VerifyContentIntegrityAsync() + { + return m_package.VerifyContentIntegrityAsync(); + } + winrt::Windows::ApplicationModel::Package Package::W_AM_Package() + { + return m_package; + } + winrt::Windows::Foundation::Collections::IVector Package::ToVector( + winrt::Windows::Foundation::Collections::IIterable& packages) + { + winrt::Windows::Foundation::Collections::IVector vector; + packages.as(vector); + return vector; + } + winrt::Windows::Foundation::Collections::IVector Package::ToVector( + winrt::Windows::Foundation::Collections::IVector& packages) + { + winrt::Windows::Foundation::Collections::IVector vector{ winrt::single_threaded_vector() }; + for (auto package : packages) + { + vector.Append(winrt::Microsoft::Windows::ApplicationModel::Package(package)); + } + return vector; + } +} diff --git a/dev/MSIX.Package/M.W.AM.Package.h b/dev/MSIX.Package/M.W.AM.Package.h new file mode 100644 index 0000000000..0500abc6e3 --- /dev/null +++ b/dev/MSIX.Package/M.W.AM.Package.h @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation and Contributors. +// Licensed under the MIT License. + +#pragma once + +#include "Microsoft.Windows.ApplicationModel.Package.g.h" + +namespace winrt::Microsoft::Windows::ApplicationModel::implementation +{ + struct Package : PackageT + { + Package() = default; + + Package(winrt::Windows::ApplicationModel::Package const& package); + static winrt::Microsoft::Windows::ApplicationModel::Package GetCurrent(); + static winrt::Microsoft::Windows::ApplicationModel::Package FindPackage(hstring const& packageFullName); + static winrt::Microsoft::Windows::ApplicationModel::Package FindPackage(winrt::Windows::System::User const& user, hstring const& packageFullName); + static winrt::Windows::Foundation::Collections::IVector FindPackages(); + static winrt::Windows::Foundation::Collections::IVector FindPackages(hstring const& packageFamilyName); + static winrt::Windows::Foundation::Collections::IVector FindPackages(hstring const& packageName, hstring const& packagePublisher); + static winrt::Windows::Foundation::Collections::IVector FindPackagesForUser(winrt::Windows::System::User const& user); + static winrt::Windows::Foundation::Collections::IVector FindPackagesForUser(winrt::Windows::System::User const& user, hstring const& packageFamilyName); + static winrt::Windows::Foundation::Collections::IVector FindPackagesForUser(winrt::Windows::System::User const& user, hstring const& packageName, hstring const& packagePublisher); + static winrt::Windows::Foundation::Collections::IVector FindPackagesForUserWithPackageTypes(winrt::Windows::System::User const& user, winrt::Windows::Management::Deployment::PackageTypes const& types); + static winrt::Windows::Foundation::Collections::IVector FindPackagesForUserWithPackageTypes(winrt::Windows::System::User const& user, hstring const& packageFamilyName, winrt::Windows::Management::Deployment::PackageTypes const& types); + static winrt::Windows::Foundation::Collections::IVector FindPackagesForUserWithPackageTypes(winrt::Windows::System::User const& user, hstring const& packageName, hstring const& packagePublisher, winrt::Windows::Management::Deployment::PackageTypes const& types); + static winrt::Windows::Foundation::Collections::IVector FindProvisionedPackages(); + static winrt::Microsoft::Windows::ApplicationModel::Package FindPackageWithOptions(winrt::Microsoft::Windows::ApplicationModel::FindPackageOptions const& options); + static winrt::Windows::Foundation::Collections::IVector FindPackagesWithOptions(winrt::Microsoft::Windows::ApplicationModel::FindPackageOptions const& options); + winrt::Microsoft::Windows::ApplicationModel::PackageDisplayInfo DisplayInfo(); + winrt::Microsoft::Windows::ApplicationModel::PackageLocation Location(); + winrt::Microsoft::Windows::ApplicationModel::PackageIdentity Identity(); + winrt::Microsoft::Windows::ApplicationModel::PackageGraph PackageGraph(); + winrt::Microsoft::Windows::ApplicationModel::PackageInstallInfo Install(); + winrt::Microsoft::Windows::ApplicationModel::PackageApplications Applications(); + winrt::Microsoft::Windows::ApplicationModel::PackageContentGroups ContentGroups(); + winrt::Windows::Management::Deployment::PackageTypes PackageType(); + bool IsMain(); + bool IsFramework(); + bool IsResource(); + bool IsOptional(); + bool IsOptionalInRelatedSet(); + bool IsBundle(); + bool IsDevelopmentMode(); + bool IsStub(); + bool IsSigned(); + winrt::Microsoft::Windows::ApplicationModel::PackageSignatureKind SignatureKind(); + winrt::Microsoft::Windows::ApplicationModel::PackageStatus Status(); + winrt::Windows::Foundation::IAsyncOperation CheckUpdateAvailabilityAsync(); + winrt::Windows::Foundation::IAsyncOperation SetInUseAsync(bool inUse); + winrt::Windows::Foundation::IAsyncOperation VerifyContentIntegrityAsync(); + winrt::Windows::ApplicationModel::Package W_AM_Package(); + + private: + static winrt::Windows::Foundation::Collections::IVector ToVector( + winrt::Windows::Foundation::Collections::IIterable& packages); + static winrt::Windows::Foundation::Collections::IVector ToVector( + winrt::Windows::Foundation::Collections::IVector& packages); + + private: + winrt::Windows::ApplicationModel::Package m_package; + }; +} +namespace winrt::Microsoft::Windows::ApplicationModel::factory_implementation +{ + struct Package : PackageT + { + }; +} diff --git a/dev/MSIX.Package/M.W.AM.Package.idl b/dev/MSIX.Package/M.W.AM.Package.idl new file mode 100644 index 0000000000..0d2d425d08 --- /dev/null +++ b/dev/MSIX.Package/M.W.AM.Package.idl @@ -0,0 +1,324 @@ +// Copyright (c) Microsoft Corporation and Contributors. +// Licensed under the MIT License. + +namespace Microsoft.Windows.ApplicationModel +{ + [contractversion(1)] + apicontract PackageContract{}; + + [contract(PackageContract, 1)] + runtimeclass PackageStatus + { + // Equivalent to a W.AM.PackageStatus object + PackageStatus(Windows.ApplicationModel.PackageStatus packageStatus); + + Boolean IsOK { get; }; + + Boolean NotAvailable { get; }; + Boolean PackageOffline { get; }; + Boolean DataOffline { get; }; + Boolean Disabled { get; }; + + Boolean NeedsRemediation { get; }; + Boolean LicenseIssue { get; }; + Boolean Modified { get; }; + Boolean Tampered { get; }; + Boolean DependencyIssue { get; }; + + Boolean Servicing { get; }; + Boolean DeploymentInProgress { get; }; + } + + [contract(PackageContract, 1)] + enum PackageSignatureKind + { + None = 0, + Developer = 1, + Enterprise = 2, //TODO Rename? + Store = 3, + System = 4, + }; + + [contract(PackageContract, 1)] + runtimeclass FindPackageOptions + { + FindPackageOptions(); + + Windows.System.User User; + String PackageFullName; + String PackageFamilyName; + String PackageName; + String PackagePublisher; + String PackagePublisherId; + Boolean IsMain; + Boolean IsFramework; + Boolean IsResource; + Boolean IsOptional; + Boolean IsOptionalInRelatedSet; + Boolean IsOptionalNotInRelatedSet; + Boolean IsBundle; + Boolean IsProvisioned; + }; + + [contract(PackageContract, 1)] + runtimeclass Package + { + // Equivalent to a W.AM.Package object + Package(Windows.ApplicationModel.Package package); + + // Equivalent to W.AM.Package.Current + static Package GetCurrent(); + + PackageDisplayInfo DisplayInfo { get; }; + + PackageLocation Location { get; }; + + PackageIdentity Identity { get; }; + + PackageGraph PackageGraph { get; }; + + PackageInstallInfo Install { get; }; //TODO Rename InstallInfo? Rename all to *Info? + + PackageApplications Applications { get; }; + + PackageContentGroups ContentGroups { get; }; + + // Equivalent to W.M.D.PackageManager.FindPackage(String) + static Package FindPackage(String packageFullName); + + // Equivalent to W.M.D.PackageManager.FindPackageForUser(String, String) + static Package FindPackage(Windows.System.User user, String packageFullName); + + // Equivalent to W.M.D.PackageManager.FindPackages() + static IVector FindPackages(); + + // Equivalent to W.M.D.PackageManager.FindPackages(String) + static IVector FindPackages(String packagFamilyName); + + // Equivalent to W.M.D.PackageManager.FindPackages(String, String) + [method_name("FindPackagesByNameAndPublisher")] + static IVector FindPackages(String packageName, String packagePublisher); + + // Equivalent to W.M.D.PackageManager.FindPackagesForUser(String) + static IVector FindPackagesForUser(Windows.System.User user); + + // Equivalent to W.M.D.PackageManager.FindPackagesForUser(String, String) + [method_name("FindPackagesByUserAndFamilyName")] + static IVector FindPackagesForUser(Windows.System.User user, String packagFamilyName); + + // Equivalent to W.M.D.PackageManager.FindPackagesForUser(String, String, String) + [method_name("FindPackagesByUserAndNameAndPublisher")] + static IVector FindPackagesForUser(Windows.System.User user, String packageName, String packagePublisher); + + // Equivalent to W.M.D.PackageManager.FindPackagesForUserWithPackageTypes(String, PackageTypes) + [method_name("FindPackagesByUserAndPackageType")] + static IVector FindPackagesForUserWithPackageTypes(Windows.System.User user, Windows.Management.Deployment.PackageTypes types); + + // Equivalent to W.M.D.PackageManager.FindPackagesForUserWithPackageTypes(String, String, PackageTypes) + [method_name("FindPackagesByUserAndFamilyNameAndPackageType")] + static IVector FindPackagesForUserWithPackageTypes(Windows.System.User user, String packagFamilyName, Windows.Management.Deployment.PackageTypes types); + + // Equivalent to W.M.D.PackageManager.FindPackagesForUserWithPackageTypes(String, String, String, PackageTypes) + [method_name("FindPackagesByUserAndNameAndPublisherAndPackageType")] + static IVector FindPackagesForUserWithPackageTypes(Windows.System.User user, String packageName, String packagePublisher, Windows.Management.Deployment.PackageTypes types); + + // Equivalent to W.M.D.PackageManager.FindProvisionedPackages() + static IVector FindProvisionedPackages(); + + static Package FindPackageWithOptions(FindPackageOptions options); + static IVector FindPackagesWithOptions(FindPackageOptions options); + + Windows.Management.Deployment.PackageTypes PackageType { get; }; + + Boolean IsMain { get; }; + Boolean IsFramework { get; }; + Boolean IsResource { get; }; + Boolean IsOptional { get; }; + Boolean IsOptionalInRelatedSet { get; }; + Boolean IsBundle { get; }; + + Boolean IsDevelopmentMode { get; }; + + Boolean IsStub { get; }; + + Boolean IsSigned { get; }; + Microsoft.Windows.ApplicationModel.PackageSignatureKind SignatureKind { get; }; + + Microsoft.Windows.ApplicationModel.PackageStatus Status { get; }; + + Windows.Foundation.IAsyncOperation CheckUpdateAvailabilityAsync(); + + Windows.Foundation.IAsyncOperation SetInUseAsync(Boolean inUse); + + Windows.Foundation.IAsyncOperation VerifyContentIntegrityAsync(); + + Windows.ApplicationModel.Package W_AM_Package { get; }; + } + + [contract(PackageContract, 1)] + runtimeclass PackageDisplayInfo + { + PackageDisplayInfo(Microsoft.Windows.ApplicationModel.Package package); + + String DisplayName { get; }; + String PublisherDisplayName { get; }; + String Description { get; }; + + String LogoFilename { get; }; + Windows.Foundation.Uri LogoUri { get; }; + Windows.Storage.Streams.RandomAccessStreamReference GetLogoStream(Windows.Foundation.Size size); + //TODO LogoImage() returning the image as byte[]? Image? ??? + } + + [contract(PackageContract, 1)] + runtimeclass PackageLocation + { + PackageLocation(Microsoft.Windows.ApplicationModel.Package package); + + // Alias for .EffectivePath + String Path { get; }; + + // Alias for .EffectiveLocation + Windows.Storage.StorageFolder Location { get; }; + + String InstalledPath { get; }; + String MutablePath { get; }; + String EffectivePath { get; }; + String EffectiveExternalPath { get; }; + String UserEffectiveExternalPath { get; }; + String MachineEffectiveExternalPath { get; }; + + Windows.Storage.StorageFolder InstalledLocation { get; }; + Windows.Storage.StorageFolder MutableLocation { get; }; + Windows.Storage.StorageFolder EffectiveLocation { get; }; + Windows.Storage.StorageFolder EffectiveExternalLocation { get; }; + Windows.Storage.StorageFolder UserEffectiveExternalLocation { get; }; + Windows.Storage.StorageFolder MachineEffectiveExternalLocation { get; }; + } + + [contract(PackageContract, 1)] + runtimeclass PackageFamilyIdentity + { + PackageFamilyIdentity(); + PackageFamilyIdentity(String name, String publisherId); + + String Name; + String PublisherId; + } + + [contract(PackageContract, 1)] + runtimeclass PackageIdentity + { + PackageIdentity(Microsoft.Windows.ApplicationModel.Package package); + + String Name { get; }; + Windows.ApplicationModel.PackageVersion Version { get; }; + Windows.System.ProcessorArchitecture Architecture { get; }; + String ResouceId { get; }; + String Publisher { get; }; + String PublisherId { get; }; + + String PackageFullName { get; }; + String PackageFamilyName { get; }; + + // Equivalent to PackageFullNameFromId(...,publisher...) in appmodel.h + static String FormatPackageFullName(String packagename, Windows.ApplicationModel.PackageVersion version, Windows.System.ProcessorArchitecture architecture, String resourceId, String publisher); + + // Equivalent to PackageFullNameFromId(...,publisherid...) in appmodel.h + static String FormatPackageFullNameGivenPublisherId(String packagename, Windows.ApplicationModel.PackageVersion version, Windows.System.ProcessorArchitecture architecture, String resourceId, String publisherId); + + // Equivalent to PackageIdFromFullName() in appmodel.h + static PackageIdentity ParsePackageFullName(String packageFullName); + + // Equivalent to PackageFamilyNameFromFullName() in appmodel.h + static String FormatPackageFamilyName(String packageFullName); + + // Equivalent to PackageFamilyNameFromId(...publisher...) in appmodel.h + static String FormatPackageFamilyName(String packagename, String publisher); + + // Equivalent to PackageFamilyNameFromId(...publisherid...) in appmodel.h + static String FormatPackageFamilyNameGivenPublisherId(String packagename, String publisherId); + + // Equivalent to PackageNameAndPublisherIdFromFamilyName() in appmodel.h + static PackageFamilyIdentity ParsePackageFamilyName(String packageFamilyName); + + // Equivalent to VerifyPackageId(...publisher...) in appmodel.h + static Boolean VerifyPackageId(String packagename, Windows.ApplicationModel.PackageVersion version, Windows.System.ProcessorArchitecture architecture, String resourceId, String publisher); + + // Equivalent to VerifyPackageId(...publisherid...) in appmodel.h + static Boolean VerifyPackageIdGivenPublisherId(String packagename, Windows.ApplicationModel.PackageVersion version, Windows.System.ProcessorArchitecture architecture, String resourceId, String publisherId); + + // Equivalent to VerifyPackageFullName() in appmodel.h + static Boolean VerifyPackageFullName(String packageFullName); + + // Equivalent to VerifyFamilyName() in appmodel.h + static Boolean VerifyPackageFamilyName(String packageFullName); + } + + [contract(PackageContract, 1)] + enum PackageRelationship + { + Dependencies = 0, + Dependents, + All + }; + + [contract(PackageContract, 1)] + runtimeclass FindRelatedPackagesOptions + { + FindRelatedPackagesOptions(PackageRelationship Relationship); + + PackageRelationship Relationship; + Boolean IncludeFrameworks; + Boolean IncludeHostRuntimes; + Boolean IncludeOptionals; + Boolean IncludeResources; + }; + + [contract(PackageContract, 1)] + runtimeclass PackageGraph + { + PackageGraph(Microsoft.Windows.ApplicationModel.Package package); + + IVector FindRelatedPackages(); + + IVector FindRelatedPackages(FindRelatedPackagesOptions options); + } + + [contract(PackageContract, 1)] + runtimeclass PackageInstallInfo + { + PackageInstallInfo(Microsoft.Windows.ApplicationModel.Package package); + + Windows.Foundation.DateTime WhenFirstRegisteredForUser { get; }; + + // Equivalent to W.AM.Package.InstalledDate + Windows.Foundation.DateTime WhenLastRegisteredForUser { get; }; + + // Equivalent to W.AM.Package.AppInstallerInfo + Windows.ApplicationModel.AppInstallerInfo GetAppInstallerInfo(); + + // Equivalent to W.AM.Package.SourceUriSchemeName + String SourceUriSchemeName { get; }; + } + + [contract(PackageContract, 1)] + runtimeclass PackageApplications + { + PackageApplications(Microsoft.Windows.ApplicationModel.Package package); + + IVector GetAppListEntries(); + Windows.Foundation.IAsyncOperation > GetAppListEntriesAsync(); + } + + [contract(PackageContract, 1)] + runtimeclass PackageContentGroups + { + PackageContentGroups(Microsoft.Windows.ApplicationModel.Package package); + + Windows.Foundation.IAsyncOperation GetContentGroupAsync(String name); + Windows.Foundation.IAsyncOperation > GetContentGroupsAsync(); + + Windows.Foundation.IAsyncOperation > StageContentGroups(); + } +} diff --git a/dev/MSIX.Package/M.W.AM.PackageApplications.cpp b/dev/MSIX.Package/M.W.AM.PackageApplications.cpp new file mode 100644 index 0000000000..32a46e9f96 --- /dev/null +++ b/dev/MSIX.Package/M.W.AM.PackageApplications.cpp @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation and Contributors. +// Licensed under the MIT License. + +#include + +#include "M.W.AM.PackageApplications.h" + +#include "Microsoft.Windows.ApplicationModel.PackageApplications.g.cpp" + +namespace winrt::Microsoft::Windows::ApplicationModel::implementation +{ + PackageApplications::PackageApplications(winrt::Microsoft::Windows::ApplicationModel::Package const& package) : + m_package(package) + { + } + winrt::Windows::Foundation::Collections::IVector PackageApplications::GetAppListEntries() + { + throw hresult_not_implemented(); + } + winrt::Windows::Foundation::IAsyncOperation> PackageApplications::GetAppListEntriesAsync() + { + throw hresult_not_implemented(); + } +} diff --git a/dev/MSIX.Package/M.W.AM.PackageApplications.h b/dev/MSIX.Package/M.W.AM.PackageApplications.h new file mode 100644 index 0000000000..789bff5f44 --- /dev/null +++ b/dev/MSIX.Package/M.W.AM.PackageApplications.h @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation and Contributors. +// Licensed under the MIT License. + +#pragma once + +#include "Microsoft.Windows.ApplicationModel.PackageApplications.g.h" + +namespace winrt::Microsoft::Windows::ApplicationModel::implementation +{ + struct PackageApplications : PackageApplicationsT + { + PackageApplications() = default; + + PackageApplications(winrt::Microsoft::Windows::ApplicationModel::Package const& package); + winrt::Windows::Foundation::Collections::IVector GetAppListEntries(); + winrt::Windows::Foundation::IAsyncOperation> GetAppListEntriesAsync(); + + private: + winrt::Microsoft::Windows::ApplicationModel::Package m_package; + }; +} +namespace winrt::Microsoft::Windows::ApplicationModel::factory_implementation +{ + struct PackageApplications : PackageApplicationsT + { + }; +} diff --git a/dev/MSIX.Package/M.W.AM.PackageContentGroups.cpp b/dev/MSIX.Package/M.W.AM.PackageContentGroups.cpp new file mode 100644 index 0000000000..be9d65415f --- /dev/null +++ b/dev/MSIX.Package/M.W.AM.PackageContentGroups.cpp @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation and Contributors. +// Licensed under the MIT License. + +#include + +#include "M.W.AM.PackageContentGroups.h" + +#include "Microsoft.Windows.ApplicationModel.PackageContentGroups.g.cpp" + +namespace winrt::Microsoft::Windows::ApplicationModel::implementation +{ + PackageContentGroups::PackageContentGroups(winrt::Microsoft::Windows::ApplicationModel::Package const& package) : + m_package(package) + { + } + winrt::Windows::Foundation::IAsyncOperation PackageContentGroups::GetContentGroupAsync(hstring name) + { + throw hresult_not_implemented(); + } + winrt::Windows::Foundation::IAsyncOperation> PackageContentGroups::GetContentGroupsAsync() + { + throw hresult_not_implemented(); + } + winrt::Windows::Foundation::IAsyncOperation> PackageContentGroups::StageContentGroups() + { + throw hresult_not_implemented(); + } +} diff --git a/dev/MSIX.Package/M.W.AM.PackageContentGroups.h b/dev/MSIX.Package/M.W.AM.PackageContentGroups.h new file mode 100644 index 0000000000..e0ac7eb66f --- /dev/null +++ b/dev/MSIX.Package/M.W.AM.PackageContentGroups.h @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation and Contributors. +// Licensed under the MIT License. + +#pragma once + +#include "Microsoft.Windows.ApplicationModel.PackageContentGroups.g.h" + +namespace winrt::Microsoft::Windows::ApplicationModel::implementation +{ + struct PackageContentGroups : PackageContentGroupsT + { + PackageContentGroups() = default; + + PackageContentGroups(winrt::Microsoft::Windows::ApplicationModel::Package const& package); + winrt::Windows::Foundation::IAsyncOperation GetContentGroupAsync(hstring name); + winrt::Windows::Foundation::IAsyncOperation> GetContentGroupsAsync(); + winrt::Windows::Foundation::IAsyncOperation> StageContentGroups(); + + private: + winrt::Microsoft::Windows::ApplicationModel::Package m_package; + }; +} +namespace winrt::Microsoft::Windows::ApplicationModel::factory_implementation +{ + struct PackageContentGroups : PackageContentGroupsT + { + }; +} diff --git a/dev/MSIX.Package/M.W.AM.PackageDisplayInfo.cpp b/dev/MSIX.Package/M.W.AM.PackageDisplayInfo.cpp new file mode 100644 index 0000000000..ac2501f464 --- /dev/null +++ b/dev/MSIX.Package/M.W.AM.PackageDisplayInfo.cpp @@ -0,0 +1,241 @@ +// Copyright (c) Microsoft Corporation and Contributors. +// Licensed under the MIT License. + +#include + +#include "M.W.AM.PackageDisplayInfo.h" + +#include "Microsoft.Windows.ApplicationModel.PackageDisplayInfo.g.cpp" + +#include + +#include + +// W.AM.Package localizable properties are fully functional only recently +// (as of 10.0.19041.0 aka 20H1 aka UniversalApiContract>=10). On older +// releases they're only functional when created via Package.Current. +// Instances created via Windows.Management.Deployment.PackageManager.FindPackage*() +// are non-functional e.g. package.DisplayName returns "". We can +// determine the same net result by loading the raw values out of +// AppxManifest.xml and calling SHLoadIndirectString(), albeit in +// obscure ways. There's a perf cost to find/load/parse appxmanifest.xml +// so we really only want to do the latter when necessary. + +namespace winrt::Microsoft::Windows::ApplicationModel::implementation +{ + PackageDisplayInfo::PackageDisplayInfo(winrt::Microsoft::Windows::ApplicationModel::Package const& package) : + m_package(package) + { + // W.AM.Package is functional for our needs as of 10.0.19041.0 aka 20H1 aka UniversalApiContract>=10 + auto contractName{ winrt::to_hstring(L"Windows.Foundation.UniversalApiContract") }; + m_isPackageFullyFunctionalForLocalization = winrt::Windows::Foundation::Metadata::ApiInformation::IsApiContractPresent(contractName, 10); + } + hstring PackageDisplayInfo::DisplayName() + { + if (m_localizedDisplayName.size() == 0) + { + if (!m_isPackageFullyFunctionalForLocalization) + { + if (m_manifestedDisplayName.size() == 0) + { + m_manifestedDisplayName = FindLoadAndParseValueFromAppxManifest(winrt::to_hstring(L"/Package/Properties/DisplayName")); + m_localizedDisplayName = ToLocalizedString(m_manifestedDisplayName); + } + } + } + return m_localizedDisplayName; + } + hstring PackageDisplayInfo::PublisherDisplayName() + { + if (m_localizedPublisherDisplayName.size() == 0) + { + if (!m_isPackageFullyFunctionalForLocalization) + { + if (m_manifestedPublisherDisplayName.size() == 0) + { + m_manifestedPublisherDisplayName = FindLoadAndParseValueFromAppxManifest(winrt::to_hstring(L"/Package/Properties/PublisherDisplayName")); + m_localizedPublisherDisplayName = ToLocalizedString(m_manifestedPublisherDisplayName); + } + } + } + return m_localizedPublisherDisplayName; + } + hstring PackageDisplayInfo::Description() + { + if (m_localizedDescription.size() == 0) + { + if (!m_isPackageFullyFunctionalForLocalization) + { + // Description is optional in appxmanifest.xml. We can't rely on + // a string from the manifest indicating we've parsed the manifest + if (m_descriptionIsParsedFromManifest && m_manifestedDescription.size() == 0) + { + m_manifestedDescription = FindLoadAndParseValueFromAppxManifest(winrt::to_hstring(L"/Package/Properties/Description")); + m_localizedDescription = ToLocalizedString(m_manifestedDescription); + } + } + } + return m_localizedDescription; + } + hstring PackageDisplayInfo::LogoFilename() + { + if (m_localizedLogo.size() == 0) + { + if (!m_isPackageFullyFunctionalForLocalization) + { + if (m_manifestedLogo.size() == 0) + { + auto string{ FindLoadAndParseValueFromAppxManifest(winrt::to_hstring("/Package/Properties/Description")) }; + m_localizedLogo = ToLocalizedPath(string); + } + } + } + return m_localizedLogo; + } + winrt::Windows::Foundation::Uri PackageDisplayInfo::LogoUri() + { + if (!m_localizedLogoUri) + { + auto logoFilename{ LogoFilename() }; + winrt::Windows::Foundation::Uri uri{ logoFilename.c_str() }; + m_localizedLogoUri = uri; + } + return m_localizedLogoUri; + } + winrt::Windows::Storage::Streams::RandomAccessStreamReference PackageDisplayInfo::GetLogoStream(winrt::Windows::Foundation::Size const& /*size*/) + { + //TODO Use Mrm APIs to get the logo in the desired TargetSize=size per https://github.com/microsoft/ProjectReunion/issues/11 + auto logo{ LogoUri() }; + return winrt::Windows::Storage::Streams::RandomAccessStreamReference::CreateFromUri(logo); + } + + hstring PackageDisplayInfo::FindLoadAndParseValueFromAppxManifest(hstring xpath) + { + auto doc{ FindLoadAndParseAppxManifest() }; + auto node{ doc.SelectSingleNode(xpath) }; + if (node) + { + return node.InnerText(); + } + return winrt::hstring(); + } + + winrt::Windows::Data::Xml::Dom::XmlDocument& PackageDisplayInfo::FindLoadAndParseAppxManifest() + { + if (!m_appxManifest) + { + auto location{ m_package.Location() }; + auto effectivePath{ location.EffectivePath() }; + auto path{ std::filesystem::path(effectivePath.c_str()) }; + auto appxmanifest{ path / L"appxmanifest.xml" }; + auto appxmanifestFilename{ appxmanifest.c_str() }; + winrt::Windows::Foundation::Uri uri{ appxmanifestFilename }; + + winrt::Windows::Data::Xml::Dom::XmlDocument doc; + m_appxManifest = doc.LoadFromUriAsync(uri).get(); + } + return m_appxManifest; + } + + hstring PackageDisplayInfo::ToLocalizedString(const hstring& string) + { + // Per https://stackoverflow.com/questions/18219915/get-localized-friendly-names-for-all-winrt-metro-apps-installed-from-wpf-applica + // + // You'll have to transform the manifest string into the proper form, though. + // It should be: ms-resource://PackageName/Resources/Id + // + // PackageName is the name rather than the full name. Resources isn't strictly + // required but it's the default and it's usually there. I'd try to look up the + // resource without inserting resources and then try again if that fails. + // + // For example, the camera app has "ms-resource:manifestDisplayName" in the manifest, + // so first you should try(*): @{Microsoft.Camera_6.2.8376.0_x64__8wekyb3d8bbwe? ms-resource://Microsoft.Camera/manifestAppDescription} + // + // When that fails, insert "resources" and try: @{Microsoft.Camera_6.2.8376.0_x64__8wekyb3d8bbwe? ms-resource://Microsoft.Camera/resources/manifestAppDescription} + // + // That should work. You'll want to try both forms because blindly inserting + // "resources" will break apps like skydrive, communications and photos which + // insert the first part of the path directly. + // + // Still a bit of a pain, but better than dumping and parsing gigantic XML files. + // + // (*) "Microsoft.Camera_6.2.8376.0_x64__8wekyb3d8bbwe" is taken from an example. + // You'll obviously want the FullName of the one that's actually present on your system. + + // Localized strings start with "ms-resource:" + std::wstring prefix{ L"ms-resource:" }; + if (prefix.compare(0, prefix.length(), string.c_str()) != 0) + { + return string; + } + + // SHLoadIndirectString() can resolve localized strings in appxmanifest.xml + // if we convert the manifest string ms-resource:resource to @{PackageFullName?resource} + // See https://docs.microsoft.com/en-us/windows/win32/api/shlwapi/nf-shlwapi-shloadindirectstring?redirectedfrom=MSDN + + // Given "ms-resource:resource" build the MRT fully-qualified reference @{pkgfullname?ms-resource://pkgname/resource} + auto resource{ string.c_str() + prefix.length() }; + auto identity{ m_package.Identity() }; + std::wstring source{ L"@{" }; + source += identity.PackageFullName(); + source += L"?ms-resource://"; + source += identity.Name(); + source += L"/"; + const auto offsetToResource{ source.length() }; + source += resource; + + WCHAR localized[4096]{}; + UINT localizedSize{ static_cast(std::size(localized)) }; + HRESULT hr{ SHLoadIndirectString(source.c_str(), localized, localizedSize, nullptr) }; + if (FAILED(hr)) + { + // Try the alternative syntax .../resources/... i.e. @{pkgfullname?ms-resource://pkgname/resources/key} + source.insert(offsetToResource, L"resources/"); + hr = SHLoadIndirectString(source.c_str(), localized, localizedSize, nullptr); + if (FAILED(hr)) + { + // Failure to match yields the MRT fully-qualified reference + // (less likely to be confusd with a real answer as 'key' would be) + // TODO: Should we return the original manifest'd value on failure? Raise an exception? + return winrt::to_hstring(source.c_str()); + } + } + return winrt::to_hstring(localized); + } + + hstring PackageDisplayInfo::ToLocalizedPath(const hstring& path) + { + // Unlike localizable strings in appxmanifest.xml, localizable paths have no ms-resource: prefix. + // Localizable paths are always potentially localizable. The only way to know for sure is to try + // (and compare if before vs after differs, if you care to know). + + // See ToLocalizedString() for more details. + + // Build the MRT fully-qualified reference @{pkgfullname?ms-resource://pkgname/resource} + auto resource{ path.c_str() }; + auto identity{ m_package.Identity() }; + std::wstring source{ L"@{" }; + source += identity.PackageFullName(); + source += L"?ms-resource://"; + source += identity.Name(); + source += L"/"; + const auto offsetToResource{ source.length() }; + source += resource; + + WCHAR localized[4096]{}; + UINT localizedSize{ static_cast(std::size(localized)) }; + HRESULT hr{ SHLoadIndirectString(source.c_str(), localized, localizedSize, nullptr) }; + if (FAILED(hr)) + { + // Try the alternative syntax .../resources/... i.e. @{pkgfullname?ms-resource://pkgname/resources/key} + source.insert(offsetToResource, L"resources/"); + hr = SHLoadIndirectString(source.c_str(), localized, localizedSize, nullptr); + if (FAILED(hr)) + { + // No match so it's a literal value; no localization needed + return path; + } + } + return winrt::to_hstring(localized); + } +} diff --git a/dev/MSIX.Package/M.W.AM.PackageDisplayInfo.h b/dev/MSIX.Package/M.W.AM.PackageDisplayInfo.h new file mode 100644 index 0000000000..57b5bd1ab0 --- /dev/null +++ b/dev/MSIX.Package/M.W.AM.PackageDisplayInfo.h @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation and Contributors. +// Licensed under the MIT License. + +#pragma once + +#include "Microsoft.Windows.ApplicationModel.PackageDisplayInfo.g.h" + +namespace winrt::Microsoft::Windows::ApplicationModel::implementation +{ + struct PackageDisplayInfo : PackageDisplayInfoT + { + PackageDisplayInfo() = default; + + PackageDisplayInfo(winrt::Microsoft::Windows::ApplicationModel::Package const& package); + hstring DisplayName(); + hstring PublisherDisplayName(); + hstring Description(); + hstring LogoFilename(); + winrt::Windows::Foundation::Uri LogoUri(); + winrt::Windows::Storage::Streams::RandomAccessStreamReference GetLogoStream(winrt::Windows::Foundation::Size const& size); + + private: + hstring FindLoadAndParseValueFromAppxManifest(hstring xpath); + winrt::Windows::Data::Xml::Dom::XmlDocument& FindLoadAndParseAppxManifest(); + hstring ToLocalizedString(const hstring& string); + hstring ToLocalizedPath(const hstring& path); + + private: + winrt::Microsoft::Windows::ApplicationModel::Package m_package; + winrt::Windows::Data::Xml::Dom::XmlDocument m_appxManifest; + hstring m_manifestedDisplayName; + hstring m_localizedDisplayName; + hstring m_manifestedPublisherDisplayName; + hstring m_localizedPublisherDisplayName; + bool m_descriptionIsParsedFromManifest{}; + hstring m_manifestedDescription; + hstring m_localizedDescription; + hstring m_manifestedLogo; + hstring m_localizedLogo; + winrt::Windows::Foundation::Uri m_localizedLogoUri{ nullptr };bool m_isPackageFullyFunctionalForLocalization{}; + }; +} +namespace winrt::Microsoft::Windows::ApplicationModel::factory_implementation +{ + struct PackageDisplayInfo : PackageDisplayInfoT + { + }; +} diff --git a/dev/MSIX.Package/M.W.AM.PackageFamilyIdentity.cpp b/dev/MSIX.Package/M.W.AM.PackageFamilyIdentity.cpp new file mode 100644 index 0000000000..8409f3755f --- /dev/null +++ b/dev/MSIX.Package/M.W.AM.PackageFamilyIdentity.cpp @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation and Contributors. +// Licensed under the MIT License. + +#include + +#include "M.W.AM.PackageFamilyIdentity.h" + +#include "Microsoft.Windows.ApplicationModel.PackageFamilyIdentity.g.cpp" + +namespace winrt::Microsoft::Windows::ApplicationModel::implementation +{ + PackageFamilyIdentity::PackageFamilyIdentity(hstring const& name, hstring const& publisherId) : + m_name(name), m_publisherId(publisherId) + { + } + hstring PackageFamilyIdentity::Name() + { + return m_name; + } + void PackageFamilyIdentity::Name(hstring const& value) + { + m_name = value; + } + hstring PackageFamilyIdentity::PublisherId() + { + return m_publisherId; + } + void PackageFamilyIdentity::PublisherId(hstring const& value) + { + m_publisherId = value; + } +} diff --git a/dev/MSIX.Package/M.W.AM.PackageFamilyIdentity.h b/dev/MSIX.Package/M.W.AM.PackageFamilyIdentity.h new file mode 100644 index 0000000000..fe3bbb6bd9 --- /dev/null +++ b/dev/MSIX.Package/M.W.AM.PackageFamilyIdentity.h @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation and Contributors. +// Licensed under the MIT License. + +#pragma once + +#include "Microsoft.Windows.ApplicationModel.PackageFamilyIdentity.g.h" + +namespace winrt::Microsoft::Windows::ApplicationModel::implementation +{ + struct PackageFamilyIdentity : PackageFamilyIdentityT + { + PackageFamilyIdentity() = default; + PackageFamilyIdentity(hstring const& name, hstring const& publisherId); + + hstring Name(); + void Name(hstring const& value); + hstring PublisherId(); + void PublisherId(hstring const& value); + + private: + hstring m_name; + hstring m_publisherId; + }; +} +namespace winrt::Microsoft::Windows::ApplicationModel::factory_implementation +{ + struct PackageFamilyIdentity : PackageFamilyIdentityT + { + }; +} diff --git a/dev/MSIX.Package/M.W.AM.PackageGraph.cpp b/dev/MSIX.Package/M.W.AM.PackageGraph.cpp new file mode 100644 index 0000000000..cf2945b16a --- /dev/null +++ b/dev/MSIX.Package/M.W.AM.PackageGraph.cpp @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation and Contributors. +// Licensed under the MIT License. + +#include + +#include "M.W.AM.PackageGraph.h" + +#include "Microsoft.Windows.ApplicationModel.PackageGraph.g.cpp" + +namespace winrt::Microsoft::Windows::ApplicationModel::implementation +{ + PackageGraph::PackageGraph(winrt::Microsoft::Windows::ApplicationModel::Package const& package) : + m_package(package) + { + } + winrt::Windows::Foundation::Collections::IVector PackageGraph::FindRelatedPackages() + { + throw hresult_not_implemented(); + } + winrt::Windows::Foundation::Collections::IVector PackageGraph::FindRelatedPackages(winrt::Microsoft::Windows::ApplicationModel::FindRelatedPackagesOptions const& options) + { + throw hresult_not_implemented(); + } +} diff --git a/dev/MSIX.Package/M.W.AM.PackageGraph.h b/dev/MSIX.Package/M.W.AM.PackageGraph.h new file mode 100644 index 0000000000..7785b7ac20 --- /dev/null +++ b/dev/MSIX.Package/M.W.AM.PackageGraph.h @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation and Contributors. +// Licensed under the MIT License. + +#pragma once + +#include "Microsoft.Windows.ApplicationModel.PackageGraph.g.h" + +namespace winrt::Microsoft::Windows::ApplicationModel::implementation +{ + struct PackageGraph : PackageGraphT + { + PackageGraph() = default; + + PackageGraph(winrt::Microsoft::Windows::ApplicationModel::Package const& package); + winrt::Windows::Foundation::Collections::IVector FindRelatedPackages(); + winrt::Windows::Foundation::Collections::IVector FindRelatedPackages(winrt::Microsoft::Windows::ApplicationModel::FindRelatedPackagesOptions const& options); + + private: + winrt::Microsoft::Windows::ApplicationModel::Package m_package; + }; +} +namespace winrt::Microsoft::Windows::ApplicationModel::factory_implementation +{ + struct PackageGraph : PackageGraphT + { + }; +} diff --git a/dev/MSIX.Package/M.W.AM.PackageIdentity.cpp b/dev/MSIX.Package/M.W.AM.PackageIdentity.cpp new file mode 100644 index 0000000000..4b9586113a --- /dev/null +++ b/dev/MSIX.Package/M.W.AM.PackageIdentity.cpp @@ -0,0 +1,92 @@ +// Copyright (c) Microsoft Corporation and Contributors. +// Licensed under the MIT License. + +#include + +#include "M.W.AM.PackageIdentity.h" + +#include "Microsoft.Windows.ApplicationModel.PackageIdentity.g.cpp" + +namespace winrt::Microsoft::Windows::ApplicationModel::implementation +{ + PackageIdentity::PackageIdentity(winrt::Microsoft::Windows::ApplicationModel::Package const& package) : + m_package(package) + { + } + hstring PackageIdentity::FormatPackageFullName(hstring const& packagename, winrt::Windows::ApplicationModel::PackageVersion const& version, winrt::Windows::System::ProcessorArchitecture const& architecture, hstring const& resourceId, hstring const& publisher) + { + throw hresult_not_implemented(); + } + hstring PackageIdentity::FormatPackageFullNameGivenPublisherId(hstring const& packagename, winrt::Windows::ApplicationModel::PackageVersion const& version, winrt::Windows::System::ProcessorArchitecture const& architecture, hstring const& resourceId, hstring const& publisherId) + { + throw hresult_not_implemented(); + } + winrt::Microsoft::Windows::ApplicationModel::PackageIdentity PackageIdentity::ParsePackageFullName(hstring const& packageFullName) + { + throw hresult_not_implemented(); + } + hstring PackageIdentity::FormatPackageFamilyName(hstring const& packageFullName) + { + throw hresult_not_implemented(); + } + hstring PackageIdentity::FormatPackageFamilyName(hstring const& packagename, hstring const& publisher) + { + throw hresult_not_implemented(); + } + hstring PackageIdentity::FormatPackageFamilyNameGivenPublisherId(hstring const& packagename, hstring const& publisherId) + { + throw hresult_not_implemented(); + } + winrt::Microsoft::Windows::ApplicationModel::PackageFamilyIdentity PackageIdentity::ParsePackageFamilyName(hstring const& packageFamilyName) + { + throw hresult_not_implemented(); + } + bool PackageIdentity::VerifyPackageId(hstring const& packagename, winrt::Windows::ApplicationModel::PackageVersion const& version, winrt::Windows::System::ProcessorArchitecture const& architecture, hstring const& resourceId, hstring const& publisher) + { + throw hresult_not_implemented(); + } + bool PackageIdentity::VerifyPackageIdGivenPublisherId(hstring const& packagename, winrt::Windows::ApplicationModel::PackageVersion const& version, winrt::Windows::System::ProcessorArchitecture const& architecture, hstring const& resourceId, hstring const& publisherId) + { + throw hresult_not_implemented(); + } + bool PackageIdentity::VerifyPackageFullName(hstring const& packageFullName) + { + throw hresult_not_implemented(); + } + bool PackageIdentity::VerifyPackageFamilyName(hstring const& packageFullName) + { + throw hresult_not_implemented(); + } + hstring PackageIdentity::Name() + { + throw hresult_not_implemented(); + } + winrt::Windows::ApplicationModel::PackageVersion PackageIdentity::Version() + { + throw hresult_not_implemented(); + } + winrt::Windows::System::ProcessorArchitecture PackageIdentity::Architecture() + { + throw hresult_not_implemented(); + } + hstring PackageIdentity::ResouceId() + { + throw hresult_not_implemented(); + } + hstring PackageIdentity::Publisher() + { + throw hresult_not_implemented(); + } + hstring PackageIdentity::PublisherId() + { + throw hresult_not_implemented(); + } + hstring PackageIdentity::PackageFullName() + { + throw hresult_not_implemented(); + } + hstring PackageIdentity::PackageFamilyName() + { + throw hresult_not_implemented(); + } +} diff --git a/dev/MSIX.Package/M.W.AM.PackageIdentity.h b/dev/MSIX.Package/M.W.AM.PackageIdentity.h new file mode 100644 index 0000000000..dfc841d3fb --- /dev/null +++ b/dev/MSIX.Package/M.W.AM.PackageIdentity.h @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation and Contributors. +// Licensed under the MIT License. + +#pragma once + +#include "Microsoft.Windows.ApplicationModel.PackageIdentity.g.h" + +namespace winrt::Microsoft::Windows::ApplicationModel::implementation +{ + struct PackageIdentity : PackageIdentityT + { + PackageIdentity() = default; + + PackageIdentity(winrt::Microsoft::Windows::ApplicationModel::Package const& package); + static hstring FormatPackageFullName(hstring const& packagename, winrt::Windows::ApplicationModel::PackageVersion const& version, winrt::Windows::System::ProcessorArchitecture const& architecture, hstring const& resourceId, hstring const& publisher); + static hstring FormatPackageFullNameGivenPublisherId(hstring const& packagename, winrt::Windows::ApplicationModel::PackageVersion const& version, winrt::Windows::System::ProcessorArchitecture const& architecture, hstring const& resourceId, hstring const& publisherId); + static winrt::Microsoft::Windows::ApplicationModel::PackageIdentity ParsePackageFullName(hstring const& packageFullName); + static hstring FormatPackageFamilyName(hstring const& packageFullName); + static hstring FormatPackageFamilyName(hstring const& packagename, hstring const& publisher); + static hstring FormatPackageFamilyNameGivenPublisherId(hstring const& packagename, hstring const& publisherId); + static winrt::Microsoft::Windows::ApplicationModel::PackageFamilyIdentity ParsePackageFamilyName(hstring const& packageFamilyName); + static bool VerifyPackageId(hstring const& packagename, winrt::Windows::ApplicationModel::PackageVersion const& version, winrt::Windows::System::ProcessorArchitecture const& architecture, hstring const& resourceId, hstring const& publisher); + static bool VerifyPackageIdGivenPublisherId(hstring const& packagename, winrt::Windows::ApplicationModel::PackageVersion const& version, winrt::Windows::System::ProcessorArchitecture const& architecture, hstring const& resourceId, hstring const& publisherId); + static bool VerifyPackageFullName(hstring const& packageFullName); + static bool VerifyPackageFamilyName(hstring const& packageFullName); + hstring Name(); + winrt::Windows::ApplicationModel::PackageVersion Version(); + winrt::Windows::System::ProcessorArchitecture Architecture(); + hstring ResouceId(); + hstring Publisher(); + hstring PublisherId(); + hstring PackageFullName(); + hstring PackageFamilyName(); + + private: + winrt::Microsoft::Windows::ApplicationModel::Package m_package; + }; +} +namespace winrt::Microsoft::Windows::ApplicationModel::factory_implementation +{ + struct PackageIdentity : PackageIdentityT + { + }; +} diff --git a/dev/MSIX.Package/M.W.AM.PackageInstallInfo.cpp b/dev/MSIX.Package/M.W.AM.PackageInstallInfo.cpp new file mode 100644 index 0000000000..1c0de351c4 --- /dev/null +++ b/dev/MSIX.Package/M.W.AM.PackageInstallInfo.cpp @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation and Contributors. +// Licensed under the MIT License. + +#include + +#include "M.W.AM.PackageInstallInfo.h" + +#include "Microsoft.Windows.ApplicationModel.PackageInstallInfo.g.cpp" + +namespace winrt::Microsoft::Windows::ApplicationModel::implementation +{ + PackageInstallInfo::PackageInstallInfo(winrt::Microsoft::Windows::ApplicationModel::Package const& package) : + m_package(package) + { + } + winrt::Windows::Foundation::DateTime PackageInstallInfo::WhenFirstRegisteredForUser() + { + throw hresult_not_implemented(); + } + winrt::Windows::Foundation::DateTime PackageInstallInfo::WhenLastRegisteredForUser() + { + throw hresult_not_implemented(); + } + winrt::Windows::ApplicationModel::AppInstallerInfo PackageInstallInfo::GetAppInstallerInfo() + { + throw hresult_not_implemented(); + } + hstring PackageInstallInfo::SourceUriSchemeName() + { + throw hresult_not_implemented(); + } +} diff --git a/dev/MSIX.Package/M.W.AM.PackageInstallInfo.h b/dev/MSIX.Package/M.W.AM.PackageInstallInfo.h new file mode 100644 index 0000000000..32db704be4 --- /dev/null +++ b/dev/MSIX.Package/M.W.AM.PackageInstallInfo.h @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation and Contributors. +// Licensed under the MIT License. + +#pragma once + +#include "Microsoft.Windows.ApplicationModel.PackageInstallInfo.g.h" + +namespace winrt::Microsoft::Windows::ApplicationModel::implementation +{ + struct PackageInstallInfo : PackageInstallInfoT + { + PackageInstallInfo() = default; + + PackageInstallInfo(winrt::Microsoft::Windows::ApplicationModel::Package const& package); + winrt::Windows::Foundation::DateTime WhenFirstRegisteredForUser(); + winrt::Windows::Foundation::DateTime WhenLastRegisteredForUser(); + winrt::Windows::ApplicationModel::AppInstallerInfo GetAppInstallerInfo(); + hstring SourceUriSchemeName(); + + private: + winrt::Microsoft::Windows::ApplicationModel::Package m_package; + }; +} +namespace winrt::Microsoft::Windows::ApplicationModel::factory_implementation +{ + struct PackageInstallInfo : PackageInstallInfoT + { + }; +} diff --git a/dev/MSIX.Package/M.W.AM.PackageLocation.cpp b/dev/MSIX.Package/M.W.AM.PackageLocation.cpp new file mode 100644 index 0000000000..7267794db3 --- /dev/null +++ b/dev/MSIX.Package/M.W.AM.PackageLocation.cpp @@ -0,0 +1,72 @@ +// Copyright (c) Microsoft Corporation and Contributors. +// Licensed under the MIT License. + +#include + +#include "M.W.AM.PackageLocation.h" + +#include "Microsoft.Windows.ApplicationModel.PackageLocation.g.cpp" + +namespace winrt::Microsoft::Windows::ApplicationModel::implementation +{ + PackageLocation::PackageLocation(winrt::Microsoft::Windows::ApplicationModel::Package const& package) : + m_package(package) + { + } + hstring PackageLocation::Path() + { + return EffectivePath(); + } + winrt::Windows::Storage::StorageFolder PackageLocation::Location() + { + return EffectiveLocation(); + } + hstring PackageLocation::InstalledPath() + { + throw hresult_not_implemented(); + } + hstring PackageLocation::MutablePath() + { + throw hresult_not_implemented(); + } + hstring PackageLocation::EffectivePath() + { + throw hresult_not_implemented(); + } + hstring PackageLocation::EffectiveExternalPath() + { + throw hresult_not_implemented(); + } + hstring PackageLocation::UserEffectiveExternalPath() + { + throw hresult_not_implemented(); + } + hstring PackageLocation::MachineEffectiveExternalPath() + { + throw hresult_not_implemented(); + } + winrt::Windows::Storage::StorageFolder PackageLocation::InstalledLocation() + { + return m_package.W_AM_Package().InstalledLocation(); + } + winrt::Windows::Storage::StorageFolder PackageLocation::MutableLocation() + { + throw hresult_not_implemented(); + } + winrt::Windows::Storage::StorageFolder PackageLocation::EffectiveLocation() + { + throw hresult_not_implemented(); + } + winrt::Windows::Storage::StorageFolder PackageLocation::EffectiveExternalLocation() + { + throw hresult_not_implemented(); + } + winrt::Windows::Storage::StorageFolder PackageLocation::UserEffectiveExternalLocation() + { + throw hresult_not_implemented(); + } + winrt::Windows::Storage::StorageFolder PackageLocation::MachineEffectiveExternalLocation() + { + throw hresult_not_implemented(); + } +} diff --git a/dev/MSIX.Package/M.W.AM.PackageLocation.h b/dev/MSIX.Package/M.W.AM.PackageLocation.h new file mode 100644 index 0000000000..2dd8d26d87 --- /dev/null +++ b/dev/MSIX.Package/M.W.AM.PackageLocation.h @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation and Contributors. +// Licensed under the MIT License. + +#pragma once + +#include "Microsoft.Windows.ApplicationModel.PackageLocation.g.h" + +namespace winrt::Microsoft::Windows::ApplicationModel::implementation +{ + struct PackageLocation : PackageLocationT + { + PackageLocation() = default; + + PackageLocation(winrt::Microsoft::Windows::ApplicationModel::Package const& package); + hstring Path(); + winrt::Windows::Storage::StorageFolder Location(); + hstring InstalledPath(); + hstring MutablePath(); + hstring EffectivePath(); + hstring EffectiveExternalPath(); + hstring UserEffectiveExternalPath(); + hstring MachineEffectiveExternalPath(); + winrt::Windows::Storage::StorageFolder InstalledLocation(); + winrt::Windows::Storage::StorageFolder MutableLocation(); + winrt::Windows::Storage::StorageFolder EffectiveLocation(); + winrt::Windows::Storage::StorageFolder EffectiveExternalLocation(); + winrt::Windows::Storage::StorageFolder UserEffectiveExternalLocation(); + winrt::Windows::Storage::StorageFolder MachineEffectiveExternalLocation(); + + private: + winrt::Microsoft::Windows::ApplicationModel::Package m_package; + }; +} +namespace winrt::Microsoft::Windows::ApplicationModel::factory_implementation +{ + struct PackageLocation : PackageLocationT + { + }; +} diff --git a/dev/MSIX.Package/M.W.AM.PackageStatus.cpp b/dev/MSIX.Package/M.W.AM.PackageStatus.cpp new file mode 100644 index 0000000000..e22ede553f --- /dev/null +++ b/dev/MSIX.Package/M.W.AM.PackageStatus.cpp @@ -0,0 +1,64 @@ +// Copyright (c) Microsoft Corporation and Contributors. +// Licensed under the MIT License. + +#include + +#include "M.W.AM.PackageStatus.h" + +#include "Microsoft.Windows.ApplicationModel.PackageStatus.g.cpp" + +namespace winrt::Microsoft::Windows::ApplicationModel::implementation +{ + PackageStatus::PackageStatus(winrt::Windows::ApplicationModel::PackageStatus const& packageStatus) : + m_packageStatus(packageStatus) + { + } + bool PackageStatus::IsOK() + { + return m_packageStatus.VerifyIsOK(); + } + bool PackageStatus::NotAvailable() + { + return m_packageStatus.NotAvailable(); + } + bool PackageStatus::PackageOffline() + { + return m_packageStatus.PackageOffline(); + } + bool PackageStatus::DataOffline() + { + return m_packageStatus.DataOffline(); + } + bool PackageStatus::Disabled() + { + return m_packageStatus.Disabled(); + } + bool PackageStatus::NeedsRemediation() + { + return m_packageStatus.NeedsRemediation(); + } + bool PackageStatus::LicenseIssue() + { + return m_packageStatus.LicenseIssue(); + } + bool PackageStatus::Modified() + { + return m_packageStatus.Modified(); + } + bool PackageStatus::Tampered() + { + return m_packageStatus.Tampered(); + } + bool PackageStatus::DependencyIssue() + { + return m_packageStatus.DependencyIssue(); + } + bool PackageStatus::Servicing() + { + return m_packageStatus.Servicing(); + } + bool PackageStatus::DeploymentInProgress() + { + return m_packageStatus.DeploymentInProgress(); + } +} diff --git a/dev/MSIX.Package/M.W.AM.PackageStatus.h b/dev/MSIX.Package/M.W.AM.PackageStatus.h new file mode 100644 index 0000000000..466798bd24 --- /dev/null +++ b/dev/MSIX.Package/M.W.AM.PackageStatus.h @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation and Contributors. +// Licensed under the MIT License. + +#pragma once + +#include "Microsoft.Windows.ApplicationModel.PackageStatus.g.h" + +namespace winrt::Microsoft::Windows::ApplicationModel::implementation +{ + struct PackageStatus : PackageStatusT + { + PackageStatus() = default; + + PackageStatus(winrt::Windows::ApplicationModel::PackageStatus const& packageStatus); + bool IsOK(); + bool NotAvailable(); + bool PackageOffline(); + bool DataOffline(); + bool Disabled(); + bool NeedsRemediation(); + bool LicenseIssue(); + bool Modified(); + bool Tampered(); + bool DependencyIssue(); + bool Servicing(); + bool DeploymentInProgress(); + + private: + winrt::Windows::ApplicationModel::PackageStatus m_packageStatus; + }; +} +namespace winrt::Microsoft::Windows::ApplicationModel::factory_implementation +{ + struct PackageStatus : PackageStatusT + { + }; +} diff --git a/dev/MSIX.Package/MSIX.Package.vcxitems b/dev/MSIX.Package/MSIX.Package.vcxitems new file mode 100644 index 0000000000..c384e7c6c2 --- /dev/null +++ b/dev/MSIX.Package/MSIX.Package.vcxitems @@ -0,0 +1,44 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + {9313B570-83C2-4474-BC23-414B31EC4D15} + MSIXPackage + + + + %(AdditionalIncludeDirectories);$(MSBuildThisFileDirectory) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/WindowsAppRuntime_DLL/WindowsAppRuntime_DLL.vcxproj b/dev/WindowsAppRuntime_DLL/WindowsAppRuntime_DLL.vcxproj index d142eaeaf9..abc62f665f 100644 --- a/dev/WindowsAppRuntime_DLL/WindowsAppRuntime_DLL.vcxproj +++ b/dev/WindowsAppRuntime_DLL/WindowsAppRuntime_DLL.vcxproj @@ -85,17 +85,18 @@ - - - - + - - + + + + + + diff --git a/dev/WindowsAppRuntime_DLL/pch.h b/dev/WindowsAppRuntime_DLL/pch.h index ec070ce0f0..906db93edd 100644 --- a/dev/WindowsAppRuntime_DLL/pch.h +++ b/dev/WindowsAppRuntime_DLL/pch.h @@ -2,6 +2,7 @@ // Licensed under the MIT License. #pragma once + #include #include #include @@ -33,6 +34,7 @@ #include #include +#include #include #include diff --git a/specs/msix.package/MSIX.Package.md b/specs/msix.package/MSIX.Package.md new file mode 100644 index 0000000000..d6b79df593 --- /dev/null +++ b/specs/msix.package/MSIX.Package.md @@ -0,0 +1,366 @@ +# 1. MSIX Package + +This feature provides APIs to query packages and related information including identity, location, +display information and other properties of a package. + +These APIs provide functionality similar to Windows.ApplicationModel.Package, +Windows.Management.Deployment.PackageManager.Find*() and appmodel.h but without their limitations. +This also provides the start and foundation of Undocked Deployment. + +# 2. Background + +MSIX packages on a system can be queried since Windows 8, but as MSIX has evolved so too have the +package query and management APIs and information. Existing APIs have been under perpetual +enhancement. Windows App SDK provides the opportunity to provide Undocked APIs with polyfill +implementations so enhancements are available to downlevel systems and not just the latest release +of Windows. + +Microsoft-internal task [TODO](https://task.ms/TODO) + +This is the spec for proposal [Undocked Package APIs #TODO](https://github.com/microsoft/WindowsAppSDK/issues/TODO). + +# 3. Description + +TODO + +# 4. Examples + +Samples illustrating the Package APIs + +- [Sample 1](sample-1.md) - [TODO](sample-1.md) + +# 5. Remarks + +TODO + +## 5.1. API Overview + +TODO + +# 6. API Details + +## 6.1. WinRT API + +```c# (but really MIDL3) +namespace Microsoft.Windows.ApplicationModel +{ + [contractversion(1)] + apicontract PackageContract{}; + + [contract(PackageContract, 1)] + runtimeclass PackageStatus + { + // Equivalent to a W.AM.PackageStatus object + PackageStatus(Windows.ApplicationModel.PackageStatus packageStatus); + + Boolean IsOK { get; }; + + Boolean NotAvailable { get; }; + Boolean PackageOffline { get; }; + Boolean DataOffline { get; }; + Boolean Disabled { get; }; + + Boolean NeedsRemediation { get; }; + Boolean LicenseIssue { get; }; + Boolean Modified { get; }; + Boolean Tampered { get; }; + Boolean DependencyIssue { get; }; + + Boolean Servicing { get; }; + Boolean DeploymentInProgress { get; }; + } + + [contract(PackageContract, 1)] + enum PackageSignatureKind + { + None = 0, + Developer = 1, + Enterprise = 2, //TODO Rename? + Store = 3, + System = 4, + }; + + [contract(PackageContract, 1)] + runtimeclass FindPackageOptions + { + FindPackageOptions(); + + Windows.System.User User; + String PackageFullName; + String PackageFamilyName; + String PackageName; + String PackagePublisher; + String PackagePublisherId; + Boolean IsMain; + Boolean IsFramework; + Boolean IsResource; + Boolean IsOptional; + Boolean IsOptionalInRelatedSet; + Boolean IsOptionalNotInRelatedSet; + Boolean IsBundle; + Boolean IsProvisioned; + }; + + [contract(PackageContract, 1)] + runtimeclass Package + { + // Equivalent to a W.AM.Package object + Package(Windows.ApplicationModel.Package package); + + // Equivalent to W.AM.Package.Current + static Package GetCurrent(); + + PackageDisplayInfo DisplayInfo { get; }; + + PackageLocation Location { get; }; + + PackageIdentity Identity { get; }; + + PackageGraph PackageGraph { get; }; + + PackageInstallInfo Install { get; }; //TODO Rename InstallInfo? Rename all to *Info? + + PackageApplications Applications { get; }; + + PackageContentGroups ContentGroups { get; }; + + // Equivalent to W.M.D.PackageManager.FindPackage(String) + static Package FindPackage(String packageFullName); + + // Equivalent to W.M.D.PackageManager.FindPackageForUser(String, String) + static Package FindPackage(Windows.System.User user, String packageFullName); + + // Equivalent to W.M.D.PackageManager.FindPackages() + static IVector FindPackages(); + + // Equivalent to W.M.D.PackageManager.FindPackages(String) + static IVector FindPackages(String packagFamilyName); + + // Equivalent to W.M.D.PackageManager.FindPackages(String, String) + [method_name("FindPackagesByNameAndPublisher")] + static IVector FindPackages(String packageName, String packagePublisher); + + // Equivalent to W.M.D.PackageManager.FindPackagesForUser(String) + static IVector FindPackagesForUser(Windows.System.User user); + + // Equivalent to W.M.D.PackageManager.FindPackagesForUser(String, String) + [method_name("FindPackagesByUserAndFamilyName")] + static IVector FindPackagesForUser(Windows.System.User user, String packagFamilyName); + + // Equivalent to W.M.D.PackageManager.FindPackagesForUser(String, String, String) + [method_name("FindPackagesByUserAndNameAndPublisher")] + static IVector FindPackagesForUser(Windows.System.User user, String packageName, String packagePublisher); + + // Equivalent to W.M.D.PackageManager.FindPackagesForUserWithPackageTypes(String, PackageTypes) + [method_name("FindPackagesByUserAndPackageType")] + static IVector FindPackagesForUserWithPackageTypes(Windows.System.User user, Windows.Management.Deployment.PackageTypes types); + + // Equivalent to W.M.D.PackageManager.FindPackagesForUserWithPackageTypes(String, String, PackageTypes) + [method_name("FindPackagesByUserAndFamilyNameAndPackageType")] + static IVector FindPackagesForUserWithPackageTypes(Windows.System.User user, String packagFamilyName, Windows.Management.Deployment.PackageTypes types); + + // Equivalent to W.M.D.PackageManager.FindPackagesForUserWithPackageTypes(String, String, String, PackageTypes) + [method_name("FindPackagesByUserAndNameAndPublisherAndPackageType")] + static IVector FindPackagesForUserWithPackageTypes(Windows.System.User user, String packageName, String packagePublisher, Windows.Management.Deployment.PackageTypes types); + + // Equivalent to W.M.D.PackageManager.FindProvisionedPackages() + static IVector FindProvisionedPackages(); + + static Package FindPackageWithOptions(FindPackageOptions options); + static IVector FindPackagesWithOptions(FindPackageOptions options); + + Windows.Management.Deployment.PackageTypes PackageType { get; }; + + Boolean IsMain { get; }; + Boolean IsFramework { get; }; + Boolean IsResource { get; }; + Boolean IsOptional { get; }; + Boolean IsOptionalInRelatedSet { get; }; + Boolean IsBundle { get; }; + + Boolean IsDevelopmentMode { get; }; + + Boolean IsStub { get; }; + + Boolean IsSigned { get; }; + Microsoft.Windows.ApplicationModel.PackageSignatureKind SignatureKind { get; }; + + Microsoft.Windows.ApplicationModel.PackageStatus Status { get; }; + + Windows.Foundation.IAsyncOperation CheckUpdateAvailabilityAsync(); + + Windows.Foundation.IAsyncOperation SetInUseAsync(Boolean inUse); + + Windows.Foundation.IAsyncOperation VerifyContentIntegrityAsync(); + + Windows.ApplicationModel.Package W_AM_Package { get; }; + } + + [contract(PackageContract, 1)] + runtimeclass PackageDisplayInfo + { + PackageDisplayInfo(Microsoft.Windows.ApplicationModel.Package package); + + String DisplayName { get; }; + String PublisherDisplayName { get; }; + String Description { get; }; + + String LogoFilename { get; }; + Windows.Foundation.Uri LogoUri { get; }; + Windows.Storage.Streams.RandomAccessStreamReference GetLogoStream(Windows.Foundation.Size size); + //TODO LogoImage() returning the image as byte[]? Image? ??? + } + + [contract(PackageContract, 1)] + runtimeclass PackageLocation + { + PackageLocation(Microsoft.Windows.ApplicationModel.Package package); + + // Alias for .EffectivePath + String Path { get; }; + + // Alias for .EffectiveLocation + Windows.Storage.StorageFolder Location { get; }; + + String InstalledPath { get; }; + String MutablePath { get; }; + String EffectivePath { get; }; + String EffectiveExternalPath { get; }; + String UserEffectiveExternalPath { get; }; + String MachineEffectiveExternalPath { get; }; + + Windows.Storage.StorageFolder InstalledLocation { get; }; + Windows.Storage.StorageFolder MutableLocation { get; }; + Windows.Storage.StorageFolder EffectiveLocation { get; }; + Windows.Storage.StorageFolder EffectiveExternalLocation { get; }; + Windows.Storage.StorageFolder UserEffectiveExternalLocation { get; }; + Windows.Storage.StorageFolder MachineEffectiveExternalLocation { get; }; + } + + [contract(PackageContract, 1)] + runtimeclass PackageFamilyIdentity + { + PackageFamilyIdentity(); + PackageFamilyIdentity(String name, String publisherId); + + String Name; + String PublisherId; + } + + [contract(PackageContract, 1)] + runtimeclass PackageIdentity + { + PackageIdentity(Microsoft.Windows.ApplicationModel.Package package); + + String Name { get; }; + Windows.ApplicationModel.PackageVersion Version { get; }; + Windows.System.ProcessorArchitecture Architecture { get; }; + String ResouceId { get; }; + String Publisher { get; }; + String PublisherId { get; }; + + String PackageFullName { get; }; + String PackageFamilyName { get; }; + + // Equivalent to PackageFullNameFromId(...,publisher...) in appmodel.h + static String FormatPackageFullName(String packagename, Windows.ApplicationModel.PackageVersion version, Windows.System.ProcessorArchitecture architecture, String resourceId, String publisher); + + // Equivalent to PackageFullNameFromId(...,publisherid...) in appmodel.h + static String FormatPackageFullNameGivenPublisherId(String packagename, Windows.ApplicationModel.PackageVersion version, Windows.System.ProcessorArchitecture architecture, String resourceId, String publisherId); + + // Equivalent to PackageIdFromFullName() in appmodel.h + static PackageIdentity ParsePackageFullName(String packageFullName); + + // Equivalent to PackageFamilyNameFromFullName() in appmodel.h + static String FormatPackageFamilyName(String packageFullName); + + // Equivalent to PackageFamilyNameFromId(...publisher...) in appmodel.h + static String FormatPackageFamilyName(String packagename, String publisher); + + // Equivalent to PackageFamilyNameFromId(...publisherid...) in appmodel.h + static String FormatPackageFamilyNameGivenPublisherId(String packagename, String publisherId); + + // Equivalent to PackageNameAndPublisherIdFromFamilyName() in appmodel.h + static PackageFamilyIdentity ParsePackageFamilyName(String packageFamilyName); + + // Equivalent to VerifyPackageId(...publisher...) in appmodel.h + static Boolean VerifyPackageId(String packagename, Windows.ApplicationModel.PackageVersion version, Windows.System.ProcessorArchitecture architecture, String resourceId, String publisher); + + // Equivalent to VerifyPackageId(...publisherid...) in appmodel.h + static Boolean VerifyPackageIdGivenPublisherId(String packagename, Windows.ApplicationModel.PackageVersion version, Windows.System.ProcessorArchitecture architecture, String resourceId, String publisherId); + + // Equivalent to VerifyPackageFullName() in appmodel.h + static Boolean VerifyPackageFullName(String packageFullName); + + // Equivalent to VerifyFamilyName() in appmodel.h + static Boolean VerifyPackageFamilyName(String packageFullName); + } + + [contract(PackageContract, 1)] + enum PackageRelationship + { + Dependencies = 0, + Dependents, + All + }; + + [contract(PackageContract, 1)] + runtimeclass FindRelatedPackagesOptions + { + FindRelatedPackagesOptions(PackageRelationship Relationship); + + PackageRelationship Relationship; + Boolean IncludeFrameworks; + Boolean IncludeHostRuntimes; + Boolean IncludeOptionals; + Boolean IncludeResources; + }; + + [contract(PackageContract, 1)] + runtimeclass PackageGraph + { + PackageGraph(Microsoft.Windows.ApplicationModel.Package package); + + IVector FindRelatedPackages(); + + IVector FindRelatedPackages(FindRelatedPackagesOptions options); + } + + [contract(PackageContract, 1)] + runtimeclass PackageInstallInfo + { + PackageInstallInfo(Microsoft.Windows.ApplicationModel.Package package); + + Windows.Foundation.DateTime WhenFirstRegisteredForUser { get; }; + + // Equivalent to W.AM.Package.InstalledDate + Windows.Foundation.DateTime WhenLastRegisteredForUser { get; }; + + // Equivalent to W.AM.Package.AppInstallerInfo + Windows.ApplicationModel.AppInstallerInfo GetAppInstallerInfo(); + + // Equivalent to W.AM.Package.SourceUriSchemeName + String SourceUriSchemeName { get; }; + } + + [contract(PackageContract, 1)] + runtimeclass PackageApplications + { + PackageApplications(Microsoft.Windows.ApplicationModel.Package package); + + IVector GetAppListEntries(); + Windows.Foundation.IAsyncOperation > GetAppListEntriesAsync(); + } + + [contract(PackageContract, 1)] + runtimeclass PackageContentGroups + { + PackageContentGroups(Microsoft.Windows.ApplicationModel.Package package); + + Windows.Foundation.IAsyncOperation GetContentGroupAsync(String name); + Windows.Foundation.IAsyncOperation > GetContentGroupsAsync(); + + Windows.Foundation.IAsyncOperation > StageContentGroups(); + } +} +``` diff --git a/test/DynamicDependency/data/Microsoft.WindowsAppRuntime.Framework/appxmanifest.xml b/test/DynamicDependency/data/Microsoft.WindowsAppRuntime.Framework/appxmanifest.xml index fecee5598d..9e85f588c2 100644 --- a/test/DynamicDependency/data/Microsoft.WindowsAppRuntime.Framework/appxmanifest.xml +++ b/test/DynamicDependency/data/Microsoft.WindowsAppRuntime.Framework/appxmanifest.xml @@ -44,6 +44,23 @@ + + + Microsoft.WindowsAppRuntime.dll + + + + + + + + + + + + + + Microsoft.WindowsAppRuntime.dll