• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 DATA_STORAGE_PDP_OPERATOR_PARSER_UTIL_H
17 #define DATA_STORAGE_PDP_OPERATOR_PARSER_UTIL_H
18 
19 #include <iostream>
20 #include <vector>
21 #include <json/json.h>
22 
23 #include "rdb_store.h"
24 
25 #include "pdp_profile_data.h"
26 #include "data_storage_errors.h"
27 
28 namespace OHOS {
29 namespace Telephony {
30 class ParserUtil {
31 public:
32     int ParserPdpProfileJson(std::vector<PdpProfile> &vec);
33     void ParserPdpProfileInfos(std::vector<PdpProfile> &vec, Json::Value &root);
34     void ParserPdpProfileToValuesBucket(NativeRdb::ValuesBucket &value, const PdpProfile &bean);
35 
36 private:
37     int LoaderJsonFile(char *&content) const;
38     int CloseFile(FILE *f) const;
39 
40 private:
41     const char *PATH = "/system/etc/telephony/pdp_profile.json";
42     const char *ITEM_OPERATOR_INFOS = "operator_infos";
43     const char *ITEM_OPERATOR_NAME = "operator_name";
44     const char *ITEM_AUTH_USER = "auth_user";
45     const char *ITEM_AUTH_PWD = "auth_pwd";
46     const char *ITEM_AUTH_TYPE = "auth_type";
47     const char *ITEM_MCC = "mcc";
48     const char *ITEM_MNC = "mnc";
49     const char *ITEM_APN = "apn";
50     const char *ITEM_APN_TYPES = "apn_types";
51     const char *ITEM_IP_ADDRESS = "ip_addr";
52     const char *ITEM_MMS_IP_ADDRESS = "mms_ip_addr";
53     const char *ITEM_HOME_URL = "home_url";
54     const std::string APN_VERSION = "apn_version";
55 };
56 } // namespace Telephony
57 } // namespace OHOS
58 #endif // DATA_STORAGE_PDP_OPERATOR_PARSER_UTIL_H
59