1 /* 2 * Copyright (C) 2022 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 OHOS_OPERATOR_FILE_PARSER_H 17 #define OHOS_OPERATOR_FILE_PARSER_H 18 #include <json/json.h> 19 20 #include "core_service_errors.h" 21 #include "operator_config_types.h" 22 #include "sim_state_type.h" 23 #include "telephony_log_wrapper.h" 24 25 namespace OHOS { 26 namespace Telephony { 27 class OperatorFileParser { 28 public: 29 bool ParseFromCustomSystem(int32_t slotId, OperatorConfig &opc, Json::Value &opcJson); 30 bool ParseOperatorConfigFromFile(OperatorConfig &poc, const std::string &path, Json::Value &opcJson); 31 bool WriteOperatorConfigJson(std::string filename, const Json::Value &root); 32 std::string GetOperatorConfigFilePath(std::string filename); 33 void ClearFilesCache(); 34 bool isCachePathExit(); 35 virtual ~OperatorFileParser(); 36 37 private: 38 void ParseOperatorConfigFromJson(const Json::Value &root, OperatorConfig &poc); 39 int32_t LoaderJsonFile(char *&content, const std::string &path); 40 void ParseArray(const std::string key, const Json::Value &arrayValue_, OperatorConfig &poc); 41 bool CloseFile(FILE *f); 42 inline static const char *DEFAULT_OPERATE_CONFIG_PATH = "etc/operator_config.json"; 43 inline static const char *DEFAULT_OPERATE_CONFIG_DIR = "/data/service/el1/public/telephony/operatorconfig"; 44 inline static const int MODE_SLOT_0 = 11; 45 inline static const int MODE_SLOT_1 = 12; 46 inline static const int SUCCESS = 0; 47 inline static const int MAX_BYTE_LEN = 10 * 1024 * 1024; 48 inline static const int LOADER_JSON_ERROR = -1; 49 }; 50 } // namespace Telephony 51 } // namespace OHOS 52 #endif // OHOS_OPERATOR_FILE_PARSER_H