~aleteoryx/muditaos

ref: sign_test muditaos/module-apps/application-call/presenter/CallPresenter.hpp -rw-r--r-- 2.9 KiB
a217eeb3 — Dawid Wojtas [BH-2024] Fix lack of alarm directory after updating software 1 year, 5 months 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
// 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 <module-apps/application-call/model/CallModel.hpp>
#include <module-apps/application-call/widgets/StateIcons.hpp>
#include "BasePresenter.hpp"

namespace app::call
{
    class CallWindowContract
    {
      public:
        class View
        {
          public:
            virtual void updateDuration(const UTF8 &text, bool isVisible = true)      = 0;
            virtual void updateEnteredNumber(const char &text, bool isVisible = true) = 0;
            virtual void setEnteredNumberVisible(bool isVisible)                      = 0;
            virtual void refreshWindow()                                              = 0;
            virtual void setNavBarForActiveCall()                                     = 0;
            virtual void setNavBarForIncomingCall()                                   = 0;
            virtual void clearNavBar()                                                = 0;
            virtual void setIncomingCallLayout(bool isValidCallerId)                  = 0;
            virtual void setActiveCallLayout()                                        = 0;
            virtual void setCallEndedLayout(bool delayedClose = true)                 = 0;
            virtual void updateNumber(const UTF8 &text)                               = 0;
            virtual gui::SpeakerIconState getSpeakerIconState()                       = 0;
            virtual void setSpeakerIconState(const gui::SpeakerIconState &icon)       = 0;

            virtual ~View() noexcept = default;
        };

        class Presenter : public BasePresenter<CallWindowContract::View>
        {
          public:
            Presenter(std::shared_ptr<app::call::AbstractCallModel> callModel);
            ~Presenter() noexcept override;

            void handleCallDurationChange();
            void handleCallStateChange();
            void buildLayout();

            bool handleLeftButton();
            bool handleRightButton();
            bool handleHeadsetOk();
            bool handleDigitButton(const uint32_t &digit);
            void muteCall();
            void unmuteCall();
            void turnLoudspeakerOn();
            void turnLoudspeakerOff();

            void hangUpCall();
            void sendSms(const UTF8 &smsBody);
            utils::PhoneNumber getPhoneNumber();

            void handleDelayedViewClose();

            void processCurrentRouting(const audio::Profile::Type &routingType);
            void attachCallbacks();
            void clearModel();
            bool isCallInProgress();

          private:
            std::shared_ptr<app::call::AbstractCallModel> model;
            UTF8 getCallerId();
            bool isIncomingCall();
            bool isProvidedCharValid(const char digitChar);
        };
    };
} // namespace app::call