~aleteoryx/muditaos

ref: 2aaed62bd8ae5ab848f84fd7ba9f78a7d992d272 muditaos/module-apps/application-settings/ApplicationSettings.cpp -rw-r--r-- 4.3 KiB
2aaed62b — KacperLewandowski [EGD-3699] Add notifications handling in calendar. 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/*
 * @file ApplicationSesttings.cpp
 * @author Robert Borzecki (robert.borzecki@mudita.com)
 * @date 8 lip 2019
 * @brief
 * @copyright Copyright (C) 2019 mudita.com
 * @details
 */
#include "Application.hpp"

#include "MessageType.hpp"
#include "windows/SettingsMainWindow.hpp"
#include "windows/LanguageWindow.hpp"
#include "windows/BtWindow.hpp"
#include "windows/DateTimeWindow.hpp"
#include "windows/FotaWindow.hpp"
#include "windows/Info.hpp"
#include "windows/LanguageWindow.hpp"
#include "windows/SettingsMainWindow.hpp"

#include "windows/UITestWindow.hpp"

#include "windows/TestMessageWindow.hpp"

#include "ApplicationSettings.hpp"

#include "service-cellular/ServiceCellular.hpp"
#include "windows/SettingsMainWindow.hpp"
#include "windows/SimSelectWindow.hpp"
#include "windows/CellularPassthroughWindow.hpp"
#include "windows/SettingsChange.hpp"

#include <module-services/service-evtmgr/api/EventManagerServiceAPI.hpp>

#include <i18/i18.hpp>

namespace app
{

    ApplicationSettings::ApplicationSettings(std::string name, std::string parent, bool startBackgound)
        : Application(name, parent, startBackgound)
    {}

    ApplicationSettings::~ApplicationSettings()
    {}

    // Invoked upon receiving data message
    sys::Message_t ApplicationSettings::DataReceivedHandler(sys::DataMessage *msgl, sys::ResponseMessage * /*resp*/)
    {

        auto retMsg = Application::DataReceivedHandler(msgl);
        // if message was handled by application's template there is no need to process further.
        if (reinterpret_cast<sys::ResponseMessage *>(retMsg.get())->retCode == sys::ReturnCodes::Success) {
            return retMsg;
        }

        // this variable defines whether message was processed.
        bool handled = true;

        if (handled)
            return std::make_shared<sys::ResponseMessage>();
        else
            return std::make_shared<sys::ResponseMessage>(sys::ReturnCodes::Unresolved);
    }

    // Invoked during initialization
    sys::ReturnCodes ApplicationSettings::InitHandler()
    {
        board = EventManagerServiceAPI::GetBoard(this);

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

        createUserInterface();

        setActiveWindow(gui::name::window::main_window);

        return ret;
    }

    sys::ReturnCodes ApplicationSettings::DeinitHandler()
    {
        return sys::ReturnCodes::Success;
    }

    void ApplicationSettings::createUserInterface()
    {

        gui::AppWindow *window = nullptr;

        window = newOptionWindow(this, gui::name::window::main_window, mainWindowOptions(this));
        window->setTitle(utils::localize.get("app_settings_title_main"));
        windows.insert(std::pair<std::string, gui::AppWindow *>(window->getName(), window));

        window = new gui::LanguageWindow(this);
        windows.insert(std::pair<std::string, gui::AppWindow *>(window->getName(), window));

        window = new gui::BtWindow(this);
        windows.insert(std::pair<std::string, gui::AppWindow *>(window->getName(), window));

        window = new gui::UiTestWindow(this);
        windows.insert(std::pair<std::string, gui::AppWindow *>(window->getName(), window));

        window = new gui::Info(this);
        windows.insert(std::pair<std::string, gui::AppWindow *>(window->getName(), window));

        window = new gui::DateTimeWindow(this);
        windows.insert(std::pair<std::string, gui::AppWindow *>(window->getName(), window));

        window = new gui::FotaWindow(this);
        LOG_INFO("fota name: %s", window->getName().c_str());
        windows.insert(std::pair<std::string, gui::AppWindow *>(window->getName(), window));

        window = newOptionWindow(this, app::sim_select, simSelectWindow(this));
        windows.insert(std::pair<std::string, gui::AppWindow *>(window->getName(), window));

        window = newOptionWindow(this, app::change_setting, settingsChangeWindow(this));
        windows.insert(std::pair<std::string, gui::AppWindow *>(window->getName(), window));

        if (board == bsp::Board::T4) {
            window = new gui::CellularPassthroughWindow(this);
            windows.insert(std::pair<std::string, gui::AppWindow *>(window->getName(), window));
        }
    }

    void ApplicationSettings::destroyUserInterface()
    {}

} /* namespace app */