From bc4d32c7d8717eebd9e2eb7b1e91ac535eb363e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Ta=C5=84ski?= Date: Thu, 14 Jan 2021 13:35:01 +0100 Subject: [PATCH] [EGD-5158] Change access to the bus methods The bus is now accessible only via Service object. --- module-apps/Application.cpp | 30 ++- module-apps/Application.hpp | 1 - .../ApplicationAlarmClock.cpp | 2 +- .../ApplicationAntenna.cpp | 3 +- .../ApplicationCalendar.cpp | 2 +- .../ApplicationDesktop.cpp | 11 +- .../widgets/PinLockHandler.cpp | 11 +- .../windows/DesktopMainWindow.cpp | 6 +- .../application-desktop/windows/Update.cpp | 2 +- .../ApplicationMessages.cpp | 2 +- .../application-notes/ApplicationNotes.cpp | 2 +- .../ApplicationPhonebook.cpp | 2 +- .../ApplicationSettings.cpp | 46 ++-- .../models/ApnSettingsModel.cpp | 4 +- .../models/LanguagesModel.cpp | 5 +- .../windows/AddDeviceWindow.cpp | 11 +- .../windows/AllDevicesWindow.cpp | 9 +- .../windows/BluetoothWindow.cpp | 13 +- .../windows/DisplayLightWindow.cpp | 1 - .../windows/PhoneNameWindow.cpp | 6 +- .../ApplicationSettings.cpp | 2 +- .../windows/BtScanWindow.cpp | 4 +- .../application-settings/windows/BtWindow.cpp | 2 +- .../windows/ColorTestWindow.cpp | 6 +- .../windows/EinkModeWindow.cpp | 6 +- .../application-settings/windows/Fota.cpp | 10 +- .../application-settings/windows/Fota.hpp | 1 - .../interface/profiles/A2DP/A2DP.cpp | 4 +- .../Bluetooth/interface/profiles/GAP.cpp | 10 +- .../Bluetooth/interface/profiles/HSP/HSP.cpp | 3 +- .../Bluetooth/interface/profiles/HSP/SCO.cpp | 3 +- .../Bluetooth/interface/profiles/HSP/SCO.hpp | 1 - .../bsp/battery-charger/battery_charger.hpp | 4 +- module-cellular/Modem/ATParser.cpp | 3 +- module-cellular/Modem/TS0710/TS0710.cpp | 3 +- .../service-antenna/ServiceAntenna.cpp | 4 +- .../service-antenna/api/AntennaServiceAPI.cpp | 7 +- module-services/service-appmgr/Controller.cpp | 29 ++- .../model/ApplicationManager.cpp | 3 +- .../service-audio/AudioServiceAPI.cpp | 25 +- .../service-audio/ServiceAudio.cpp | 16 +- .../service-bluetooth/ServiceBluetooth.cpp | 5 +- .../CellularRequestHandler.cpp | 20 +- .../service-cellular/CellularServiceAPI.cpp | 81 +++---- .../service-cellular/CellularUrcHandler.cpp | 7 +- .../service-cellular/ServiceCellular.cpp | 50 ++-- module-services/service-db/DBServiceAPI.cpp | 34 ++- .../service-db/DBServiceAPI_GetByQuery.cpp | 10 +- module-services/service-db/ServiceDB.cpp | 3 +- .../agents/file_indexer/FileIndexerAgent.cpp | 19 +- .../service-db/agents/settings/Settings.cpp | 7 +- .../agents/settings/SettingsAgent.cpp | 25 +- .../service-db/service-db/DBServiceAPI.hpp | 1 - .../test-service-db-settings-messages.cpp | 34 ++- .../test-service-db-settings-api.cpp | 6 +- .../test-service-db-settings-testapps.hpp | 24 +- .../test-service-db-settings-testservices.hpp | 37 ++- .../service-desktop/ServiceDesktop.cpp | 3 +- .../endpoints/backup/BackupEndpoint.cpp | 3 +- .../developerMode/DeveloperModeHelper.cpp | 13 +- .../factoryReset/FactoryResetEndpoint.cpp | 3 +- .../endpoints/restore/RestoreEndpoint.cpp | 3 +- .../endpoints/update/UpdateEndpoint.cpp | 3 +- .../endpoints/update/UpdateMuditaOS.cpp | 5 +- module-services/service-eink/ServiceEink.cpp | 4 +- .../service-evtmgr/EventManager.cpp | 29 ++- .../service-evtmgr/WorkerEvent.cpp | 17 +- .../alarm/EventManagerAlarm.cpp | 3 +- .../api/EventManagerServiceAPI.cpp | 5 +- .../battery-level-check/BatteryLevelCheck.cpp | 5 +- .../ServiceFileIndexer.cpp | 3 +- .../service-fileindexer/StartupIndexer.cpp | 3 +- .../service-fota/FotaServiceAPI.cpp | 13 +- module-services/service-fota/ServiceFota.cpp | 26 +- module-services/service-gui/ServiceGUI.cpp | 4 +- module-services/service-gui/WorkerGUI.cpp | 3 +- module-services/service-lwip/ServiceLwIP.cpp | 3 +- module-services/service-time/ServiceTime.cpp | 2 +- module-sys/CMakeLists.txt | 21 +- module-sys/Service/Bus.cpp | 223 ------------------ module-sys/Service/Bus.hpp | 57 ----- module-sys/Service/BusProxy.cpp | 51 ++++ module-sys/Service/BusProxy.hpp | 43 ++++ module-sys/Service/Channel.hpp | 24 -- module-sys/Service/Common.hpp | 28 +-- module-sys/Service/Message.cpp | 11 +- module-sys/Service/Message.hpp | 6 +- module-sys/Service/Service.cpp | 18 +- module-sys/Service/Service.hpp | 4 +- module-sys/Service/Timer.cpp | 5 +- module-sys/Service/details/bus/Bus.cpp | 210 +++++++++++++++++ module-sys/Service/details/bus/Bus.hpp | 81 +++++++ module-sys/SystemManager/SystemManager.cpp | 32 ++- module-sys/SystemManager/SystemManager.hpp | 3 +- module-utils/state/ServiceState.hpp | 3 +- 95 files changed, 821 insertions(+), 830 deletions(-) delete mode 100644 module-sys/Service/Bus.cpp delete mode 100644 module-sys/Service/Bus.hpp create mode 100644 module-sys/Service/BusProxy.cpp create mode 100644 module-sys/Service/BusProxy.hpp delete mode 100644 module-sys/Service/Channel.hpp create mode 100644 module-sys/Service/details/bus/Bus.cpp create mode 100644 module-sys/Service/details/bus/Bus.hpp diff --git a/module-apps/Application.cpp b/module-apps/Application.cpp index a89db0fc1628e47ed4a08257d26b06bc51ae137a..871b30320bf9a1b0d7535446aa7a17a79a295973 100644 --- a/module-apps/Application.cpp +++ b/module-apps/Application.cpp @@ -77,7 +77,7 @@ namespace app settings(std::make_unique(this)) { topBarManager->enableIndicators({gui::top_bar::Indicator::Time}); - busChannels.push_back(sys::BusChannels::ServiceCellularNotifications); + bus.channels.push_back(sys::BusChannel::ServiceCellularNotifications); longPressTimer = std::make_unique("LongPress", this, key_timer_ms); longPressTimer->connect([&](sys::Timer &) { longPressTimerCallback(); }); @@ -146,7 +146,7 @@ namespace app else if (suspendInProgress) { message->setCommandType(service::gui::DrawMessage::Type::SUSPEND); } - sys::Bus::SendUnicast(std::move(message), service::name::gui, this); + bus.sendUnicast(std::move(message), service::name::gui); } if (suspendInProgress) @@ -171,12 +171,12 @@ namespace app window = getCurrentWindow()->getName(); auto msg = std::make_shared(window, getCurrentWindow()->getName(), std::move(data), cmd); - sys::Bus::SendUnicast(msg, this->GetName(), this); + bus.sendUnicast(msg, this->GetName()); } else { auto msg = std::make_shared( windowName, getCurrentWindow() ? getCurrentWindow()->getName() : "", std::move(data), cmd); - sys::Bus::SendUnicast(msg, this->GetName(), this); + bus.sendUnicast(msg, this->GetName()); } } @@ -195,7 +195,7 @@ namespace app { if (not windowsStack.isEmpty()) { auto msg = std::make_shared(mode, getCurrentWindow()->getName()); - sys::Bus::SendUnicast(msg, this->GetName(), this); + bus.sendUnicast(msg, this->GetName()); } } @@ -549,10 +549,8 @@ namespace app { using namespace bsp; - auto retGetState = sys::Bus::SendUnicast(std::make_shared(torch::Action::getState), - service::name::evt_manager, - this, - pdMS_TO_TICKS(1500)); + auto message = std::make_shared(torch::Action::getState); + auto retGetState = bus.sendUnicast(std::move(message), service::name::evt_manager, pdMS_TO_TICKS(1500)); if (retGetState.first == sys::ReturnCodes::Success) { auto msgGetState = dynamic_cast(retGetState.second.get()); if (msgGetState == nullptr) { @@ -569,7 +567,7 @@ namespace app msgSetState->state = torch::State::off; break; } - sys::Bus::SendUnicast(msgSetState, service::name::evt_manager, this); + bus.sendUnicast(msgSetState, service::name::evt_manager); } } @@ -579,7 +577,7 @@ namespace app manager::actions::ActionParamsPtr &&data) { auto msg = std::make_shared(actionId, std::move(data)); - sys::Bus::SendUnicast(msg, applicationName, sender); + sender->bus.sendUnicast(msg, applicationName); } void Application::messageSwitchApplication(sys::Service *sender, @@ -588,26 +586,26 @@ namespace app std::unique_ptr data) { auto msg = std::make_shared(application, window, std::move(data)); - sys::Bus::SendUnicast(msg, application, sender); + sender->bus.sendUnicast(msg, application); } void Application::messageCloseApplication(sys::Service *sender, std::string application) { auto msg = std::make_shared(MessageType::AppClose); - sys::Bus::SendUnicast(msg, application, sender); + sender->bus.sendUnicast(msg, application); } void Application::messageRebuildApplication(sys::Service *sender, std::string application) { auto msg = std::make_shared(); - sys::Bus::SendUnicast(msg, application, sender); + sender->bus.sendUnicast(msg, application); } void Application::messageApplicationLostFocus(sys::Service *sender, std::string application) { auto msg = std::make_shared(); - sys::Bus::SendUnicast(msg, application, sender); + sender->bus.sendUnicast(msg, application); } void Application::messageInputEventApplication(sys::Service *sender, @@ -615,7 +613,7 @@ namespace app const gui::InputEvent &event) { auto msg = std::make_shared(event); - sys::Bus::SendUnicast(msg, application, sender); + sender->bus.sendUnicast(msg, application); } bool Application::popToWindow(const std::string &window) diff --git a/module-apps/Application.hpp b/module-apps/Application.hpp index c2cb2d4e1d9cb31e7b3b35854af66bb6f06b4853..68cc6fa245d743cc11f2583b82dfaef423668cc0 100644 --- a/module-apps/Application.hpp +++ b/module-apps/Application.hpp @@ -7,7 +7,6 @@ #include "Audio/AudioCommon.hpp" // for Volume, Play... #include "Audio/Profiles/Profile.hpp" // for Profile, Pro... #include "CallbackStorage.hpp" -#include "Service/Bus.hpp" // for Bus #include "Service/Common.hpp" // for ReturnCodes #include "Service/Message.hpp" // for MessagePointer #include "Service/Service.hpp" // for Service diff --git a/module-apps/application-alarm-clock/ApplicationAlarmClock.cpp b/module-apps/application-alarm-clock/ApplicationAlarmClock.cpp index 56199174819dcfd1b92b9f980d51c9a6760c5385..1e20fc56f4b9c87a87977c2b6ca2141a0db2afb4 100644 --- a/module-apps/application-alarm-clock/ApplicationAlarmClock.cpp +++ b/module-apps/application-alarm-clock/ApplicationAlarmClock.cpp @@ -23,7 +23,7 @@ namespace app sys::ServicePriority priority) : Application(name, parent, false, stackDepth, priority) { - busChannels.push_back(sys::BusChannels::ServiceDBNotifications); + bus.channels.push_back(sys::BusChannel::ServiceDBNotifications); } sys::MessagePointer ApplicationAlarmClock::DataReceivedHandler(sys::DataMessage *msgl, sys::ResponseMessage *resp) diff --git a/module-apps/application-antenna/ApplicationAntenna.cpp b/module-apps/application-antenna/ApplicationAntenna.cpp index 0f2dbdf71042c2935c9bc2753b101e64d52c7f0c..0869b221ce1137dda92330bf4b57b0a71f08bdfc 100644 --- a/module-apps/application-antenna/ApplicationAntenna.cpp +++ b/module-apps/application-antenna/ApplicationAntenna.cpp @@ -37,8 +37,7 @@ namespace app ApplicationAntenna::ApplicationAntenna(std::string name, std::string parent, StartInBackground startInBackground) : Application(name, parent, startInBackground, 4096 * 2) { - busChannels.push_back(sys::BusChannels::AntennaNotifications); - busChannels.push_back(sys::BusChannels::AntennaNotifications); + bus.channels.push_back(sys::BusChannel::AntennaNotifications); appTimer = std::make_unique("Antena", this, 2000); appTimer->connect([=](sys::Timer &) { timerHandler(); }); appTimer->start(); diff --git a/module-apps/application-calendar/ApplicationCalendar.cpp b/module-apps/application-calendar/ApplicationCalendar.cpp index 8736f5c47fb67d53fe2abb077bd75fa9a2a58273..0e00a22602bc641a20ded9c2617b614d7643be14 100644 --- a/module-apps/application-calendar/ApplicationCalendar.cpp +++ b/module-apps/application-calendar/ApplicationCalendar.cpp @@ -49,7 +49,7 @@ namespace app sys::ServicePriority priority) : Application(name, parent, startInBackground, stackDepth, priority) { - busChannels.push_back(sys::BusChannels::ServiceDBNotifications); + bus.channels.push_back(sys::BusChannel::ServiceDBNotifications); addActionReceiver(manager::actions::ShowReminder, [this](auto &&data) { switchWindow(style::window::calendar::name::event_reminder_window, std::move(data)); return msgHandled(); diff --git a/module-apps/application-desktop/ApplicationDesktop.cpp b/module-apps/application-desktop/ApplicationDesktop.cpp index cc897dca5ce0df6eb5d0fb87ad49edb0ecc23698..9adb5bf2bac1be52f87b8055246d412e97b0aca1 100644 --- a/module-apps/application-desktop/ApplicationDesktop.cpp +++ b/module-apps/application-desktop/ApplicationDesktop.cpp @@ -44,7 +44,7 @@ namespace app Indicator::Battery, Indicator::SimCard, Indicator::NetworkAccessTechnology}); - busChannels.push_back(sys::BusChannels::ServiceDBNotifications); + bus.channels.push_back(sys::BusChannel::ServiceDBNotifications); addActionReceiver(app::manager::actions::RequestPin, [this](auto &&data) { lockHandler.handlePasscodeRequest(gui::PinLock::LockType::SimPin, std::move(data)); @@ -169,7 +169,7 @@ namespace app if (event != nullptr) { auto event = std::make_unique(lockHandler.isScreenLocked()); auto msg = std::make_shared(std::move(event)); - sys::Bus::SendUnicast(std::move(msg), service::name::service_desktop, this); + bus.sendUnicast(std::move(msg), service::name::service_desktop); } return true; @@ -240,9 +240,8 @@ namespace app return true; } else if (need_sim_select == false) { - sys::Bus::SendUnicast(std::make_shared(MessageType::CellularSimProcedure), - ServiceCellular::serviceName, - this); + bus.sendUnicast(std::make_shared(MessageType::CellularSimProcedure), + ServiceCellular::serviceName); } } if (msg->request == cellular::State::ST::ModemFatalFailure) { @@ -327,7 +326,7 @@ namespace app auto msgToSend = std::make_shared(updateos::UpdateMessageType::UpdateCheckForUpdateOnce); - sys::Bus::SendUnicast(msgToSend, service::name::service_desktop, this); + bus.sendUnicast(msgToSend, service::name::service_desktop); settings->registerValueChange( settings::SystemProperties::activeSim, diff --git a/module-apps/application-desktop/widgets/PinLockHandler.cpp b/module-apps/application-desktop/widgets/PinLockHandler.cpp index 87f3f8ba7165811267dc8fa82c993c38790d6322..f51e3d76165919e46e829ca6a6cf8a02a5770971 100644 --- a/module-apps/application-desktop/widgets/PinLockHandler.cpp +++ b/module-apps/application-desktop/widgets/PinLockHandler.cpp @@ -173,8 +173,7 @@ namespace gui { if (type == PinLock::LockType::SimPin) { setSimLockHandled(); - sys::Bus::SendUnicast( - std::make_shared(simLock.sim, passcode), serviceCellular, app); + app->bus.sendUnicast(std::make_shared(simLock.sim, passcode), serviceCellular); } else if (type == PinLock::LockType::SimPuk) { handlePasscodeChange(passcode); @@ -213,12 +212,12 @@ namespace gui { setSimLockHandled(); if (type == PinLock::LockType::SimPin) { - sys::Bus::SendUnicast( - std::make_shared(simLock.sim, passcode, pin), serviceCellular, app); + app->bus.sendUnicast(std::make_shared(simLock.sim, passcode, pin), + serviceCellular); } else if (type == PinLock::LockType::SimPuk) { - sys::Bus::SendUnicast( - std::make_shared(simLock.sim, passcode, pin), serviceCellular, app); + app->bus.sendUnicast(std::make_shared(simLock.sim, passcode, pin), + serviceCellular); } } diff --git a/module-apps/application-desktop/windows/DesktopMainWindow.cpp b/module-apps/application-desktop/windows/DesktopMainWindow.cpp index 8f484c7e23af3e7f3b50f5925bbde7ce396a435b..803c32b250c301f80a92d255521789de8d05db11 100644 --- a/module-apps/application-desktop/windows/DesktopMainWindow.cpp +++ b/module-apps/application-desktop/windows/DesktopMainWindow.cpp @@ -109,8 +109,7 @@ namespace gui setFocusItem(nullptr); buildNotifications(app); - sys::Bus::SendUnicast( - std::make_shared(), service::name::service_time, application); + application->bus.sendUnicast(std::make_shared(), service::name::service_time); } else { if (!buildNotifications(app)) { @@ -122,8 +121,7 @@ namespace gui app::manager::Controller::sendAction(application, app::manager::actions::SelectSimCard); } - sys::Bus::SendUnicast( - std::make_shared(), service::name::service_time, application); + application->bus.sendUnicast(std::make_shared(), service::name::service_time); } application->refreshWindow(RefreshModes::GUI_REFRESH_FAST); } diff --git a/module-apps/application-desktop/windows/Update.cpp b/module-apps/application-desktop/windows/Update.cpp index 5e2f34c057353dadd7d351459e73b0259891db23..29f1ac77cebe2568eb5b8884c54463e608938570 100644 --- a/module-apps/application-desktop/windows/Update.cpp +++ b/module-apps/application-desktop/windows/Update.cpp @@ -228,7 +228,7 @@ namespace gui percentLabel->setVisible(true); percentLabel->setText(utils::localize.get("app_desktop_update_start")); auto msgToSend = std::make_shared(updateFile.c_str(), 0); - sys::Bus::SendUnicast(msgToSend, service::name::service_desktop, application); + application->bus.sendUnicast(msgToSend, service::name::service_desktop); return true; } diff --git a/module-apps/application-messages/ApplicationMessages.cpp b/module-apps/application-messages/ApplicationMessages.cpp index 4a0c010e7a2c1a808322c4663115db41e9b1cf82..a27117aea74d29c46587640672695c506a3bd0a5 100644 --- a/module-apps/application-messages/ApplicationMessages.cpp +++ b/module-apps/application-messages/ApplicationMessages.cpp @@ -40,7 +40,7 @@ namespace app ApplicationMessages::ApplicationMessages(std::string name, std::string parent, StartInBackground startInBackground) : Application(name, parent, startInBackground, 4096 * 2), AsyncCallbackReceiver{this} { - busChannels.push_back(sys::BusChannels::ServiceDBNotifications); + bus.channels.push_back(sys::BusChannel::ServiceDBNotifications); addActionReceiver(manager::actions::CreateSms, [this](auto &&data) { switchWindow(gui::name::window::new_sms, std::move(data)); return msgHandled(); diff --git a/module-apps/application-notes/ApplicationNotes.cpp b/module-apps/application-notes/ApplicationNotes.cpp index a61f03733e1dcbb1c4f993a5a08c9f8909102085..f5ca5050dee29e220a344c647507689c19e7428d 100644 --- a/module-apps/application-notes/ApplicationNotes.cpp +++ b/module-apps/application-notes/ApplicationNotes.cpp @@ -30,7 +30,7 @@ namespace app ApplicationNotes::ApplicationNotes(std::string name, std::string parent, StartInBackground startInBackground) : Application(name, parent, startInBackground, NotesStackSize) { - busChannels.push_back(sys::BusChannels::ServiceDBNotifications); + bus.channels.push_back(sys::BusChannel::ServiceDBNotifications); } // Invoked upon receiving data message diff --git a/module-apps/application-phonebook/ApplicationPhonebook.cpp b/module-apps/application-phonebook/ApplicationPhonebook.cpp index 48cef132d64c8f858bdfc0b50d908731bbb2f9a8..4c5feebbb3e006b2f017bc9241837468c6e8d713 100644 --- a/module-apps/application-phonebook/ApplicationPhonebook.cpp +++ b/module-apps/application-phonebook/ApplicationPhonebook.cpp @@ -24,7 +24,7 @@ namespace app StartInBackground startInBackground) : Application(name, parent, startInBackground, phonebook_stack_size) { - busChannels.push_back(sys::BusChannels::ServiceDBNotifications); + bus.channels.push_back(sys::BusChannel::ServiceDBNotifications); addActionReceiver(manager::actions::ShowContacts, [this](auto &&data) { switchWindow(gui::name::window::main_window, std::move(data)); return msgHandled(); diff --git a/module-apps/application-settings-new/ApplicationSettings.cpp b/module-apps/application-settings-new/ApplicationSettings.cpp index 48b51ae898bd0a2a9781cec537f0ebf5a78c61bd..f0c00fdd3941e9f5aec2ac5f9686bd2a35dee8aa 100644 --- a/module-apps/application-settings-new/ApplicationSettings.cpp +++ b/module-apps/application-settings-new/ApplicationSettings.cpp @@ -374,8 +374,8 @@ namespace app { constexpr int timeout = pdMS_TO_TICKS(1500); - auto response = sys::Bus::SendUnicast( - std::make_shared(), service::name::evt_manager, this, timeout); + auto response = bus.sendUnicast( + std::make_shared(), service::name::evt_manager, timeout); if (response.first == sys::ReturnCodes::Success) { auto msgState = dynamic_cast(response.second.get()); @@ -392,39 +392,35 @@ namespace app void ApplicationSettingsNew::setBrightness(bsp::eink_frontlight::BrightnessPercentage value) { screen_light_control::Parameters parameters{value}; - sys::Bus::SendUnicast(std::make_shared( - screen_light_control::Action::setManualModeBrightness, parameters), - service::name::evt_manager, - this); + bus.sendUnicast(std::make_shared( + screen_light_control::Action::setManualModeBrightness, parameters), + service::name::evt_manager); } void ApplicationSettingsNew::setMode(bool isAutoLightSwitchOn) { - sys::Bus::SendUnicast(std::make_shared( - isAutoLightSwitchOn ? screen_light_control::Action::enableAutomaticMode - : screen_light_control::Action::disableAutomaticMode), - service::name::evt_manager, - this); + bus.sendUnicast(std::make_shared( + isAutoLightSwitchOn ? screen_light_control::Action::enableAutomaticMode + : screen_light_control::Action::disableAutomaticMode), + service::name::evt_manager); } void ApplicationSettingsNew::setStatus(bool isDisplayLightSwitchOn) { - sys::Bus::SendUnicast( - std::make_shared( - isDisplayLightSwitchOn ? screen_light_control::Action::turnOn : screen_light_control::Action::turnOff), - service::name::evt_manager, - this); + bus.sendUnicast(std::make_shared(isDisplayLightSwitchOn + ? screen_light_control::Action::turnOn + : screen_light_control::Action::turnOff), + service::name::evt_manager); } auto ApplicationSettingsNew::isKeypadBacklightOn() -> bool { constexpr int timeout = pdMS_TO_TICKS(1500); - auto response = sys::Bus::SendUnicast( - std::make_shared(bsp::keypad_backlight::Action::checkState), - service::name::evt_manager, - this, - timeout); + auto response = + bus.sendUnicast(std::make_shared(bsp::keypad_backlight::Action::checkState), + service::name::evt_manager, + timeout); if (response.first == sys::ReturnCodes::Success) { auto msgState = dynamic_cast(response.second.get()); @@ -439,11 +435,9 @@ namespace app void ApplicationSettingsNew::setKeypadBacklightState(bool newState) { - sys::Bus::SendUnicast( - std::make_shared(newState ? bsp::keypad_backlight::Action::turnOn - : bsp::keypad_backlight::Action::turnOff), - service::name::evt_manager, - this); + bus.sendUnicast(std::make_shared( + newState ? bsp::keypad_backlight::Action::turnOn : bsp::keypad_backlight::Action::turnOff), + service::name::evt_manager); } } /* namespace app */ diff --git a/module-apps/application-settings-new/models/ApnSettingsModel.cpp b/module-apps/application-settings-new/models/ApnSettingsModel.cpp index f6772aa7a84d1ec6d84aa9b50d320f94597f06c4..be05bbead9d66f9f20db97057ddb84483986c6e2 100644 --- a/module-apps/application-settings-new/models/ApnSettingsModel.cpp +++ b/module-apps/application-settings-new/models/ApnSettingsModel.cpp @@ -10,7 +10,7 @@ ApnSettingsModel::ApnSettingsModel(app::Application *application) : application{ void ApnSettingsModel::requestAPNList() { - sys::Bus::SendUnicast(std::make_shared(), ServiceCellular::serviceName, application); + application->bus.sendUnicast(std::make_shared(), ServiceCellular::serviceName); } void ApnSettingsModel::saveAPN(std::shared_ptr apn) @@ -31,5 +31,5 @@ void ApnSettingsModel::removeAPN(std::shared_ptr apn) void ApnSettingsModel::setAsDefaultAPN(std::shared_ptr apn) { apn->apnType = packet_data::APN::APNType::Default; - sys::Bus::SendUnicast(std::make_shared(apn), ServiceCellular::serviceName, application); + application->bus.sendUnicast(std::make_shared(apn), ServiceCellular::serviceName); } diff --git a/module-apps/application-settings-new/models/LanguagesModel.cpp b/module-apps/application-settings-new/models/LanguagesModel.cpp index 3ca22a35d9645b303233fa6387cf005c47d1dae3..91afdd2389ac3391451a87bc7a2106a51644f290 100644 --- a/module-apps/application-settings-new/models/LanguagesModel.cpp +++ b/module-apps/application-settings-new/models/LanguagesModel.cpp @@ -7,7 +7,6 @@ void LanguagesModel::requestCurrentDisplayLanguage() { - sys::Bus::SendUnicast(std::make_shared(), - app::manager::ApplicationManager::ServiceName, - application); + application->bus.sendUnicast(std::make_shared(), + app::manager::ApplicationManager::ServiceName); } diff --git a/module-apps/application-settings-new/windows/AddDeviceWindow.cpp b/module-apps/application-settings-new/windows/AddDeviceWindow.cpp index 767e477dc9e99d93e4db9b400c9dd15e55d9791d..636baa6bc021e51c5d567dc4b90b7542596d4065 100644 --- a/module-apps/application-settings-new/windows/AddDeviceWindow.cpp +++ b/module-apps/application-settings-new/windows/AddDeviceWindow.cpp @@ -33,10 +33,9 @@ namespace gui device.name, [=](gui::Item &item) { LOG_DEBUG("Device: %s", device.name.c_str()); - sys::Bus::SendUnicast(std::make_shared(bd_addr_to_str(device.address)), - "ServiceBluetooth", - application, - 5000); + application->bus.sendUnicast(std::make_shared(bd_addr_to_str(device.address)), + "ServiceBluetooth", + 5000); return true; }, nullptr, @@ -44,8 +43,8 @@ namespace gui gui::option::SettingRightItem::Bt)); } - sys::Bus::SendUnicast( - std::make_shared(BluetoothMessage::Request::StopScan), "ServiceBluetooth", application); + application->bus.sendUnicast(std::make_shared(BluetoothMessage::Request::StopScan), + "ServiceBluetooth"); bottomBar->setText(BottomBar::Side::CENTER, utils::localize.get(style::strings::common::add)); diff --git a/module-apps/application-settings-new/windows/AllDevicesWindow.cpp b/module-apps/application-settings-new/windows/AllDevicesWindow.cpp index 9d0fffcefd605d4a7e0c7d8bae487537f8e6125a..85aaf325732b249edb572822d56f39440500a331 100644 --- a/module-apps/application-settings-new/windows/AllDevicesWindow.cpp +++ b/module-apps/application-settings-new/windows/AllDevicesWindow.cpp @@ -21,8 +21,8 @@ namespace gui AllDevicesWindow::AllDevicesWindow(app::Application *app) : OptionWindow(app, gui::window::name::all_devices) { setTitle(utils::localize.get("app_settings_bluetooth_all_devices")); - sys::Bus::SendUnicast( - std::make_shared<::message::bluetooth::RequestBondedDevices>(), service::name::bluetooth, application); + application->bus.sendUnicast(std::make_shared<::message::bluetooth::RequestBondedDevices>(), + service::name::bluetooth); } void AllDevicesWindow::onBeforeShow(ShowMode mode, SwitchData *data) @@ -38,9 +38,8 @@ namespace gui if (inputEvent.state == InputEvent::State::keyReleasedShort) { if (inputEvent.keyCode == KeyCode::KEY_LEFT) { - sys::Bus::SendUnicast(std::make_shared(BluetoothMessage::Request::Scan), - "ServiceBluetooth", - application); + application->bus.sendUnicast(std::make_shared(BluetoothMessage::Request::Scan), + "ServiceBluetooth"); gui::DialogMetadata meta; meta.icon = "search_big"; meta.text = utils::localize.get("app_settings_bluetooth_searching_devices"); diff --git a/module-apps/application-settings-new/windows/BluetoothWindow.cpp b/module-apps/application-settings-new/windows/BluetoothWindow.cpp index a1d4e4e211330d6438f2041191dcc1571b17900c..65156c9b402fdf4727945325aaf7ad34e3cb3034 100644 --- a/module-apps/application-settings-new/windows/BluetoothWindow.cpp +++ b/module-apps/application-settings-new/windows/BluetoothWindow.cpp @@ -15,8 +15,7 @@ namespace gui BluetoothWindow::BluetoothWindow(app::Application *app) : OptionWindow(app, gui::window::name::bluetooth) { - sys::Bus::SendUnicast( - std::make_shared<::message::bluetooth::RequestStatus>(), service::name::bluetooth, application); + application->bus.sendUnicast(std::make_shared<::message::bluetooth::RequestStatus>(), service::name::bluetooth); } void BluetoothWindow::onBeforeShow(ShowMode mode, SwitchData *data) @@ -111,17 +110,15 @@ namespace gui void BluetoothWindow::changeBluetoothState(bool currentState) { ::message::bluetooth::SetStatus setStatus(makeDesiredStatus(!currentState, isPhoneVisibilitySwitchOn)); - sys::Bus::SendUnicast(std::make_shared<::message::bluetooth::SetStatus>(std::move(setStatus)), - service::name::bluetooth, - application); + application->bus.sendUnicast(std::make_shared<::message::bluetooth::SetStatus>(std::move(setStatus)), + service::name::bluetooth); } void BluetoothWindow::changeVisibility(bool currentVisibility) { ::message::bluetooth::SetStatus setStatus(makeDesiredStatus(isBluetoothSwitchOn, !currentVisibility)); - sys::Bus::SendUnicast(std::make_shared<::message::bluetooth::SetStatus>(std::move(setStatus)), - service::name::bluetooth, - application); + application->bus.sendUnicast(std::make_shared<::message::bluetooth::SetStatus>(std::move(setStatus)), + service::name::bluetooth); } BluetoothStatus BluetoothWindow::makeDesiredStatus(bool desiredBluetoothState, bool desiredVisibility) noexcept diff --git a/module-apps/application-settings-new/windows/DisplayLightWindow.cpp b/module-apps/application-settings-new/windows/DisplayLightWindow.cpp index 1ae896ab3d273944feb9e17435604ba7f60a578a..9b91ba25db2a925300d2ea7faaccee344f6002f1 100644 --- a/module-apps/application-settings-new/windows/DisplayLightWindow.cpp +++ b/module-apps/application-settings-new/windows/DisplayLightWindow.cpp @@ -10,7 +10,6 @@ #include #include -#include namespace gui { diff --git a/module-apps/application-settings-new/windows/PhoneNameWindow.cpp b/module-apps/application-settings-new/windows/PhoneNameWindow.cpp index 9d0761a540114a5f618e3aaa5bb42a48303f9d00..3ba74608949aaeeb6eba65bd5fc66e80d5cb100e 100644 --- a/module-apps/application-settings-new/windows/PhoneNameWindow.cpp +++ b/module-apps/application-settings-new/windows/PhoneNameWindow.cpp @@ -33,8 +33,8 @@ namespace gui bottomBar->setText(BottomBar::Side::CENTER, utils::localize.get(style::strings::common::save)); bottomBar->setText(BottomBar::Side::RIGHT, utils::localize.get(style::strings::common::back)); - sys::Bus::SendUnicast( - std::make_shared<::message::bluetooth::RequestDeviceName>(), service::name::bluetooth, application); + application->bus.sendUnicast(std::make_shared<::message::bluetooth::RequestDeviceName>(), + service::name::bluetooth); setFocusItem(inputField); } @@ -59,7 +59,7 @@ namespace gui if (inputEvent.is(gui::KeyCode::KEY_ENTER) && !inputField->isEmpty()) { auto result = std::make_shared<::message::bluetooth::SetDeviceName>(inputField->getText()); - sys::Bus::SendUnicast(std::move(result), service::name::bluetooth, application); + application->bus.sendUnicast(std::move(result), service::name::bluetooth); return true; } diff --git a/module-apps/application-settings/ApplicationSettings.cpp b/module-apps/application-settings/ApplicationSettings.cpp index 5e339b02075804ff8f15461f14b24afdca6959b5..9e21b4a43c9d79e2ad7d51701940fa56255a80be 100644 --- a/module-apps/application-settings/ApplicationSettings.cpp +++ b/module-apps/application-settings/ApplicationSettings.cpp @@ -43,7 +43,7 @@ namespace app ApplicationSettings::ApplicationSettings(std::string name, std::string parent, StartInBackground startInBackground) : Application(name, parent, startInBackground) { - busChannels.push_back(sys::BusChannels::AntennaNotifications); + bus.channels.push_back(sys::BusChannel::AntennaNotifications); addActionReceiver(manager::actions::SelectSimCard, [this](auto &&data) { switchWindow(app::sim_select); return msgHandled(); diff --git a/module-apps/application-settings/windows/BtScanWindow.cpp b/module-apps/application-settings/windows/BtScanWindow.cpp index 0a06248669375f507f8afb9b6c63447eb0e8ee7f..c6f59cea8bf2810c5163d1e971e63a612fb36b75 100644 --- a/module-apps/application-settings/windows/BtScanWindow.cpp +++ b/module-apps/application-settings/windows/BtScanWindow.cpp @@ -43,7 +43,7 @@ namespace gui sys::ReturnCodes message_bt2(app::Application *app, BluetoothMessage::Request req) { std::shared_ptr msg = std::make_shared(req); - auto ret = sys::Bus::SendUnicast(msg, "ServiceBluetooth", app); + auto ret = app->bus.sendUnicast(msg, "ServiceBluetooth"); if (!ret) { LOG_ERROR("err: %d", static_cast(ret)); } @@ -68,7 +68,7 @@ namespace gui std::shared_ptr msg = std::make_shared(bd_addr_to_str(device.address)); - sys::Bus::SendUnicast(msg, "ServiceBluetooth", application, 5000); + application->bus.sendUnicast(msg, "ServiceBluetooth", 5000); message_bt2(application, BluetoothMessage::Request::StopScan); // message_bt2(application, BluetoothMessage::Request::Start); diff --git a/module-apps/application-settings/windows/BtWindow.cpp b/module-apps/application-settings/windows/BtWindow.cpp index 71552f1146a35afcc644aeb8d73e886305bdc19d..e6952b5c2ec869a3b6ed15859e85bbb15624167c 100644 --- a/module-apps/application-settings/windows/BtWindow.cpp +++ b/module-apps/application-settings/windows/BtWindow.cpp @@ -45,7 +45,7 @@ namespace gui sys::ReturnCodes message_bt(app::Application *app, BluetoothMessage::Request req) { std::shared_ptr msg = std::make_shared(req); - auto ret = sys::Bus::SendUnicast(msg, "ServiceBluetooth", app); + auto ret = app->bus.sendUnicast(msg, "ServiceBluetooth"); if (!ret) { LOG_ERROR("err: %d", static_cast(ret)); } diff --git a/module-apps/application-settings/windows/ColorTestWindow.cpp b/module-apps/application-settings/windows/ColorTestWindow.cpp index 819660583956e0faab5f65eb052a12af54ad4be3..d5e3e8ebe0c2b0dd4b6078a1e3863c3a47853c92 100644 --- a/module-apps/application-settings/windows/ColorTestWindow.cpp +++ b/module-apps/application-settings/windows/ColorTestWindow.cpp @@ -78,10 +78,8 @@ namespace gui { if (scheme != currentColorScheme) { currentColorScheme = scheme; - sys::Bus::SendUnicast(std::make_shared(std::move(scheme)), - service::name::gui, - this->application, - 100); + application->bus.sendUnicast( + std::make_shared(std::move(scheme)), service::name::gui, 100); LOG_INFO("Updated color scheme"); application->refreshWindow(RefreshModes::GUI_REFRESH_DEEP); diff --git a/module-apps/application-settings/windows/EinkModeWindow.cpp b/module-apps/application-settings/windows/EinkModeWindow.cpp index c43414c48a29752c31fba3741f34a2d2fce6df70..8d4ca7e31e08b68b96ce5ee953c343f9661a41ef 100644 --- a/module-apps/application-settings/windows/EinkModeWindow.cpp +++ b/module-apps/application-settings/windows/EinkModeWindow.cpp @@ -39,10 +39,8 @@ namespace gui last_mode = service::eink::EinkModeMessage::Mode::Normal; } - sys::Bus::SendUnicast(std::make_shared(last_mode), - service::name::eink, - this->application, - 5000); + application->bus.sendUnicast( + std::make_shared(last_mode), service::name::eink, 5000); return true; }; setFocusItem(label); diff --git a/module-apps/application-settings/windows/Fota.cpp b/module-apps/application-settings/windows/Fota.cpp index 3c98d953e0872d68b7d57200f52b4598d318e320..33c3ab25a9adff94eb616131975fa5c5e6820f54 100644 --- a/module-apps/application-settings/windows/Fota.cpp +++ b/module-apps/application-settings/windows/Fota.cpp @@ -19,19 +19,13 @@ Fota::Fota(gui::FotaWindow *parent) : currentState(State::Disconnected), parent( { app = std::shared_ptr(parent->getApplication(), [](app::Application *) {}); /// with deleter that doesn't delete. - app->busChannels.push_back(sys::BusChannels::ServiceFotaNotifications); + app->bus.channels.push_back(sys::BusChannel::ServiceFotaNotifications); registerHandlers(); - sys::Bus::Add(std::static_pointer_cast(app)); getCurrentVersion(); parent->statusLabel->setText(getStateString()); } -Fota::~Fota() -{ - sys::Bus::Remove(std::static_pointer_cast(app)); -} - void Fota::next() { switch (currentState) { @@ -200,7 +194,7 @@ void Fota::reboot() currentState = State::Reboot; parent->statusLabel->setText(getStateString()); auto msg = std::make_shared(sys::Code::Reboot); - sys::Bus::SendUnicast(std::move(msg), service::name::system_manager, app.get()); + app->bus.sendUnicast(std::move(msg), service::name::system_manager); } void Fota::registerHandlers() diff --git a/module-apps/application-settings/windows/Fota.hpp b/module-apps/application-settings/windows/Fota.hpp index d152dee9e35eeec375128c29724c2eefd6b5a13a..29936a089686993fe3a48e2aeee2a4fac4cafc49 100644 --- a/module-apps/application-settings/windows/Fota.hpp +++ b/module-apps/application-settings/windows/Fota.hpp @@ -40,7 +40,6 @@ class Fota }; using VersionMap = std::unordered_map; Fota(gui::FotaWindow *parent); - virtual ~Fota(); void next(); std::string getCurrentFirmwareVersion() { diff --git a/module-bluetooth/Bluetooth/interface/profiles/A2DP/A2DP.cpp b/module-bluetooth/Bluetooth/interface/profiles/A2DP/A2DP.cpp index 2b728f6256ac349d64f2d839aee36e452746b357..b1f0dc3d728f93f1b590bf26d074093fc57dfd97 100644 --- a/module-bluetooth/Bluetooth/interface/profiles/A2DP/A2DP.cpp +++ b/module-bluetooth/Bluetooth/interface/profiles/A2DP/A2DP.cpp @@ -12,7 +12,6 @@ #include #include #include -#include #include #include