~aleteoryx/muditaos

ref: 4c661d4f2c736d3cbc13614864511873efc48678 muditaos/module-services/service-desktop/endpoints/developerMode/Mode/UI_Helper.cpp -rw-r--r-- 1.3 KiB
4c661d4f — Lukasz Mastalerz [BH-1412] Improve system shutdown procedure 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include <endpoints/developerMode/Mode/UI_Helper.hpp>
#include <log/log.hpp>
#include "service-desktop/Constants.hpp"
#include "service-desktop/DeveloperModeMessage.hpp"
#include <service-appmgr/Constants.hpp>
#include <service-appmgr/messages/DOMRequest.hpp>

namespace sdesktop::endpoints
{
    void UI_Helper::preProcess(http::Method method, Context &context)
    {
        LOG_INFO("In UI helper - requesting %d", static_cast<int>(method));
    }

    class UIEvent : public sdesktop::Event
    {
      public:
        UIEvent(Context &ctx)
        {
            context = ctx;
        }
    };

    auto UI_Helper::processGet(Context &context) -> ProcessResult
    {
        const auto &body = context.getBody();
        if (body["getWindow"] == true) {
            auto event = UIEvent(context);
            owner->bus.sendUnicast(
                std::make_shared<app::manager::DOMRequest>(service::name::service_desktop,
                                                           std::make_unique<sdesktop::Event>(std::move(event))),
                service::name::appmgr);
            return {sent::delayed, std::nullopt};
        }
        return {sent::no, std::nullopt};
    }
}; // namespace sdesktop::endpoints