~aleteoryx/muditaos

ref: 5447774803ddda4df9e2e54ee7778c80a317ca92 muditaos/module-apps/application-call/presenter/CallPresenter.hpp -rw-r--r-- 2.2 KiB
54477748 — Mateusz Piesta [BH-1449] Fix crash during startup 3 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
// Copyright (c) 2017-2022, 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 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()                                    = 0;
            virtual void updateNumber(const UTF8 &text)                          = 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();
            utils::PhoneNumber getPhoneNumber();

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