Skip to content

Commit

Permalink
Workloads (microsoft#4010)
Browse files Browse the repository at this point in the history
  • Loading branch information
DrusTheAxe authored Dec 4, 2023
1 parent f0d6f3b commit 74a5990
Show file tree
Hide file tree
Showing 18 changed files with 558 additions and 62 deletions.
8 changes: 8 additions & 0 deletions WindowsAppRuntime.sln
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PackageManager.Test.F.Redde
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PackageManager.Test.F.Redder.msix", "test\PackageManager\data\PackageManager.Test.F.Redder.msix\PackageManager.Test.F.Redder.msix.vcxproj", "{D0A1DFB8-8CEE-4CFC-B57B-B7C574B411C2}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Workloads", "Workloads", "{48948EF9-8B91-4F7A-98AD-0F8FA3EFAA38}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Workloads", "dev\Workloads\Workloads.vcxitems", "{B5798CEB-4E60-4D2D-B456-7C406B5F5B67}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -2584,6 +2588,8 @@ Global
{FBAE1876-C50A-4EFC-A686-3008B6438731} = {39A17DBB-F1DB-4D0C-B90E-D5F9BEC2283A}
{B6B68924-6A0B-457E-AD53-018696EC8889} = {B03C7C69-0A52-4553-B465-04C995161E42}
{D0A1DFB8-8CEE-4CFC-B57B-B7C574B411C2} = {B6B68924-6A0B-457E-AD53-018696EC8889}
{48948EF9-8B91-4F7A-98AD-0F8FA3EFAA38} = {448ED2E5-0B37-4D97-9E6B-8C10A507976A}
{B5798CEB-4E60-4D2D-B456-7C406B5F5B67} = {48948EF9-8B91-4F7A-98AD-0F8FA3EFAA38}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4B3D7591-CFEC-4762-9A07-ABE99938FB77}
Expand All @@ -2607,12 +2613,14 @@ Global
dev\Kozani\Common\Common.vcxitems*{a11c6664-f26a-4e71-b440-2e4e1ba09a93}*SharedItemsImports = 4
dev\AppNotifications\AppNotifications.vcxitems*{b4824897-88e0-4927-8fb9-e60106f01ed9}*SharedItemsImports = 9
test\inc\inc.vcxitems*{b567fe2e-3a03-48d0-b2b5-760cdec35891}*SharedItemsImports = 9
dev\Workloads\Workloads.vcxitems*{b5798ceb-4e60-4d2d-b456-7c406b5f5b67}*SharedItemsImports = 9
dev\Common\Common.vcxitems*{b73ad907-6164-4294-88fb-f3c9c10da1f1}*SharedItemsImports = 4
dev\DynamicDependency\API\DynamicDependency.vcxitems*{b73ad907-6164-4294-88fb-f3c9c10da1f1}*SharedItemsImports = 4
dev\Licensing\Licensing.vcxitems*{b73ad907-6164-4294-88fb-f3c9c10da1f1}*SharedItemsImports = 4
dev\PackageManager\API\PackageManager.vcxitems*{b73ad907-6164-4294-88fb-f3c9c10da1f1}*SharedItemsImports = 4
dev\PowerNotifications\PowerNotifications.vcxitems*{b73ad907-6164-4294-88fb-f3c9c10da1f1}*SharedItemsImports = 4
dev\UndockedRegFreeWinRT\UndockedRegFreeWinRT.vcxitems*{b73ad907-6164-4294-88fb-f3c9c10da1f1}*SharedItemsImports = 4
dev\Workloads\Workloads.vcxitems*{b73ad907-6164-4294-88fb-f3c9c10da1f1}*SharedItemsImports = 4
dev\PowerNotifications\PowerNotifications.vcxitems*{b75c1b22-553c-40e4-b38e-6ab4d01fdb9d}*SharedItemsImports = 9
dev\DynamicDependency\API\DynamicDependency.vcxitems*{bf055a59-0919-4e34-9b76-dd055495cc5a}*SharedItemsImports = 9
test\inc\inc.vcxitems*{c62688a1-16a0-4729-b6ed-842f4faa29f3}*SharedItemsImports = 4
Expand Down
2 changes: 2 additions & 0 deletions build/CopyFilesToStagingDir.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\StrippedWinMD\Microsoft.Windo
PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\StrippedWinMD\Microsoft.Windows.Security.AccessControl.winmd $FullPublishDir\Microsoft.WindowsAppRuntime\
PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\StrippedWinMD\Microsoft.Windows.System.Power.winmd $FullPublishDir\Microsoft.WindowsAppRuntime\
PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\StrippedWinMD\Microsoft.Windows.System.winmd $FullPublishDir\Microsoft.WindowsAppRuntime\
PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\StrippedWinMD\Microsoft.Windows.System.Workloads.winmd $FullPublishDir\Microsoft.WindowsAppRuntime\
PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\MsixDynamicDependency.h $FullPublishDir\Microsoft.WindowsAppRuntime\
PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\wil_msixdynamicdependency.h $FullPublishDir\Microsoft.WindowsAppRuntime\
PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\Security.AccessControl.h $FullPublishDir\Microsoft.WindowsAppRuntime\
Expand Down Expand Up @@ -179,6 +180,7 @@ PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\StrippedWinMD\Microsoft.Windo
PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\StrippedWinMD\Microsoft.Windows.Management.Deployment.winmd $NugetDir\lib\uap10.0
PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\StrippedWinMD\Microsoft.Windows.PushNotifications.winmd $NugetDir\lib\uap10.0
PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\StrippedWinMD\Microsoft.Windows.Security.AccessControl.winmd $NugetDir\lib\uap10.0
PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\StrippedWinMD\Microsoft.Windows.System.Workloads.winmd $NugetDir\lib\uap10.0
PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\StrippedWinMD\Microsoft.Windows.System.Power.winmd $NugetDir\lib\uap10.0
PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\StrippedWinMD\Microsoft.Windows.System.winmd $NugetDir\lib\uap10.0
#
Expand Down
32 changes: 32 additions & 0 deletions dev/Common/TerminalVelocityFeatures-Workloads.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.

