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