|
1 /* |
|
2 * Copyright (c) 2007 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: This file defines class CIpsPlgMsgMapper. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef IPSPLGMSGMAPPER_H |
|
20 #define IPSPLGMSGMAPPER_H |
|
21 |
|
22 |
|
23 class CMsvSession; |
|
24 class CMsvEntry; |
|
25 class CFSMailMessage; |
|
26 class CFSMailMessagePart; |
|
27 class CFSMailAddress; |
|
28 class CIpsPlgSosBasePlugin; |
|
29 |
|
30 /** |
|
31 * |
|
32 * |
|
33 * @lib |
|
34 * @since FS 1.0 |
|
35 */ |
|
36 NONSHARABLE_CLASS( CIpsPlgMsgMapper ) : public CBase |
|
37 { |
|
38 public: |
|
39 |
|
40 /** |
|
41 * Symbian 2nd phase construcror |
|
42 * |
|
43 * @since FS 1.0 |
|
44 * @return Created object |
|
45 */ |
|
46 static CIpsPlgMsgMapper* NewL( |
|
47 CMsvSession& aSession, |
|
48 CIpsPlgSosBasePlugin& aPlugin ); |
|
49 |
|
50 /** |
|
51 * Symbian 2nd phase construcror |
|
52 * |
|
53 * @since FS 1.0 |
|
54 * @return Created object |
|
55 */ |
|
56 static CIpsPlgMsgMapper* NewLC( |
|
57 CMsvSession& aSession, |
|
58 CIpsPlgSosBasePlugin& aPlugin ); |
|
59 |
|
60 /** |
|
61 * Class destructor |
|
62 * |
|
63 * @since FS 1.0 |
|
64 */ |
|
65 virtual ~CIpsPlgMsgMapper(); |
|
66 |
|
67 |
|
68 /** |
|
69 * Returns CFSMailMessge constructed from Symbian's message types |
|
70 * Ownership is transferred |
|
71 * |
|
72 * @since FS 1.0 |
|
73 */ |
|
74 CFSMailMessage* GetMailMessageL( |
|
75 const TFSMailMsgId& aMailboxId, |
|
76 const TMsvEmailEntry& aEntry, |
|
77 const TFSMailDetails& aDetails ); |
|
78 |
|
79 /** |
|
80 * Returns CFSMailMessge constructed from Symbian's message types |
|
81 * Ownership is transferred |
|
82 * |
|
83 * @since FS 1.0 |
|
84 */ |
|
85 CFSMailMessage* GetMailMessageL( CMsvEntry& aEntry ); |
|
86 |
|
87 /** |
|
88 * Constructs the FS message part objects for the child parts |
|
89 * of the entry/part referred by the message ID parameters. |
|
90 * |
|
91 * @param aMailBoxId The mailbox where message is located |
|
92 * @param aParentFolderId The parent folder where message is located |
|
93 * @param aMessageId The id of the message that message part |
|
94 * belongs to |
|
95 * @param aParentId The id of the parent message part |
|
96 * @param aParts List of contructed child parts |
|
97 */ |
|
98 void GetChildPartsL( |
|
99 const TFSMailMsgId& aMailBoxId, |
|
100 const TFSMailMsgId& aMessageId, |
|
101 const TFSMailMsgId& aParentId, |
|
102 RPointerArray<CFSMailMessagePart>& aParts ); |
|
103 |
|
104 /** |
|
105 * Returns a message part object filled with data from a entry |
|
106 * in Symbian message store. |
|
107 * |
|
108 * @param aEntryId Identifier of the message part |
|
109 * @param aMailBoxId |
|
110 * @param aMessageId |
|
111 * @return Message part object. Ownership is transferred. |
|
112 */ |
|
113 CFSMailMessagePart* GetMessagePartL( |
|
114 TMsvId aEntryId, |
|
115 const TFSMailMsgId& aMailBoxId, |
|
116 const TFSMailMsgId& aMessageId ); |
|
117 |
|
118 /** |
|
119 * Updatest the message flags to the message store |
|
120 * |
|
121 * @param aEntryId Identifier of the message |
|
122 * @param aMessagePart The message part containing the new flag values |
|
123 * @since FS 1.0 |
|
124 */ |
|
125 void UpdateMessageFlagsL( |
|
126 TMsvId aEntryId, |
|
127 const CFSMailMessage& aMessage ); |
|
128 |
|
129 /** |
|
130 * Change message flags and return msvoperation if flags is modified |
|
131 * |
|
132 * @param aEntryId Identifier of the message |
|
133 * @param aMessagePart The message part containing the new flag values |
|
134 * @param aStatus status of msv operation observer |
|
135 * @return CMsvOperation* operation pointer or NULL |
|
136 * if there is no need to update flags |
|
137 * @since FS 2.0 |
|
138 */ |
|
139 CMsvOperation* UpdateMessageFlagsAsyncL( |
|
140 TMsvId aEntryId, |
|
141 const CFSMailMessage& aMessage, |
|
142 TRequestStatus& aStatus ); |
|
143 |
|
144 /** |
|
145 * Updatest the message flags to FS message |
|
146 * |
|
147 * @param aEntry email entry of FS message |
|
148 * @param aMsg updated FS message |
|
149 * @since FS 1.0 |
|
150 */ |
|
151 void SetFSMessageFlagsL( |
|
152 const TMsvEmailEntry& aEntry, CFSMailMessage& aMsg ); |
|
153 |
|
154 /** |
|
155 * Creates a new empty child part. The method only multipart types |
|
156 * currently. |
|
157 * |
|
158 * @param aMailBoxId Mailbox identifier |
|
159 * @param aMessageId Message identifier |
|
160 * @param aParentPartId Parent message part identifier |
|
161 * @param aContentType Content type |
|
162 * @return The new message part object |
|
163 */ |
|
164 CFSMailMessagePart* NewChildPartL( |
|
165 const TFSMailMsgId& aMailBoxId, |
|
166 const TFSMailMsgId& aMessageId, |
|
167 const TFSMailMsgId& aParentPartId, |
|
168 const TDesC& aContentType ); |
|
169 |
|
170 protected: |
|
171 |
|
172 /** |
|
173 * Class constructor |
|
174 * |
|
175 * @since FS 1.0 |
|
176 */ |
|
177 CIpsPlgMsgMapper( |
|
178 CMsvSession& aSession, |
|
179 CIpsPlgSosBasePlugin& aPlugin ); |
|
180 |
|
181 private: |
|
182 |
|
183 /** |
|
184 * Symbian 2nd phase construct |
|
185 * |
|
186 * @since FS 1.0 |
|
187 */ |
|
188 void ConstructL(); |
|
189 |
|
190 /** |
|
191 * |
|
192 * |
|
193 * @since FS 1.0 |
|
194 */ |
|
195 void SetDateL( const TMsvEntry& aEntry, CFSMailMessage& aMsg ); |
|
196 |
|
197 /** |
|
198 * |
|
199 * |
|
200 * @since FS 1.0 |
|
201 */ |
|
202 void SetSubjectL( const TMsvEntry& aEntry, CFSMailMessage& aMsg ); |
|
203 |
|
204 /** |
|
205 * |
|
206 * |
|
207 * @since FS 1.0 |
|
208 */ |
|
209 void SetSenderL( TPtrC aSender, CFSMailMessage& aMsg ); |
|
210 |
|
211 /** |
|
212 * |
|
213 * |
|
214 * @since FS 1.0 |
|
215 */ |
|
216 void SetEnvelopeL( |
|
217 const CMsvEntry* aEntry, |
|
218 CMsvStore* aStore, |
|
219 CFSMailMessage& aMsg ); |
|
220 |
|
221 /** |
|
222 * |
|
223 * |
|
224 * @since FS 1.0 |
|
225 */ |
|
226 void SetStructureL( const CMsvEntry* aEntry, CFSMailMessage& aMsg ); |
|
227 |
|
228 /* |
|
229 * Sets the flags of the message object based on the contents of |
|
230 * TMsvEmailEntry instance |
|
231 */ |
|
232 void SetFlags( const TMsvEmailEntry& aEntry, CFSMailMessage& aMsg ); |
|
233 |
|
234 /** |
|
235 * Sets the fetch state of the FS message objects based on the state |
|
236 * of TMsvEmailEntry instance |
|
237 */ |
|
238 void SetFetchStateL( |
|
239 const TMsvEmailEntry& aEntry, |
|
240 TMsvId aMsgMainId, |
|
241 TBool aIsAtta, |
|
242 CFSMailMessagePart& aMessage ); |
|
243 |
|
244 /** |
|
245 * Sets the fetch state of imap message entry |
|
246 */ |
|
247 void DoSetFetchStateL( |
|
248 const TMsvEmailEntry& aEntry, |
|
249 TMsvId aMsgMainId, |
|
250 TBool aIsAtta, |
|
251 CFSMailMessagePart& aMessage ); |
|
252 |
|
253 /* |
|
254 * Converts Symbian's enumerated folder type as a MIME type |
|
255 */ |
|
256 TPtrC ConvertMultipartMimeType( TImEmailFolderType aFolderType ) const; |
|
257 |
|
258 // <cmail> |
|
259 /* |
|
260 * Converts entry type field UID as a MIME type |
|
261 */ |
|
262 TInt ConvertBodyPartMimeType( |
|
263 const TUid& aEntryType, |
|
264 TDes& aMimeType ); |
|
265 |
|
266 /** |
|
267 * Digs out charset of content, and constructs a Content-Type field parameter appending it |
|
268 * to given content-type |
|
269 * (e.g. "text/html" -> "text/html; charset=windows-1252") |
|
270 * @param attachment entry |
|
271 * @param descriptor where charset will be appended. |
|
272 * No validation is done for the given content. |
|
273 */ |
|
274 void GetCharsetParameterL( |
|
275 const TMsvEmailEntry& aEntry, |
|
276 TDes& aContentType ); |
|
277 // </cmail> |
|
278 |
|
279 /** |
|
280 * Separates the actual email address and the alias (display name) |
|
281 * and stores them to FS address object |
|
282 */ |
|
283 void ConvertAddressL( |
|
284 TPtrC aSourceAddress, |
|
285 CFSMailAddress& aTargetAddress ); |
|
286 |
|
287 /** |
|
288 * Simple utility function that digs the MIME type out from the |
|
289 * MIME header object and copies it to FS message part object |
|
290 */ |
|
291 void SetContentTypeL( |
|
292 CImMimeHeader& aMimeHeader, |
|
293 CFSMailMessagePart& aMessagePart ); |
|
294 |
|
295 /** |
|
296 * XOR function that regards all non-zero values as 'true' and |
|
297 * zero as 'false'. |
|
298 */ |
|
299 inline TBool LogicalXor( TInt aLeft, TInt aRight ); |
|
300 |
|
301 // <cmail> implemented to get rid of cs warning |
|
302 /** |
|
303 * Gets attachment count of entry |
|
304 */ |
|
305 TInt GetAttachmentCountL( const TMsvEmailEntry& aEntry ); |
|
306 |
|
307 /** |
|
308 * Checks email if it has attachments or not. |
|
309 * |
|
310 */ |
|
311 void AttaCheckForIncompleteMsgL( |
|
312 const TMsvEmailEntry& aEntry, |
|
313 CFSMailMessage& aMsg ); |
|
314 |
|
315 // </cmail> |
|
316 |
|
317 private: |
|
318 |
|
319 /** |
|
320 * Constructs the FS message part objects for the direct descendants of |
|
321 * the message. In the case of a multipart message, these are the top |
|
322 * level parts. In the case of simple (one-part) message, one part is |
|
323 * constructed. |
|
324 */ |
|
325 void GetChildPartsOfMessageEntryL( |
|
326 const TFSMailMsgId& aMailBoxId, |
|
327 const TFSMailMsgId& aMessageId, |
|
328 RPointerArray<CFSMailMessagePart>& aParts ); |
|
329 |
|
330 /** |
|
331 * Constructs the FS message part objects for the children of |
|
332 * the folder entry that represents a MIME multipart structure. |
|
333 */ |
|
334 void GetChildPartsOfFolderEntryL( |
|
335 const TFSMailMsgId& aMailBoxId, |
|
336 const TFSMailMsgId& aMessageId, |
|
337 TMsvId aParentId, |
|
338 RPointerArray<CFSMailMessagePart>& aParts ); |
|
339 |
|
340 /** |
|
341 * Converts an entry representing a message body part as a |
|
342 * FS message part object. Ownership of the returned object |
|
343 * is moved. |
|
344 */ |
|
345 CFSMailMessagePart* ConvertBodyEntry2MessagePartL( |
|
346 const TMsvEmailEntry& aEntry, |
|
347 const TFSMailMsgId& aMailBoxId, |
|
348 const TFSMailMsgId& aMessageId ); |
|
349 |
|
350 /** |
|
351 * Converts an entry representing an attachment as a |
|
352 * FS message part object. Ownership of the returned object |
|
353 * is moved. |
|
354 */ |
|
355 CFSMailMessagePart* ConvertAttachmentEntry2MessagePartL( |
|
356 const TMsvEmailEntry& aEntry, |
|
357 const TFSMailMsgId& aMailBoxId, |
|
358 const TFSMailMsgId& aMessageId ); |
|
359 |
|
360 /** |
|
361 * Converts a folder entry representing a multipart structure as |
|
362 * a FS message part object. Ownership of the returned object |
|
363 * is moved. |
|
364 */ |
|
365 CFSMailMessagePart* ConvertFolderEntry2MessagePartL( |
|
366 const TMsvEmailEntry& aEntry, |
|
367 const TFSMailMsgId& aMailBoxId, |
|
368 const TFSMailMsgId& aMessageId ); |
|
369 |
|
370 /** |
|
371 * Returns False if TMsvEntry is not changed |
|
372 */ |
|
373 TBool ChangeTEntryFlagsL( |
|
374 TMsvEmailEntry& aEmlEntry, |
|
375 const CFSMailMessage& aMessage ); |
|
376 |
|
377 /** |
|
378 * Changes CMsvEntry Attachment flag to correspond real situation |
|
379 */ |
|
380 void SetAttachmentFlagL( const TMsvEmailEntry& aEntry, |
|
381 TBool aHasAttachment ); |
|
382 |
|
383 private: |
|
384 |
|
385 CMsvSession& iSession; |
|
386 |
|
387 CIpsPlgSosBasePlugin& iPlugin; |
|
388 |
|
389 }; |
|
390 |
|
391 #include "ipsplgmsgmapper.inl" |
|
392 |
|
393 #endif /* IPSPLGMSGMAPPER_H */ |
|
394 |
|
395 // End of File |