From ec26699ca8d86c2084b34867b670ba8e3bb4ae0f Mon Sep 17 00:00:00 2001 From: pawpMudita Date: Tue, 15 Dec 2020 18:11:44 +0100 Subject: [PATCH] [EGD-4898] Add GUI for Custom MMI messages- call forwarding Visitor framework for displaing MMI messages. GUI for call forwarding custom messages. --- changelog.md | 1 + image/assets/lang/English.json | 17 ++++ module-apps/application-desktop/data/Mmi.hpp | 79 +++++++++++++++++++ .../windows/MmiInternalMsgWindow.cpp | 41 +++++++--- .../windows/MmiInternalMsgWindow.hpp | 6 +- .../windows/MmiPushWindow.cpp | 2 +- .../service-appmgr/data/MmiActionsParams.cpp | 35 ++++++-- .../service-appmgr/data/MmiActionsParams.hpp | 50 +++++++++--- .../CellularRequestHandler.cpp | 4 +- .../service-cellular/CellularMessage.hpp | 16 ++-- 10 files changed, 207 insertions(+), 44 deletions(-) diff --git a/changelog.md b/changelog.md index 068472fb456b37b20f9459d953aba43a3707f564..baabe8fb16bb0abf8552f4656c2787e85104590b 100644 --- a/changelog.md +++ b/changelog.md @@ -7,6 +7,7 @@ * Add GUI visitor and DOM documentation. * `[PowerManagement]` Critial battery level notification to SystemManager. * `[Bluetooth]` Add settings storage to bluetooth related items +* `[cellular]` Add GUI for Custom MMI messages- call forwarding. * Add Bluetooth virtual audio device. * Add custom repeat window for the alarm application diff --git a/image/assets/lang/English.json b/image/assets/lang/English.json index 6bff976313c3b2175f5884cdee301a2cdd9e5508..8e76a76c7e944ddee4dc5da31b7e5a96eda93070 100644 --- a/image/assets/lang/English.json +++ b/image/assets/lang/English.json @@ -183,6 +183,23 @@ "app_desktop_menu": "MENU", "app_desktop_emergency": "SOS", "app_desktop_info": "Info", + "app_desktop_info_mmi_none_specified_failed": "Operation failed", + "app_desktop_info_mmi_none_specified_success": "Operation successful", + "app_desktop_info_mmi_common_failed": "failed", + "app_desktop_info_mmi_common_no" :"not", + "app_desktop_info_mmi_registration_failed": "Registration failed", + "app_desktop_info_mmi_registration_success": "Registration was successful", + "app_desktop_info_mmi_erasure_failed": "Erasure failed", + "app_desktop_info_mmi_erasure_success": "Erasure was successful", + "app_desktop_info_mmi_disabling_failed": "Service disabling failed", + "app_desktop_info_mmi_disabling_success": "Service has been disabled", + "app_desktop_info_mmi_enabling_failed": "Service enabling failed", + "app_desktop_info_mmi_enabling_success": "Service has been enabled", + "app_desktop_info_mmi_voice": "voice", + "app_desktop_info_mmi_fax": "FAX", + "app_desktop_info_mmi_sync": "sync", + "app_desktop_info_mmi_async": "async", + "app_desktop_info_mmi_call_forwarding" : "Call forwarding", "app_desktop_info_mmi_result_success": "Success", "app_desktop_info_mmi_result_failed": "Failed", "app_desktop_header_sim_setup": "$SIM setup", diff --git a/module-apps/application-desktop/data/Mmi.hpp b/module-apps/application-desktop/data/Mmi.hpp index 2d9cf60dda1e4a1e8ce4ce2a33497ebfb99761ee..b0aea5d1b4f731972be1e3496cc9172011096e1d 100644 --- a/module-apps/application-desktop/data/Mmi.hpp +++ b/module-apps/application-desktop/data/Mmi.hpp @@ -3,8 +3,11 @@ #pragma once +#include + namespace mmi { + static inline std::string removePhrase(std::string str, std::string phrase) { auto find_pos = str.find(phrase); @@ -14,4 +17,80 @@ namespace mmi } return str; } + + class MMIMessageVisitor : public app::manager::actions::Visitor + { + public: + MMIMessageVisitor() + { + messageDictionary.clear(); + messageDictionary.emplace(mmiactions::IMMICustomResultParams::MMIResultMessage::NoneSpecifiedFailed, + "app_desktop_info_mmi_none_specified_failed"); + messageDictionary.emplace(mmiactions::IMMICustomResultParams::MMIResultMessage::NoneSpecifiedSuccess, + "app_desktop_info_mmi_none_specified_success"); + messageDictionary.emplace(mmiactions::IMMICustomResultParams::MMIResultMessage::CommonFailure, + "app_desktop_info_mmi_common_failed"); + messageDictionary.emplace(mmiactions::IMMICustomResultParams::MMIResultMessage::CommonNoMessage, + "app_desktop_info_mmi_common_no"); + messageDictionary.emplace(mmiactions::IMMICustomResultParams::MMIResultMessage::RegistrationSuccessful, + "app_desktop_info_mmi_registration_success"); + messageDictionary.emplace(mmiactions::IMMICustomResultParams::MMIResultMessage::RegistrationFailed, + "app_desktop_info_mmi_registration_failed"); + messageDictionary.emplace(mmiactions::IMMICustomResultParams::MMIResultMessage::ErasureSuccessful, + "app_desktop_info_mmi_erasure_success"); + messageDictionary.emplace(mmiactions::IMMICustomResultParams::MMIResultMessage::ErasureFailed, + "app_desktop_info_mmi_erasure_failed"); + messageDictionary.emplace(mmiactions::IMMICustomResultParams::MMIResultMessage::DisablingSuccessful, + "app_desktop_info_mmi_disabling_success"); + messageDictionary.emplace(mmiactions::IMMICustomResultParams::MMIResultMessage::DisablingFailed, + "app_desktop_info_mmi_disabling_failed"); + messageDictionary.emplace(mmiactions::IMMICustomResultParams::MMIResultMessage::EnablingSuccessful, + "app_desktop_info_mmi_enabling_success"); + messageDictionary.emplace(mmiactions::IMMICustomResultParams::MMIResultMessage::EnablingFailed, + "app_desktop_info_mmi_enabling_failed"); + }; + + virtual void visit(mmiactions::MMINoneSpecifiedResult &customResult, std::string &displayMessage) + { + displayMessage += getSelectedMessagesFromDictionary(customResult.getMessage()); + } + + virtual void visit(mmiactions::MMICustomResultParams &customResult, std::string &displayMessage) + { + displayMessage += getSelectedMessagesFromDictionary(customResult.getMessage()); + } + + virtual void visit(mmiactions::MMICallForwardingResult &customResult, std::string &displayMessage) + { + displayMessage += utils::localize.get("app_desktop_info_mmi_call_forwarding") + "\n"; + if (customResult.getMessageType() == mmiactions::IMMICustomResultParams::MMIType::CallForwardingData) { + auto [voice, fax, sync, async] = customResult.getData(); + displayMessage += utils::localize.get("app_desktop_info_mmi_voice") + ": " + voice + "\n" + + utils::localize.get("app_desktop_info_mmi_fax") + ": " + fax + "\n" + + utils::localize.get("app_desktop_info_mmi_sync") + ": " + sync + "\n" + + utils::localize.get("app_desktop_info_mmi_async") + ": " + async + "\n"; + } + else if (customResult.getMessageType() == + mmiactions::IMMICustomResultParams::MMIType::CallForwardingNotification) { + displayMessage += getSelectedMessagesFromDictionary(customResult.getMessage()); + } + } + + UTF8 getSelectedMessagesFromDictionary( + const std::vector &msgList) + { + UTF8 selectedMessages = ""; + for (const auto &msg : msgList) { + auto it = messageDictionary.find(msg); + if (messageDictionary.end() != it) { + selectedMessages += utils::localize.get(it->second) + "\n"; + } + } + return selectedMessages; + } + + private: + std::map messageDictionary; + }; + } // namespace mmi diff --git a/module-apps/application-desktop/windows/MmiInternalMsgWindow.cpp b/module-apps/application-desktop/windows/MmiInternalMsgWindow.cpp index 5cf63e6395c730d5f689d530d08916623fb948c1..98ed62af66c9abb71e26af836805d8e1ae8afc02 100644 --- a/module-apps/application-desktop/windows/MmiInternalMsgWindow.cpp +++ b/module-apps/application-desktop/windows/MmiInternalMsgWindow.cpp @@ -5,6 +5,7 @@ #include "MmiInternalMsgWindow.hpp" #include #include +#include #include using namespace gui; @@ -14,18 +15,34 @@ MmiInternalMsgWindow::MmiInternalMsgWindow(app::Application *app, const std::str void MmiInternalMsgWindow::onBeforeShow(ShowMode mode, SwitchData *data) { - if (auto metadata = dynamic_cast(data); metadata != nullptr) { - auto result = metadata->getData(); - switch (result) { - case app::manager::actions::MMIResultParams::MMIResult::Success: - text->setText(utils::localize.get("app_desktop_info_mmi_result_success")); - break; - case app::manager::actions::MMIResultParams::MMIResult::Failed: - text->setText(utils::localize.get("app_desktop_info_mmi_result_failed")); - break; - default: - text->clear(); - break; + if (auto metadata = dynamic_cast(data); metadata != nullptr) { + if (metadata->getCustomData() != nullptr) { + mmi::MMIMessageVisitor customMMIvisitor; + std::string displayMessage; + metadata->getCustomData()->accept(customMMIvisitor, displayMessage); + text->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Top)); + text->setText(displayMessage); } + else { + handleInternalMessages(metadata); + } + } +} + +void MmiInternalMsgWindow::handleInternalMessages(mmiactions::MMIResultParams *metadata) +{ + std::string displayMessage; + text->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Top)); + auto result = metadata->getData(); + switch (result) { + case mmiactions::MMIResultParams::MMIResult::Success: + text->setText(displayMessage + utils::localize.get("app_desktop_info_mmi_result_success")); + break; + case mmiactions::MMIResultParams::MMIResult::Failed: + text->setText(displayMessage + utils::localize.get("app_desktop_info_mmi_result_failed")); + break; + default: + text->clear(); + break; } } diff --git a/module-apps/application-desktop/windows/MmiInternalMsgWindow.hpp b/module-apps/application-desktop/windows/MmiInternalMsgWindow.hpp index 68d5c67d1d5482e33f115458e70d812b67973e57..b246f0407faf8285f10b6f653b3fa6013af79a16 100644 --- a/module-apps/application-desktop/windows/MmiInternalMsgWindow.hpp +++ b/module-apps/application-desktop/windows/MmiInternalMsgWindow.hpp @@ -7,8 +7,11 @@ #include #include -#include #include +#include + +#include +#include namespace gui { @@ -17,6 +20,7 @@ namespace gui public: MmiInternalMsgWindow(app::Application *app, const std::string &name); void onBeforeShow(ShowMode mode, SwitchData *data) override; + void handleInternalMessages(mmiactions::MMIResultParams *metadata); }; }; // namespace gui diff --git a/module-apps/application-desktop/windows/MmiPushWindow.cpp b/module-apps/application-desktop/windows/MmiPushWindow.cpp index a00cff09e298e4e5dc8ea3abcf86ee516f067762..591f6059a3e707f49424af72baa2f8bfb515c708 100644 --- a/module-apps/application-desktop/windows/MmiPushWindow.cpp +++ b/module-apps/application-desktop/windows/MmiPushWindow.cpp @@ -22,7 +22,7 @@ namespace style::desktop constexpr uint32_t x = 40; constexpr uint32_t y = 300; constexpr uint32_t w = 400; - constexpr uint32_t h = 135; + constexpr uint32_t h = 300; } // namespace text } // namespace style::desktop diff --git a/module-services/service-appmgr/data/MmiActionsParams.cpp b/module-services/service-appmgr/data/MmiActionsParams.cpp index b026c0b17af61b813b0215bc3b71b2bb71f6f71c..7c7ecad018420bbac55ad2f5cc6b03d1196db6dc 100644 --- a/module-services/service-appmgr/data/MmiActionsParams.cpp +++ b/module-services/service-appmgr/data/MmiActionsParams.cpp @@ -7,19 +7,39 @@ using namespace app::manager::actions; void MMICustomResultParams::addMessage(const MMIResultMessage &message) { - messages.push_back(message); + messages.emplace_back(message); } -auto MMICustomResultParams::getMessage() -> std::vector +auto MMICustomResultParams::getMessage() const -> std::vector { - return std::move(messages); + return messages; } -auto MMICustomResultParams::getType() -> MMIType +auto MMICustomResultParams::getMessageType() const noexcept -> MMIType { return type; } +void MMICustomResultParams::accept(Visitor &v, std::string &displayMessage) +{ + v.visit(*this, displayMessage); +}; + +void MMINoneSpecifiedResult::accept(Visitor &v, std::string &displayMessage) +{ + v.visit(*this, displayMessage); +}; + +auto MMICallForwardingResult::getData() const -> std::tuple +{ + return std::make_tuple(voice, fax, sync, async); +} + +void MMICallForwardingResult::accept(Visitor &v, std::string &displayMessage) +{ + v.visit(*this, displayMessage); +}; + MMIParams::MMIParams(std::string mmiData) : mmiData{std::move(mmiData)} {} @@ -28,18 +48,17 @@ std::string MMIParams::getData() const return mmiData; } -MMIResultParams::MMIResultParams(MMIResult result) : result(result) +MMIResultParams::MMIResultParams(MMIResult result, std::shared_ptr customResult) + : result(result), customResult(std::move(customResult)) {} -MMIResultParams::MMIResultParams(std::shared_ptr cResult) : customResult(cResult) -{} MMIResultParams::MMIResult MMIResultParams::getData() const noexcept { return result; } -auto MMIResultParams::getCustomMessage() const noexcept -> std::shared_ptr +auto MMIResultParams::getCustomData() const noexcept -> std::shared_ptr { return customResult; } diff --git a/module-services/service-appmgr/service-appmgr/data/MmiActionsParams.hpp b/module-services/service-appmgr/service-appmgr/data/MmiActionsParams.hpp index b3e400d64269220fbb8ecca992cfc26edc21d839..89987c8b8697415475f61e7111afb243ad88db47 100644 --- a/module-services/service-appmgr/service-appmgr/data/MmiActionsParams.hpp +++ b/module-services/service-appmgr/service-appmgr/data/MmiActionsParams.hpp @@ -5,8 +5,23 @@ #include +namespace mmiactions = app::manager::actions; + namespace app::manager::actions { + + class MMINoneSpecifiedResult; + class MMICallForwardingResult; + class MMICustomResultParams; + + class Visitor + { + public: + virtual void visit(MMINoneSpecifiedResult &, std::string &) = 0; + virtual void visit(MMICallForwardingResult &, std::string &) = 0; + virtual void visit(MMICustomResultParams &, std::string &) = 0; + }; + class IMMICustomResultParams { public: @@ -43,18 +58,21 @@ namespace app::manager::actions EnablingSuccessful, EnablingFailed }; - virtual auto getMessage() -> std::vector = 0; - virtual void addMessage(const MMIResultMessage &message) = 0; - virtual auto getType() -> MMIType = 0; + + virtual auto getMessage() const -> std::vector = 0; + virtual void addMessage(const MMIResultMessage &message) = 0; + virtual auto getMessageType() const noexcept -> MMIType = 0; + virtual void accept(Visitor &v, std::string &displayMessage) = 0; }; class MMICustomResultParams : public IMMICustomResultParams { public: MMICustomResultParams(MMIType resultType) : type(resultType){}; - void addMessage(const MMIResultMessage &message) override; - auto getMessage() -> std::vector override; - auto getType() -> MMIType override; + virtual void addMessage(const MMIResultMessage &message) override; + virtual auto getMessage() const -> std::vector override; + virtual auto getMessageType() const noexcept -> MMIType override; + virtual void accept(Visitor &v, std::string &displayMessage) override; protected: MMIType type; @@ -66,14 +84,23 @@ namespace app::manager::actions public: MMINoneSpecifiedResult() : MMICustomResultParams(MMIType::NoneSpecified) {} + virtual void accept(Visitor &v, std::string &displayMessage) override; }; class MMICallForwardingResult : public MMICustomResultParams { public: - MMICallForwardingResult() : MMICustomResultParams(MMIType::CallForwardingData) + explicit MMICallForwardingResult(MMIType resultType) : MMICustomResultParams(resultType) + {} + + MMICallForwardingResult( + MMIType resultType, std::string voice, std::string fax, std::string sync, std::string async) + : MMICustomResultParams(resultType), voice(voice), fax(fax), sync(sync), async(async) {} + auto getData() const -> std::tuple; + virtual void accept(Visitor &v, std::string &displayMessage) override; + private: std::string voice; std::string fax; @@ -107,13 +134,14 @@ namespace app::manager::actions Success, Failed }; - explicit MMIResultParams(MMIResult result); - explicit MMIResultParams(std::shared_ptr cParams); + + explicit MMIResultParams(MMIResult result, std::shared_ptr customResult = nullptr); + [[nodiscard]] MMIResult getData() const noexcept; - [[nodiscard]] auto getCustomMessage() const noexcept -> std::shared_ptr; + [[nodiscard]] auto getCustomData() const noexcept -> std::shared_ptr; private: MMIResult result; - std::shared_ptr customResult = nullptr; + std::shared_ptr customResult = nullptr; }; } // namespace app::manager::actions diff --git a/module-services/service-cellular/CellularRequestHandler.cpp b/module-services/service-cellular/CellularRequestHandler.cpp index 738f91825c75cf2dbae490082ccb8ba083e56e00..dba5104eaf81888b8cf7ca96824f278f878180c9 100644 --- a/module-services/service-cellular/CellularRequestHandler.cpp +++ b/module-services/service-cellular/CellularRequestHandler.cpp @@ -92,7 +92,7 @@ void CellularRequestHandler::handle(ClirRequest &request, at::Result &result) using namespace at::response; auto requestHandled = request.checkModemResponse(result); - std::shared_ptr response = std::make_shared(); + std::shared_ptr response = std::make_shared(); if (requestHandled) { auto procedureType = request.getProcedureType(); if (procedureType == SupplementaryServicesRequest::ProcedureType::Activation) { @@ -112,7 +112,7 @@ void CellularRequestHandler::handle(ClirRequest &request, at::Result &result) response->addMessage(IMMICustomResultParams::MMIResultMessage::CommonFailure); } } - auto msg = std::make_shared(response); + auto msg = std::make_shared(MMIResultParams::MMIResult::Success, response); sys::Bus::SendUnicast(msg, app::manager::ApplicationManager::ServiceName, &cellular); request.setHandled(requestHandled); } diff --git a/module-services/service-cellular/service-cellular/CellularMessage.hpp b/module-services/service-cellular/service-cellular/CellularMessage.hpp index 3ca4928815dc31c4b75d2d43991d542ec1b27571..e7f3836d1995b2912c3a7c15b776db6be6a4cd82 100644 --- a/module-services/service-cellular/service-cellular/CellularMessage.hpp +++ b/module-services/service-cellular/service-cellular/CellularMessage.hpp @@ -549,23 +549,21 @@ class CellularMMIResult : public CellularMessage protected: app::manager::actions::MMIResultParams params; - CellularMMIResult(app::manager::actions::MMIResultParams::MMIResult result) - : CellularMessage(MessageType::CellularMMIData), params(result) - {} - CellularMMIResult(std::shared_ptr &result) - : CellularMessage(MessageType::CellularMMIData), params(result) + explicit CellularMMIResult(app::manager::actions::MMIResultParams::MMIResult result, + std::shared_ptr customResult = nullptr) + : CellularMessage(MessageType::CellularMMIData), params(result, std::move(customResult)) {} }; class CellularMMIResultMessage : public CellularMMIResult, public app::manager::actions::ConvertibleToAction { public: - CellularMMIResultMessage(app::manager::actions::MMIResultParams::MMIResult result) : CellularMMIResult(result) + explicit CellularMMIResultMessage( + app::manager::actions::MMIResultParams::MMIResult result, + std::shared_ptr customResult = nullptr) + : CellularMMIResult(result, std::move(customResult)) {} - CellularMMIResultMessage(std::shared_ptr &result) - : CellularMMIResult(result) - {} [[nodiscard]] auto toAction() const -> std::unique_ptr {