Files
MuditaOS/module-apps/application-settings/models/network/ApnSettingsModel.cpp
Lukasz Mastalerz f7ad63c951 [BH-1412] Fix services dependencies
Changes in dependecy managment
Replacing state flags with states in ServiceGUI
Unifying some parts of code
2023-08-01 17:22:48 +02:00

35 lines
1.1 KiB
C++

// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include "ApnSettingsModel.hpp"
#include <service-cellular/ServiceCellular.hpp>
ApnSettingsModel::ApnSettingsModel(app::ApplicationCommon *application) : application{application}
{}
void ApnSettingsModel::requestAPNList()
{
application->bus.sendUnicast(std::make_shared<cellular::GetAPNMessage>(), service::name::cellular);
}
void ApnSettingsModel::saveAPN(const std::shared_ptr<packet_data::APN::Config> &apn)
{
if (apn->contextId != packet_data::EmptyContextId) {
CellularServiceAPI::SetAPN(application, *apn);
}
else {
CellularServiceAPI::NewAPN(application, *apn);
}
}
void ApnSettingsModel::removeAPN(const std::shared_ptr<packet_data::APN::Config> &apn)
{
CellularServiceAPI::DeleteAPN(application, apn->contextId);
}
void ApnSettingsModel::setAsDefaultAPN(const std::shared_ptr<packet_data::APN::Config> &apn)
{
apn->apnType = packet_data::APN::APNType::Default;
application->bus.sendUnicast(std::make_shared<cellular::SetAPNMessage>(apn), service::name::cellular);
}