|
1 /* |
|
2 * Copyright (c) 2002-2004 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: Message container class for mail editor / viewer |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef CMAILMESSAGE_H |
|
21 #define CMAILMESSAGE_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <msvstd.h> |
|
25 #include <cmsvattachment.h> |
|
26 |
|
27 // DATA TYPES |
|
28 |
|
29 // FORWARD DECLARATIONS |
|
30 class CMsvEntry; |
|
31 class CImHeader; |
|
32 class CImEmailMessage; |
|
33 class CRichText; |
|
34 class CParaFormatLayer; |
|
35 class CCharFormatLayer; |
|
36 class MMessageLoadObserver; |
|
37 class MMsvAttachmentManager; |
|
38 class TMsvEmailEntry; |
|
39 class CMsvSession; |
|
40 class CMsvAttachment; |
|
41 class RFile; |
|
42 class CMuiuOperationWait; |
|
43 class CImMimeHeader; |
|
44 |
|
45 // CLASS DECLARATION |
|
46 /** |
|
47 * Internal helper class for linked html files. |
|
48 */ |
|
49 NONSHARABLE_CLASS(CLinkedHtmlItem): public CBase |
|
50 { |
|
51 public: |
|
52 inline CLinkedHtmlItem(const TDesC& aURI, TMsvAttachmentId aLinkedfileId ) |
|
53 { |
|
54 delete iUriAddress; |
|
55 iUriAddress = NULL; |
|
56 iUriAddress = aURI.AllocL(); |
|
57 iLinkedItemId = aLinkedfileId; |
|
58 }; |
|
59 inline ~CLinkedHtmlItem() |
|
60 { |
|
61 delete iUriAddress; |
|
62 }; |
|
63 public: // Data |
|
64 HBufC* iUriAddress; |
|
65 TMsvAttachmentId iLinkedItemId; |
|
66 }; |
|
67 |
|
68 /** |
|
69 * Mail message. |
|
70 * Mail message container |
|
71 * |
|
72 * @lib MsgMailUtils.dll |
|
73 * @since Series 60 3.0 |
|
74 */ |
|
75 NONSHARABLE_CLASS(CMailMessage) : public CActive |
|
76 { |
|
77 public: // Load state |
|
78 enum TLoadState |
|
79 { |
|
80 EHeaderReady = 0, |
|
81 EBodyTextReady, |
|
82 EAttachmentsReady, |
|
83 EAttachedMessagesReady, |
|
84 ELinkedFileReady, |
|
85 ELoadEnd |
|
86 }; |
|
87 public: // Constructors and destructor |
|
88 /** |
|
89 * Two-phased constructor. |
|
90 * @param aEntry CMsvEntry that contais mail message. |
|
91 */ |
|
92 IMPORT_C static CMailMessage* NewL(CMsvEntry& aEntry); |
|
93 |
|
94 /** |
|
95 * Destructor. |
|
96 */ |
|
97 virtual ~CMailMessage(); |
|
98 |
|
99 public: // New functions |
|
100 |
|
101 /** |
|
102 * Start Message loading. |
|
103 * @since Series 60 3.0 |
|
104 * @param aMessageObserver loading observer |
|
105 */ |
|
106 IMPORT_C void LoadMessageL( |
|
107 MMessageLoadObserver& aMessageObserver); |
|
108 |
|
109 /** |
|
110 * Start loading linked HtmlContent |
|
111 * @param aBase |
|
112 * @param aURI |
|
113 * Observer from LoadMessageL is Notified "ELinkedFileReady" |
|
114 * when file loaded. |
|
115 * *DEPRECATED* |
|
116 */ |
|
117 IMPORT_C void LoadLinkedHtmlContentL( |
|
118 const TDesC& aBase, const TDesC& aURI); |
|
119 |
|
120 /** |
|
121 * inline MessageHeader. |
|
122 * @since Series 60 3.0 |
|
123 * @return pointer to message body text. Ownership not transferred. |
|
124 */ |
|
125 CImHeader* MessageHeader(); |
|
126 |
|
127 /** |
|
128 * HtmlCharsetIdL. |
|
129 * @since Series 60 3.1 |
|
130 * @return character set id of message html part. |
|
131 */ |
|
132 IMPORT_C TUint HtmlCharsetIdL(); |
|
133 |
|
134 /** |
|
135 * CharsetIdL. |
|
136 * @since Series 60 3.0 |
|
137 * @return character set id. |
|
138 */ |
|
139 IMPORT_C TUint CharsetIdL(); |
|
140 |
|
141 /** |
|
142 * ConvertToCharsetL. |
|
143 * @since Series 60 3.0 |
|
144 * @param character set id. |
|
145 */ |
|
146 IMPORT_C void ConvertToCharsetL(TUint aCharsetId); |
|
147 |
|
148 /** |
|
149 * inline MessageBody. |
|
150 * @since Series 60 3.0 |
|
151 * @return pointer to message body text. Ownership not transferred. |
|
152 */ |
|
153 CRichText* MessageBody(); |
|
154 |
|
155 /** |
|
156 * AttachmentManager. |
|
157 * @since Series 60 3.0 |
|
158 * @return attachment manager |
|
159 */ |
|
160 IMPORT_C MMsvAttachmentManager& AttachmentManager() const; |
|
161 |
|
162 /** |
|
163 * LoadAttachments |
|
164 * @param aObserver load observer. |
|
165 * client will be notified trought aObserver when loading is done. |
|
166 */ |
|
167 IMPORT_C void LoadAttachmentsL(MMessageLoadObserver& aObserver); |
|
168 |
|
169 /** |
|
170 * LoadAttachedMessagesL |
|
171 * @param aObserver load observer. |
|
172 * client will be notified trought aObserver when loading is done. |
|
173 */ |
|
174 IMPORT_C void LoadAttachedMessagesL(MMessageLoadObserver& aObserver); |
|
175 |
|
176 /** |
|
177 * LoadHtmlContentL |
|
178 * @param aObserver load observer. |
|
179 * client will be notified trought aObserver when loading is done. |
|
180 */ |
|
181 IMPORT_C void LoadHtmlContentL(MMessageLoadObserver& aObserver); |
|
182 |
|
183 /** |
|
184 * LoadLinkedHtmlContentL. |
|
185 * @since Series 60 3.0 |
|
186 * @param aBase. Base |
|
187 * @param aURI. Content to be searched. |
|
188 * @param aObserver load observer. |
|
189 * Client must call "LoadHtmlContentL" before calling this method. |
|
190 * Result can be read by calling "LinkedHtmlContent" |
|
191 * when observer is notified. |
|
192 */ |
|
193 IMPORT_C void LoadLinkedHtmlContentL( |
|
194 const TDesC& aBase, |
|
195 const TDesC& aURI, |
|
196 MMessageLoadObserver& aObserver ); |
|
197 |
|
198 /** |
|
199 * GetFileHandleL |
|
200 * Returns file handle to attachment. |
|
201 * @param aId attachment id. |
|
202 * Caller must close the handle. |
|
203 */ |
|
204 IMPORT_C RFile GetFileHandleL( TMsvAttachmentId aId ); |
|
205 |
|
206 /** |
|
207 * Overrides the html character set |
|
208 */ |
|
209 IMPORT_C void OverrideHtmlMessageCharset( TUint aCharsetId ); |
|
210 |
|
211 /** |
|
212 * inline MessageEntry |
|
213 * @return message TMsvEmailEntry |
|
214 */ |
|
215 TMsvEmailEntry MessageEntry(); |
|
216 |
|
217 /** |
|
218 * inline MessageType |
|
219 * @return message type uid (iMtm) |
|
220 */ |
|
221 TUid MessageType(); |
|
222 |
|
223 /** |
|
224 * inline HtmlContent |
|
225 * @return File handle to HTML content. |
|
226 * Client must close the handle. |
|
227 */ |
|
228 RFile HtmlContent(); |
|
229 |
|
230 /** |
|
231 * inline LinkedHtmlContent |
|
232 * @return File handle to linked HTML content |
|
233 * Client must close the handle. |
|
234 */ |
|
235 RFile LinkedHtmlContent(); |
|
236 |
|
237 /** |
|
238 * inline Session |
|
239 * @return Messge server session. Ownership not transferred. |
|
240 */ |
|
241 CMsvSession* Session(); |
|
242 |
|
243 /** |
|
244 * inline Selection |
|
245 * @return Message selection |
|
246 */ |
|
247 const CMsvEntrySelection& Selection(); |
|
248 |
|
249 /** |
|
250 * inline LinkedHtmlId |
|
251 * @return Linked content id |
|
252 */ |
|
253 TMsvId LinkedHtmlId(); |
|
254 |
|
255 /** |
|
256 * inline HtmlFileId |
|
257 * @return Html file id |
|
258 */ |
|
259 TMsvId MhtmlPartId(); |
|
260 |
|
261 /** |
|
262 * inline SetNew |
|
263 * @param aNew ETrue if new message. |
|
264 */ |
|
265 void SetNew( TBool aNew ); |
|
266 |
|
267 /** |
|
268 * inline IsNew |
|
269 * @return ETrue if new message. |
|
270 */ |
|
271 TBool IsNew() const; |
|
272 |
|
273 public: // Functions from base classes |
|
274 |
|
275 protected: // Functions from base classes |
|
276 // From CActive |
|
277 void DoCancel(); |
|
278 void RunL(); |
|
279 TInt RunError(TInt aError); |
|
280 |
|
281 private: // Implementation |
|
282 void DoNextStateL(); |
|
283 TUint DoGetMimeCharsetIdL( CMsvEntry& aEntry ); |
|
284 TUint DetermineCharactersetIdFromMimeHeaderL( CMsvEntry& aEntry, |
|
285 const CImMimeHeader* aMime ); |
|
286 TBool NextStateL(); |
|
287 void LoadBodyTextL(); |
|
288 void LoadHTMLContentL(); |
|
289 void LoadLinkedHTMLContentL(const TDesC& aBase, const TDesC& aURI); |
|
290 void LoadAttachmentsL(); |
|
291 void LoadAttachedMessagesL(); |
|
292 void NotifyObserverL(TInt aState); |
|
293 TBool IsLinkedItemL( RFile& aHandle, TMsvAttachmentId aId ); |
|
294 void ShowErrorNoteL( TInt aError ); |
|
295 // cleanups the array of active scheduler waits |
|
296 void CleanupWaitArray(); |
|
297 private: |
|
298 /** |
|
299 * constructor. |
|
300 */ |
|
301 CMailMessage(); |
|
302 |
|
303 /** |
|
304 * By default Symbian 2nd phase constructor is private. |
|
305 */ |
|
306 void ConstructL(CMsvEntry& aEntry); |
|
307 |
|
308 private: // Data |
|
309 TBool iNewMessage; |
|
310 // message id |
|
311 TMsvId iMessageID; |
|
312 // own: copy of message entry |
|
313 CMsvEntry* iEntry; |
|
314 // Own: Mail message |
|
315 CImEmailMessage* iMessage; |
|
316 // Own: Message header |
|
317 CImHeader* iHeader; |
|
318 // Own: Message Body text |
|
319 CRichText* iBodyText; |
|
320 // Own: Para & Char layer for rich text body |
|
321 CParaFormatLayer* iGlobalParaLayer; |
|
322 CCharFormatLayer* iGlobalCharLayer; |
|
323 // Internal loading state |
|
324 TInt iState; |
|
325 // Html file handle |
|
326 RFile iHtmlFile; |
|
327 // html id |
|
328 TMsvId iMhtmlPartId; |
|
329 // linked content id |
|
330 TMsvId iLinkedfileId; |
|
331 // Linked html file |
|
332 RFile iLinkedHtmlFile; |
|
333 // messge flags |
|
334 TInt iFlags; |
|
335 // character set id |
|
336 TUint iCharacterSetId; |
|
337 // Ref: Mail viewer app ui |
|
338 MMessageLoadObserver* iMessageObserver; |
|
339 // Own: uri address |
|
340 HBufC* iURI; |
|
341 // Own: linked html items array |
|
342 RPointerArray<CLinkedHtmlItem>* iLinkedHtmlItems; |
|
343 // Own: object which converts asynchronous -> synchronous |
|
344 // must be a member to handle exiting during wait properly |
|
345 RPointerArray<CMuiuOperationWait> iWaitArray; |
|
346 CMuiuOperationWait* iAsyncWait; |
|
347 }; |
|
348 |
|
349 #include "CMailMessage.inl" |
|
350 |
|
351 #endif // CMAILMESSAGE_H |
|
352 |
|
353 // End of File |