~aleteoryx/muditaos

ref: 44d3306f280cc7d6daa718d2a9f6323e48f54616 muditaos/module-apps/application-desktop/windows/MmiInternalMsgWindow.cpp -rw-r--r-- 2.1 KiB
44d3306f — rrandomsky [CP-1059] Fix for erase only sensitive data from logs 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "Mmi.hpp"
#include "MmiInternalMsgWindow.hpp"
#include "MmiPushWindow.hpp"

#include <i18n/i18n.hpp>
#include <service-appmgr/data/MmiActionsParams.hpp>

using namespace gui;

MmiInternalMsgWindow::MmiInternalMsgWindow(app::ApplicationCommon *app, const std::string &name)
    : MmiPushWindow(app, name)
{}

void MmiInternalMsgWindow::onBeforeShow([[maybe_unused]] ShowMode mode, SwitchData *data)
{
    if (const auto metadata = dynamic_cast<mmiactions::MMIResultParams *>(data); metadata != nullptr) {
        if (metadata->getCustomData() != nullptr) {
            mmi::MMIMessageVisitor customMMIvisitor;
            std::string displayMessage;
            metadata->getCustomData()->accept(customMMIvisitor, displayMessage);
            icon->text->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Top));
            icon->text->setText(displayMessage);
        }
        else {
            handleInternalMessages(metadata);
        }
    }
}

void MmiInternalMsgWindow::handleInternalMessages(mmiactions::MMIResultParams *metadata)
{
    icon->text->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Top));

    const auto result = metadata->getData();
    switch (result) {
    case mmiactions::MMIResultParams::MMIResult::Success:
        icon->text->setText(utils::translate("app_desktop_info_mmi_result_success"));
        break;
    case mmiactions::MMIResultParams::MMIResult::Failed:
        icon->text->setText(utils::translate("app_desktop_info_mmi_result_failed"));
        break;
    case mmiactions::MMIResultParams::MMIResult::Timeout:
        icon->text->setText(utils::translate("app_desktop_info_mmi_result_timeout"));
        break;
    case mmiactions::MMIResultParams::MMIResult::AbortedByUser:
        icon->text->setText(utils::translate("app_desktop_info_mmi_result_aborted"));
        break;
    default:
        icon->text->clear();
        break;
    }
}