1 /* 2 * Copyright (C) 2021-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 MMS_BODY_PART_HEADER_H 17 #define MMS_BODY_PART_HEADER_H 18 19 #include "mms_content_type.h" 20 21 namespace OHOS { 22 namespace Telephony { 23 enum class MmsHeaderParam { 24 P_CONTENT_LOCATION_V1 = 0x04, 25 P_CONTENT_LOCATION_V2 = 0x0E, 26 P_CONTENT_ID = 0x40, 27 P_CONTENT_DISPOSITION_V1 = 0x2E, 28 P_CONTENT_DISPOSITION_V2 = 0x45 29 }; 30 31 enum class MmsDispositonParam { 32 P_DISPOSITION_FROM_DATA = 0x80, 33 P_DISPOSITION_ATTACHMENT = 0x81, 34 P_DISPOSITION_INLINE = 0x82 35 }; 36 37 class MmsBodyPartHeader { 38 public: 39 MmsBodyPartHeader() = default; 40 ~MmsBodyPartHeader() = default; 41 MmsBodyPartHeader(const MmsBodyPartHeader &obj); 42 MmsBodyPartHeader &operator=(const MmsBodyPartHeader &srcHeader); 43 void DumpBodyPartHeader(); 44 bool DecodeWellKnownHeader(MmsDecodeBuffer &decodeBuffer, uint32_t &headerLen); 45 bool DecodeApplicationHeader(MmsDecodeBuffer &decodeBuffer, uint32_t &headerLen); 46 bool DecodeContentLocation(MmsDecodeBuffer &decodeBuffer, uint32_t &Len); 47 bool DecodeContentId(MmsDecodeBuffer &decodeBuffer, uint32_t &Len); 48 bool DecodeContentDisposition(MmsDecodeBuffer &decodeBuffer, uint32_t &Len); 49 bool DecodeDispositionParameter(MmsDecodeBuffer &decodeBuffer, uint32_t dispLen, uint32_t beginPos); 50 51 bool EncodeContentLocation(MmsEncodeBuffer &encodeBuffer); 52 bool EncodeContentId(MmsEncodeBuffer &encodeBuffer); 53 bool EncodeContentDisposition(MmsEncodeBuffer &encodeBuffer); 54 bool EncodeContentTransferEncoding(MmsEncodeBuffer &encodeBuffer); 55 bool EncodeMmsBodyPartHeader(MmsEncodeBuffer &encodeBuffer); 56 57 public: 58 bool GetContentId(std::string &contentId); 59 bool GetContentLocation(std::string &contentLocation); 60 bool GetContentDisposition(std::string &contentDisposition); 61 bool GetContentTransferEncoding(std::string &contentTransferEncoding); 62 63 bool SetContentId(std::string contentId); 64 bool SetContentLocation(std::string contentLocation); 65 bool SetContentDisposition(std::string contentDisposition); 66 bool SetContentTransferEncoding(std::string contentTransferEncoding); 67 68 private: 69 const std::string DISPOSITION_FROM_DATA = "from-data"; 70 const std::string DISPOSITION_ATTACHMENT = "attachment"; 71 const std::string DISPOSITION_INLINE = "inline"; 72 73 std::string strContentTransferEncoding_ = "binary"; 74 std::string strFileName_ = ""; 75 std::string strDisposition_ = ""; 76 std::string strContentID_ = ""; 77 std::string strContentLocation_ = ""; 78 std::map<std::string, std::string> textMap_; 79 }; 80 } // namespace Telephony 81 } // namespace OHOS 82 #endif 83