~aleteoryx/muditaos

5f30b606e3e511cceb5ddc3a421dad6baa8a877a — Pawel Olejniczak 4 years ago ef63ee2
[EGD-6010] Fix addres in retry window

Address was lost while being forwarded to the retry window.
M module-apps/application-settings-new/ApplicationSettings.cpp => module-apps/application-settings-new/ApplicationSettings.cpp +17 -19
@@ 180,23 180,22 @@ namespace app

        connect(typeid(BluetoothPairResultMessage), [&](sys::Message *msg) {
            auto bluetoothPairResultMsg = static_cast<BluetoothPairResultMessage *>(msg);
            if (bluetoothPairResultMsg->status) {
            if (bluetoothPairResultMsg->isSucceed()) {
                bus.sendUnicast(std::make_shared<::message::bluetooth::RequestBondedDevices>(),
                                service::name::bluetooth);
                return sys::MessageNone{};
            }
            auto addr                       = bluetoothPairResultMsg->getAddr();
            const std::string toReplace     = "%NAME";
            std::string pairingErrorMessage = utils::localize.get("app_settings_bluetooth_pairing_error_message");
            pairingErrorMessage.replace(
                pairingErrorMessage.find(toReplace), toReplace.size(), bluetoothPairResultMsg->name);

                pairingErrorMessage.find(toReplace), toReplace.size(), bluetoothPairResultMsg->getName());
            switchWindow(
                gui::window::name::dialog_retry,
                gui::ShowMode::GUI_SHOW_INIT,
                std::make_unique<gui::DialogMetadataMessage>(gui::DialogMetadata{
                    utils::localize.get("app_settings_bt"), "search_big", pairingErrorMessage, "", [=]() -> bool {
                        bus.sendUnicast(std::make_shared<BluetoothPairMessage>(std::move(bluetoothPairResultMsg->addr)),
                                        service::name::bluetooth);
                        bus.sendUnicast(std::make_shared<BluetoothPairMessage>(addr), service::name::bluetooth);
                        return true;
                    }}));



@@ 213,6 212,7 @@ namespace app
            if (unpairResultMsg->isSucceed()) {
                return sys::MessageNone{};
            }
            auto addr = unpairResultMsg->getAddr();
            bus.sendUnicast(std::make_shared<::message::bluetooth::RequestBondedDevices>(), service::name::bluetooth);
            switchWindow(gui::window::name::dialog_retry,
                         gui::ShowMode::GUI_SHOW_INIT,


@@ 222,8 222,7 @@ namespace app
                                                 utils::localize.get("app_settings_bluetooth_unpairing_error_message"),
                                                 "",
                                                 [=]() -> bool {
                                                     bus.sendUnicast(std::make_shared<message::bluetooth::Unpair>(
                                                                         unpairResultMsg->getAddr()),
                                                     bus.sendUnicast(std::make_shared<message::bluetooth::Unpair>(addr),
                                                                     service::name::bluetooth);
                                                     return true;
                                                 }}));


@@ 237,20 236,19 @@ namespace app
                                service::name::bluetooth);
                return sys::MessageNone{};
            }

            auto addr = connectResultMsg->getAddr();
            switchWindow(gui::window::name::dialog_retry,
                         gui::ShowMode::GUI_SHOW_INIT,
                         std::make_unique<gui::DialogMetadataMessage>(
                             gui::DialogMetadata{utils::localize.get("app_settings_bt"),
                                                 "search_big",
                                                 utils::localize.get("app_settings_bluetooth_connecting_error_message"),
                                                 "",
                                                 [=]() -> bool {
                                                     bus.sendUnicast(std::make_shared<message::bluetooth::Connect>(
                                                                         connectResultMsg->getAddr()),
                                                                     service::name::bluetooth);
                                                     return true;
                                                 }}));
                         std::make_unique<gui::DialogMetadataMessage>(gui::DialogMetadata{
                             utils::localize.get("app_settings_bt"),
                             "search_big",
                             utils::localize.get("app_settings_bluetooth_connecting_error_message"),
                             "",
                             [=]() -> bool {
                                 bus.sendUnicast(std::make_shared<message::bluetooth::Connect>(addr),
                                                 service::name::bluetooth);
                                 return true;
                             }}));

            return sys::MessageNone{};
        });

M module-apps/application-settings/ApplicationSettings.cpp => module-apps/application-settings/ApplicationSettings.cpp +2 -3
@@ 51,8 51,7 @@ namespace app
    }

    ApplicationSettings::~ApplicationSettings()
    {
    }
    {}

    // Invoked upon receiving data message
    sys::MessagePointer ApplicationSettings::DataReceivedHandler(sys::DataMessage *msgl,


@@ 74,7 73,7 @@ namespace app
            render(gui::RefreshModes::GUI_REFRESH_FAST);
        }
        if (auto btmsg = dynamic_cast<BluetoothPairResultMessage *>(msgl); btmsg != nullptr) {
            if (btmsg->status) {
            if (btmsg->isSucceed()) {
                LOG_INFO("Paired successfully");
            }
            else {

M module-services/service-bluetooth/service-bluetooth/BluetoothMessage.hpp => module-services/service-bluetooth/service-bluetooth/BluetoothMessage.hpp +19 -4
@@ 58,12 58,27 @@ class BluetoothScanResultMessage : public sys::DataMessage
class BluetoothPairResultMessage : public sys::DataMessage
{
  public:
    explicit BluetoothPairResultMessage(std::string addr, std::string name, bool succeed)
        : sys::DataMessage(MessageType::BluetoothPairResult), addr(std::move(addr)), name(std::move(name)),
          succeed(succeed)
    {}
    [[nodiscard]] auto getAddr() const -> std::string
    {
        return addr;
    }
    [[nodiscard]] auto getName() const -> std::string
    {
        return name;
    }
    [[nodiscard]] auto isSucceed() const noexcept -> bool
    {
        return succeed;
    }

  private:
    std::string addr;
    std::string name;
    bool status;
    explicit BluetoothPairResultMessage(std::string addr, std::string name, bool status)
        : sys::DataMessage(MessageType::BluetoothPairResult), addr(std::move(addr)), name(std::move(name)),
          status(status){};
    bool succeed;
};

class BluetoothScanMessage : public sys::DataMessage