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 NDEF_HAR_DATA_PARSER_H 16 #define NDEF_HAR_DATA_PARSER_H 17 18 #include <string> 19 #include "ndef_message.h" 20 #include "ndef_har_dispatch.h" 21 #include "inci_tag_interface.h" 22 #include "taginfo.h" 23 24 namespace OHOS { 25 namespace NFC { 26 namespace TAG { 27 using namespace OHOS::NFC::KITS; 28 29 class NdefHarDataParser { 30 public: 31 NdefHarDataParser(std::weak_ptr<NCI::INciTagInterface> nciTagProxy); ~NdefHarDataParser()32 ~NdefHarDataParser() {} 33 bool TryNdef(const std::string& msg, std::shared_ptr<KITS::TagInfo> tagInfo); 34 35 private: 36 std::string IsWebUri(std::shared_ptr<NdefRecord> record); 37 std::string GetUriPayload(std::shared_ptr<NdefRecord> record); 38 std::string GetUriPayload(std::shared_ptr<NdefRecord> record, bool isSmartPoster); 39 bool ParseWebLink(std::vector<std::shared_ptr<NdefRecord>> records); 40 bool ParseHarPackage( 41 std::vector<std::string> harPackages, std::shared_ptr<KITS::TagInfo> tagInfo, const std::string &mimeType, 42 const std::string &uri); 43 bool ParseHarPackageInner( 44 std::vector<std::string> harPackages, std::shared_ptr<KITS::TagInfo> tagInfo, const std::string &mimeType, 45 const std::string &uri); 46 bool ParseUriLink(std::vector<std::shared_ptr<NdefRecord>> records); 47 bool ParseOtherType(std::vector<std::shared_ptr<NdefRecord>> records, std::shared_ptr<KITS::TagInfo> tagInfo); 48 std::string ToMimeType(std::shared_ptr<NdefRecord> record); 49 std::vector<std::string> ExtractHarPackages(std::vector<std::shared_ptr<NdefRecord>> records); 50 std::string CheckForHar(std::shared_ptr<NdefRecord> record); 51 bool IsOtherPlatformAppType(const std::string &appType); 52 53 std::shared_ptr<NdefHarDispatch> ndefHarDispatch_ {nullptr}; 54 std::weak_ptr<NCI::INciTagInterface> nciTagProxy_ {}; 55 }; 56 } // namespace TAG 57 } // namespace NFC 58 } // namespace OHOS 59 #endif // NDEF_HAR_DATA_PARSER_H