~aleteoryx/muditaos

ref: a4a5a09c307af62cfbaaba11aa97cbcc118f0a7f muditaos/module-services/service-desktop/endpoints/developerMode/DeveloperModeHelper.hpp -rw-r--r-- 3.2 KiB
a4a5a09c — Wojtek Rzepecki [BH-826] Add key input abstraction layer 4 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// 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 <endpoints/Context.hpp>

#include <Common/Query.hpp>
#include <Service/Common.hpp>
#include <Service/Service.hpp>
#include <hal/key_input/KeyEventDefinitions.hpp>
#include <input/InputEvent.hpp>
#include <module-db/Interface/SMSRecord.hpp>
#include <endpoints/BaseHelper.hpp>

namespace sys
{
    class Service;
} // namespace sys

namespace parserFSM
{

    class DeveloperModeHelper : public BaseHelper
    {
        static auto getKeyCode(int val) noexcept -> bsp::KeyCodes;
        bool sendKeypress(bsp::KeyCodes keyCode, gui::InputEvent::State state);

        void requestSimChange(int simSelected);
        auto smsRecordFromJson(const json11::Json &msgJson) -> SMSRecord;
        bool requestCellularPowerStateChange(int simSelected);
        bool requestServiceStateInfo(sys::Service *serv);
        bool requestCellularSleepModeInfo(sys::Service *serv);
        auto prepareSMS(Context &context) -> ProcessResult;

      public:
        explicit DeveloperModeHelper(sys::Service *p) : BaseHelper(p)
        {}

      private:
        auto processPut(Context &context) -> ProcessResult final;
        auto processGet(Context &context) -> ProcessResult final;
    };

    namespace json::developerMode
    {
        inline constexpr auto keyPressed             = "keyPressed";
        inline constexpr auto state                  = "state";
        inline constexpr auto ATResponse             = "ATResponse";
        inline constexpr auto AT                     = "AT";
        inline constexpr auto timeout                = "timeout";
        inline constexpr auto focus                  = "focus";
        inline constexpr auto phoneLocked            = "phoneLocked";
        inline constexpr auto changeSim              = "changeSim";
        inline constexpr auto changeAutoLockTimeout  = "changeAutoLockTimeout";
        inline constexpr auto smsCommand             = "smsCommand";
        inline constexpr auto changeCellularStateCmd = "changeCellularStateCmd";
        inline constexpr auto getInfo                = "getInfo";
        inline constexpr auto tethering              = "tethering";
        inline constexpr auto switchApplication      = "switchApplication";
        inline constexpr auto switchWindow           = "switchWindow";
        inline constexpr auto phoneLockCodeEnabled   = "phoneLockCodeEnabled";

        namespace switchData
        {
            inline constexpr auto applicationName = "applicationName";
            inline constexpr auto windowName      = "windowName";
        } // namespace switchData

        /// values for getInfo cmd
        inline constexpr auto simStateInfo          = "simState";
        inline constexpr auto cellularStateInfo     = "cellularState";
        inline constexpr auto cellularSleepModeInfo = "cellularSleepMode";

        /// values for smsCommand
        inline constexpr auto smsAdd = "smsAdd";

        /// values for tethering
        inline constexpr auto tetheringOn  = "on";
        inline constexpr auto tetheringOff = "off";

    } // namespace json::developerMode

} // namespace parserFSM