// THIS FILE IS AUTOMATICALLY GENERATED; DO NOT EDIT IT

// INPUT FILE: dev\common\TerminalVelocityFeatures-Workloads.xml
// OPTIONS: -Channel Experimental -Language C++ -Namespace Microsoft.Windows.System.Workloads -Path dev\common\TerminalVelocityFeatures-Workloads.xml -Output dev\common\TerminalVelocityFeatures-Workloads.h

#if defined(__midlrt)
namespace features
{
feature_name Feature_Workloads = { DisabledByDefault, FALSE };
}
#endif // defined(__midlrt)

// Feature constants
#define WINDOWSAPPRUNTIME_MICROSOFT_WINDOWS_SYSTEM_WORKLOADS_FEATURE_WORKLOADS_ENABLED 1

#if defined(__cplusplus)

namespace Microsoft::Windows::System::Workloads
{

__pragma(detect_mismatch("ODR_violation_WINDOWSAPPRUNTIME_MICROSOFT_WINDOWS_SYSTEM_WORKLOADS_FEATURE_WORKLOADS_ENABLED_mismatch", "AlwaysEnabled"))
struct Feature_Workloads
{
static constexpr bool IsEnabled() { return WINDOWSAPPRUNTIME_MICROSOFT_WINDOWS_SYSTEM_WORKLOADS_FEATURE_WORKLOADS_ENABLED == 1; }
};

} // namespace Microsoft.Windows.System.Workloads

#endif // defined(__cplusplus)
20 changes: 20 additions & 0 deletions dev/Common/TerminalVelocityFeatures-Workloads.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0"?>
<features xmlns="http://microsoft.com/windowsappsdk/TerminalVelocity/20210729/TerminalVelocityFeatures.xsd">

<!-- Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the MIT License. See LICENSE in the project root for license information.
-->

<!-- See docs/TerminalVelocity.md for more info. -->

<!-- Enabled variants -->
<feature>
<name>Feature_Workloads</name>
<description>Workloads APIs</description>
<state>AlwaysEnabled</state>
<alwaysDisabledChannelTokens>
<channelToken>Preview</channelToken>
<channelToken>Stable</channelToken>
</alwaysDisabledChannelTokens>
</feature>
</features>
1 change: 1 addition & 0 deletions dev/WindowsAppRuntime_DLL/WindowsAppRuntime_DLL.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
<Import Project="..\EnvironmentManager\ChangeTracker\ChangeTracker.vcxitems" Label="ChangeTracker" />
<Import Project="..\VersionInfo\VersionInfo.vcxitems" Label="VersionInfo" />
<Import Project="..\PackageManager\API\PackageManager.vcxitems" Label="Shared" />
<Import Project="..\Workloads\Workloads.vcxitems" Label="Shared" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
Expand Down
39 changes: 39 additions & 0 deletions dev/Workloads/M.W.S.W.Workload.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.

#include "pch.h"

#include "M.W.S.W.Workload.h"
#include "Microsoft.Windows.System.Workloads.Workload.g.cpp"

#include <wil/winrt.h>

