~aleteoryx/muditaos

ref: 06d16390c21c37457bc875e841bb12039d1123d7 muditaos/module-apps/apps-common/locks/data/LockData.hpp -rw-r--r-- 2.1 KiB
06d16390 — Lefucjusz [MOS-1021] Fix blocked passcode behavior 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
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
// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once

#include <memory>
#include "gui/SwitchData.hpp"
#include "locks/widgets/Lock.hpp"

namespace locks
{
    using LockInput = const std::vector<unsigned int> &;

    enum class PhoneLockInputTypeAction
    {
        Unlock,
        Enable,
        Disable,
        ConfirmCurrent,
        Change,
        Set
    };

    enum class SimInputTypeAction
    {
        UnlockWithPin,
        UnlockWithPuk,
        ChangePin,
        EnablePin,
        DisablePin,
        Blocked,
        Error,
    };

    // class template that stores information that was sent along with switch message
    class LockData : public gui::SwitchData
    {
        Lock lock;
        PhoneLockInputTypeAction phoneLockInputTypeAction;

      public:
        explicit LockData(Lock lock,
                          PhoneLockInputTypeAction phoneLockInputTypeAction = PhoneLockInputTypeAction::Unlock)
            : SwitchData(), lock(std::move(lock)), phoneLockInputTypeAction(phoneLockInputTypeAction)
        {
            description = "LockPhoneData";
        }

        [[nodiscard]] auto getLock() const noexcept
        {
            return lock;
        }

        [[nodiscard]] auto getPhoneLockInputTypeAction() const noexcept
        {
            return phoneLockInputTypeAction;
        }
    };

    class SimLockData : public LockData
    {
        SimInputTypeAction simInputTypeAction;
        unsigned int errorCode;

      public:
        explicit SimLockData(Lock lock, SimInputTypeAction simInputTypeAction, unsigned int errorCode)
            : LockData(std::move(lock)), simInputTypeAction(simInputTypeAction), errorCode(errorCode)
        {
            description = "SimLockPhoneData";
        }

        [[nodiscard]] auto getSimInputTypeAction() const noexcept
        {
            return simInputTypeAction;
        }

        [[nodiscard]] auto getErrorCode() const noexcept
        {
            return errorCode;
        }
    };
} // namespace locks