mirror of
https://github.com/mudita/MuditaOS.git
synced 2026-01-24 05:47:58 -05:00
114 lines
4.5 KiB
C++
114 lines
4.5 KiB
C++
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
|
|
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
|
|
|
|
#include <utility>
|
|
|
|
#include "ApplicationOnBoarding.hpp"
|
|
|
|
#include "windows/OnBoardingMainWindow.hpp"
|
|
#include "windows/StartConfigurationWindow.hpp"
|
|
#include "windows/OnBoardingLanguagesWindow.hpp"
|
|
#include "windows/EULALicenseWindow.hpp"
|
|
|
|
#include <service-db/DBMessage.hpp>
|
|
#include <module-services/service-appmgr/service-appmgr/messages/GetCurrentDisplayLanguageResponse.hpp>
|
|
#include <module-apps/application-settings-new/data/LanguagesData.hpp>
|
|
#include <module-services/service-db/agents/settings/SystemSettings.hpp>
|
|
|
|
namespace app
|
|
{
|
|
namespace
|
|
{
|
|
constexpr auto OnBoardingStackSize = 4096U;
|
|
} // namespace
|
|
|
|
ApplicationOnBoarding::ApplicationOnBoarding(std::string name,
|
|
std::string parent,
|
|
StartInBackground startInBackground)
|
|
: Application(std::move(name), std::move(parent), startInBackground, OnBoardingStackSize)
|
|
{
|
|
using namespace gui::top_bar;
|
|
topBarManager->enableIndicators({Indicator::Signal,
|
|
Indicator::Time,
|
|
Indicator::Battery,
|
|
Indicator::SimCard,
|
|
Indicator::NetworkAccessTechnology});
|
|
|
|
bus.channels.push_back(sys::BusChannel::ServiceDBNotifications);
|
|
}
|
|
|
|
// Invoked upon receiving data message
|
|
sys::MessagePointer ApplicationOnBoarding::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;
|
|
}
|
|
|
|
return msgNotHandled();
|
|
}
|
|
|
|
sys::ReturnCodes ApplicationOnBoarding::InitHandler()
|
|
{
|
|
const auto ret = Application::InitHandler();
|
|
if (ret != sys::ReturnCodes::Success) {
|
|
return ret;
|
|
}
|
|
|
|
createUserInterface();
|
|
setActiveWindow(gui::name::window::main_window);
|
|
|
|
connect(typeid(manager::GetCurrentDisplayLanguageResponse), [&](sys::Message *msg) {
|
|
if (gui::window::name::onBoarding_languages == getCurrentWindow()->getName()) {
|
|
switchWindow(gui::window::name::onBoarding_eula, nullptr);
|
|
return msgHandled();
|
|
}
|
|
else {
|
|
return msgNotHandled();
|
|
}
|
|
});
|
|
|
|
return ret;
|
|
}
|
|
|
|
void ApplicationOnBoarding::acceptEULA()
|
|
{
|
|
settings->setValue(settings::SystemProperties::eulaAccepted, "1", settings::SettingsScope::Global);
|
|
}
|
|
|
|
sys::ReturnCodes ApplicationOnBoarding::DeinitHandler()
|
|
{
|
|
return sys::ReturnCodes::Success;
|
|
}
|
|
|
|
sys::ReturnCodes ApplicationOnBoarding::SwitchPowerModeHandler(const sys::ServicePowerMode mode)
|
|
{
|
|
return sys::ReturnCodes::Success;
|
|
}
|
|
|
|
void ApplicationOnBoarding::createUserInterface()
|
|
{
|
|
windowsFactory.attach(gui::name::window::main_window, [](Application *app, const std::string &name) {
|
|
return std::make_unique<app::onBoarding::OnBoardingMainWindow>(app);
|
|
});
|
|
windowsFactory.attach(gui::window::name::onBoarding_languages, [](Application *app, const std::string &name) {
|
|
return std::make_unique<app::onBoarding::OnBoardingLanguagesWindow>(app);
|
|
});
|
|
windowsFactory.attach(gui::window::name::onBoarding_start_configuration,
|
|
[](Application *app, const std::string &name) {
|
|
return std::make_unique<app::onBoarding::StartConfigurationWindow>(app);
|
|
});
|
|
windowsFactory.attach(gui::window::name::onBoarding_eula, [&](Application *app, const std::string &name) {
|
|
auto eulaRepository = std::make_unique<app::onBoarding::EULARepository>("assets/licenses", "eula.txt");
|
|
auto presenter = std::make_unique<app::onBoarding::EULALicenseWindowPresenter>([&]() { acceptEULA(); },
|
|
std::move(eulaRepository));
|
|
return std::make_unique<app::onBoarding::EULALicenseWindow>(app, std::move(presenter));
|
|
});
|
|
}
|
|
|
|
void ApplicationOnBoarding::destroyUserInterface()
|
|
{}
|
|
|
|
} // namespace app
|