1/*
2 * Copyright (C) 2021 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#ifndef APN_ITEM_H
17#define APN_ITEM_H
18
19#include <string>
20#include <vector>
21
22#include "refbase.h"
23
24#include "pdp_profile_data.h"
25
26#include "cellular_data_constant.h"
27
28namespace OHOS {
29namespace Telephony {
30class ApnItem : public RefBase {
31public:
32    ApnItem();
33    ~ApnItem();
34    std::vector<std::string> GetApnTypes() const;
35    bool CanDealWithType(const std::string &type) const;
36    void MarkBadApn(bool badApn);
37    bool IsBadApn() const;
38    static sptr<ApnItem> MakeDefaultApn(const std::string &apnType);
39    static sptr<ApnItem> MakeApn(const PdpProfile &apnData);
40
41private:
42    static sptr<ApnItem> BuildOtherApnAttributes(sptr<ApnItem> &apnItem, const PdpProfile &apnData);
43
44public:
45    constexpr static int ALL_APN_ITEM_CHAR_LENGTH = 256;
46    struct Attribute {
47        char types_[ALL_APN_ITEM_CHAR_LENGTH] = { 0 };
48        char numeric_[ALL_APN_ITEM_CHAR_LENGTH] = { 0 };
49        int32_t profileId_ = 0;
50        char protocol_[ALL_APN_ITEM_CHAR_LENGTH] = { 0 };
51        char roamingProtocol_[ALL_APN_ITEM_CHAR_LENGTH] = { 0 };
52        int32_t authType_ = 0;
53        char apn_[ALL_APN_ITEM_CHAR_LENGTH] = { 0 };
54        char apnName_[ALL_APN_ITEM_CHAR_LENGTH] = { 0 };
55        char user_[ALL_APN_ITEM_CHAR_LENGTH] = { 0 };
56        char password_[ALL_APN_ITEM_CHAR_LENGTH] = { 0 };
57        bool isRoamingApn_ = false;
58        char homeUrl_[ALL_APN_ITEM_CHAR_LENGTH] = { 0 };
59        char proxyIpAddress_[ALL_APN_ITEM_CHAR_LENGTH] = { 0 };
60        char mmsIpAddress_[ALL_APN_ITEM_CHAR_LENGTH] = { 0 };
61        bool isEdited_ = false;
62    } attr_;
63
64private:
65    std::vector<std::string> apnTypes_;
66    bool badApn_ = false;
67};
68} // namespace Telephony
69} // namespace OHOS
70#endif // APN_ITEM_H
71