~aleteoryx/muditaos

ref: d13f45b6ce5691457bd58ec97d996ec4b110b82f muditaos/module-apps/application-call/ApplicationCall.hpp -rw-r--r-- 2.5 KiB
d13f45b6 — jimmorrisson [EGD-4203] UTF8 smart pointers refactor (#938) 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
// 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 "Service/Message.hpp"
#include "Service/Timer.hpp"
#include "SystemManager/SystemManager.hpp"
#include <service-cellular/api/CellularServiceAPI.hpp>
#include <time/time_conversion.hpp>

namespace app
{
    inline const std::string name_call      = "ApplicationCall";
    constexpr std::uint16_t call_stack_size = 8192;

    namespace window
    {
        inline const std::string name_call              = "CallWindow";
        inline const std::string name_enterNumber       = "EnterNumberWindow";
        inline const std::string name_emergencyCall     = "EmergencyCallWindow";
        inline const std::string name_duplicatedContact = "DuplicatedContactWindow";
        inline const std::string name_dialogConfirm     = "DialogConfirm";
    } // namespace window

    inline const std::string ringtone_path = "assets/audio/ringtone.wav"; // Should bo moved to database

    class ApplicationCall : public Application
    {
      private:
        void CallAbortHandler();
        void CallActiveHandler();
        void IncomingCallHandler(const CellularCallMessage *const msg);
        void RingingHandler(const CellularCallMessage *const msg);

      protected:
        sys::ms callDelayedStopTime = 3000;

      public:
        ApplicationCall(std::string name = name_call, std::string parent = "", bool startBackgound = false);
        sys::Message_t DataReceivedHandler(sys::DataMessage *msgl, sys::ResponseMessage *resp) override;
        sys::ReturnCodes InitHandler() override;
        sys::ReturnCodes DeinitHandler() override;

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

        void createUserInterface() override;
        void destroyUserInterface() override;
        void setDisplayedNumber(std::string num);
        const std::string &getDisplayedNumber();

        void handleCallEvent(const std::string &number);
        void handleAddContactEvent(const std::string &number);

        bool showNotification(std::function<bool()> action);
        void transmitDtmfTone(uint32_t digit);
        auto getDelayedStopTime() const
        {
            return callDelayedStopTime;
        }

        void stopAudio();
        void startRinging();
        void startRouting();
    };
} /* namespace app */