|
1 /* |
|
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CJAVAMMSMESSAGEHANDLER_H |
|
20 #define CJAVAMMSMESSAGEHANDLER_H |
|
21 |
|
22 #include <jni.h> |
|
23 #include <string> |
|
24 #include <s32mem.h> |
|
25 #include <s32strm.h> |
|
26 #include <e32base.h> |
|
27 #include <e32const.h> |
|
28 #include <charconv.h> |
|
29 #include "cmmsmessageinformation.h" |
|
30 |
|
31 namespace java |
|
32 { |
|
33 namespace wma |
|
34 { |
|
35 |
|
36 const TInt KPriorityLow = 1; |
|
37 const TInt KPriorityNormal = 2; |
|
38 const TInt KPriorityHigh = 3; |
|
39 |
|
40 const TInt K2BitsMask = 2; |
|
41 const TInt K4BitsMask = 4; |
|
42 const TInt K8BitsMask = 8; |
|
43 const TInt K16BitsMask = 16; |
|
44 const TInt K24BitsMask = 24; |
|
45 const TInt K32BitsMask = 32; |
|
46 const TInt K40BitsMask = 40; |
|
47 const TInt K48BitsMask = 48; |
|
48 const TInt K56BitsMask = 56; |
|
49 const TInt K64BitsMask = 64; |
|
50 |
|
51 class CJavaMMSMessageHandler:public CBase |
|
52 { |
|
53 public: |
|
54 //Destructor |
|
55 virtual ~CJavaMMSMessageHandler(); |
|
56 |
|
57 static CJavaMMSMessageHandler* NewL(RFs aFs); |
|
58 /** |
|
59 * Deserializes a byte array containing a multimedia message to be sent |
|
60 * into an internal representation of the multimedia message. |
|
61 * |
|
62 * @param aMMS A Buffer containing the multimedia message in a byte |
|
63 * array representation |
|
64 * @return The internal representation of the multimedia message to be |
|
65 * sent |
|
66 */ |
|
67 CMMSMessageInformation& DeSerializeL(CBufFlat& aMMS); |
|
68 /** |
|
69 * Serializes an internal representation of the multimedia message into |
|
70 * a byte array representation. |
|
71 * |
|
72 * @param aMMS A Buffer containing the multimedia message in the |
|
73 * internal representation |
|
74 * @return The byte array representation of the multimedia message |
|
75 */ |
|
76 CBufFlat& SerializeLC(CMMSMessageInformation& aMMS); |
|
77 |
|
78 private: |
|
79 //Constructor |
|
80 CJavaMMSMessageHandler(RFs aRFs); |
|
81 /** |
|
82 * Returns the rest of dividing aNum1 with aNum2. |
|
83 * |
|
84 * @param aNum1 The number to divide |
|
85 * @param aNum2 The number to be divided with |
|
86 * @return The rest of dividing aNum1 with aNum2 |
|
87 */ |
|
88 int Divide(int aNum1, int aNum2); |
|
89 /** |
|
90 * Reads an integer as 4 bytes from the read stream. |
|
91 * |
|
92 * @param aStream The stream containing a byte array |
|
93 * @return An integer read as 4 bytes |
|
94 */ |
|
95 TInt32 ReadIntL(RBufReadStream& aStream); |
|
96 /** |
|
97 * Reads an integer as 8 bytes from the read stream. |
|
98 * |
|
99 * @param aStream The stream containing a byte array |
|
100 * @return An integer read as 8 bytes |
|
101 */ |
|
102 TInt64 ReadInt64L(RBufReadStream& aStream); |
|
103 /** |
|
104 * Resolves the map of the multimedia message. The map of the multimedia |
|
105 * message consists of a byte whose bits indicate which of the |
|
106 * multimedia message headers are present. See implementation comments |
|
107 * for more details. |
|
108 * |
|
109 * @param aStream The stream containing the multimedia message |
|
110 * @param aHeaderLengths The lengths of the multimedia message |
|
111 * headers |
|
112 */ |
|
113 void ResolveMapL(RBufReadStream& aStream, TInt32 aHeaderLengths[]); |
|
114 /** |
|
115 * Resolves/reads the headers of the multimedia message from the stream |
|
116 * and sets them to the internal representation of the multimedia |
|
117 * message |
|
118 * |
|
119 * @param aStream The stream containing the multimedia message |
|
120 * @param aHeaderLengths The lengths of the multimedia message |
|
121 * headers |
|
122 * @return The internal representation of the multimedia message with |
|
123 * the headers being set |
|
124 */ |
|
125 CMMSMessageInformation& ResolveHeadersLC(RBufReadStream& aStream, |
|
126 TInt32 aHeaderLengths[]); |
|
127 /** |
|
128 * Splits the concatenated addresses (";" separated string/descriptor) |
|
129 * into sepparate tokens and sets them individually to the internal |
|
130 * representation of the multimedia message. |
|
131 * |
|
132 * @param aAddressType The address type. Possible values are: |
|
133 * EMsvRecipientTo, EMsvRecipient and BccEMsvRecipientCc |
|
134 * @param aMsg The internal representation of the multimedia |
|
135 * message where the sepparate addresses will be set to |
|
136 */ |
|
137 void ParseAndSetAddressL(TMsvRecipientTypeValues aAddressType, |
|
138 TDes8& aAddr, CMMSMessageInformation& aMsg); |
|
139 /** |
|
140 * Save data to the D-drive. MMS engine assume that attachments are |
|
141 * always files. It also help us to use less RAM. |
|
142 * |
|
143 * @param aDataArray |
|
144 * @return TDesC* FileName |
|
145 */ |
|
146 void SaveDataToFileL(const TDesC8& aDataArray, TDesC8*& aFileName, |
|
147 const TDesC8& aDataType); |
|
148 |
|
149 /** |
|
150 * Concatenates all the addresses/recipients into a ";" separated |
|
151 * string/descriptor. |
|
152 * |
|
153 * @param aAddressType The address type. Possible values are: |
|
154 * EMsvRecipientTo, EMsvRecipient and BccEMsvRecipientCc |
|
155 * @param aMMS The internal representation of the multimedia |
|
156 * message containing the addresses |
|
157 */ |
|
158 HBufC8& BuildAddressLC(TMsvRecipientTypeValues aAddressType, |
|
159 CMMSMessageInformation& aMMS); |
|
160 |
|
161 /** |
|
162 * Calculates the mms map. See the implementation for more details |
|
163 * about the mms map. |
|
164 * |
|
165 * @param aReplyToAppID The sender's application identifier |
|
166 * @param aAppID The application identifier |
|
167 * @param aSubject The subject |
|
168 * @param aFrom The 'from' address |
|
169 * @param aTo The 'to' address |
|
170 * @param aBcc The 'bcc' address |
|
171 * @param aCc The 'cc' address |
|
172 * @return The mms map |
|
173 */ |
|
174 TInt CalculateMap(TDesC8& aReplyToAppID, TDesC8& aAppID, TDesC8& aSubject, |
|
175 TDesC8& aFrom, HBufC8& aTo, HBufC8& aBcc, HBufC8& aCc); |
|
176 |
|
177 /** |
|
178 * Writes an integer as 8 bytes into the write stream. |
|
179 * |
|
180 * @param aStream The stream where the integer will be written to |
|
181 * @param aInteger The integer to be written |
|
182 */ |
|
183 void WriteInt64L(RBufWriteStream& aStream, const TInt64 aInteger); |
|
184 |
|
185 /** |
|
186 * Writes an integer as 4 bytes into the write stream. |
|
187 * |
|
188 * @param aStream The stream where the integer will be written to |
|
189 * @param aInteger The integer to be written |
|
190 */ |
|
191 void WriteIntL(RBufWriteStream& aStream, const TInt32 aInteger); |
|
192 |
|
193 /** |
|
194 * Writes the lengths of all attachments into the write stream. |
|
195 * |
|
196 * @param aStream The stream where the attachment lengths will be |
|
197 * written to |
|
198 * @param aMMS The internal representation of the multimedia |
|
199 * message containing all the attachments to be written |
|
200 * @param aConv The symbian's character converter used for translating |
|
201 * the encoding from the MIBEnum into the text representation |
|
202 * @return The index (within the aMMS) of the first attachment |
|
203 * (if such an attachment has been set to be the first one), or -1 if |
|
204 * none of the attachments has been set to be the first one |
|
205 */ |
|
206 TInt WriteAttachmentsLengthsL(RBufWriteStream& aStream, |
|
207 CMMSMessageInformation& aMMS, CCnvCharacterSetConverter& aConv); |
|
208 |
|
209 /** |
|
210 * Writes the lengths of an attachment into the write stream. |
|
211 * |
|
212 * @param aStream The stream where the attachment lengths will be |
|
213 * written to |
|
214 * @param aAttch The attachment whose lengths are to be written |
|
215 * @param aConv The symbian's character converter used for translating |
|
216 * the encoding from the MIBEnum into the text representation |
|
217 */ |
|
218 void WriteAttachmentLengthsL(RBufWriteStream& aStream, |
|
219 CMMSMessageAttachment& aAttch, CCnvCharacterSetConverter& aConv); |
|
220 |
|
221 /** |
|
222 * Writes all the attachments into the write stream. |
|
223 * |
|
224 * @param aStream The stream where the attachments will be written to |
|
225 * @param aMMS The internal representation of the multimedia |
|
226 * message containing all the attachments to be written |
|
227 * @param aConv The symbian's character converter used for translating |
|
228 * the encoding from the MIBEnum into the text representation |
|
229 * @param aFirstAttchmt The index of the first attachment to be written |
|
230 * or -1 if the attachments could be written in an arbitrary order |
|
231 */ |
|
232 void WriteAttachmentsL(RBufWriteStream& aStream, |
|
233 CMMSMessageInformation& aMMS, CCnvCharacterSetConverter& aConv, |
|
234 TInt aFirstAttchmt); |
|
235 |
|
236 /** |
|
237 * Writes an attachment into the write stream. |
|
238 * |
|
239 * @param aStream The stream where the attachment will be written to |
|
240 * @param aAttch The attachment which will be written |
|
241 * @param aConv The symbian's character converter used for translating |
|
242 * the encoding from the MIBEnum into the text representation |
|
243 */ |
|
244 void WriteAttachmentL(RBufWriteStream& aStream, |
|
245 CMMSMessageAttachment& aAttch, CCnvCharacterSetConverter& aConv); |
|
246 |
|
247 /** |
|
248 * Writes a descriptor (if not NULL) into the write stream. |
|
249 * |
|
250 * @param aStream The stream where the descriptor will be written to |
|
251 * @param aDes The descriptor which will be written |
|
252 */ |
|
253 void WriteDes8L(RBufWriteStream& aStream, const TDesC8& aDes); |
|
254 |
|
255 /** |
|
256 * Writes a descriptor's length (if the descriptor is not NULL) |
|
257 * |
|
258 * @param aStream The stream where the descriptor's length will be |
|
259 * written to |
|
260 * @param aDes The descriptor whose length will be written |
|
261 */ |
|
262 void WriteDes8LengthL(RBufWriteStream& aStream, const TDesC8& aDes); |
|
263 |
|
264 /** |
|
265 * Writes a descriptor's length (if the descriptor is not NULL) or zero |
|
266 * (if the descriptor is NULL) |
|
267 * |
|
268 * @param aStream The stream where the descriptor's length will be |
|
269 * written to |
|
270 * @param aDes The descriptor whose length will be written |
|
271 */ |
|
272 void WriteDes8LengthOrZeroL(RBufWriteStream& aStream, const TDesC8& aDes); |
|
273 |
|
274 /** |
|
275 * Writes a descriptor's length (if the descriptor is not NULL) or zero |
|
276 * (if the descriptor is NULL) |
|
277 * |
|
278 * @param aStream The stream where the descriptor's length will be |
|
279 * written to |
|
280 * @param aDes The descriptor whose length will be written |
|
281 */ |
|
282 void WriteDesLengthOrZeroL(RBufWriteStream& aStream, const TDesC8& aDes); |
|
283 |
|
284 private: |
|
285 |
|
286 // handle to file server |
|
287 RFs mRFs; |
|
288 }; |
|
289 } //namespace wma |
|
290 } //namespace java |
|
291 #endif // CJAVAMMSMESSAGEHANDLER_H |