mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-08 04:07:40 +02:00
notifications: add support for unpackaged apps and protocol activation
This commit is contained in:
committed by
Andrey Nekrasov
parent
b90f1fc237
commit
c543b7585a
@@ -8,7 +8,6 @@ namespace winrt::PowerToysNotifications::implementation
|
||||
{
|
||||
using Windows::ApplicationModel::Background::IBackgroundTaskInstance;
|
||||
using Windows::UI::Notifications::ToastNotificationActionTriggerDetail;
|
||||
using Windows::Foundation::WwwFormUrlDecoder;
|
||||
|
||||
void BackgroundHandler::Run(IBackgroundTaskInstance bti)
|
||||
{
|
||||
@@ -18,10 +17,6 @@ namespace winrt::PowerToysNotifications::implementation
|
||||
return;
|
||||
}
|
||||
|
||||
WwwFormUrlDecoder decoder{details.Argument()};
|
||||
|
||||
const size_t button_id = std::stoi(decoder.GetFirstValueByName(L"button_id").c_str());
|
||||
auto handler = decoder.GetFirstValueByName(L"handler");
|
||||
dispatch_to_backround_handler(std::move(handler), std::move(bti), button_id);
|
||||
dispatch_to_backround_handler(details.Argument());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,19 +2,26 @@
|
||||
|
||||
#include "handler_functions.h"
|
||||
|
||||
using handler_function_t = void (*)(IBackgroundTaskInstance, const size_t button_id);
|
||||
#include <winrt/Windows.System.h>
|
||||
|
||||
using handler_function_t = void (*)(const size_t button_id);
|
||||
|
||||
namespace
|
||||
{
|
||||
const std::unordered_map<std::wstring_view, handler_function_t> handlers_map;
|
||||
}
|
||||
|
||||
void dispatch_to_backround_handler(std::wstring_view background_handler_id, IBackgroundTaskInstance bti, const size_t button_id)
|
||||
void dispatch_to_backround_handler(std::wstring_view argument)
|
||||
{
|
||||
const auto found_handler = handlers_map.find(background_handler_id);
|
||||
winrt::Windows::Foundation::WwwFormUrlDecoder decoder{ argument };
|
||||
|
||||
const size_t button_id = std::stoi(decoder.GetFirstValueByName(L"button_id").c_str());
|
||||
auto handler = decoder.GetFirstValueByName(L"handler");
|
||||
|
||||
const auto found_handler = handlers_map.find(handler);
|
||||
if (found_handler == end(handlers_map))
|
||||
{
|
||||
return;
|
||||
}
|
||||
found_handler->second(std::move(bti), button_id);
|
||||
found_handler->second(button_id);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
using winrt::Windows::ApplicationModel::Background::IBackgroundTaskInstance;
|
||||
#include <string_view>
|
||||
|
||||
void dispatch_to_backround_handler(std::wstring_view background_handler_id, IBackgroundTaskInstance bti, const size_t button_id);
|
||||
void dispatch_to_backround_handler(std::wstring_view argument);
|
||||
|
||||
Reference in New Issue
Block a user