~aleteoryx/muditaos

ref: 55c41de597d14ba4946de0bf2580c469f4738cf8 muditaos/module-apps/application-settings/ApplicationSettings.hpp -rw-r--r-- 2.6 KiB
55c41de5 — Wiktor S. Ovalle Correa [EGD-6575] Rename Unicast with timeout as UnicastSync 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
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#ifndef MODULE_APPS_APPLICATION_SETTINGS_APPLICATIONSETTINGS_HPP_
#define MODULE_APPS_APPLICATION_SETTINGS_APPLICATIONSETTINGS_HPP_

#include "Application.hpp"
#include "bsp/common.hpp"
#include <common_data/EventStore.hpp>

namespace app
{

    inline constexpr auto name_settings  = "ApplicationSettings";
    inline constexpr auto sim_select     = "SimSelect";
    inline constexpr auto change_setting = "ChangeSetting";

    class SimSetter
    {
      public:
        virtual ~SimSetter()                     = default;
        virtual void setSim(Store::GSM::SIM sim) = 0;
    };

    class PinLockSetter
    {
      public:
        virtual ~PinLockSetter()              = default;
        virtual void setPin(unsigned int pin) = 0;
        virtual void clearPin()               = 0;
    };

    class ApplicationSettings : public app::Application, public SimSetter, public PinLockSetter
    {
      public:
        ApplicationSettings(std::string name                    = name_settings,
                            std::string parent                  = {},
                            sys::phone_modes::PhoneMode mode    = sys::phone_modes::PhoneMode::Connected,
                            StartInBackground startInBackground = {false});
        virtual ~ApplicationSettings();
        sys::MessagePointer DataReceivedHandler(sys::DataMessage *msgl, sys::ResponseMessage *resp) override;
        sys::ReturnCodes InitHandler() override;
        sys::ReturnCodes DeinitHandler() override;

        sys::ReturnCodes SwitchPowerModeHandler(const sys::ServicePowerMode mode) override final
        {
            return sys::ReturnCodes::Success;
        }

        void createUserInterface() override;
        void destroyUserInterface() override;
        bsp::Board board = bsp::Board::none;
        void setSim(Store::GSM::SIM sim) override;
        void setPin(unsigned int pin) override;
        void clearPin() override;
        void lockPassChanged(std::string value);
        void timeDateChanged(std::string value);

      private:
        unsigned int lockPassHash;
        bool europeanDateTimeFormat = false; // true europe format, false american format
    };

    template <> struct ManifestTraits<ApplicationSettings>
    {
        static auto GetManifest() -> manager::ApplicationManifest
        {
            return {{manager::actions::Launch, manager::actions::SelectSimCard, manager::actions::PhoneModeChanged}};
        }
    };
} /* namespace app */

#endif /* MODULE_APPS_APPLICATION_SETTINGS_APPLICATIONSETTINGS_HPP_ */