1 /* 2 * Copyright (C) 2024 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 #ifndef PACKAGE_PARSER 16 #define PACKAGE_PARSER 17 #include "xml_parser.h" 18 #include "wifi_internal_msg.h" 19 #include <unordered_map> 20 21 constexpr auto TAG_HEADER = "WifiPackages"; 22 constexpr auto TAG_SCAN_CONTROL = "ScanControlPackages"; 23 constexpr auto TAG_CANDIDATE_FILTER = "CandidateFilterPackages"; 24 constexpr auto TAG_CORE_PACKAGEINFO = "CorePackages"; 25 constexpr auto TAG_ACL_AUTH = "AclAuthPackages"; 26 constexpr auto PARAM_NAME = "name"; 27 constexpr auto PARAM_APPID = "appid"; 28 29 namespace OHOS { 30 namespace Wifi { 31 32 class PackageXmlParser : public XmlParser { 33 public: 34 PackageXmlParser() = default; 35 ~PackageXmlParser() override; 36 void GetScanControlPackages(std::map<std::string, std::vector<PackageInfo>> &packageMap); 37 void GetCandidateFilterPackages(std::vector<PackageInfo> &packageList); 38 void GetCorePackages(std::map<std::string, std::vector<PackageInfo>> &packageMap); 39 void GetAclAuthPackages(std::vector<PackageInfo> &packageList); 40 41 private: 42 bool ParseInternal(xmlNodePtr node) override; 43 void GetPackageMap(xmlNodePtr &innode, std::map<std::string, std::vector<PackageInfo>> &result); 44 void GetPackageList(xmlNodePtr &innode, std::vector<PackageInfo> &packageNodeList); 45 void ParseFinalNode(xmlNodePtr &innode, PackageInfo &info); 46 47 std::map<std::string, std::vector<PackageInfo>> mScanControlFilterMap; 48 std::vector<PackageInfo> mCandidateFilterList; 49 std::map<std::string, std::vector<PackageInfo>> mCorePackageMap; 50 std::vector<PackageInfo> mAclAuthList; 51 }; 52 } 53 } 54 #endif