• 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_MSG_H
17 #define MMS_MSG_H
18 
19 #include <vector>
20 
21 #include "mms_header.h"
22 #include "mms_body.h"
23 #include "mms_body_part.h"
24 #include "mms_content_param.h"
25 #include "mms_decode_buffer.h"
26 #include "mms_attachment.h"
27 #include "mms_address.h"
28 
29 namespace OHOS {
30 namespace Telephony {
31 class MmsMsg {
32 public:
33     MmsMsg() = default;
34     ~MmsMsg() = default;
35 
36     /**
37      * @brief Dump the mms Message
38      * Printf Mms Message Infomations
39      */
40     void DumpMms();
41 
42     /**
43      * @brief Get the Mms Version
44      * Get Mms Header Protocol Version
45      * @return the Mms Version
46      */
47     uint16_t GetMmsVersion();
48 
49     /**
50      * @brief Set the Mms Version
51      * Set Mms Header Protocol Version
52      * @param value
53      * @return true
54      * @return false
55      */
56     bool SetMmsVersion(uint16_t value);
57 
58     /**
59      * @brief Get the Mms Message Type
60      * Get Mms Header Message Type
61      * @return uint8_t
62      */
63     uint8_t GetMmsMessageType();
64 
65     /**
66      * @brief Set the Mms Message Type
67      * Set Mms Header Message Type
68      * @param value
69      * @return true
70      * @return false
71      */
72     bool SetMmsMessageType(uint8_t value);
73 
74     /**
75      * @brief Get the Mms Transaction Id From Header
76      * A unique identifier for the PDU.
77      * @return std::string
78      */
79     std::string GetMmsTransactionId();
80 
81     /**
82      * @brief Set the Mms Transaction Id To Header
83      * A unique identifier for the PDU.
84      * @param value
85      * @return true
86      * @return false
87      */
88     bool SetMmsTransactionId(std::string value);
89 
90     /**
91      * @brief Get the Mms Date From Header
92      * Get Mms Message Header Date Infomations
93      * @return int64_t
94      */
95     int64_t GetMmsDate();
96 
97     /**
98      * @brief Set the Mms Date To Header
99      * Set Mms Message Header Date Infomations
100      * @return true
101      * @return false
102      */
103     bool SetMmsDate(int64_t value);
104 
105     /**
106      * @brief Get the Mms Subject From Header
107      * Get Mms Message Header SubJect Infomations
108      * @return std::string
109      */
110     std::string GetMmsSubject();
111 
112     /**
113      * @brief Set the Mms Subject To Header
114      * Set Mms Message Header SubJect Infomations
115      * @return std::string
116      */
117     bool SetMmsSubject(std::string value);
118 
119     /**
120      * @brief Get the Mms From
121      * Get Mms Message Header From Address Infomations
122      * @return MmsAddress
123      */
124     MmsAddress GetMmsFrom();
125 
126     /**
127      * @brief Set the Mms From To Header
128      * Set Mms Message Header From Address Infomations
129      * @param address
130      * @return true
131      * @return false
132      */
133     bool SetMmsFrom(MmsAddress address);
134 
135     /**
136      * @brief Set the Mms To Address to Header
137      * it can support multiple address to header
138      * @param address
139      * @return true
140      * @return false
141      */
142     bool SetMmsTo(std::vector<MmsAddress>& toAddrs);
143 
144     /**
145      * @brief Get the Mms Msg to address from the header
146      * it can support multiple address to header
147      * @param address
148      * @return true
149      * @return false
150      */
151     bool GetMmsTo(std::vector<MmsAddress>& toAddrs);
152 
153     /**
154      * @brief Get Octet Type Value From the Header
155      * This is Generic methods to Get Mms Message Header
156      * Field Octet Value
157      * @param fieldId
158      * @return uint8_t
159      */
160     uint8_t GetHeaderOctetValue(uint8_t fieldId);
161 
162     /**
163      * @brief Set the Header Octet Value To Header
164      * This is Generic methods to Set Mms Message Header
165      * Field Octet Value
166      * @param fieldId
167      * @param value
168      * @return true
169      * @return false
170      */
171     bool SetHeaderOctetValue(uint8_t fieldId, uint8_t value);
172 
173     /**
174      * @brief Get the Header Integer Value From Header
175      * This is Generic methods to Get Mms Message Header
176      * Field Integer Value
177      * @param fieldId
178      * @return int32_t
179      */
180     int32_t GetHeaderIntegerValue(uint8_t fieldId);
181 
182     /**
183      * @brief Set the Header Integer Value To Header
184      * This is Generic methods to Set Mms Message Header
185      * Field Integer Value
186      * @param fieldId
187      * @param value
188      * @return true
189      * @return false
190      */
191     bool SetHeaderIntegerValue(uint8_t fieldId, int32_t value);
192 
193     /**
194      * @brief Get Long Type Value From the Header
195      * This is Generic methods to Get Mms Message Header
196      * Field Long Value
197      * @param fieldId
198      * @return int64_t
199      */
200     int64_t GetHeaderLongValue(uint8_t fieldId);
201 
202     /**
203      * @brief Set the Header Long Value To Header
204      * This is Generic methods to Set Mms Message Header
205      * Field Long Value
206      * @param fieldId
207      * @param value
208      * @return true
209      * @return false
210      */
211     bool SetHeaderLongValue(uint8_t fieldId, int64_t value);
212 
213     /**
214      * @brief Get String or Encode String Type Value From the Header
215      * This is Generic methods to Get Mms Message Header
216      * Field Text Value Or EncondeString with UTF_8
217      * @param fieldId
218      * @return std::string
219      */
220     std::string GetHeaderStringValue(uint8_t fieldId);
221 
222     /**
223      * @brief Set the Header String Value To Header
224      * This is Generic methods to Set Mms Message Header
225      * Field Text Value
226      * @param fieldId
227      * @param value
228      * @return true
229      * @return false
230      */
231     bool SetHeaderStringValue(uint8_t fieldId, std::string &value);
232 
233     /**
234      * @brief Set the Header Encoded String Value From Header
235      * This is Generic methods to Set Mms Message Header
236      * Field EncondeString Value
237      * @param fieldId
238      * @param value
239      * @param charset
240      * @return true
241      * @return false
242      */
243     bool SetHeaderEncodedStringValue(uint8_t fieldId, const std::string &value, uint32_t charset);
244 
245     /**
246      * @brief AddHeaderAddressValue
247      * for example: To / Cc / Bcc
248      * @param fieldId
249      * @param address
250      * @return true
251      * @return false
252      */
253     bool AddHeaderAddressValue(uint8_t fieldId, MmsAddress &address);
254 
255     /**
256      * @brief Get the Header All Address Value From Header
257      * for example: To / Cc / Bcc
258      * @param fieldId
259      * @param addressValue
260      * @return true
261      * @return false
262      */
263     bool GetHeaderAllAddressValue(uint8_t fieldId, std::vector<MmsAddress> &addressValue);
264 
265     /**
266      * @brief Set the Content Type
267      *
268      * @param strType
269      * @return true
270      * @return false
271      */
272     bool SetHeaderContentType(std::string strType);
273 
274     /**
275      * @brief Get the Content Type
276      *
277      * @return std::string
278      */
279     std::string GetHeaderContentType();
280 
281     /**
282      * @brief Get the Content Type start parameter
283      *
284      * @return std::string
285      */
286     std::string GetHeaderContentTypeStart();
287 
288     /**
289      * @brief add attachment to mms message
290      * if attachment is smil file must to add first
291      * @param attachment
292      * @return true
293      * @return false
294      */
295     bool AddAttachment(MmsAttachment &attachment);
296 
297     /**
298      * @brief Get the All Attachment from mms message
299      * if has smil attachments defalut place frist
300      * @param attachments
301      * @return true
302      * @return false
303      */
304     bool GetAllAttachment(std::vector<MmsAttachment> &attachments);
305 
306     /**
307      * @brief DecodeMsg from a mms file
308      *
309      * @param mmsFilePathName
310      * @return true
311      * @return false
312      */
313     bool DecodeMsg(std::string mmsFilePathName);
314 
315     /**
316      * @brief DecodeMsg from a mms from buff
317      *
318      * @param inBuff
319      * @param inLen
320      * @return true
321      * @return false
322      */
323     bool DecodeMsg(std::unique_ptr<char[]> inBuff, uint32_t inLen);
324 
325     /**
326      * @brief EncodeMsg form MmsMsg
327      * return eoncode MmsMsg result data buff
328      * @param outLen
329      * @return std::unique_ptr<char[]>
330      */
331     std::unique_ptr<char[]> EncodeMsg(uint32_t &outLen);
332 
333     MmsHeader &GetHeader();
334 
335 private:
336     MmsHeader mmsHeader_;
337     MmsBody mmsBody_;
338 };
339 } // namespace Telephony
340 } // namespace OHOS
341 #endif
342