mirror of
https://github.com/mudita/MuditaOS.git
synced 2026-07-21 05:24:22 -04:00
Secure all endpoints by returning 403(Forbidden) when USB is connected. Request screen passcode to enable secured endpoints.
60 lines
1.4 KiB
C++
60 lines
1.4 KiB
C++
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
|
|
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
|
|
|
|
#pragma once
|
|
|
|
#include <Service/Service.hpp>
|
|
#include <json/json11.hpp>
|
|
#include <log/log.hpp>
|
|
|
|
#include <string>
|
|
|
|
namespace sys
|
|
{
|
|
class Service;
|
|
} // namespace sys
|
|
|
|
extern "C"
|
|
{
|
|
#include <FreeRTOS.h> // for xQueueHandle
|
|
#include <queue.h>
|
|
}
|
|
|
|
class EndpointFactory;
|
|
|
|
namespace parserFSM
|
|
{
|
|
class MessageHandler
|
|
{
|
|
static xQueueHandle sendQueue;
|
|
|
|
json11::Json messageJson;
|
|
std::string JsonErrorMsg;
|
|
sys::Service *OwnerServicePtr = nullptr;
|
|
std::unique_ptr<EndpointFactory> endpointFactory;
|
|
|
|
public:
|
|
MessageHandler(sys::Service *OwnerService, std::unique_ptr<EndpointFactory> endpointFactory);
|
|
|
|
[[nodiscard]] auto isJSONNull() const -> bool
|
|
{
|
|
return messageJson.is_null();
|
|
};
|
|
[[nodiscard]] auto isValid() const noexcept -> bool
|
|
{
|
|
return JsonErrorMsg.empty();
|
|
}
|
|
[[nodiscard]] auto getErrorString() const -> const std::string &
|
|
{
|
|
return JsonErrorMsg;
|
|
};
|
|
void parseMessage(const std::string &msg);
|
|
void processMessage();
|
|
static void putToSendQueue(const std::string &msg);
|
|
static void setSendQueueHandle(xQueueHandle handle)
|
|
{
|
|
sendQueue = handle;
|
|
}
|
|
};
|
|
} // namespace parserFSM
|