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 TAG_SCAN_LIMIT = "ScanLimitPackages"; 27 constexpr auto TAG_LANDSCAPE_SWITCH_LIMIT = "LandscapeSwitchLimitList"; 28 constexpr auto PARAM_NAME = "name"; 29 constexpr auto PARAM_APPID = "appid"; 30 31 namespace OHOS { 32 namespace Wifi { 33 34 class PackageXmlParser : public XmlParser { 35 public: 36 PackageXmlParser() = default; 37 ~PackageXmlParser() override; 38 void GetScanControlPackages(std::map<std::string, std::vector<PackageInfo>> &packageMap); 39 void GetCandidateFilterPackages(std::vector<PackageInfo> &packageList); 40 void GetCorePackages(std::map<std::string, std::vector<PackageInfo>> &packageMap); 41 void GetAclAuthPackages(std::vector<PackageInfo> &packageList); 42 void GetScanLimitPackages(std::vector<PackageInfo> &packageList); 43 void GetLandscapeSwitchLimitList(std::vector<PackageInfo> &packageList); 44 45 private: 46 bool ParseInternal(xmlNodePtr node) override; 47 void GetPackageMap(xmlNodePtr &innode, std::map<std::string, std::vector<PackageInfo>> &result); 48 void GetPackageList(xmlNodePtr &innode, std::vector<PackageInfo> &packageNodeList); 49 void ParseFinalNode(xmlNodePtr &innode, PackageInfo &info); 50 51 std::map<std::string, std::vector<PackageInfo>> mScanControlFilterMap; 52 std::vector<PackageInfo> mCandidateFilterList; 53 std::map<std::string, std::vector<PackageInfo>> mCorePackageMap; 54 std::vector<PackageInfo> mAclAuthList; 55 std::vector<PackageInfo> mScanLimitPackage_; 56 std::vector<PackageInfo> mLandscapeSwitchLimitList_; 57 }; 58 } 59 } 60 #endif