• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 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_H
17 #define MMS_BODY_PART_H
18 
19 #include "mms_attachment.h"
20 #include "mms_content_type.h"
21 #include "mms_body_part_header.h"
22 
23 namespace OHOS {
24 namespace Telephony {
25 class MmsBodyPart {
26 public:
27     MmsBodyPart();
28     MmsBodyPart(const MmsBodyPart &obj);
29     MmsBodyPart &operator=(const MmsBodyPart &srcBodyPart);
30     ~MmsBodyPart();
31     void DumpMmsBodyPart();
32     bool DecodePartHeader(MmsDecodeBuffer &decodeBuffer, uint32_t headerLen);
33     bool DecodePart(MmsDecodeBuffer &decodeBuffer); // main entry
34     bool DecodePartBody(MmsDecodeBuffer &decodeBuffer, uint32_t bodyLength);
35     bool EncodeMmsBodyPart(MmsEncodeBuffer &encodeBuffer);
36     bool SetAttachment(MmsAttachment &attachment);
37 
38 public:
39     bool IsSmilFile();
40     void SetSmilFile(bool isSmil);
41     bool SetContentType(std::string strContentType);
42     bool GetContentType(std::string &strContentType);
43     bool SetContentId(std::string contentId);
44     bool GetContentId(std::string &contentId);
45     bool SetContentLocation(std::string contentLocation);
46     bool GetContentLocation(std::string &contentLocation);
47     bool SetContentDisposition(std::string contentDisposition);
48     bool GetContentDisposition(std::string &contentDisposition);
49 
50     void SetFileName(std::string fileName);
51     MmsContentType &GetContentType();
52     MmsBodyPartHeader &GetPartHeader();
53     std::string GetPartFileName();
54     std::unique_ptr<char[]> ReadBodyPartBuffer(uint32_t &len);
55 
56 private:
57     void AssignBodyPart(const MmsBodyPart &obj);
58     bool WriteBodyFromAttachmentBuffer(MmsAttachment &attachment);
59     bool WriteBodyFromFile(std::string path);
60     void DecodeSetFileName();
61 
62 private:
63     bool isSmilFile_ = false;
64     std::string strFileName_ = "";
65     uint32_t headerLen_ = 0;
66     uint32_t bodyLen_ = 0;
67     MmsContentType bodyPartContentType_;
68     MmsBodyPartHeader mmsBodyPartHeader_;
69     std::unique_ptr<char[]> pbodyPartBuffer_ = nullptr;
70 };
71 } // namespace Telephony
72 } // namespace OHOS
73 #endif
74