Files
PowerToys/src/common/notifications_winrt/handler_functions.cpp
Josh Soref c2c163ac4e Spelling: ... common (#3781)
* spelling: alignment

* spelling: awareness

* spelling: background

* spelling: bottom

* spelling: buttons

* spelling: comparison

* spelling: cortana

* spelling: exiting

* spelling: initialization

* spelling: middle

* spelling: properly

* spelling: succeeded

* spelling: unknown
2020-05-27 16:58:47 +02:00

28 lines
705 B
C++

#include "pch.h"
#include "handler_functions.h"
#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_background_handler(std::wstring_view argument)
{
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(button_id);
}