namespace winrt::Microsoft::Windows::System::Workloads::implementation
{
Workload::Workload(hstring const& id, hstring const& displayName, hstring const& workloadHandlerActivatableClassId) :
m_id(id),
m_displayName(displayName),
m_workloadHandlerActivatableClassId(m_workloadHandlerActivatableClassId)
{
}
hstring Workload::Id()
{
return m_id;
}
hstring Workload::DisplayName()
{
return m_displayName;
}
hstring Workload::WorkloadHandlerActivatableClassId()
{
return m_workloadHandlerActivatableClassId;
}
winrt::Microsoft::Windows::System::Workloads::IWorkloadHandler Workload::WorkloadHandler()
{
if (!m_workloadHandler)
{
//TODO
}
return m_workloadHandler;
}
}
32 changes: 32 additions & 0 deletions dev/Workloads/M.W.S.W.Workload.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.

#pragma once

#include "Microsoft.Windows.System.Workloads.Workload.g.h"

namespace winrt::Microsoft::Windows::System::Workloads::implementation
{
struct Workload : WorkloadT<Workload>
{
Workload() = default;
Workload(hstring const& id, hstring const& displayName, hstring const& workloadHandlerActivatableClassId);

hstring Id();
hstring DisplayName();
hstring WorkloadHandlerActivatableClassId();
winrt::Microsoft::Windows::System::Workloads::IWorkloadHandler WorkloadHandler();

private:
hstring m_id;
hstring m_displayName;
hstring m_workloadHandlerActivatableClassId;
winrt::Microsoft::Windows::System::Workloads::IWorkloadHandler m_workloadHandler{};
};
}
namespace winrt::Microsoft::Windows::System::Workloads::factory_implementation
{
struct Workload : WorkloadT<Workload, implementation::Workload>
{
};
}
62 changes: 62 additions & 0 deletions dev/Workloads/M.W.S.W.WorkloadManager.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.

#include "pch.h"

#include "M.W.S.W.WorkloadManager.h"
#include "Microsoft.Windows.System.Workloads.WorkloadManager.g.cpp"

namespace winrt::Microsoft::Windows::System::Workloads::implementation
{
winrt::Microsoft::Windows::System::Workloads::WorkloadManager WorkloadManager::GetDefault()
{
return winrt::make<winrt::Microsoft::Windows::System::Workloads::implementation::WorkloadManager>();
}
winrt::Microsoft::Windows::System::Workloads::Workload WorkloadManager::GetWorkload(hstring const& workloadId)
{
//TODO winrt::Windows::Foundation::Collections::IPropertySet properties;
//TODO THROW_IF_FAILED(FrameworkUDk.PackageManagementWorkloads_GetWorkload(workloadId.c_str(), wil::out_param(properties)));
//TODO
//TODO auto id{ properties.Lookup(L"Id").as<winrt::Windows::Foundation::IPropertyValue>() };
//TODO THROW_HR_IF_NULL(E_UNEXPECTED, id);
//TODO THROW_HR_IF(E_UNEXPECTED, id.Type() != winrt::Windows::Foundation::PropertyType::String);
//TODO
//TODO auto displayName{ properties.Lookup(L"DisplayName").as<winrt::Windows::Foundation::IPropertyValue>() };
//TODO THROW_HR_IF_NULL(E_UNEXPECTED, displayName);
//TODO THROW_HR_IF(E_UNEXPECTED, displayName.Type() != winrt::Windows::Foundation::PropertyType::String);
//TODO
//TODO winrt::hstring action_remove_activatableClassId;
//TODO {
//TODO auto actions{ properties.Lookup(L"Actions").as<winrt::Windows::Foundation::IPropertyValue>() };
//TODO THROW_HR_IF_NULL(E_UNEXPECTED, actions);
//TODO THROW_HR_IF(E_UNEXPECTED, actions.Type() != winrt::Windows::Foundation::PropertyType::Inspectable);
//TODO auto actions_remove{ actions.Lookup(L"Actions").as<winrt::Windows::Foundation::IPropertyValue>() };
//TODO if (actions_remove)
//TODO {
//TODO THROW_HR_IF(E_UNEXPECTED, actions_remove.Type() != winrt::Windows::Foundation::PropertyType::Inspectable);
//TODO action_remove_activatableClassId = properties.Lookup(L"@ActivatableClassId").as<winrt::Windows::Foundation::IPropertyValue>() };
//TODO THROW_HR_IF_NULL(E_UNEXPECTED, action_remove_activatableClassId);
//TODO THROW_HR_IF(E_UNEXPECTED, action_remove_activatableClassId.Type() != winrt::Windows::Foundation::PropertyType::String);
//TODO }
//TODO }
//TODO
//TODO return winrt::make<winrt::Microsoft::Windows::System::Workloads::implementation::Workload>(id.GetString(), displayName.GetString(), action_remove_activatableClassId.GetString());

throw hresult_not_implemented();
}
winrt::Windows::Foundation::Collections::IVector<hstring> WorkloadManager::FindIds()
{
auto ids{ winrt::single_threaded_vector<hstring>() };

//TODO wil::unique_cotaskmem_ptr<PWSTR[]> workloadIds;
//TODO uint32_t workloadIdsCount{};
//TODO THROW_IF_FAILED(FrameworkUDk.PackageManagementWorkloads_FindIds(&workloadIdsCount, wil::out_param(workloadIds)));
//TODO for (uint32_t index=0; index < workloadIdsCount; ++index)
//TODO {
//TODO const winrt::hstring id{ workloadIds[index] };
//TODO ids.Append(id);
//TODO }

return ids;
}
}
24 changes: 24 additions & 0 deletions dev/Workloads/M.W.S.W.WorkloadManager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.

