Skip to content

Commit b3951a4

Browse files
authored
User/aeloros/get args (#268)
* Initial template for the AppLifecycle object and it's tests. * Initial set of components * Basic Launch and Protocol support * Move registration methods to new runtimeclass. Stub out new ancillary interfaces on the event args classes. * Remove samples from the project dll. * Remove work for file type associations for now. Remove shared samples completely. * Block registration for packaged apps (they should use their manifest for v1). Make GetActivatedEventArgs defer to the platform for packaged apps. * Add LaunchActivatedEventArgs test. * Remove unneeded interfaces. * use a static const wstring instead of a C define for comparison. * PR feedback around default constructor. * PR feedback * PR feedback * PR Feedback * PR Feedback
1 parent dfb500d commit b3951a4

32 files changed

+534
-370
lines changed

ProjectReunion.sln

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ VisualStudioVersion = 16.0.30011.22
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dev", "dev", "{448ED2E5-0B37-4D97-9E6B-8C10A507976A}"
77
EndProject
8-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SampleWinRT", "SampleWinRT", "{428CCA9E-ADC5-4917-B51B-7D13E35950C5}"
9-
EndProject
108
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{F3659DFF-232D-46E0-967E-61FCC9A1132F}"
119
ProjectSection(SolutionItems) = preProject
1210
docs\contributor-guide.md = docs\contributor-guide.md
@@ -15,12 +13,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{F3659DFF-2
1513
docs\roadmap.md = docs\roadmap.md
1614
EndProjectSection
1715
EndProject
18-
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SampleWinRT", "dev\SampleWinRT\SampleWinRT.vcxitems", "{0DE4FEFE-5471-4B50-B74B-D817A02B7F0D}"
19-
EndProject
20-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SampleFlatC", "SampleFlatC", "{8A5C2FE6-86D7-4AAA-BE2E-924B8E03B888}"
21-
EndProject
22-
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SampleFlatC", "dev\SampleFlatC\SampleFlatC.vcxitems", "{CDCE22EC-F7BF-43D4-95D8-2E786229A4E5}"
23-
EndProject
2416
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{8630F7AA-2969-4DC9-8700-9B468C1DC21D}"
2517
EndProject
2618
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CppShared", "test\CppShared\CppShared.vcxitems", "{682DED8C-3A27-48CD-866D-E853EA2024DE}"
@@ -31,15 +23,19 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CppTest_Win32", "test\CppTe
3123
EndProject
3224
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CppTest_UWP", "test\CppTest_UWP\CppTest_UWP.vcxproj", "{B1A6F5EC-5418-4354-BACF-F7D998EE960D}"
3325
EndProject
26+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AppLifecycle", "AppLifecycle", "{3DE93B2F-F887-437D-B512-6B1024ABA290}"
27+
EndProject
28+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AppLifecycle", "dev\AppLifecycle\AppLifecycle.vcxitems", "{E3A522A3-6635-4A42-BDED-1AF46A15F63C}"
29+
EndProject
30+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AppLifecycle", "test\AppLifecycle\AppLifecycle.vcxitems", "{80E07022-9E99-44FE-B875-901FB6C82F52}"
31+
EndProject
3432
Global
3533
GlobalSection(SharedMSBuildProjectFiles) = preSolution
36-
dev\SampleWinRT\SampleWinRT.vcxitems*{0de4fefe-5471-4b50-b74b-d817a02b7f0d}*SharedItemsImports = 9
3734
test\CppShared\CppShared.vcxitems*{682ded8c-3a27-48cd-866d-e853ea2024de}*SharedItemsImports = 9
35+
test\AppLifecycle\AppLifecycle.vcxitems*{80e07022-9e99-44fe-b875-901fb6c82f52}*SharedItemsImports = 9
3836
test\CppShared\CppShared.vcxitems*{b1a6f5ec-5418-4354-bacf-f7d998ee960d}*SharedItemsImports = 4
39-
dev\SampleFlatC\SampleFlatC.vcxitems*{b73ad907-6164-4294-88fb-f3c9c10da1f1}*SharedItemsImports = 4
40-
dev\SampleWinRT\SampleWinRT.vcxitems*{b73ad907-6164-4294-88fb-f3c9c10da1f1}*SharedItemsImports = 4
4137
test\CppShared\CppShared.vcxitems*{c62688a1-16a0-4729-b6ed-842f4faa29f3}*SharedItemsImports = 4
42-
dev\SampleFlatC\SampleFlatC.vcxitems*{cdce22ec-f7bf-43d4-95d8-2e786229a4e5}*SharedItemsImports = 9
38+
dev\AppLifecycle\AppLifecycle.vcxitems*{e3a522a3-6635-4a42-bded-1af46a15f63c}*SharedItemsImports = 9
4339
EndGlobalSection
4440
GlobalSection(SolutionConfigurationPlatforms) = preSolution
4541
Debug_test|Any CPU = Debug_test|Any CPU
@@ -157,14 +153,13 @@ Global
157153
HideSolutionNode = FALSE
158154
EndGlobalSection
159155
GlobalSection(NestedProjects) = preSolution
160-
{428CCA9E-ADC5-4917-B51B-7D13E35950C5} = {448ED2E5-0B37-4D97-9E6B-8C10A507976A}
161-
{0DE4FEFE-5471-4B50-B74B-D817A02B7F0D} = {428CCA9E-ADC5-4917-B51B-7D13E35950C5}
162-
{8A5C2FE6-86D7-4AAA-BE2E-924B8E03B888} = {448ED2E5-0B37-4D97-9E6B-8C10A507976A}
163-
{CDCE22EC-F7BF-43D4-95D8-2E786229A4E5} = {8A5C2FE6-86D7-4AAA-BE2E-924B8E03B888}
164156
{682DED8C-3A27-48CD-866D-E853EA2024DE} = {8630F7AA-2969-4DC9-8700-9B468C1DC21D}
165157
{B73AD907-6164-4294-88FB-F3C9C10DA1F1} = {448ED2E5-0B37-4D97-9E6B-8C10A507976A}
166158
{C62688A1-16A0-4729-B6ED-842F4FAA29F3} = {8630F7AA-2969-4DC9-8700-9B468C1DC21D}
167159
{B1A6F5EC-5418-4354-BACF-F7D998EE960D} = {8630F7AA-2969-4DC9-8700-9B468C1DC21D}
160+
{3DE93B2F-F887-437D-B512-6B1024ABA290} = {448ED2E5-0B37-4D97-9E6B-8C10A507976A}
161+
{E3A522A3-6635-4A42-BDED-1AF46A15F63C} = {3DE93B2F-F887-437D-B512-6B1024ABA290}
162+
{80E07022-9E99-44FE-B875-901FB6C82F52} = {8630F7AA-2969-4DC9-8700-9B468C1DC21D}
168163
EndGlobalSection
169164
GlobalSection(ExtensibilityGlobals) = postSolution
170165
SolutionGuid = {4B3D7591-CFEC-4762-9A07-ABE99938FB77}

build/CopyFilesToStagingDir.ps1

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ function PublishFile {
3333

3434
PublishFile -IfExists $FullBuildOutput\projectreunion_dll\Microsoft.ProjectReunion.dll $FullPublishDir\Microsoft.ProjectReunion\
3535
PublishFile -IfExists $FullBuildOutput\projectreunion_dll\Microsoft.ProjectReunion.lib $FullPublishDir\Microsoft.ProjectReunion\
36-
PublishFile -IfExists $FullBuildOutput\projectreunion_dll\SampleFlatC.h $FullPublishDir\Microsoft.ProjectReunion\
3736
#PublishFile -IfExists $FullBuildOutput\projectreunion_dll\Microsoft.ProjectReunion.pri $FullPublishDir\Microsoft.ProjectReunion\
3837
#UNDONE - xaml vcxproj re-runs an mdmerge into the sdk node, we are skipping this for now and leaving the winmd in its normal outdir
3938
#PublishFile -IfExists $FullBuildOutput\projectreunion_dll\sdk\Microsoft.ProjectReunion.winmd $FullPublishDir\Microsoft.ProjectReunion\sdk\

build/NuSpecs/ProjectReunionFrameworkPackage.nuspec

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
<file target="lib\uap10.0" src="Intellisense\Microsoft.ProjectReunion.xml"/>
2626
<!-- C++ projects need the flat C header declarations and implib -->
2727
<file target="lib\native" src="$BUILDOUTPUT$\$BUILDFLAVOR$\$BUILDARCH$\Microsoft.ProjectReunion\Microsoft.ProjectReunion.lib" />
28-
<file target="include" src="$BUILDOUTPUT$\$BUILDFLAVOR$\$BUILDARCH$\Microsoft.ProjectReunion\SampleFlatC.h" />
2928

3029
<!-- <file target="tools" src="$TOOLSDIR$\**\*.*"/> -->
3130

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License. See LICENSE in the project root for license information.
3+
#pragma once
4+
5+
namespace winrt::Microsoft::ProjectReunion::implementation
6+
{
7+
using namespace winrt::Windows::ApplicationModel::Activation;
8+
9+
class ActivatedEventArgsBase : public winrt::implements<ActivatedEventArgsBase,
10+
IActivatedEventArgs>
11+
{
12+
public:
13+
// IActivatedEventArgs
14+
ActivationKind Kind()
15+
{
16+
return m_kind;
17+
}
18+
19+
ApplicationExecutionState PreviousExecutionState()
20+
{
21+
return m_previousState;
22+
}
23+
24+
SplashScreen SplashScreen()
25+
{
26+
return m_splashScreen;
27+
}
28+
29+
protected:
30+
ActivatedEventArgsBase() = default;
31+
32+
ActivationKind m_kind = ActivationKind::Launch;
33+
ApplicationExecutionState m_previousState;
34+
winrt::Windows::ApplicationModel::Activation::SplashScreen m_splashScreen{ nullptr };
35+
};
36+
}
37+
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License. See LICENSE in the project root for license information.
3+
#include <pch.h>
4+
#include <ActivationRegistrationManager.h>
5+
#include <ActivationRegistrationManager.g.cpp>
6+
7+
#include "LaunchActivatedEventArgs.h"
8+
#include "ProtocolActivatedEventArgs.h"
9+
#include "Shared.h"
10+
11+
namespace winrt::Microsoft::ProjectReunion::implementation
12+
{
13+
void ActivationRegistrationManager::RegisterForFileTypeActivation(hstring const& groupName,
14+
hstring const& logo, array_view<hstring const> supportedFileTypes,
15+
array_view<hstring const> supportedVerbs)
16+
{
17+
throw hresult_not_implemented();
18+
}
19+
20+
void ActivationRegistrationManager::RegisterForProtocolActivation(hstring const& scheme,
21+
hstring const& displayName)
22+
{
23+
if (scheme.empty() || displayName.empty())
24+
{
25+
throw winrt::hresult_invalid_argument();
26+
}
27+
28+
if (HasIdentity())
29+
{
30+
throw hresult_not_implemented();
31+
}
32+
33+
RegisterProtocol(scheme.c_str(), displayName.c_str());
34+
}
35+
36+
void ActivationRegistrationManager::RegisterForStartupActivation(hstring const& taskId,
37+
bool isEnabled, hstring const& displayName)
38+
{
39+
throw hresult_not_implemented();
40+
}
41+
42+
void ActivationRegistrationManager::RegisterForToastActivation(hstring const& displayName)
43+
{
44+
throw hresult_not_implemented();
45+
}
46+
47+
void ActivationRegistrationManager::UnregisterForFileTypeActivation(hstring const& groupName)
48+
{
49+
throw hresult_not_implemented();
50+
}
51+
52+
void ActivationRegistrationManager::UnregisterForProtocolActivation(hstring const& scheme)
53+
{
54+
if (scheme.empty())
55+
{
56+
throw winrt::hresult_invalid_argument();
57+
}
58+
59+
if (HasIdentity())
60+
{
61+
throw hresult_not_implemented();
62+
}
63+
64+
UnregisterProtocol(scheme.c_str());
65+
}
66+
67+
void ActivationRegistrationManager::UnregisterForStartupActivation()
68+
{
69+
throw hresult_not_implemented();
70+
}
71+
72+
void ActivationRegistrationManager::UnregisterForToastActivation()
73+
{
74+
throw hresult_not_implemented();
75+
}
76+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License. See LICENSE in the project root for license information.
3+
#pragma once
4+
5+
#include <ActivationRegistrationManager.g.h>
6+
7+
namespace winrt::Microsoft::ProjectReunion::implementation
8+
{
9+
struct ActivationRegistrationManager
10+
{
11+
ActivationRegistrationManager() = default;
12+
13+
static void RegisterForFileTypeActivation(hstring const& groupName, hstring const& logo,
14+
array_view<hstring const> supportedFileTypes, array_view<hstring const> supportedVerbs);
15+
static void RegisterForProtocolActivation(hstring const& scheme, hstring const& displayName);
16+
static void RegisterForStartupActivation(hstring const& taskId, bool isEnabled,
17+
hstring const& displayName);
18+
static void RegisterForToastActivation(hstring const& displayName);
19+
20+
static void UnregisterForFileTypeActivation(hstring const& groupName);
21+
static void UnregisterForProtocolActivation(hstring const& scheme);
22+
static void UnregisterForStartupActivation();
23+
static void UnregisterForToastActivation();
24+
};
25+
}
26+
27+
namespace winrt::Microsoft::ProjectReunion::factory_implementation
28+
{
29+
struct ActivationRegistrationManager : ActivationRegistrationManagerT<ActivationRegistrationManager,
30+
implementation::ActivationRegistrationManager>
31+
{
32+
};
33+
}

dev/AppLifecycle/AppLifecycle.cpp

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License. See LICENSE in the project root for license information.
3+
4+
#include <pch.h>
5+
#include <AppLifecycle.h>
6+
#include <AppLifecycle.g.cpp>
7+
8+
#include "LaunchActivatedEventArgs.h"
9+
#include "ProtocolActivatedEventArgs.h"
10+
#include "Shared.h"
11+
12+
namespace winrt::Microsoft::ProjectReunion::implementation
13+
{
14+
std::tuple<std::wstring, std::wstring> ParseCommandLine(std::wstring commandLine)
15+
{
16+
auto argsStart = commandLine.rfind(L"----") + 4;
17+
if (argsStart == std::wstring::npos)
18+
{
19+
return {L"", L""};
20+
}
21+
22+
// We explicitly use find_first_of here, so that the resulting data may contain : as a valid character.
23+
auto argsEnd = commandLine.find_first_of(L":", argsStart);
24+
if (argsEnd == std::wstring::npos)
25+
{
26+
return {L"", L""};
27+
}
28+
29+
if (argsStart > argsEnd)
30+
{
31+
throw std::overflow_error("commandLine");
32+
}
33+
34+
auto argsLength = argsEnd - argsStart;
35+
auto dataStart = argsEnd + 1;
36+
37+
return {commandLine.substr(argsStart, argsLength), commandLine.substr(dataStart)};
38+
}
39+
40+
Windows::ApplicationModel::Activation::IActivatedEventArgs AppLifecycle::GetActivatedEventArgs()
41+
{
42+
if (HasIdentity())
43+
{
44+
return Windows::ApplicationModel::AppInstance::GetActivatedEventArgs();
45+
}
46+
else
47+
{
48+
// Generate IActivatedEventArgs for non-Packaged applications.
49+
std::wstring contractId;
50+
std::wstring contractData;
51+
auto commandLine = std::wstring(GetCommandLine());
52+
std::tie(contractId, contractData) = ParseCommandLine(commandLine);
53+
54+
if (!contractId.empty() && contractId == c_protocolArgumentString)
55+
{
56+
return winrt::make<ProtocolActivatedEventArgs>(contractData);
57+
}
58+
59+
return winrt::make<LaunchActivatedEventArgs>(commandLine);
60+
}
61+
}
62+
}

dev/AppLifecycle/AppLifecycle.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License. See LICENSE in the project root for license information.
3+
#pragma once
4+
5+
#include <AppLifecycle.g.h>
6+
7+
namespace winrt::Microsoft::ProjectReunion::implementation
8+
{
9+
struct AppLifecycle
10+
{
11+
AppLifecycle() = default;
12+
13+
static Windows::ApplicationModel::Activation::IActivatedEventArgs GetActivatedEventArgs();
14+
};
15+
}
16+
17+
namespace winrt::Microsoft::ProjectReunion::factory_implementation
18+
{
19+
struct AppLifecycle : AppLifecycleT<AppLifecycle, implementation::AppLifecycle>
20+
{
21+
};
22+
}

dev/AppLifecycle/AppLifecycle.idl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License. See LICENSE in the project root for license information.
3+
4+
namespace Microsoft.ProjectReunion
5+
{
6+
static runtimeclass AppLifecycle
7+
{
8+
static Windows.ApplicationModel.Activation.IActivatedEventArgs GetActivatedEventArgs();
9+
}
10+
11+
static runtimeclass ActivationRegistrationManager
12+
{
13+
static void RegisterForFileTypeActivation(String groupName, String logo, String[] supportedFileTypes, String[] supportedVerbs);
14+
static void RegisterForProtocolActivation(String scheme, String displayName);
15+
static void RegisterForStartupActivation(String taskId, Boolean isEnabled, String displayName);
16+
static void RegisterForToastActivation(String displayName);
17+
18+
static void UnregisterForFileTypeActivation(String groupName);
19+
static void UnregisterForProtocolActivation(String scheme);
20+
static void UnregisterForStartupActivation();
21+
static void UnregisterForToastActivation();
22+
};
23+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup Label="Globals">
4+
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
5+
<HasSharedItems>true</HasSharedItems>
6+
<ItemsProjectGuid>{E3A522A3-6635-4A42-BDED-1AF46A15F63C}</ItemsProjectGuid>
7+
<ItemsProjectName>AppLifecycle</ItemsProjectName>
8+
</PropertyGroup>
9+
<ItemDefinitionGroup>
10+
<ClCompile>
11+
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(MSBuildThisFileDirectory)</AdditionalIncludeDirectories>
12+
</ClCompile>
13+
</ItemDefinitionGroup>
14+
<ItemGroup>
15+
<ProjectCapability Include="SourceItemsFromImports" />
16+
</ItemGroup>
17+
<ItemGroup>
18+
<ClCompile Include="$(MSBuildThisFileDirectory)ActivationRegistrationManager.cpp" />
19+
<ClCompile Include="$(MSBuildThisFileDirectory)Shared.cpp" />
20+
<ClInclude Include="$(MSBuildThisFileDirectory)ActivatedEventArgsBase.h" />
21+
<ClInclude Include="$(MSBuildThisFileDirectory)ActivationRegistrationManager.h" />
22+
<ClInclude Include="$(MSBuildThisFileDirectory)Shared.h" />
23+
<ClInclude Include="$(MSBuildThisFileDirectory)LaunchActivatedEventArgs.h" />
24+
<ClInclude Include="$(MSBuildThisFileDirectory)ProtocolActivatedEventArgs.h" />
25+
<Midl Include="$(MSBuildThisFileDirectory)AppLifecycle.idl" />
26+
<ClInclude Include="$(MSBuildThisFileDirectory)AppLifecycle.h" />
27+
<ClCompile Include="$(MSBuildThisFileDirectory)AppLifecycle.cpp" />
28+
</ItemGroup>
29+
</Project>

0 commit comments

Comments
 (0)