~aleteoryx/muditaos

ref: 2a53becd2524fc0dba7260632d3ec409eb3a61fd muditaos/module-apps/application-messages/data/SMSdata.hpp -rw-r--r-- 2.4 KiB
2a53becd — Maciej Janicki [BH-1136] Fix bootloop after low power 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// 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 <SwitchData.hpp>
#include <SMSTemplateRecord.hpp>
#include <ContactRecord.hpp>
#include <ThreadRecord.hpp>
#include <Database/Database.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 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:
    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
{};

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;
};