2020-02-04 19:41:00 +03:00
|
|
|
#include "pch.h"
|
|
|
|
|
|
|
|
|
|
#include "handler_functions.h"
|
|
|
|
|
|
2020-02-25 23:04:19 +03:00
|
|
|
#include <winrt/Windows.System.h>
|
|
|
|
|
|
|
|
|
|
using handler_function_t = void (*)(const size_t button_id);
|
2020-02-04 19:41:00 +03:00
|
|
|
|
|
|
|
|
namespace
|
|
|
|
|
{
|
|
|
|
|
const std::unordered_map<std::wstring_view, handler_function_t> handlers_map;
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-27 10:58:47 -04:00
|
|
|
void dispatch_to_background_handler(std::wstring_view argument)
|
2020-02-04 19:41:00 +03:00
|
|
|
{
|
2020-02-25 23:04:19 +03:00
|
|
|
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);
|
2020-02-04 19:41:00 +03:00
|
|
|
if (found_handler == end(handlers_map))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2020-02-25 23:04:19 +03:00
|
|
|
found_handler->second(button_id);
|
2020-02-04 19:41:00 +03:00
|
|
|
}
|