~aleteoryx/muditaos

d4d7c1c042627191fc5b38337fecb66c9a1da7a0 — pawpMudita 5 years ago b996cff
[EGD-5527] Fix APN GUI functions: add/edit/delete

redefine functions: saveAPN, renameAPN
add activeApn field to hold selected APN
refresh Apn list after add/edit/delete
M module-apps/application-settings-new/models/ApnSettingsModel.cpp => module-apps/application-settings-new/models/ApnSettingsModel.cpp +9 -2
@@ 15,11 15,18 @@ void ApnSettingsModel::requestAPNList()

void ApnSettingsModel::saveAPN(std::shared_ptr<packet_data::APN::Config> apn)
{
    sys::Bus::SendUnicast(std::make_shared<CellularSetAPNMessage>(apn), ServiceCellular::serviceName, application);
    if (apn->contextId != packet_data::EmptyContextId) {
        CellularServiceAPI::SetAPN(application, *apn);
    }
    else {
        CellularServiceAPI::NewAPN(application, *apn);
    }
}

void ApnSettingsModel::removeAPN(std::shared_ptr<packet_data::APN::Config> apn)
{}
{
    CellularServiceAPI::DeleteAPN(application, apn->contextId);
}

void ApnSettingsModel::setAsDefaultAPN(std::shared_ptr<packet_data::APN::Config> apn)
{

M module-apps/application-settings-new/models/ApnSettingsModel.hpp => module-apps/application-settings-new/models/ApnSettingsModel.hpp +1 -0
@@ 4,6 4,7 @@
#pragma once

#include <service-cellular/PacketDataTypes.hpp>
#include <service-cellular/CellularServiceAPI.hpp>
#include <module-apps/Application.hpp>

class ApnSettingsModel

M module-apps/application-settings-new/windows/ApnSettingsWindow.cpp => module-apps/application-settings-new/windows/ApnSettingsWindow.cpp +12 -5
@@ 4,7 4,6 @@
#include "ApnSettingsWindow.hpp"
#include "application-settings-new/ApplicationSettings.hpp"
#include "application-settings-new/data/ApnListData.hpp"
#include "application-settings-new/models/ApnSettingsModel.hpp"
#include "application-settings-new/widgets/SettingsStyle.hpp"
#include "application-settings-new/data/SettingsItemData.hpp"
#include "OptionSetting.hpp"


@@ 45,7 44,8 @@ namespace gui

        bottomBar->setText(BottomBar::Side::LEFT, utils::localize.get(style::strings::common::options));

        auto apnSettingsModel = new ApnSettingsModel(application);
        activeApn        = std::make_shared<packet_data::APN::Config>();
        apnSettingsModel = std::make_shared<ApnSettingsModel>(application);
        apnSettingsModel->requestAPNList();
    }
    auto ApnSettingsWindow::handleSwitchData(SwitchData *data) -> bool


@@ 82,6 82,11 @@ namespace gui
        }

        addOptions(optionsList(apns));

        if (mode == gui::ShowMode::GUI_SHOW_RETURN) {
            apnSettingsModel->requestAPNList();
        }

        bottomBar->setActive(gui::BottomBar::Side::LEFT, true);
        bottomBar->setActive(gui::BottomBar::Side::CENTER, true);
    }


@@ 101,8 106,7 @@ namespace gui
            return true;
        }
        if (inputEvent.is(gui::KeyCode::KEY_LF)) {
            auto apnRecord                        = std::make_shared<packet_data::APN::Config>();
            std::unique_ptr<gui::SwitchData> data = std::make_unique<ApnItemData>(apnRecord);
            std::unique_ptr<gui::SwitchData> data = std::make_unique<ApnItemData>(activeApn);
            application->switchWindow(gui::window::name::apn_options, gui::ShowMode::GUI_SHOW_INIT, std::move(data));
            return true;
        }


@@ 125,7 129,10 @@ namespace gui
                        gui::window::name::new_apn, gui::ShowMode::GUI_SHOW_INIT, std::move(apnData));
                    return true;
                },
                nullptr,
                [=](gui::Item &item) {
                    activeApn = apn;
                    return true;
                },
                nullptr));
        }


M module-apps/application-settings-new/windows/ApnSettingsWindow.hpp => module-apps/application-settings-new/windows/ApnSettingsWindow.hpp +4 -0
@@ 4,6 4,8 @@
#pragma once

#include "OptionWindow.hpp"
#include "application-settings-new/models/ApnSettingsModel.hpp"

#include <Icon.hpp>
#include <service-cellular/PacketDataTypes.hpp>



@@ 25,5 27,7 @@ namespace gui
        Image *crossImage     = nullptr;
        Icon *emptyListIcon   = nullptr;
        std::vector<std::shared_ptr<packet_data::APN::Config>> apns;
        std::shared_ptr<packet_data::APN::Config> activeApn;
        std::shared_ptr<ApnSettingsModel> apnSettingsModel;
    };
}; // namespace gui

M module-services/service-cellular/service-cellular/PacketDataTypes.hpp => module-services/service-cellular/service-cellular/PacketDataTypes.hpp +1 -1
@@ 210,7 210,7 @@ namespace packet_data
        };

    } // namespace APN

    constexpr unsigned char EmptyContextId = 0;
    constexpr unsigned char MINContextId = 1;
    constexpr unsigned char MAXContextId = 16;