-
Notifications
You must be signed in to change notification settings - Fork 386
Initial implementation of AppLifecycle and ActivationRegistrationManager APIs. #268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
fff39fa
15192c2
3a4b42d
188c6a8
ec5d7db
66f11a0
76012b6
5d6099d
49ea88b
f18ab1b
2a62059
3f92d51
a7b99ee
140155c
484f8df
4d2a9e7
143d420
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. See LICENSE in the project root for license information. | ||
#pragma once | ||
|
||
namespace winrt::Microsoft::ProjectReunion::implementation | ||
{ | ||
using namespace winrt::Windows::ApplicationModel::Activation; | ||
|
||
class ActivatedEventArgsBase : public winrt::implements<ActivatedEventArgsBase, | ||
IActivatedEventArgs> | ||
{ | ||
public: | ||
// IActivatedEventArgs | ||
ActivationKind Kind() | ||
{ | ||
return m_kind; | ||
} | ||
|
||
ApplicationExecutionState PreviousExecutionState() | ||
{ | ||
return m_previousState; | ||
} | ||
|
||
SplashScreen SplashScreen() | ||
{ | ||
return m_splashScreen; | ||
} | ||
|
||
protected: | ||
ActivatedEventArgsBase() = default; | ||
|
||
ActivationKind m_kind = ActivationKind::Launch; | ||
ApplicationExecutionState m_previousState; | ||
winrt::Windows::ApplicationModel::Activation::SplashScreen m_splashScreen{ nullptr }; | ||
}; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. See LICENSE in the project root for license information. | ||
#include <pch.h> | ||
#include <ActivationRegistrationManager.h> | ||
#include <ActivationRegistrationManager.g.cpp> | ||
|
||
#include "LaunchActivatedEventArgs.h" | ||
#include "ProtocolActivatedEventArgs.h" | ||
#include "Shared.h" | ||
|
||
namespace winrt::Microsoft::ProjectReunion::implementation | ||
{ | ||
void ActivationRegistrationManager::RegisterForFileTypeActivation(hstring const& groupName, | ||
hstring const& logo, array_view<hstring const> supportedFileTypes, | ||
array_view<hstring const> supportedVerbs) | ||
{ | ||
throw hresult_not_implemented(); | ||
EHO-makai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
void ActivationRegistrationManager::RegisterForProtocolActivation(hstring const& scheme, | ||
hstring const& displayName) | ||
{ | ||
if (scheme.empty() || displayName.empty()) | ||
{ | ||
throw winrt::hresult_invalid_argument(); | ||
} | ||
|
||
if (HasIdentity()) | ||
EHO-makai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
throw hresult_not_implemented(); | ||
} | ||
|
||
RegisterProtocol(scheme.c_str(), displayName.c_str()); | ||
} | ||
|
||
void ActivationRegistrationManager::RegisterForStartupActivation(hstring const& taskId, | ||
bool isEnabled, hstring const& displayName) | ||
{ | ||
throw hresult_not_implemented(); | ||
} | ||
|
||
void ActivationRegistrationManager::RegisterForToastActivation(hstring const& displayName) | ||
{ | ||
throw hresult_not_implemented(); | ||
} | ||
|
||
void ActivationRegistrationManager::UnregisterForFileTypeActivation(hstring const& groupName) | ||
{ | ||
throw hresult_not_implemented(); | ||
} | ||
|
||
void ActivationRegistrationManager::UnregisterForProtocolActivation(hstring const& scheme) | ||
{ | ||
if (scheme.empty()) | ||
{ | ||
throw winrt::hresult_invalid_argument(); | ||
} | ||
|
||
if (HasIdentity()) | ||
{ | ||
throw hresult_not_implemented(); | ||
} | ||
|
||
UnregisterProtocol(scheme.c_str()); | ||
} | ||
|
||
void ActivationRegistrationManager::UnregisterForStartupActivation() | ||
{ | ||
throw hresult_not_implemented(); | ||
} | ||
|
||
void ActivationRegistrationManager::UnregisterForToastActivation() | ||
{ | ||
throw hresult_not_implemented(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. See LICENSE in the project root for license information. | ||
#pragma once | ||
|
||
#include <ActivationRegistrationManager.g.h> | ||
|
||
namespace winrt::Microsoft::ProjectReunion::implementation | ||
{ | ||
struct ActivationRegistrationManager | ||
{ | ||
ActivationRegistrationManager() = default; | ||
|
||
static void RegisterForFileTypeActivation(hstring const& groupName, hstring const& logo, | ||
array_view<hstring const> supportedFileTypes, array_view<hstring const> supportedVerbs); | ||
static void RegisterForProtocolActivation(hstring const& scheme, hstring const& displayName); | ||
static void RegisterForStartupActivation(hstring const& taskId, bool isEnabled, | ||
hstring const& displayName); | ||
static void RegisterForToastActivation(hstring const& displayName); | ||
|
||
static void UnregisterForFileTypeActivation(hstring const& groupName); | ||
static void UnregisterForProtocolActivation(hstring const& scheme); | ||
static void UnregisterForStartupActivation(); | ||
static void UnregisterForToastActivation(); | ||
}; | ||
} | ||
|
||
namespace winrt::Microsoft::ProjectReunion::factory_implementation | ||
{ | ||
struct ActivationRegistrationManager : ActivationRegistrationManagerT<ActivationRegistrationManager, | ||
implementation::ActivationRegistrationManager> | ||
{ | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. See LICENSE in the project root for license information. | ||
|
||
#include <pch.h> | ||
#include <AppLifecycle.h> | ||
#include <AppLifecycle.g.cpp> | ||
|
||
#include "LaunchActivatedEventArgs.h" | ||
#include "ProtocolActivatedEventArgs.h" | ||
#include "Shared.h" | ||
|
||
namespace winrt::Microsoft::ProjectReunion::implementation | ||
{ | ||
std::tuple<std::wstring, std::wstring> ParseCommandLine(std::wstring commandLine) | ||
{ | ||
auto argsStart = commandLine.rfind(L"----") + 4; | ||
aeloros marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (argsStart == std::wstring::npos) | ||
{ | ||
return {L"", L""}; | ||
} | ||
|
||
// We explicitly use find_first_of here, so that the resulting data may contain : as a valid character. | ||
auto argsEnd = commandLine.find_first_of(L":", argsStart); | ||
if (argsEnd == std::wstring::npos) | ||
{ | ||
return {L"", L""}; | ||
} | ||
|
||
if (argsStart > argsEnd) | ||
{ | ||
throw std::overflow_error("commandLine"); | ||
} | ||
|
||
auto argsLength = argsEnd - argsStart; | ||
aeloros marked this conversation as resolved.
Show resolved
Hide resolved
|
||
auto dataStart = argsEnd + 1; | ||
|
||
return {commandLine.substr(argsStart, argsLength), commandLine.substr(dataStart)}; | ||
} | ||
|
||
Windows::ApplicationModel::Activation::IActivatedEventArgs AppLifecycle::GetActivatedEventArgs() | ||
{ | ||
if (HasIdentity()) | ||
{ | ||
return Windows::ApplicationModel::AppInstance::GetActivatedEventArgs(); | ||
} | ||
else | ||
{ | ||
// Generate IActivatedEventArgs for non-Packaged applications. | ||
std::wstring contractId; | ||
std::wstring contractData; | ||
auto commandLine = std::wstring(GetCommandLine()); | ||
std::tie(contractId, contractData) = ParseCommandLine(commandLine); | ||
|
||
if (!contractId.empty() && contractId == c_protocolArgumentString) | ||
{ | ||
return winrt::make<ProtocolActivatedEventArgs>(contractData); | ||
} | ||
|
||
return winrt::make<LaunchActivatedEventArgs>(commandLine); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. See LICENSE in the project root for license information. | ||
#pragma once | ||
|
||
#include <AppLifecycle.g.h> | ||
|
||
namespace winrt::Microsoft::ProjectReunion::implementation | ||
{ | ||
struct AppLifecycle | ||
{ | ||
AppLifecycle() = default; | ||
|
||
static Windows::ApplicationModel::Activation::IActivatedEventArgs GetActivatedEventArgs(); | ||
}; | ||
} | ||
|
||
namespace winrt::Microsoft::ProjectReunion::factory_implementation | ||
{ | ||
struct AppLifecycle : AppLifecycleT<AppLifecycle, implementation::AppLifecycle> | ||
{ | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. See LICENSE in the project root for license information. | ||
|
||
namespace Microsoft.ProjectReunion | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jonwis , I was imagining that we would not have anything in "Microsoft.ProjectReuion" namespace. Is this OK? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For now it is, but we should probably move this to Ms.AppModel.Something eventually |
||
{ | ||
static runtimeclass AppLifecycle | ||
{ | ||
static Windows.ApplicationModel.Activation.IActivatedEventArgs GetActivatedEventArgs(); | ||
} | ||
|
||
static runtimeclass ActivationRegistrationManager | ||
{ | ||
static void RegisterForFileTypeActivation(String groupName, String logo, String[] supportedFileTypes, String[] supportedVerbs); | ||
static void RegisterForProtocolActivation(String scheme, String displayName); | ||
static void RegisterForStartupActivation(String taskId, Boolean isEnabled, String displayName); | ||
static void RegisterForToastActivation(String displayName); | ||
|
||
static void UnregisterForFileTypeActivation(String groupName); | ||
static void UnregisterForProtocolActivation(String scheme); | ||
static void UnregisterForStartupActivation(); | ||
static void UnregisterForToastActivation(); | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup Label="Globals"> | ||
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects> | ||
<HasSharedItems>true</HasSharedItems> | ||
<ItemsProjectGuid>{E3A522A3-6635-4A42-BDED-1AF46A15F63C}</ItemsProjectGuid> | ||
<ItemsProjectName>AppLifecycle</ItemsProjectName> | ||
</PropertyGroup> | ||
<ItemDefinitionGroup> | ||
<ClCompile> | ||
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(MSBuildThisFileDirectory)</AdditionalIncludeDirectories> | ||
</ClCompile> | ||
</ItemDefinitionGroup> | ||
<ItemGroup> | ||
<ProjectCapability Include="SourceItemsFromImports" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClCompile Include="$(MSBuildThisFileDirectory)ActivationRegistrationManager.cpp" /> | ||
<ClCompile Include="$(MSBuildThisFileDirectory)Shared.cpp" /> | ||
<ClInclude Include="$(MSBuildThisFileDirectory)ActivatedEventArgsBase.h" /> | ||
<ClInclude Include="$(MSBuildThisFileDirectory)ActivationRegistrationManager.h" /> | ||
<ClInclude Include="$(MSBuildThisFileDirectory)Shared.h" /> | ||
<ClInclude Include="$(MSBuildThisFileDirectory)LaunchActivatedEventArgs.h" /> | ||
<ClInclude Include="$(MSBuildThisFileDirectory)ProtocolActivatedEventArgs.h" /> | ||
<Midl Include="$(MSBuildThisFileDirectory)AppLifecycle.idl" /> | ||
<ClInclude Include="$(MSBuildThisFileDirectory)AppLifecycle.h" /> | ||
<ClCompile Include="$(MSBuildThisFileDirectory)AppLifecycle.cpp" /> | ||
</ItemGroup> | ||
</Project> |
Uh oh!
There was an error while loading. Please reload this page.