~aleteoryx/muditaos

ref: 2e6899a4923ef53e5f02e9a018aec1967e7eed82 muditaos/module-apps/application-messages/ApplicationMessages.hpp -rw-r--r-- 3.8 KiB
2e6899a4 — Marek Niepieklo [CP-2] I don't want to see data from Pure in Center when Pure is locked 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
// 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 <Application.hpp>
#include <Interface/ThreadRecord.hpp>
#include <Interface/SMSTemplateRecord.hpp>
#include <Interface/SMSRecord.hpp>
#include <PhoneNumber.hpp>

namespace gui
{
    // fw declarations
    class OptionWindow;
    class Text;
    namespace name
    {
        namespace window
        {
            inline constexpr auto dialog_yes_no     = "DialogYesNo";
            inline constexpr auto dialog_confirm    = "DialogConfirm";
            inline constexpr auto dialog            = "Dialog";
            inline constexpr auto new_sms           = "NewSMS";
            inline constexpr auto thread_sms_search = "SMSSearch";
            inline constexpr auto sms_templates     = "SMSTemplates";
            inline constexpr auto thread_view       = "ThreadViewWindow";

        }; // namespace window
    };     // namespace name
};         // namespace gui

namespace app
{

    inline constexpr auto name_messages = "ApplicationMessages";

    class ApplicationMessages : public app::Application, public app::AsyncCallbackReceiver
    {
      public:
        ApplicationMessages(std::string name                    = name_messages,
                            std::string parent                  = {},
                            sys::phone_modes::PhoneMode mode    = sys::phone_modes::PhoneMode::Connected,
                            StartInBackground startInBackground = {false});

        sys::MessagePointer DataReceivedHandler(sys::DataMessage *msgl, sys::ResponseMessage *resp) override;
        sys::ReturnCodes InitHandler() override;

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

        void createUserInterface() override;
        void destroyUserInterface() override;

        bool removeSms(const SMSRecord &record);
        bool removeSmsThread(const ThreadRecord *record);
        bool markSmsThreadAsRead(const uint32_t id);
        bool markSmsThreadAsUnread(const uint32_t id);
        /// show dialog with big search icon and text which was used for query
        bool searchEmpty(const std::string &query = "");
        bool showSearchResults(const UTF8 &title, const UTF8 &search_text);
        bool sendSms(const utils::PhoneNumber::View &number, const UTF8 &body);
        bool resendSms(const SMSRecord &record);
        bool newMessageOptions(const std::string &requestingWindow, gui::Text *text);
        bool showNotification(std::function<bool()> action,
                              const std::string &notification,
                              bool ignoreCurrentWindowOnStack = false);
        bool handleSendSmsFromThread(const utils::PhoneNumber::View &number, const UTF8 &body);

        std::pair<SMSRecord, bool> createDraft(const utils::PhoneNumber::View &number, const UTF8 &body);
        bool updateDraft(SMSRecord &record, const UTF8 &body);
        bool removeDraft(const SMSRecord &record);

        bool onRemoveSmsThreadConfirmed(const ThreadRecord &record);
        bool onRemoveSmsConfirmed(const SMSRecord &record);

        // used by sms template items
        std::function<bool(std::shared_ptr<SMSTemplateRecord> templ)> templatesCallback;
    };

    template <> struct ManifestTraits<ApplicationMessages>
    {
        static auto GetManifest() -> manager::ApplicationManifest
        {
            return {{manager::actions::Launch,
                     manager::actions::CreateSms,
                     manager::actions::ShowSmsTemplates,
                     manager::actions::SmsRejectNoSim,
                     manager::actions::SMSRejectedByOfflineNotification,
                     manager::actions::PhoneModeChanged}};
        }
    };
} /* namespace app */