~aleteoryx/muditaos

ref: 87ed83ca5ce1209cd4591fc58d16e441928b147c muditaos/module-apps/application-bell-alarm/ApplicationBellAlarm.cpp -rw-r--r-- 1.7 KiB
87ed83ca — Mateusz Grzegorzek [BH-701] Use TimeSetFmtSpinner in Alarm app 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
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include <application-bell-alarm/ApplicationBellAlarm.hpp>
#include <application-bell-alarm/presenter/BellAlarmWindowPresenter.hpp>
#include <application-bell-alarm/windows/BellAlarmWindow.hpp>

namespace app
{
    ApplicationBellAlarm::ApplicationBellAlarm(std::string name,
                                               std::string parent,
                                               sys::phone_modes::PhoneMode mode,
                                               StartInBackground startInBackground)
        : Application(std::move(name), std::move(parent), mode, startInBackground)
    {}

    sys::ReturnCodes ApplicationBellAlarm::InitHandler()
    {
        auto ret = Application::InitHandler();
        if (ret != sys::ReturnCodes::Success) {
            return ret;
        }

        createUserInterface();

        return sys::ReturnCodes::Success;
    }

    void ApplicationBellAlarm::createUserInterface()
    {
        windowsFactory.attach(gui::name::window::main_window, [](Application *app, const std::string &name) {
            auto presenter = std::make_unique<bell_alarm::BellAlarmWindowPresenter>();
            return std::make_unique<gui::BellAlarmWindow>(app, std::move(presenter));
        });
    }

    sys::MessagePointer ApplicationBellAlarm::DataReceivedHandler(sys::DataMessage *msgl, sys::ResponseMessage *resp)
    {
        auto retMsg = Application::DataReceivedHandler(msgl);
        if (dynamic_cast<sys::ResponseMessage *>(retMsg.get())->retCode == sys::ReturnCodes::Success) {
            return retMsg;
        }
        return std::make_shared<sys::ResponseMessage>();
    }
} // namespace app