In MuditaOS, application is a service derivative which:
This paragraph is using applicaton-test as an example.
WARNING All applications are enabled by default. Please disable yours if it's not always needed in CMakeLists.txt. I.e.: option(ENABLE_APP_TEST "Enable application test" OFF)
application catalog in module-apps i.e. application-testinclude/application-test/ for public includes for this applicationApplicationInitHandler() for application.
InitHandler()createUserInterface(), which role is:
windowsFactory with windows blueprints for this applicationgui::name::window::main_window. Without that window application may be never shown properlyBasic example can be found in this catalog: application-test
Launch
example:return app::manager::Controller::sendAction(application,
app::manager::actions::Launch,
std::make_unique<app::ApplicationLaunchData>("ApplicationAlarmClock"));
});
startInBackground in Application constructorWARNING Enabling app in the background means it will always lay on stack and heap and never terminate
WARNING App in the background just doesn't handle Launch. This means that if you call Launch on the system, there will be a "Terrible, terrible damage" log due to undefined system behavior. Launch action is meant to launch applications - the issue is system-side - the application manager might not be started yet.
IMPORTANT Please always remember that it goes the same as with services:
application-managerInitHandler()
log explaining:2290 ms INFO [ApplicationManager] ApplicationTest.cpp:ApplicationTest:19: created!
2293 ms INFO [ApplicationTest] ApplicationTest.cpp:InitHandler:27: initializing!
Due to the fact that the application can be closed before asynchronous data is received one should have initialized AsyncCallbackReceiver(this).
To have notifications on changed DB one should connect to the notifications:
bus.channels.push_back(sys::BusChannel::ServiceDBNotifications);
To propagate changes from the database to UI handling, one has to pass these from the application to windows. It can be done via presenter, but here's an alternative approach:
if (msgl->messageType == MessageType::DBServiceNotification) {
auto msg = dynamic_cast<db::NotificationMessage *>(msgl);
if (msg != nullptr) {
userInterfaceDBNotification(msgl,
[&]([[maybe_unused]] sys::Message *, [[maybe_unused]] const std::string &) {
// your code here
});
return std::make_shared<sys::ResponseMessage>();
}
}
You can perform datababase queries via query interface.
To have a safe way to perform asynchronous calls there is app::AsyncQuery which:
It's defined here: AsyncTask.hpp
NOTE to automatically pass async db::query data to an application you have to:
public app::AsyncCallbackReceiverreturn handleAsyncResponse(resp); at the end of DataReceivedHandler()GUI library documentation: module-gui Please mind that it has Doxygen documentation explaining its use for all base elements and functions.
System action is a call from service to application. NOTE By design applications are running only when required, whereas services are available all time when started.
With this, we can:
WARNING In the MuditaOS a popup is a Window that can be shown any time on an action request.
NOTE attachPopups should be most probably moved to manifest and popup enum just removed
NOTE Pop-ups regarding SIM cards' presence/availability currently have some special logic regarding windows stack around them.
Popups weren't designed as a part of the system, but rather step by step integrated into it. While there should be no issue with partially overflowing popups in the applications and UI, it would mean major source code refactoring and planning.
Each popup has:
attachPopupscreateUserInterface() attachPopups({gui::popup::ID::AppTestPopup});}Now we can open such popup in the application via: app::manager::Controller::sendAction(..., ShowPopup, ...)
NOTE Mapping enum <-> string from Popups.cpp can be overridden in popup blueprint. More advanced popups will most likely require it.
NOTE Default fallback won't pass any data to the popup - application won't have the information that requested window is a popup and any additional SwitchData. To have this data - you need to call popupBlueprint.registerBlueprint(...)
Please follow information here: third party libraries
Please follow information here: unit tests gathering cmake
ApplicationManifest.hpp is undocumented. Its role is to:
ActionPopup - it enables applications to show popupAutoLockPolicy - which defines if the application is on top should phone permit auto-lockWARNING ApplicationManifest does not have a dependency on services. Applications are started when application-manager is started:
InitHandler()