|
1 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // cimmessagepart.h |
|
15 // |
|
16 |
|
17 /** |
|
18 * @file |
|
19 * @ |
|
20 * @released |
|
21 */ |
|
22 |
|
23 #ifndef __CIMMESSAGEPART_H__ |
|
24 #define __CIMMESSAGEPART_H__ |
|
25 |
|
26 class CImEmailMessage; |
|
27 class CImMimeHeader; |
|
28 class CMsvMimeHeaders; |
|
29 class CImHtmlConverter; |
|
30 |
|
31 class TImCreateMessageOptions |
|
32 /** |
|
33 @internalComponent |
|
34 @released |
|
35 */ |
|
36 { |
|
37 public: |
|
38 TMsvPartList iMsvPartList; |
|
39 TMsvEmailTypeList iMsvEmailTypeList; |
|
40 TUid iMessageType; |
|
41 }; |
|
42 |
|
43 |
|
44 class CImRemoveMessagePart : public CMsvOperation |
|
45 /** |
|
46 @internalComponent |
|
47 @released |
|
48 */ |
|
49 { |
|
50 public: |
|
51 static CImRemoveMessagePart* DeleteAttachmentL(TRequestStatus &aStatus, CMsvEntry& aMsvEntry, TMsvId aMessageId, TMsvId aAttachmentId); |
|
52 static CImRemoveMessagePart* DeleteAttachedMessageL(TRequestStatus &aStatus, CMsvEntry& aMsvEntry, TMsvId aMessageId, TMsvId aAttachedMessageId); |
|
53 ~CImRemoveMessagePart(); |
|
54 const TDesC8& FinalProgress(); |
|
55 void DoCancel(); |
|
56 void RunL(); |
|
57 const TDesC8& ProgressL(); // returns NULL until operation completed - then returns MessageId |
|
58 TMsvId RemovedAttachmentId(); |
|
59 private: |
|
60 CImRemoveMessagePart(TRequestStatus& aStatus, CMsvEntry& aMsvEntry, TMsvId aMessageId); |
|
61 void ConstructL(TMsvId aAttachmentId); |
|
62 void ErrorRecovery(TInt aError); |
|
63 void SelectNextStateL(); // selects next state to go to |
|
64 void ChangeStateL(); // initiates the next state operation |
|
65 void SelectAndChangeToNextStateL(); |
|
66 void RequestComplete(TInt aError); |
|
67 void Recover(); // leave message in a 'good' state |
|
68 |
|
69 void CheckAttachmentParentTypeL(); |
|
70 void MoveOtherEntryToParentOfFolderL(); |
|
71 void DeleteAttachmentEntryL(); |
|
72 void DeleteFolderEntryL(); |
|
73 void CompleteRemoveMessagePartL(); |
|
74 private: |
|
75 enum TImRemoveMessagePartState |
|
76 { |
|
77 ECheckAttachmentParentType, |
|
78 EMoveOtherEntryToParentOfFolder, |
|
79 EDeleteAttachmentEntry, |
|
80 EDeleteFolderEntry, |
|
81 ECompleteRemoveMessagePart, |
|
82 EFinished |
|
83 }; |
|
84 CMsvEntry& iMsvEntry; |
|
85 CMsvOperation* iMsvOperation; |
|
86 |
|
87 CMsvEntrySelection* iMessageEntrySelection; |
|
88 CImEmailMessage* iEmailMessage; |
|
89 |
|
90 TInt iState; |
|
91 TPckgBuf<TMsvId> iDataMember; |
|
92 TMsvId iMessageId; |
|
93 TMsvId iFolderToDeleteId; |
|
94 TInt iAttachmentSize; |
|
95 TMsvId iAttachmentId; |
|
96 TMsvId iEntryToMoveId; |
|
97 }; |
|
98 |
|
99 class CImStoreMessagePart : public CMsvOperation |
|
100 /** |
|
101 @internalComponent |
|
102 @released |
|
103 */ |
|
104 { |
|
105 public: |
|
106 static CImStoreMessagePart* AddAttachmentL(TMsvId aMessageId, const TDesC& aFilePath, CMsvEntry& aMsvEntry,CMsvAttachment* aAttachmentInfo,TRequestStatus& aStatus ); |
|
107 static CImStoreMessagePart* AddEntryAsAttachmentL(TMsvId aMessageId,TMsvId aAttachmentMessageId, CMsvEntry& aMsvEntry, CMsvAttachment* aAttachmentInfo,TRequestStatus& aStatus); |
|
108 static CImStoreMessagePart* AddAttachmentL(TMsvId aMessageId,RFile& aFile, CMsvEntry& aMsvEntry, CMsvAttachment* aAttachmentInfo, TRequestStatus& aStatus); |
|
109 static CImStoreMessagePart* AddLinkedAttachmentL(TMsvId aMessageId,const TDesC& aFilePath, CMsvEntry& aMsvEntry,CMsvAttachment* aAttachmentInfo,TRequestStatus& aStatus ); |
|
110 static CImStoreMessagePart* CreateAttachmentL(TMsvId aMessageId,const TDesC& aFileName, RFile& aAttachmentFile,CMsvEntry& aMsvEntry, CMsvAttachment* aAttachmentInfo, TRequestStatus& aStatus); |
|
111 static CImStoreMessagePart* AddRelatedPartL(TRequestStatus &aStatus, CMsvEntry& aMsvEntry, TMsvId aMessageId, const TDesC& aAttachmentFullName, TMsvId aRelatedPartId, const TDesC8& aContentId); |
|
112 static CImStoreMessagePart* StoreBodyTextL(TRequestStatus& aStatus, CMsvEntry& aMsvEntry, TMsvId aMessageId, CRichText& aRichText, TBool aUsePlainTextStorage = EFalse); |
|
113 static CImStoreMessagePart* StoreBodyTextWithMimeHeaderL(TRequestStatus& aStatus, CMsvEntry& aMsvEntry, TMsvId aMessageId, CRichText& aRichText, const CImMimeHeader& aMimeHeader, TBool aUsePlainTextStorage = EFalse); |
|
114 static CImStoreMessagePart* StorePlainBodyTextL(TRequestStatus& aStatus, CMsvEntry& aMsvEntry, TMsvId aMessageId, TBool aUsePlainTextStorage = ETrue); |
|
115 static CImStoreMessagePart* StorePlainBodyTextL(TRequestStatus& aStatus, CMsvEntry& aMsvEntry, TMsvId aMessageId, CImMimeHeader& aMimeHeader, TBool aUsePlainTextStorage = ETrue); |
|
116 ~CImStoreMessagePart(); |
|
117 const TDesC8& FinalProgress(); |
|
118 void DoCancel(); |
|
119 void RunL(); |
|
120 const TDesC8& ProgressL(); |
|
121 private: |
|
122 enum TImMessagePart |
|
123 { |
|
124 EMessagePartAttachment, |
|
125 EMessagePartBody, |
|
126 EMessagePartMessageAttachment |
|
127 }; |
|
128 void ConstructL(RFile& aFile); |
|
129 void ConstructL(RFile& aFile,const TDesC& aAttachmentName); |
|
130 void ConstructL(const TDesC& aAttachmentFullName, const TDesC8& aContentId); |
|
131 void ConstructAttachmentInfo(CMsvAttachment* aAttachmentInfo,TInt aAttachmentCreationState); |
|
132 CImStoreMessagePart(TRequestStatus& aStatus, CMsvEntry& aMsvEntry, TMsvId aMessageId, TBool aUsePlainTextStorage = EFalse); |
|
133 |
|
134 void ConstructL(); |
|
135 void ConstructL(const TDesC& aAttachmentFullName); |
|
136 void ConstructL(TMsvId aAttachmentMessageId); |
|
137 void ConstructL(const TDesC& aAttachmentFullName, TMsvId aRelatedPartId, const TDesC8& aContentId); |
|
138 void ConstructL(CRichText& aRichText); |
|
139 void ConstructL(CRichText& aRichText, const CImMimeHeader& aMimeHeader); |
|
140 void ConstructL(CImMimeHeader& aMimeHeader); |
|
141 void ConstructL(TImMessagePart aMessagePart); |
|
142 void ErrorRecovery(TInt error); |
|
143 void SelectNextStateL(); // selects next state to go to |
|
144 void ChangeStateL(); // initiates the next state operation |
|
145 void SelectAndChangeToNextStateL(); |
|
146 void RequestComplete(TInt aError); |
|
147 void Recover(); |
|
148 |
|
149 TBool HTMLMessage() const; |
|
150 void SetHTMLMessage(TBool aFlag); |
|
151 TBool MultipartMixedExists() const; |
|
152 void SetMultipartMixedExists(TBool aFlag); |
|
153 TBool MultipartMixedCreated() const; |
|
154 void SetMultipartMixedCreated(TBool aFlag); |
|
155 TBool MultipartAlternativeExists() const; |
|
156 void SetMultipartAlternativeExists(TBool aFlag); |
|
157 TBool MultipartAlternativeCreated() const; |
|
158 void SetMultipartAlternativeCreated(TBool aFlag); |
|
159 TBool MultipartRelatedExists() const; |
|
160 void SetMultipartRelatedExists(TBool aFlag); |
|
161 TBool MultipartRelatedCreated() const; |
|
162 void SetMultipartRelatedCreated(TBool aFlag); |
|
163 TBool TextPartExists() const; |
|
164 void SetTextPartExists(TBool aFlag); |
|
165 TBool TextPartCreated() const; |
|
166 void SetTextPartCreated(TBool aFlag); |
|
167 TBool AttachmentEntryCreated() const; |
|
168 void SetAttachmentEntryCreated(TBool aFlag); |
|
169 |
|
170 void FindMultipartRelatedFolderL(); |
|
171 void CheckForSubfolderL(); |
|
172 void CreateAttachmentEntryL(); |
|
173 void CopyOrigMessageToMessageL(); |
|
174 void CreateMultipartMixedFolderEntryL(); |
|
175 void CreateMultipartAlternativeFolderEntryL(); |
|
176 void CreateMultipartRelatedFolderEntryL(); |
|
177 void MoveOriginalMessageEntryChildrenToNewFolderL(); |
|
178 void CreateTextEntryL(); |
|
179 void StoreRichTextL(); |
|
180 void CompleteStoreMessagePartL(); |
|
181 void CreateHTMLEntryL(); |
|
182 void PrepareToStoreHTMLEntryTextL(); |
|
183 void StoreHTMLEntryTextL(); |
|
184 void RemoveHTMLEntryL(); |
|
185 void MoveTextEntryToAltFolderL(); |
|
186 TPtrC GetDefaultAttachmentName(); |
|
187 void OpenAndReadResourceFileL(); |
|
188 void StoreMimeHeaderL(); |
|
189 TBool CreateAttachmentMimeHeaderL(CImMimeHeader& aMimeHeader, const TDesC& aDetails); |
|
190 void CreateFolderMimeHeaderL(CImMimeHeader& aMimeHeader); |
|
191 void CreateMessageMimeHeaderL(CImMimeHeader& aMimeHeader); |
|
192 void AddAttachmentL(); |
|
193 void AddAttachmentUsingFileHandleL(); |
|
194 void AddLinkedAttachmentL(); |
|
195 void AddEntryAsAttachmentL(); |
|
196 void CreateAttachmentL(); |
|
197 void DoAttachmentStoreL(); |
|
198 TInt CheckMimeInAttachmentInfoL(CMsvMimeHeaders& aMsvMimeHeaders); |
|
199 CImMimeHeader* ProcessAttachmentMimeHeadersL(); |
|
200 void SetEntryDetailsL(TMsvEntry& aEntry); |
|
201 void StorePlainTextL(); |
|
202 private: |
|
203 enum TImStoreMessagePartState |
|
204 { |
|
205 EFindMultipartRelatedFolder, |
|
206 ECheckForSubfolder, |
|
207 ECreateAttachmentEntry, |
|
208 EStoreAttachment, |
|
209 ECopyOrigMessageToMessage, |
|
210 ECreateMultipartMixedFolderEntry, |
|
211 ECreateMultipartRelatedFolderEntry, |
|
212 ECreateMultipartAlternativeFolderEntry, |
|
213 EMoveOriginalMessageEntryChildrenToNewFolder, |
|
214 ECreateTextEntry, |
|
215 EStoreRichText, |
|
216 ERemoveHTMLEntry, |
|
217 EMoveTextToAlternativeFolder, |
|
218 ECreateHTMLEntry, |
|
219 EPrepareToStoreHTMLEntryText, |
|
220 EStoreHTMLEntryText, |
|
221 ECompleteStoreMessage, |
|
222 EFinished |
|
223 ,EStoreHTMLTextInEntry, |
|
224 EAddEntryAttachment |
|
225 }; |
|
226 |
|
227 enum TImStoreMessagePartFlags |
|
228 { |
|
229 KStoreMessagePartClearFlag = 0x00000000, |
|
230 KStoreMessagePartHTMLMessage = 0x00000001, |
|
231 KStoreMessagePartMultipartMixedExists = 0x00000002, |
|
232 KStoreMessagePartMultipartMixedCreated = 0x00000004, |
|
233 KStoreMessagePartMultipartAlternativeExists = 0x00000008, |
|
234 KStoreMessagePartMultipartAlternativeCreated = 0x00000010, |
|
235 KStoreMessagePartTextPartExists = 0x00000020, |
|
236 KStoreMessagePartTextPartCreated = 0x00000040, |
|
237 KStoreMessagePartAttachmentEntryCreated = 0x00000080, |
|
238 KStoreMessagePartOrigMessageEntryChildrenCopied = 0x00000100, |
|
239 KStoreMessagePartOrigMessageEntryChildrenDeleted = 0x00000200, |
|
240 KStoreMessagePartMultipartRelatedExists = 0x00000400, |
|
241 KStoreMessagePartMultipartRelatedCreated = 0x00000800 |
|
242 }; |
|
243 CMsvEntry& iMsvEntry; |
|
244 CMsvOperation* iMsvOperation; |
|
245 |
|
246 CRichText* iRichTextToStore; // I don't own this object! |
|
247 CImMimeHeader* iMimeHeaderOfBodyText; |
|
248 CRichText* iRichText; |
|
249 CFileMan* iFileMan; |
|
250 CMsvEntrySelection* iMessageEntrySelection; |
|
251 |
|
252 TInt iState; |
|
253 TPckgBuf<TMsvId> iDataMember; |
|
254 TMsvId iMessageId; |
|
255 TImMessagePart iMessagePart; |
|
256 TMsvId iMixFolderId; |
|
257 TMsvId iAltFolderId; |
|
258 TMsvId iRelFolderId; |
|
259 HBufC* iAttachmentFullName; |
|
260 TInt iAttachmentSize; |
|
261 TMsvId iAttachmentId; |
|
262 TMsvId iTextId; |
|
263 TMsvId iHtmlId; |
|
264 TMsvId iRelatedPartId; |
|
265 TMsvId iAttachmentMessageId; |
|
266 TUint32 iFlags; |
|
267 HBufC8* iContentId; |
|
268 CImEmailMessage* iEmailMessage; |
|
269 |
|
270 // Used when converting rich text to html |
|
271 CParaFormatLayer* iParaLayer; |
|
272 CCharFormatLayer* iCharLayer; |
|
273 CImHtmlConverter* iHtmlConverter; |
|
274 TBool iFinishedConvertingHTML; |
|
275 CMsvAttachment* iAttachmentInfo; |
|
276 CMsvStore* iStore; |
|
277 TInt iAttachmentCreateState; |
|
278 TBool iIsAddByFileHandle; |
|
279 RFile* iFileHandle; |
|
280 RFile iFile; |
|
281 // Indicates whether to store message body as CRichText or plaintext. |
|
282 TBool iUsePlainTextStorage; |
|
283 // Size of the plain text body. |
|
284 TInt iSizeOfBody; |
|
285 // Size of the Fwd'ed/ReplyTo plaintext body part. |
|
286 TInt iSizeFwdReplyBody; |
|
287 // The error value returned when CRichText is populated with message body text. |
|
288 TInt iRestoreErr; |
|
289 enum TImAttachmentCreation |
|
290 { |
|
291 EAddAttachment, |
|
292 EAddAttachmentUsingFileHandle, |
|
293 EAddLinkedAttachment, |
|
294 EAddEntryAsAttachment, |
|
295 ECreateAttachment |
|
296 }; |
|
297 }; |
|
298 |
|
299 class CImHtmlConverter : public CBase |
|
300 /** |
|
301 @internalComponent |
|
302 @released |
|
303 */ |
|
304 { |
|
305 public: |
|
306 static CImHtmlConverter* NewL(CMsvEntry& aMsvEntry, CParaFormatLayer& aParaLayer, CCharFormatLayer& aCharLayer); |
|
307 ~CImHtmlConverter(); |
|
308 void PrepareToStoreHTMLEntryTextL(TMsvId& aHtmlId, const TMsvId aTextId); |
|
309 void ResetStoreL(); |
|
310 void ResetStoreWithoutCommit(); |
|
311 TBool StoreHTMLEntryTextAL(TRequestStatus& aStatus); |
|
312 CMsvOperation* ChangeHTMLTextInEnrtyL(TRequestStatus& aStatus); |
|
313 |
|
314 void ReadDefaultAttachmentNameL( RResourceFile& resourceFile); |
|
315 TInt Size() const; |
|
316 |
|
317 private: |
|
318 CImHtmlConverter(CMsvEntry& aMsvEntry, CParaFormatLayer& aParaLayer, CCharFormatLayer& aCharLayer); |
|
319 TFileName HtmlFilename(CMsvEntry& aEntry, TPtrC aFileName); |
|
320 TPtrC GetDefaultAttachmentName(); |
|
321 void ConstructL(); |
|
322 |
|
323 private: |
|
324 CMsvEntry& iMsvEntry; |
|
325 CParaFormatLayer& iParaLayer; |
|
326 CCharFormatLayer& iCharLayer; |
|
327 |
|
328 CConverterBase* iToHTMLConverter; |
|
329 CCnaConverterList* iConverterList; |
|
330 |
|
331 TMsvId iTextId; |
|
332 TMsvId iHtmlId; |
|
333 TInt iSize; |
|
334 HBufC* iDefaultAttachmentName; |
|
335 CRichText* iRichText; |
|
336 RDesReadStream iSourceStream; |
|
337 RFileWriteStream iTargetStream; |
|
338 CMsvStore* iStore; |
|
339 RFile iFile; |
|
340 }; |
|
341 |
|
342 class CImStoreResolver : public CBase, public MRichTextStoreResolver |
|
343 /** |
|
344 @internalComponent |
|
345 @released |
|
346 */ |
|
347 { |
|
348 public: |
|
349 CImStoreResolver(CStreamStore* aStore); |
|
350 ~CImStoreResolver(); |
|
351 // |
|
352 private: |
|
353 const CStreamStore& StreamStoreL(TInt aPos)const; |
|
354 // |
|
355 private: |
|
356 CStreamStore* iStore; |
|
357 }; |
|
358 |
|
359 #endif //__CIMMESSAGEPART_H__ |