M changelog.md => changelog.md +1 -0
@@ 13,6 13,7 @@
* `[calendar]` Set 'all day' as a default option
* `[bus]` Message handling refactored.
+* `[appmgr]` Translating messages to actions introduced.
### Fixed
M module-apps/UiCommonActions.cpp => module-apps/UiCommonActions.cpp +1 -1
@@ 12,7 12,7 @@
#include "application-special-input/ApplicationSpecialInput.hpp"
#include <service-appmgr/Controller.hpp>
-#include <service-appmgr/Message.hpp>
+#include <service-appmgr/messages/Message.hpp>
#include <i18/i18.hpp>
#include <log/log.hpp>
M module-services/service-appmgr/CMakeLists.txt => module-services/service-appmgr/CMakeLists.txt +13 -0
@@ 7,6 7,19 @@ set(SOURCES
model/ApplicationManager.cpp
model/ApplicationHandle.cpp
model/ApplicationsRegistry.cpp
+ messages/ActionRequest.cpp
+ messages/ApplicationCloseRequest.cpp
+ messages/ApplicationInitialised.cpp
+ messages/ApplicationStatus.cpp
+ messages/BaseMessage.cpp
+ messages/CloseConfirmation.cpp
+ messages/LanguageChangeRequest.cpp
+ messages/PowerSaveModeInitRequest.cpp
+ messages/PreventBlockingRequest.cpp
+ messages/ShutdownRequest.cpp
+ messages/SwitchBackRequest.cpp
+ messages/SwitchConfirmation.cpp
+ messages/SwitchRequest.cpp
)
add_library(${PROJECT_NAME} STATIC ${SOURCES})
M module-services/service-appmgr/Controller.cpp => module-services/service-appmgr/Controller.cpp +1 -2
@@ 22,8 22,7 @@ namespace app::manager
StartupStatus status,
StartInBackground startInBackground) -> bool
{
- auto msg =
- std::make_shared<app::manager::ApplicationInitialisation>(sender->GetName(), status, startInBackground);
+ auto msg = std::make_shared<app::manager::ApplicationInitialised>(sender->GetName(), status, startInBackground);
return sys::Bus::SendUnicast(msg, ApplicationManager::ServiceName, sender);
}
A module-services/service-appmgr/messages/ActionRequest.cpp => module-services/service-appmgr/messages/ActionRequest.cpp +23 -0
@@ 0,0 1,23 @@
+// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#include <service-appmgr/messages/ActionRequest.hpp>
+
+namespace app::manager
+{
+ ActionRequest::ActionRequest(const ApplicationName &senderName,
+ actions::ActionId _actionId,
+ actions::ActionParamsPtr &&_data)
+ : BaseMessage{MessageType::APMAction, senderName}, actionId{_actionId}, data{std::move(_data)}
+ {}
+
+ [[nodiscard]] auto ActionRequest::getAction() const noexcept -> actions::ActionId
+ {
+ return actionId;
+ }
+
+ [[nodiscard]] auto ActionRequest::getData() noexcept -> actions::ActionParamsPtr &
+ {
+ return data;
+ }
+} // namespace app::manager
A module-services/service-appmgr/messages/ApplicationCloseRequest.cpp => module-services/service-appmgr/messages/ApplicationCloseRequest.cpp +16 -0
@@ 0,0 1,16 @@
+// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#include <service-appmgr/messages/ApplicationCloseRequest.hpp>
+
+namespace app::manager
+{
+ ApplicationCloseRequest::ApplicationCloseRequest(const ApplicationName &senderName, ApplicationName application)
+ : BaseMessage(MessageType::APMDelayedClose, senderName), application{std::move(application)}
+ {}
+
+ [[nodiscard]] auto ApplicationCloseRequest::getApplication() const noexcept -> const ApplicationName &
+ {
+ return application;
+ }
+} // namespace app::manager
A module-services/service-appmgr/messages/ApplicationInitialised.cpp => module-services/service-appmgr/messages/ApplicationInitialised.cpp +23 -0
@@ 0,0 1,23 @@
+// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#include <service-appmgr/messages/ApplicationInitialised.hpp>
+
+namespace app::manager
+{
+ ApplicationInitialised::ApplicationInitialised(const ApplicationName &senderName,
+ StartupStatus _status,
+ StartInBackground _startInBackground)
+ : BaseMessage(MessageType::APMInit, senderName), status{_status}, startInBackground{_startInBackground}
+ {}
+
+ [[nodiscard]] auto ApplicationInitialised::getStatus() const noexcept -> StartupStatus
+ {
+ return status;
+ }
+
+ [[nodiscard]] auto ApplicationInitialised::isBackgroundApplication() const noexcept -> bool
+ {
+ return startInBackground.value;
+ }
+} // namespace app::manager
A module-services/service-appmgr/messages/ApplicationStatus.cpp => module-services/service-appmgr/messages/ApplicationStatus.cpp +17 -0
@@ 0,0 1,17 @@
+// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#include <service-appmgr/messages/ApplicationStatus.hpp>
+
+namespace app::manager
+{
+ ApplicationStatusRequest::ApplicationStatusRequest(const ApplicationName &senderName,
+ ApplicationName applicationName)
+ : BaseMessage(MessageType::APMCheckAppRunning, senderName), checkAppName(std::move(applicationName))
+ {}
+
+ ApplicationStatusResponse::ApplicationStatusResponse(const ApplicationName &_applicationName, bool _isRunning)
+ : sys::ResponseMessage(sys::ReturnCodes::Success, MessageType::APMCheckAppRunning),
+ applicationName{std::move(_applicationName)}, isRunning{_isRunning}
+ {}
+} // namespace app::manager
A module-services/service-appmgr/messages/BaseMessage.cpp => module-services/service-appmgr/messages/BaseMessage.cpp +16 -0
@@ 0,0 1,16 @@
+// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#include <service-appmgr/messages/BaseMessage.hpp>
+
+namespace app::manager
+{
+ BaseMessage::BaseMessage(MessageType type, ApplicationName sender)
+ : sys::DataMessage(type), senderName{std::move(sender)}
+ {}
+
+ [[nodiscard]] auto BaseMessage::getSenderName() const noexcept -> const ApplicationName &
+ {
+ return senderName;
+ }
+} // namespace app::manager
A module-services/service-appmgr/messages/CloseConfirmation.cpp => module-services/service-appmgr/messages/CloseConfirmation.cpp +11 -0
@@ 0,0 1,11 @@
+// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#include <service-appmgr/messages/CloseConfirmation.hpp>
+
+namespace app::manager
+{
+ CloseConfirmation::CloseConfirmation(const ApplicationName &sender)
+ : BaseMessage(MessageType::APMConfirmClose, sender)
+ {}
+} // namespace app::manager
A module-services/service-appmgr/messages/LanguageChangeRequest.cpp => module-services/service-appmgr/messages/LanguageChangeRequest.cpp +24 -0
@@ 0,0 1,24 @@
+// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#include <service-appmgr/messages/LanguageChangeRequest.hpp>
+
+namespace app::manager
+{
+ LanguageChangeRequest::LanguageChangeRequest(const ApplicationName &senderName, utils::Lang language)
+ : BaseMessage(MessageType::APMChangeLanguage, senderName), language{language}
+ {}
+
+ [[nodiscard]] auto LanguageChangeRequest::getLanguage() const noexcept -> utils::Lang
+ {
+ return language;
+ }
+
+ DisplayLanguageChangeRequest::DisplayLanguageChangeRequest(const ApplicationName &senderName, utils::Lang language)
+ : LanguageChangeRequest(senderName, language)
+ {}
+
+ InputLanguageChangeRequest::InputLanguageChangeRequest(const ApplicationName &senderName, utils::Lang language)
+ : LanguageChangeRequest(senderName, language)
+ {}
+} // namespace app::manager
A module-services/service-appmgr/messages/PowerSaveModeInitRequest.cpp => module-services/service-appmgr/messages/PowerSaveModeInitRequest.cpp +11 -0
@@ 0,0 1,11 @@
+// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#include <service-appmgr/messages/PowerSaveModeInitRequest.hpp>
+
+namespace app::manager
+{
+ PowerSaveModeInitRequest::PowerSaveModeInitRequest(const ApplicationName &senderName)
+ : BaseMessage(MessageType::APMInitPowerSaveMode, senderName)
+ {}
+} // namespace app::manager
A module-services/service-appmgr/messages/PreventBlockingRequest.cpp => module-services/service-appmgr/messages/PreventBlockingRequest.cpp +11 -0
@@ 0,0 1,11 @@
+// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#include <service-appmgr/messages/PreventBlockingRequest.hpp>
+
+namespace app::manager
+{
+ PreventBlockingRequest::PreventBlockingRequest(const ApplicationName &senderName)
+ : BaseMessage(MessageType::APMPreventBlocking, senderName)
+ {}
+} // namespace app::manager
A module-services/service-appmgr/messages/ShutdownRequest.cpp => module-services/service-appmgr/messages/ShutdownRequest.cpp +10 -0
@@ 0,0 1,10 @@
+// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#include <service-appmgr/messages/ShutdownRequest.hpp>
+
+namespace app::manager
+{
+ ShutdownRequest::ShutdownRequest(const ApplicationName &senderName) : BaseMessage(MessageType::APMClose, senderName)
+ {}
+} // namespace app::manager
A module-services/service-appmgr/messages/SwitchBackRequest.cpp => module-services/service-appmgr/messages/SwitchBackRequest.cpp +16 -0
@@ 0,0 1,16 @@
+// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#include <service-appmgr/messages/SwitchBackRequest.hpp>
+
+namespace app::manager
+{
+ SwitchBackRequest::SwitchBackRequest(const ApplicationName &name, std::unique_ptr<gui::SwitchData> data)
+ : BaseMessage(MessageType::APMSwitchPrevApp, name), data{std::move(data)}
+ {}
+
+ [[nodiscard]] auto SwitchBackRequest::getData() noexcept -> std::unique_ptr<gui::SwitchData> &
+ {
+ return data;
+ }
+} // namespace app::manager
A module-services/service-appmgr/messages/SwitchConfirmation.cpp => module-services/service-appmgr/messages/SwitchConfirmation.cpp +11 -0
@@ 0,0 1,11 @@
+// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#include <service-appmgr/messages/SwitchConfirmation.hpp>
+
+namespace app::manager
+{
+ SwitchConfirmation::SwitchConfirmation(const ApplicationName &sender)
+ : BaseMessage(MessageType::APMConfirmSwitch, sender)
+ {}
+} // namespace app::manager
A module-services/service-appmgr/messages/SwitchRequest.cpp => module-services/service-appmgr/messages/SwitchRequest.cpp +30 -0
@@ 0,0 1,30 @@
+// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#include <service-appmgr/messages/SwitchRequest.hpp>
+
+namespace app::manager
+{
+ SwitchRequest::SwitchRequest(const ApplicationName &senderName,
+ ApplicationName applicationName,
+ std::string windowName,
+ std::unique_ptr<gui::SwitchData> data)
+ : BaseMessage(MessageType::APMSwitch, senderName),
+ application{std::move(applicationName)}, window{std::move(windowName)}, data{std::move(data)}
+ {}
+
+ [[nodiscard]] auto SwitchRequest::getName() const noexcept -> const ApplicationName &
+ {
+ return application;
+ }
+
+ [[nodiscard]] auto SwitchRequest::getWindow() const noexcept -> const std::string &
+ {
+ return window;
+ }
+
+ [[nodiscard]] auto SwitchRequest::getData() noexcept -> std::unique_ptr<gui::SwitchData> &
+ {
+ return data;
+ }
+} // namespace app::manager
M module-services/service-appmgr/model/ApplicationHandle.cpp => module-services/service-appmgr/model/ApplicationHandle.cpp +22 -18
@@ 7,38 7,42 @@ namespace app::manager
{
ApplicationHandle::ApplicationHandle(std::unique_ptr<app::ApplicationLauncher> &&_launcher)
: launcher{std::move(_launcher)}
- {}
+ {
+ if (!launcher) {
+ throw std::invalid_argument{"The application launcher must not be null."};
+ }
+ }
- auto ApplicationHandle::manifest() const -> const ApplicationManifest &
+ auto ApplicationHandle::valid() const noexcept -> bool
{
- return launcher ? launcher->getManifest() : InvalidManifest;
+ return launcher && launcher->handle;
}
auto ApplicationHandle::name() const -> ApplicationName
{
- return launcher ? launcher->getName() : InvalidAppName.data();
+ return launcher->getName();
}
auto ApplicationHandle::state() const noexcept -> State
{
- return launcher && launcher->handle ? launcher->handle->getState() : State::NONE;
+ return valid() ? launcher->handle->getState() : State::NONE;
}
void ApplicationHandle::setState(State state) noexcept
{
- if (launcher && launcher->handle) {
+ if (valid()) {
launcher->handle->setState(state);
}
}
auto ApplicationHandle::preventsBlocking() const noexcept -> bool
{
- return launcher ? launcher->isBlocking() : false;
+ return launcher->isBlocking();
}
auto ApplicationHandle::closeable() const noexcept -> bool
{
- return launcher ? launcher->isCloseable() : false;
+ return launcher->isCloseable();
}
auto ApplicationHandle::started() const noexcept -> bool
@@ 50,27 54,27 @@ namespace app::manager
auto ApplicationHandle::handles(actions::ActionId action) const noexcept -> bool
{
- return manifest().contains(action);
+ const auto manifest = getManifest();
+ return manifest.contains(action);
}
void ApplicationHandle::run(sys::Service *caller)
{
- if (launcher) {
- launcher->run(caller);
- }
+ launcher->run(caller);
}
void ApplicationHandle::runInBackground(sys::Service *caller)
{
- if (launcher) {
- launcher->runBackground(caller);
- }
+ launcher->runBackground(caller);
}
void ApplicationHandle::close() noexcept
{
- if (launcher) {
- launcher->handle = nullptr;
- }
+ launcher->handle = nullptr;
+ }
+
+ auto ApplicationHandle::getManifest() const -> const ApplicationManifest &
+ {
+ return launcher->getManifest();
}
} // namespace app::manager
M module-services/service-appmgr/model/ApplicationManager.cpp => module-services/service-appmgr/model/ApplicationManager.cpp +5 -5
@@ 15,7 15,7 @@
#include <application-special-input/ApplicationSpecialInput.hpp>
#include <i18/i18.hpp>
#include <log/log.hpp>
-#include <service-appmgr/Message.hpp>
+#include <service-appmgr/messages/Message.hpp>
#include <service-db/api/DBServiceAPI.hpp>
#include <service-evtmgr/EventManager.hpp>
#include <service-gui/ServiceGUI.hpp>
@@ 235,8 235,8 @@ namespace app::manager
closeApplication(applications.findByName(msg->getApplication()));
return std::make_shared<sys::ResponseMessage>();
});
- connect(typeid(ApplicationInitialisation), [this](sys::Message *request) {
- auto msg = static_cast<ApplicationInitialisation *>(request);
+ connect(typeid(ApplicationInitialised), [this](sys::Message *request) {
+ auto msg = static_cast<ApplicationInitialised *>(request);
handleInitApplication(msg);
return std::make_shared<sys::ResponseMessage>();
});
@@ 483,7 483,7 @@ namespace app::manager
previousApp.switchWindow = std::move(targetWindow);
}
- auto ApplicationManager::handleInitApplication(ApplicationInitialisation *msg) -> bool
+ auto ApplicationManager::handleInitApplication(ApplicationInitialised *msg) -> bool
{
auto app = getApplication(msg->getSenderName());
if (app == nullptr) {
@@ 565,7 565,7 @@ namespace app::manager
void ApplicationManager::rebuildActiveApplications()
{
for (const auto &app : getApplications()) {
- if (app && app->launcher && app->launcher->handle) {
+ if (app && app->valid()) {
if (const auto appState = app->state(); appState == ApplicationHandle::State::ACTIVE_FORGROUND ||
appState == ApplicationHandle::State::ACTIVE_BACKGROUND) {
app::Application::messageRebuildApplication(this, app->name());
M module-services/service-appmgr/service-appmgr/Actions.hpp => module-services/service-appmgr/service-appmgr/Actions.hpp +25 -12
@@ 9,18 9,31 @@
#include <string>
#include <vector>
-namespace app::manager::actions
+namespace app::manager
{
- using ActionId = int;
- using ActionFilter = std::vector<ActionId>;
+ class ActionRequest; // Forward declaration.
- enum Action : ActionId
+ namespace actions
{
- Launch,
- Call,
- UserAction
- };
-
- using ActionParams = gui::SwitchData;
- using ActionParamsPtr = std::unique_ptr<ActionParams>;
-} // namespace app::manager::actions
+ using ActionId = int;
+ using ActionFilter = std::vector<ActionId>;
+ using ActionParams = gui::SwitchData;
+ using ActionParamsPtr = std::unique_ptr<ActionParams>;
+
+ enum Action : ActionId
+ {
+ Launch,
+ Call,
+ UserAction // The last enumerator in the Action enum.
+ // All user-defined actions shall have values greater than UserAction.
+ };
+
+ class ConvertibleToAction
+ {
+ public:
+ virtual ~ConvertibleToAction() noexcept = default;
+
+ virtual auto toAction() const -> std::unique_ptr<ActionRequest> = 0;
+ };
+ } // namespace actions
+} // namespace app::manager
M module-services/service-appmgr/service-appmgr/Controller.hpp => module-services/service-appmgr/service-appmgr/Controller.hpp +1 -1
@@ 4,7 4,7 @@
#pragma once
#include "Actions.hpp"
-#include "Message.hpp"
+#include "messages/Message.hpp"
#include "model/ApplicationManager.hpp"
#include <module-sys/Service/Service.hpp>
D module-services/service-appmgr/service-appmgr/Message.hpp => module-services/service-appmgr/service-appmgr/Message.hpp +0 -247
@@ 1,247 0,0 @@
-// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
-// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
-
-#pragma once
-
-#include "Actions.hpp"
-#include "ApplicationManifest.hpp"
-
-#include <Service/Message.hpp>
-#include <MessageType.hpp>
-#include <i18/i18.hpp>
-
-#include <module-apps/Application.hpp>
-#include <module-gui/gui/SwitchData.hpp>
-
-namespace app::manager
-{
- /// A template for all messages to application manager.
- class Message : public sys::DataMessage
- {
- public:
- Message(MessageType messageType, ApplicationName senderName)
- : sys::DataMessage(messageType), senderName{std::move(senderName)}
- {}
-
- [[nodiscard]] auto getSenderName() const noexcept -> ApplicationName
- {
- return senderName;
- }
-
- protected:
- /// name of the application that is sending message to application manager.
- ApplicationName senderName;
- };
-
- /// Requests a switch to a given application. Optionally to a specified window, too.
- class SwitchRequest : public Message
- {
- public:
- SwitchRequest(const ApplicationName &senderName,
- ApplicationName applicationName,
- std::string windowName,
- std::unique_ptr<gui::SwitchData> data)
- : Message(MessageType::APMSwitch, senderName),
- application{std::move(applicationName)}, window{std::move(windowName)}, data{std::move(data)}
- {}
-
- [[nodiscard]] auto getName() const noexcept -> const ApplicationName &
- {
- return application;
- }
-
- [[nodiscard]] auto getWindow() const noexcept -> const std::string &
- {
- return window;
- }
-
- [[nodiscard]] auto getData() noexcept -> std::unique_ptr<gui::SwitchData> &
- {
- return data;
- }
-
- private:
- ApplicationName application;
- std::string window;
- std::unique_ptr<gui::SwitchData> data;
- };
-
- /// Requests a switch to a previous application.
- class SwitchBackRequest : public Message
- {
- public:
- SwitchBackRequest(const ApplicationName &name, std::unique_ptr<gui::SwitchData> data = nullptr)
- : Message(MessageType::APMSwitchPrevApp, name), data{std::move(data)}
- {}
-
- [[nodiscard]] auto getData() noexcept -> std::unique_ptr<gui::SwitchData> &
- {
- return data;
- }
-
- private:
- std::unique_ptr<gui::SwitchData> data;
- };
-
- /// Confirms that the applications lost/gained focus.
- class SwitchConfirmation : public Message
- {
- public:
- SwitchConfirmation(const ApplicationName &name) : Message(MessageType::APMConfirmSwitch, name)
- {}
- };
-
- /// Confirms that the application closed successfully.
- class CloseConfirmation : public Message
- {
- public:
- CloseConfirmation(const ApplicationName &name) : Message(MessageType::APMConfirmClose, name)
- {}
- };
-
- ///
- class ApplicationInitialisation : public Message
- {
- public:
- ApplicationInitialisation(const ApplicationName &senderName,
- StartupStatus _status,
- StartInBackground _startInBackground)
- : Message(MessageType::APMInit, senderName), status{_status}, startInBackground{_startInBackground}
- {}
-
- [[nodiscard]] auto getStatus() const noexcept -> StartupStatus
- {
- return status;
- }
-
- [[nodiscard]] auto isBackgroundApplication() const noexcept -> bool
- {
- return startInBackground.value;
- }
-
- private:
- StartupStatus status;
- StartInBackground startInBackground;
- };
-
- /// Requests the application to close.
- class ApplicationCloseRequest : public Message
- {
- public:
- ApplicationCloseRequest(const ApplicationName &senderName, ApplicationName application)
- : Message(MessageType::APMDelayedClose, senderName), application{std::move(application)}
- {}
-
- [[nodiscard]] auto getApplication() const noexcept -> const ApplicationName &
- {
- return application;
- }
-
- private:
- ApplicationName application;
- };
-
- /// Requests to change the display language.
- class DisplayLanguageChangeRequest : public Message
- {
- public:
- DisplayLanguageChangeRequest(const ApplicationName &senderName, utils::Lang language)
- : Message(MessageType::APMChangeLanguage, senderName), language{language}
- {}
-
- [[nodiscard]] auto getLanguage() const noexcept -> utils::Lang
- {
- return language;
- }
-
- private:
- utils::Lang language;
- };
-
- /// Requests to change the input language.
- class InputLanguageChangeRequest : public Message
- {
- public:
- InputLanguageChangeRequest(const ApplicationName &senderName, utils::Lang language)
- : Message(MessageType::APMChangeLanguage, senderName), language{language}
- {}
-
- [[nodiscard]] auto getLanguage() const noexcept -> utils::Lang
- {
- return language;
- }
-
- private:
- utils::Lang language;
- };
-
- /// Requests the application manager to close.
- class ShutdownRequest : public Message
- {
- public:
- ShutdownRequest(const ApplicationName &senderName) : Message(MessageType::APMClose, senderName)
- {}
- };
-
- /// Requests application manager to prevent device blocking.
- class PreventBlockingRequest : public Message
- {
- public:
- PreventBlockingRequest(const ApplicationName &senderName) : Message(MessageType::APMPreventBlocking, senderName)
- {}
- };
-
- /// Requests the application manager to enter power save mode.
- class PowerSaveModeInitRequest : public Message
- {
- public:
- PowerSaveModeInitRequest(const ApplicationName &senderName)
- : Message(MessageType::APMInitPowerSaveMode, senderName)
- {}
- };
-
- /// Requests the application manager to check the status of the application.
- class ApplicationStatusRequest : public Message
- {
- public:
- ApplicationStatusRequest(const ApplicationName &senderName, ApplicationName applicationName)
- : Message(MessageType::APMCheckAppRunning, senderName), checkAppName(std::move(applicationName))
- {}
-
- ApplicationName checkAppName;
- };
-
- class ApplicationStatusResponse : public sys::ResponseMessage
- {
- public:
- ApplicationStatusResponse(const ApplicationName &_applicationName, bool _isRunning)
- : sys::ResponseMessage(sys::ReturnCodes::Success, MessageType::APMCheckAppRunning),
- applicationName{std::move(_applicationName)}, isRunning{_isRunning}
- {}
-
- ApplicationName applicationName;
- bool isRunning;
- };
-
- class ActionRequest : public Message
- {
- public:
- ActionRequest(const ApplicationName &senderName, actions::ActionId _actionId, actions::ActionParamsPtr &&_data)
- : Message{MessageType::APMAction, senderName}, actionId{_actionId}, data{std::move(_data)}
- {}
-
- [[nodiscard]] auto getAction() const noexcept -> actions::ActionId
- {
- return actionId;
- }
-
- [[nodiscard]] auto getData() noexcept -> actions::ActionParamsPtr &
- {
- return data;
- }
-
- private:
- actions::ActionId actionId;
- actions::ActionParamsPtr data;
- };
-} // namespace app::manager
A module-services/service-appmgr/service-appmgr/messages/ActionRequest.hpp => module-services/service-appmgr/service-appmgr/messages/ActionRequest.hpp +25 -0
@@ 0,0 1,25 @@
+// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#pragma once
+
+#include "BaseMessage.hpp"
+
+#include <module-services/service-appmgr/service-appmgr/Actions.hpp>
+#include <module-services/service-appmgr/service-appmgr/ApplicationManifest.hpp>
+
+namespace app::manager
+{
+ class ActionRequest : public BaseMessage
+ {
+ public:
+ ActionRequest(const ApplicationName &senderName, actions::ActionId _actionId, actions::ActionParamsPtr &&_data);
+
+ [[nodiscard]] auto getAction() const noexcept -> actions::ActionId;
+ [[nodiscard]] auto getData() noexcept -> actions::ActionParamsPtr &;
+
+ private:
+ actions::ActionId actionId;
+ actions::ActionParamsPtr data;
+ };
+} // namespace app::manager
A module-services/service-appmgr/service-appmgr/messages/ApplicationCloseRequest.hpp => module-services/service-appmgr/service-appmgr/messages/ApplicationCloseRequest.hpp +20 -0
@@ 0,0 1,20 @@
+// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#pragma once
+
+#include "BaseMessage.hpp"
+
+namespace app::manager
+{
+ class ApplicationCloseRequest : public BaseMessage
+ {
+ public:
+ ApplicationCloseRequest(const ApplicationName &senderName, ApplicationName application);
+
+ [[nodiscard]] auto getApplication() const noexcept -> const ApplicationName &;
+
+ private:
+ ApplicationName application;
+ };
+} // namespace app::manager
A module-services/service-appmgr/service-appmgr/messages/ApplicationInitialised.hpp => module-services/service-appmgr/service-appmgr/messages/ApplicationInitialised.hpp +24 -0
@@ 0,0 1,24 @@
+// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#pragma once
+
+#include "BaseMessage.hpp"
+
+namespace app::manager
+{
+ class ApplicationInitialised : public BaseMessage
+ {
+ public:
+ ApplicationInitialised(const ApplicationName &senderName,
+ StartupStatus _status,
+ StartInBackground _startInBackground);
+
+ [[nodiscard]] auto getStatus() const noexcept -> StartupStatus;
+ [[nodiscard]] auto isBackgroundApplication() const noexcept -> bool;
+
+ private:
+ StartupStatus status;
+ StartInBackground startInBackground;
+ };
+} // namespace app::manager
A module-services/service-appmgr/service-appmgr/messages/ApplicationStatus.hpp => module-services/service-appmgr/service-appmgr/messages/ApplicationStatus.hpp +27 -0
@@ 0,0 1,27 @@
+// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#pragma once
+
+#include "BaseMessage.hpp"
+
+namespace app::manager
+{
+ /// Requests the application manager to check the status of the application.
+ class ApplicationStatusRequest : public BaseMessage
+ {
+ public:
+ ApplicationStatusRequest(const ApplicationName &senderName, ApplicationName applicationName);
+
+ ApplicationName checkAppName;
+ };
+
+ class ApplicationStatusResponse : public sys::ResponseMessage
+ {
+ public:
+ ApplicationStatusResponse(const ApplicationName &_applicationName, bool _isRunning);
+
+ ApplicationName applicationName;
+ bool isRunning;
+ };
+} // namespace app::manager
A module-services/service-appmgr/service-appmgr/messages/BaseMessage.hpp => module-services/service-appmgr/service-appmgr/messages/BaseMessage.hpp +23 -0
@@ 0,0 1,23 @@
+// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#pragma once
+
+#include <Service/Message.hpp>
+#include <MessageType.hpp>
+
+#include <module-apps/Application.hpp>
+
+namespace app::manager
+{
+ class BaseMessage : public sys::DataMessage
+ {
+ public:
+ BaseMessage(MessageType type, ApplicationName sender);
+
+ [[nodiscard]] auto getSenderName() const noexcept -> const ApplicationName &;
+
+ private:
+ ApplicationName senderName;
+ };
+} // namespace app::manager
A module-services/service-appmgr/service-appmgr/messages/CloseConfirmation.hpp => module-services/service-appmgr/service-appmgr/messages/CloseConfirmation.hpp +15 -0
@@ 0,0 1,15 @@
+// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#pragma once
+
+#include "BaseMessage.hpp"
+
+namespace app::manager
+{
+ class CloseConfirmation : public BaseMessage
+ {
+ public:
+ explicit CloseConfirmation(const ApplicationName &sender);
+ };
+} // namespace app::manager
A module-services/service-appmgr/service-appmgr/messages/LanguageChangeRequest.hpp => module-services/service-appmgr/service-appmgr/messages/LanguageChangeRequest.hpp +37 -0
@@ 0,0 1,37 @@
+// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#pragma once
+
+#include "BaseMessage.hpp"
+
+#include <i18/i18.hpp>
+
+namespace app::manager
+{
+ class LanguageChangeRequest : public BaseMessage
+ {
+ public:
+ [[nodiscard]] auto getLanguage() const noexcept -> utils::Lang;
+
+ protected:
+ LanguageChangeRequest(const ApplicationName &senderName, utils::Lang language);
+
+ private:
+ utils::Lang language;
+ };
+
+ /// Requests to change the display language.
+ class DisplayLanguageChangeRequest : public LanguageChangeRequest
+ {
+ public:
+ DisplayLanguageChangeRequest(const ApplicationName &senderName, utils::Lang language);
+ };
+
+ /// Requests to change the input language.
+ class InputLanguageChangeRequest : public LanguageChangeRequest
+ {
+ public:
+ InputLanguageChangeRequest(const ApplicationName &senderName, utils::Lang language);
+ };
+} // namespace app::manager
A module-services/service-appmgr/service-appmgr/messages/Message.hpp => module-services/service-appmgr/service-appmgr/messages/Message.hpp +18 -0
@@ 0,0 1,18 @@
+// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#pragma once
+
+#include "BaseMessage.hpp"
+#include "ActionRequest.hpp"
+#include "SwitchRequest.hpp"
+#include "SwitchBackRequest.hpp"
+#include "SwitchConfirmation.hpp"
+#include "ApplicationCloseRequest.hpp"
+#include "CloseConfirmation.hpp"
+#include "ApplicationInitialised.hpp"
+#include "ApplicationStatus.hpp"
+#include "LanguageChangeRequest.hpp"
+#include "PowerSaveModeInitRequest.hpp"
+#include "PreventBlockingRequest.hpp"
+#include "ShutdownRequest.hpp"
A module-services/service-appmgr/service-appmgr/messages/PowerSaveModeInitRequest.hpp => module-services/service-appmgr/service-appmgr/messages/PowerSaveModeInitRequest.hpp +15 -0
@@ 0,0 1,15 @@
+// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#pragma once
+
+#include "BaseMessage.hpp"
+
+namespace app::manager
+{
+ class PowerSaveModeInitRequest : public BaseMessage
+ {
+ public:
+ explicit PowerSaveModeInitRequest(const ApplicationName &senderName);
+ };
+} // namespace app::manager
A module-services/service-appmgr/service-appmgr/messages/PreventBlockingRequest.hpp => module-services/service-appmgr/service-appmgr/messages/PreventBlockingRequest.hpp +15 -0
@@ 0,0 1,15 @@
+// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#pragma once
+
+#include "BaseMessage.hpp"
+
+namespace app::manager
+{
+ class PreventBlockingRequest : public BaseMessage
+ {
+ public:
+ explicit PreventBlockingRequest(const ApplicationName &senderName);
+ };
+} // namespace app::manager
A module-services/service-appmgr/service-appmgr/messages/ShutdownRequest.hpp => module-services/service-appmgr/service-appmgr/messages/ShutdownRequest.hpp +15 -0
@@ 0,0 1,15 @@
+// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#pragma once
+
+#include "BaseMessage.hpp"
+
+namespace app::manager
+{
+ class ShutdownRequest : public BaseMessage
+ {
+ public:
+ explicit ShutdownRequest(const ApplicationName &senderName);
+ };
+} // namespace app::manager
A module-services/service-appmgr/service-appmgr/messages/SwitchBackRequest.hpp => module-services/service-appmgr/service-appmgr/messages/SwitchBackRequest.hpp +22 -0
@@ 0,0 1,22 @@
+// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#pragma once
+
+#include "BaseMessage.hpp"
+
+#include <module-gui/gui/SwitchData.hpp>
+
+namespace app::manager
+{
+ class SwitchBackRequest : public BaseMessage
+ {
+ public:
+ SwitchBackRequest(const ApplicationName &name, std::unique_ptr<gui::SwitchData> data = nullptr);
+
+ [[nodiscard]] auto getData() noexcept -> std::unique_ptr<gui::SwitchData> &;
+
+ private:
+ std::unique_ptr<gui::SwitchData> data;
+ };
+} // namespace app::manager
A module-services/service-appmgr/service-appmgr/messages/SwitchConfirmation.hpp => module-services/service-appmgr/service-appmgr/messages/SwitchConfirmation.hpp +15 -0
@@ 0,0 1,15 @@
+// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#pragma once
+
+#include "BaseMessage.hpp"
+
+namespace app::manager
+{
+ class SwitchConfirmation : public BaseMessage
+ {
+ public:
+ explicit SwitchConfirmation(const ApplicationName &sender);
+ };
+} // namespace app::manager
A module-services/service-appmgr/service-appmgr/messages/SwitchRequest.hpp => module-services/service-appmgr/service-appmgr/messages/SwitchRequest.hpp +29 -0
@@ 0,0 1,29 @@
+// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#pragma once
+
+#include "BaseMessage.hpp"
+
+#include <module-gui/gui/SwitchData.hpp>
+
+namespace app::manager
+{
+ class SwitchRequest : public BaseMessage
+ {
+ public:
+ SwitchRequest(const ApplicationName &senderName,
+ ApplicationName applicationName,
+ std::string windowName,
+ std::unique_ptr<gui::SwitchData> data);
+
+ [[nodiscard]] auto getName() const noexcept -> const ApplicationName &;
+ [[nodiscard]] auto getWindow() const noexcept -> const std::string &;
+ [[nodiscard]] auto getData() noexcept -> std::unique_ptr<gui::SwitchData> &;
+
+ private:
+ ApplicationName application;
+ std::string window;
+ std::unique_ptr<gui::SwitchData> data;
+ };
+} // namespace app::manager
M module-services/service-appmgr/service-appmgr/model/ApplicationHandle.hpp => module-services/service-appmgr/service-appmgr/model/ApplicationHandle.hpp +8 -9
@@ 19,9 19,6 @@ namespace app::manager
class ApplicationHandle
{
public:
- static inline constexpr std::string_view InvalidAppName{"NONE"};
- static inline const ApplicationManifest InvalidManifest;
-
using State = app::Application::State;
explicit ApplicationHandle(std::unique_ptr<app::ApplicationLauncher> &&_launcher);
@@ 31,8 28,8 @@ namespace app::manager
void runInBackground(sys::Service *caller);
void close() noexcept;
+ auto valid() const noexcept -> bool;
auto name() const -> ApplicationName;
- auto manifest() const -> const ApplicationManifest &;
auto state() const noexcept -> State;
auto preventsBlocking() const noexcept -> bool;
auto closeable() const noexcept -> bool;
@@ 42,10 39,12 @@ namespace app::manager
std::unique_ptr<app::ApplicationLauncher> launcher; // Handle to the application's start function.
std::unique_ptr<gui::SwitchData> switchData;
std::string switchWindow;
- bool blockClosing =
- false; //< Informs the application manager that this application mustn't be closed temporarily.
- //< This flag is used to prevent application closing when application is closeable and there is
- //< incoming call. This flag is also used when closeable application is on front and there is a
- //< timeout to block the application.
+ bool blockClosing = false; //< Informs the application manager that this application mustn't be closed
+ // temporarily. This flag is used to prevent application closing when application
+ // is closeable and there is incoming call. This flag is also used when closeable
+ // application is on front and there is a timeout to block the application.
+
+ private:
+ auto getManifest() const -> const ApplicationManifest &;
};
} // namespace app::manager
M module-services/service-appmgr/service-appmgr/model/ApplicationManager.hpp => module-services/service-appmgr/service-appmgr/model/ApplicationManager.hpp +2 -2
@@ 9,7 9,7 @@
#include <module-apps/Application.hpp>
#include <module-apps/ApplicationLauncher.hpp>
-#include <service-appmgr/Message.hpp>
+#include <service-appmgr/messages/Message.hpp>
#include <Service/Common.hpp>
#include <Service/Message.hpp>
#include <Service/Service.hpp>
@@ 116,7 116,7 @@ namespace app::manager
auto handleCloseConfirmation(CloseConfirmation *msg) -> bool;
auto handleSwitchConfirmation(SwitchConfirmation *msg) -> bool;
auto handleSwitchBack(SwitchBackRequest *msg) -> bool;
- auto handleInitApplication(ApplicationInitialisation *msg) -> bool;
+ auto handleInitApplication(ApplicationInitialised *msg) -> bool;
auto handleDisplayLanguageChange(DisplayLanguageChangeRequest *msg) -> bool;
auto handleInputLanguageChange(InputLanguageChangeRequest *msg) -> bool;
auto handlePowerSavingModeInit() -> bool;