~aleteoryx/muditaos

ref: 433322b582957fbfc5888c11b303fa816f28a8f9 muditaos/module-apps/application-messages/data/SMSdata.hpp -rw-r--r-- 3.0 KiB
433322b5 — Dawid Wojtas [BH-1671] Reinit eMMC driver 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
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
// 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 <SwitchData.hpp>
#include <SMSTemplateRecord.hpp>
#include <ContactRecord.hpp>
#include <ThreadRecord.hpp>
#include <SMSRecord.hpp>
#include <Database/Database.hpp>
#include <ApplicationCommon.hpp>
#include <memory>
#include <string>
#include <utility>

class SMSThreadData : public gui::SwitchData
{
  public:
    std::shared_ptr<ThreadRecord> thread;
    std::optional<UTF8> threadName;

    SMSThreadData(std::shared_ptr<ThreadRecord> _thread, std::optional<UTF8> _threadName = std::nullopt)
        : thread(std::move(_thread)), threadName{std::move(_threadName)}
    {}
};

class SMSSwitchData : public gui::SwitchData
{
  protected:
    SMSRecord record;

  public:
    SMSSwitchData() = delete;
    explicit SMSSwitchData(SMSRecord record) : record(std::move(record))
    {}
    ~SMSSwitchData() override = default;

    [[nodiscard]] auto getRecord() const noexcept -> const SMSRecord &
    {
        return record;
    };
};

class SMSRequest : public gui::SwitchData
{
  protected:
    utils::PhoneNumber::View phoneNumber;

  public:
    SMSRequest() = delete;
    SMSRequest(const utils::PhoneNumber::View &phoneNumber) : phoneNumber(phoneNumber)
    {}
    ~SMSRequest() override = default;

    [[nodiscard]] auto getPhoneNumber() const -> const utils::PhoneNumber::View &
    {
        return phoneNumber;
    };
};

class SMSSendRequest : public SMSRequest
{
  public:
    SMSSendRequest(const utils::PhoneNumber::View &phoneNumber, UTF8 textData)
        : SMSRequest(phoneNumber), textData(std::move(textData))
    {}
    ~SMSSendRequest() override = default;
    UTF8 textData;
};

class SMSSendTemplateRequest : public SMSRequest
{
  public:
    explicit SMSSendTemplateRequest(const utils::PhoneNumber::View &phoneNumber, bool preventAutoLock = false)
        : SMSRequest(phoneNumber), preventAutoLock(preventAutoLock)
    {}
    ~SMSSendTemplateRequest() override = default;

    [[nodiscard]] bool isAutoLockPrevented() const
    {
        return preventAutoLock;
    }

  private:
    bool preventAutoLock;
};

class SMSTemplateSent : public gui::SwitchData
{
  public:
    explicit SMSTemplateSent(const UTF8 &text) : smsText(text){};
    auto getText() -> UTF8
    {
        return smsText;
    }

  private:
    UTF8 smsText;
};

class SMSTextData : public gui::SwitchData
{
  public:
    enum class Concatenate : bool
    {
        True,
        False
    };

    SMSTextData(UTF8 text, Concatenate concatenate = Concatenate::False)
        : text(std::move(text)), concatenate(concatenate)
    {}
    ~SMSTextData() override = default;
    UTF8 text;
    Concatenate concatenate = Concatenate::False;
};

class SMSTemplateRequest : public gui::SwitchData
{
  public:
    SMSTemplateRequest(std::string requestingWindow) : requestingWindow(std::move(requestingWindow))
    {}
    ~SMSTemplateRequest() override = default;

    std::string requestingWindow;
};