• 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_ATTACHMENT_H
17 #define MMS_ATTACHMENT_H
18 
19 #include <cstring>
20 #include <string>
21 
22 namespace OHOS {
23 namespace Telephony {
24 class MmsAttachment {
25 public:
26     MmsAttachment() = default;
27     ~MmsAttachment();
28     MmsAttachment(const MmsAttachment &srcAttachment);
29 
30     /**
31      * @brief Set the Attachment File Path Name
32      *
33      * @param strPath
34      * @return true
35      * @return false
36      */
37     bool SetAttachmentFilePath(std::string strPath, bool isSmil = false);
38 
39     /**
40      * @brief Get the Attachment File Path Name
41      *
42      * @return std::string
43      */
44     std::string GetAttachmentFilePath();
45 
46     /**
47      * @brief Set the Attachment Content Id
48      *
49      * @param contentId
50      * @return true
51      * @return false
52      */
53     bool SetContentId(std::string contentId);
54 
55     /**
56      * @brief Get the Attachment Content Id
57      *
58      * @return std::string
59      */
60     std::string GetContentId();
61 
62     /**
63      * @brief Set the Attachment Content Location
64      *
65      * @param contentLocation
66      * @return true
67      * @return false
68      */
69     bool SetContentLocation(std::string contentLocation);
70 
71     /**
72      * @brief Get the Attachment Content Location
73      *
74      * @return std::string
75      */
76     std::string GetContentLocation();
77 
78     /**
79      * @brief Set the Attachment Content Disposition
80      *
81      * @param contentDisposition
82      * @return true
83      * @return false
84      */
85     bool SetContentDisposition(std::string contentDisposition);
86 
87     /**
88      * @brief Get Attachment the Content Disposition
89      *
90      * @return std::string
91      */
92     std::string GetContentDisposition();
93 
94     /**
95      * @brief Set the Attachment Content Transfer Encoding
96      *
97      * @param contentTransferEncoding
98      * @return true
99      * @return false
100      */
101     bool SetContentTransferEncoding(std::string contentTransferEncoding);
102 
103     /**
104      * @brief Get the Attachment Content Transfer Encoding
105      *
106      * @return std::string
107      */
108     std::string GetContentTransferEncoding();
109 
110     /**
111      * @brief Set the Attachment Content Type
112      *
113      * @param strContentType
114      * @return true
115      * @return false
116      */
117     bool SetContentType(std::string strContentType);
118 
119     /**
120      * @brief Get the Attachment Content Type
121      *
122      * @return std::string
123      */
124     std::string GetContentType();
125 
126     /**
127      * @brief Set the File Name object
128      *
129      * @param strFileName
130      * @return true
131      * @return false
132      */
133     bool SetFileName(std::string strFileName);
134 
135     /**
136      * @brief Get the File Name object
137      *
138      * @return std::string
139      */
140     std::string GetFileName();
141 
142     /* @brief Get the Attachment ContentType CharSet
143      *
144      * @return uint32_t
145      */
146     uint32_t GetCharSet();
147     /**
148      * @brief Set the Attachment ContentType CharSet
149      *
150      * @return void
151      */
152     void SetCharSet(uint32_t charset);
153 
154     /**
155      * @brief Check the Attachment Is Smil File
156      *
157      * @return true
158      * @return false
159      */
160     bool IsSmilFile();
161 
162     /**
163      * @brief Set the Attachment Is Smil File
164      *
165      * @param isSmilFile
166      */
167     void SetIsSmilFile(bool isSmilFile);
168 
169     /**
170      * @brief Get the Data Buffer The Attachment
171      *
172      * @param len out put buffer len
173      * @return std::unique_ptr<char[]>
174      */
175     std::unique_ptr<char[]> GetDataBuffer(uint32_t &len);
176 
177     /**
178      * @brief Set the Data Buffer To Attachment
179      *
180      * @param inBuff data input buffer pointer
181      * @param len data input len
182      * @return true
183      * @return false
184      */
185     bool SetDataBuffer(std::unique_ptr<char[]> inBuff, uint32_t len);
186 
187 private:
188     bool isSmilFile_ = false;
189     std::string strPathName_;
190     std::string contentId_;
191     std::string contentLocation_;
192     std::string contentDispositon_;
193     std::string contenTransferEncoding_;
194     std::string contentType_;
195     std::string strFileName_;
196     uint32_t charset_ = 0;
197     uint32_t dataLength_ = 0;
198     std::unique_ptr<char[]> pAttachmentBuffer_ = nullptr;
199     static constexpr uint32_t MAX_MMS_ATTACHMENT_LEN = 300 * 1024;
200 };
201 } // namespace Telephony
202 } // namespace OHOS
203 #endif
204