~aleteoryx/muditaos

ref: 249e584a843e061f3ecbf2290f2562ab9c735c18 muditaos/module-services/service-cellular/src/volte/VolteAllowedList.cpp -rw-r--r-- 2.1 KiB
249e584a — Lefucjusz [MOS-1040] Add HNI codes for Egypt 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "VolteAllowedList.hpp"
#include "ImsiParser_Poland.hpp"
#include "ImsiParser_UnitedStates.hpp"
#include "ImsiParser_Netherlands.hpp"
#include "ImsiParser_Germany.hpp"
#include "ImsiParser_Denmark.hpp"
#include "ImsiParser_GreatBritain.hpp"
#include "ImsiParser_Canada.hpp"
#include "ImsiParser_Austria.hpp"
#include "ImsiParser_Egypt.hpp"

#include <log/log.hpp>
#include <magic_enum.hpp>

namespace
{
    template <typename Container, typename... Items>
    void pushBack(Container &container, Items &&...items)
    {
        (container.push_back(std::forward<Items>(items)), ...);
    }
} // namespace

namespace cellular::service
{
    auto VolteAllowedList::isVolteAllowed(const std::string &imsi) const -> bool
    {
        for (const auto &country : allowedList) {
            if (country.isAllowed(imsi)) {
                LOG_INFO("MCC supported, VoLTE allowed.");
                return true;
            }
        }

        LOG_ERROR("MCC not supported, VoLTE not allowed.");
        return false;
    }

    auto VolteAllowedList::getSupportStatus(const std::string &imsi) const -> ImsiParser::SupportStatus
    {
        for (const auto &country : allowedList) {
            if (country.isAllowed(imsi)) {
                const auto supportStatus = country.getSupportStatus();
                LOG_INFO("MCC supported with status %s.", magic_enum::enum_name(supportStatus).data());
                return supportStatus;
            }
        }

        LOG_ERROR("MCC not supported.");
        return ImsiParser::SupportStatus::Unsupported;
    }

    void VolteAllowedList::buildList()
    {
        pushBack(allowedList,
                 ImsiParserPL(),
                 ImsiParserUS(),
                 ImsiParserDK(),
                 ImsiParserDE(),
                 ImsiParserNL(),
                 ImsiParserGB(),
                 ImsiParserCA(),
                 ImsiParserAT(),
                 ImsiParserEG());
    }
} // namespace cellular::service