~aleteoryx/muditaos

ref: 3d13f10839e218b65dc247f03a15fb5dfa87bc8b muditaos/module-apps/apps-common/popups/data/PopupRequestParams.hpp -rw-r--r-- 4.9 KiB
3d13f108 — Bartosz [MOS-668] Modify USB notifications logging 3 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once

#include "popups/Popups.hpp"
#include "PopupRequestParamsBase.hpp"

#include <PhoneModes/Common.hpp>
#include <module-audio/Audio/AudioCommon.hpp>
#include <service-bluetooth/messages/Authenticate.hpp>
#include <locks/widgets/Lock.hpp>
#include <locks/data/LockData.hpp>

namespace gui
{
    class PhoneUnlockInputRequestParams : public PopupRequestParams
    {
      public:
        PhoneUnlockInputRequestParams(gui::popup::ID popupId,
                                      locks::Lock lock,
                                      locks::PhoneLockInputTypeAction phoneLockInputTypeAction)
            : PopupRequestParams{popupId}, lock{std::move(lock)}, phoneLockInputTypeAction(phoneLockInputTypeAction)
        {}

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

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

      private:
        locks::Lock lock;
        locks::PhoneLockInputTypeAction phoneLockInputTypeAction;
    };

    class SimUnlockInputRequestParams : public PopupRequestParams
    {
      public:
        SimUnlockInputRequestParams(gui::popup::ID popupId,
                                    locks::Lock lock,
                                    locks::SimInputTypeAction simInputTypeAction,
                                    unsigned int errorCode = 0)
            : PopupRequestParams{popupId}, lock{std::move(lock)}, simInputTypeAction(simInputTypeAction),
              errorCode(errorCode)
        {}

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

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

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

      private:
        locks::Lock lock;
        locks::SimInputTypeAction simInputTypeAction;
        unsigned int errorCode;
    };

    class PhoneModePopupRequestParams : public PopupRequestParams
    {
      public:
        explicit PhoneModePopupRequestParams(sys::phone_modes::PhoneMode mode)
            : PopupRequestParams{gui::popup::ID::PhoneModes}, phoneMode{mode}
        {}

        [[nodiscard]] auto getPhoneMode() const noexcept
        {
            return phoneMode;
        }

      private:
        sys::phone_modes::PhoneMode phoneMode;
    };

    class BluetoothAuthenticateRequestParams : public PopupRequestParams
    {
      private:
        Devicei device;
        bluetooth::AuthenticateType type;
        std::optional<unsigned long> pairingCode;

      public:
        explicit BluetoothAuthenticateRequestParams(const Devicei &dev,
                                                    bluetooth::AuthenticateType type,
                                                    std::optional<unsigned long> pairingCode = std::nullopt)
            : PopupRequestParams{gui::popup::ID::BluetoothAuthenticate}, device{dev}, type{type}, pairingCode{
                                                                                                      pairingCode}
        {}

        [[nodiscard]] auto getDevice() const noexcept
        {
            return device;
        }

        [[nodiscard]] auto getAuthenticateType() const noexcept
        {
            return type;
        }
        [[nodiscard]] auto getPairingCode() const noexcept
        {
            return pairingCode;
        }
    };

    class BluetoothInfoParams : public PopupRequestParams
    {
      private:
        Devicei device;
        bool succeed;
        std::string errorCode;

      public:
        explicit BluetoothInfoParams(const Devicei &dev, bool succeed, std::string errorCode = "")
            : PopupRequestParams{gui::popup::ID::BluetoothInfo}, device{dev}, succeed{succeed}, errorCode{errorCode}
        {}

        [[nodiscard]] auto getDevice() const noexcept
        {
            return device;
        }

        [[nodiscard]] auto isSucceed() const noexcept -> bool
        {
            return succeed;
        }
        [[nodiscard]] auto getErrorCode() const noexcept -> std::string
        {
            return errorCode;
        }
    };

    class VolumePopupRequestParams : public PopupRequestParams
    {
      public:
        VolumePopupRequestParams(audio::Volume volume, const audio::Context audioContext)
            : PopupRequestParams{gui::popup::ID::Volume}, volume{volume}, audioContext{audioContext}
        {}

        [[nodiscard]] auto getVolume() const noexcept
        {
            return volume;
        }

        [[nodiscard]] auto getAudioContext() const noexcept
        {
            return audioContext;
        }

      private:
        const audio::Volume volume;
        const audio::Context audioContext;
    };

} // namespace gui