#pragma once

#include "Microsoft.Windows.System.Workloads.WorkloadManager.g.h"

namespace winrt::Microsoft::Windows::System::Workloads::implementation
{
struct WorkloadManager : WorkloadManagerT<WorkloadManager>
{
WorkloadManager() = default;

static winrt::Microsoft::Windows::System::Workloads::WorkloadManager GetDefault();
winrt::Microsoft::Windows::System::Workloads::Workload GetWorkload(hstring const& id);
winrt::Windows::Foundation::Collections::IVector<hstring> FindIds();
};
}
namespace winrt::Microsoft::Windows::System::Workloads::factory_implementation
{
struct WorkloadManager : WorkloadManagerT<WorkloadManager, implementation::WorkloadManager>
{
};
}
27 changes: 27 additions & 0 deletions dev/Workloads/M.W.S.W.WorkloadProgress.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.

#include "pch.h"

#include "M.W.S.W.WorkloadProgress.h"
#include "Microsoft.Windows.System.Workloads.WorkloadProgress.g.cpp"

namespace winrt::Microsoft::Windows::System::Workloads::implementation
{
winrt::Microsoft::Windows::System::Workloads::WorkloadProgressStatus WorkloadProgress::status()
{
return m_status;
}
void WorkloadProgress::status(winrt::Microsoft::Windows::System::Workloads::WorkloadProgressStatus const& value)
{
m_status = value;
}
double WorkloadProgress::percentage()
{
return m_percentage;
}
void WorkloadProgress::percentage(double value)
{
m_percentage = value;
}
}
23 changes: 23 additions & 0 deletions dev/Workloads/M.W.S.W.WorkloadProgress.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.

#pragma once

#include "Microsoft.Windows.System.Workloads.WorkloadProgress.g.h"

namespace winrt::Microsoft::Windows::System::Workloads::implementation
{
struct WorkloadProgress : WorkloadProgressT<WorkloadProgress>
{
WorkloadProgress() = default;

winrt::Microsoft::Windows::System::Workloads::WorkloadProgressStatus status();
void status(winrt::Microsoft::Windows::System::Workloads::WorkloadProgressStatus const& value);
double percentage();
void percentage(double value);

private:
winrt::Microsoft::Windows::System::Workloads::WorkloadProgressStatus m_status{};
double m_percentage{};
};
}
19 changes: 19 additions & 0 deletions dev/Workloads/M.W.S.W.WorkloadResult.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.

#include "pch.h"

#include "M.W.S.W.WorkloadResult.h"
#include "Microsoft.Windows.System.Workloads.WorkloadResult.g.cpp"

namespace winrt::Microsoft::Windows::System::Workloads::implementation
{
winrt::Microsoft::Windows::System::Workloads::WorkloadStatus WorkloadResult::Status()
{
return m_status;
}
winrt::hresult WorkloadResult::ExtendedError()
{
return m_extendedError;
}
}
21 changes: 21 additions & 0 deletions dev/Workloads/M.W.S.W.WorkloadResult.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.

#pragma once

#include "Microsoft.Windows.System.Workloads.WorkloadResult.g.h"

namespace winrt::Microsoft::Windows::System::Workloads::implementation
{
struct WorkloadResult : WorkloadResultT<WorkloadResult>
{
WorkloadResult() = default;

winrt::Microsoft::Windows::System::Workloads::WorkloadStatus Status();
winrt::hresult ExtendedError();

private:
winrt::Microsoft::Windows::System::Workloads::WorkloadStatus m_status{};
winrt::hresult m_extendedError{};
};
}
Loading

0 comments on commit 74a5990

Please sign in to comment.