~aleteoryx/muditaos

ref: 452135b30414899b65010069deee3d8b2dbb39ff muditaos/module-apps/application-messages/ApplicationMessages.hpp -rw-r--r-- 3.3 KiB
452135b3 — Piotr Tanski [EGD-4373] Fix for changing the content of option window. (#1054) 5 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
// Copyright (c) 2017-2020, 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:
        ApplicationMessages(std::string name                    = name_messages,
                            std::string parent                  = {},
                            StartInBackground startInBackground = {false});
        virtual ~ApplicationMessages();

        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, 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}};
        }
    };
} /* namespace app */