|
1 /* |
|
2 * Copyright (c) 2005 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: |
|
15 * CUniDataModel |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 #ifndef __UNIDATAMODEL_H |
|
23 #define __UNIDATAMODEL_H |
|
24 |
|
25 // INCLUDES |
|
26 #include <gmxmlparser.h> |
|
27 #include <gmxmldocument.h> |
|
28 #include <msvapi.h> // CMsvEntry |
|
29 #include <unidatautils.h> |
|
30 #include <unismilmodel.h> |
|
31 #include <unismillist.h> |
|
32 #include <uniobject.h> |
|
33 |
|
34 #include <mmsvattachmentmanager.h> |
|
35 #include <mmsvattachmentmanagersync.h> |
|
36 #include <MsgMediaInfo.h> |
|
37 |
|
38 // CONSTANTS |
|
39 |
|
40 // MACROS |
|
41 |
|
42 // DATA TYPES |
|
43 |
|
44 // FUNCTION PROTOTYPES |
|
45 |
|
46 // FORWARD DECLARATIONS |
|
47 |
|
48 class CBaseMtm; |
|
49 class CUniDataUtils; |
|
50 class CUniObjectsModel; |
|
51 class CUniObjectList; |
|
52 class CUniObjectsInfo; |
|
53 class CMsgMediaResolver; |
|
54 class CMmsConformance; |
|
55 class CMsvMimeHeaders; |
|
56 class CMsvAttachment; |
|
57 |
|
58 // CLASS DECLARATION |
|
59 |
|
60 /** |
|
61 * MUniDataModelObserver - Callback API for model operations. |
|
62 * |
|
63 * @since 3.1 |
|
64 */ |
|
65 class MUniDataModelObserver |
|
66 { |
|
67 public: |
|
68 virtual void RestoreReady( TInt aParseResult, TInt aError ) = 0; |
|
69 }; |
|
70 |
|
71 /** |
|
72 * CUniDataModel - A container class that owns instances of CMsgMediaResolver, |
|
73 * CMmsConformance, CUniDataUtils, CUniObjectList, CUniSmilList and CUniSmilModel. |
|
74 * It also handles the initialization of the lists & the SMIL model. |
|
75 * |
|
76 * @lib UniDataModel.lib |
|
77 * @since 3.1 |
|
78 */ |
|
79 class CUniDataModel : public CBase, |
|
80 public MMDXMLParserObserver, |
|
81 public MMediaInfoObserver |
|
82 { |
|
83 public: // Constructors and destructor |
|
84 |
|
85 static IMPORT_C CUniDataModel* NewL( RFs& aFs, CBaseMtm& aMtm ); |
|
86 |
|
87 /** |
|
88 * Destructor. |
|
89 */ |
|
90 IMPORT_C ~CUniDataModel(); |
|
91 |
|
92 public: // New functions |
|
93 |
|
94 /** |
|
95 * RestoreL |
|
96 * Loads attachments from message store and initializes |
|
97 * the model. |
|
98 * @param aObserver IN Callback observer |
|
99 * @param aRemoveCorrupted IN If ETrue removes corrupted attachments |
|
100 * If EFalse leaves if corrupted attachments detected |
|
101 * @param aAllowSmil IN If ETrue puts SMIL files to "SmilList" |
|
102 * If EFalse puts SMIL files to "AttachmentList" |
|
103 */ |
|
104 IMPORT_C void RestoreL( |
|
105 MUniDataModelObserver& aObserver, |
|
106 TBool aRemoveCorrupted = ETrue, |
|
107 TBool aAllowSmil = ETrue ); |
|
108 |
|
109 /** |
|
110 * AddObjectL |
|
111 * Adds an object into msg store and smil slide |
|
112 * |
|
113 * @since 3.1 |
|
114 * @param aObserver IN Object save observer |
|
115 * @param aMedia IN media info - ownership transferred to MsgObject |
|
116 * @param aSaveType IN either "file" or "linked file" |
|
117 * @return Pointer to the added object |
|
118 * Ownership NOT transferred. |
|
119 */ |
|
120 IMPORT_C CUniObject* AddAttachmentL( |
|
121 MUniObjectSaveObserver& aObserver, |
|
122 CMsgMediaInfo* aMedia, |
|
123 CMsvAttachment::TMsvAttachmentType aSaveType = CMsvAttachment::EMsvLinkedFile ); |
|
124 |
|
125 /** |
|
126 * AddStoredAttachmentL |
|
127 * Adds an object that is already in msg store to smil slide |
|
128 * |
|
129 * @since 3.1 |
|
130 * @param aAttachmentId IN file to be added |
|
131 * @param aMedia IN media info - ownership transferred to MsgObject |
|
132 * @return Pointer to the added object |
|
133 * Ownership NOT transferred. |
|
134 */ |
|
135 IMPORT_C CUniObject* AddStoredAttachmentL( |
|
136 TMsvAttachmentId aAttachmentId, |
|
137 CMsgMediaInfo* aMedia ); |
|
138 |
|
139 /** |
|
140 * FinalizeMediaParse |
|
141 * This function synchronizes asynchronous media info parsing if it is still ongoing |
|
142 * To be called from editor/viewer when the message is to be send/saved/forwarded |
|
143 * @since 3.2 |
|
144 */ |
|
145 IMPORT_C void FinalizeMediaParse(); |
|
146 |
|
147 public: |
|
148 |
|
149 /** |
|
150 * MediaInfoParsed |
|
151 * Callback for MediaInfo active object |
|
152 * @since 3.2 |
|
153 */ |
|
154 void MediaInfoParsed(); |
|
155 |
|
156 /** |
|
157 * ParseNextObject |
|
158 * Parses the next object in a to-be-parsed list |
|
159 * Actual parsing is dedicated to MediaInfo's asynchronous method |
|
160 * @since 3.2 |
|
161 */ |
|
162 void ParseNextObject(); |
|
163 |
|
164 /** |
|
165 * ParseFileCompleteL |
|
166 * Call back function used to inform client of Parser when RunL function completes |
|
167 */ |
|
168 void ParseFileCompleteL(); |
|
169 |
|
170 public: // inlines |
|
171 |
|
172 /** |
|
173 * Returns number of corrupted attachments encountered at load time |
|
174 * i.e. entry is stil there but binary file is missing |
|
175 * Includes corrupted link, presentations etc. |
|
176 * |
|
177 * @return attachment count |
|
178 */ |
|
179 inline TInt CorruptedCount() const; |
|
180 |
|
181 /** |
|
182 * Returns attachment count before any filtering for "presentation objects" |
|
183 * or corrupted attachments. SMIL attachments are not included in the count. |
|
184 * |
|
185 * @return attachment count |
|
186 */ |
|
187 inline TInt OriginalAttachmentCount() const; |
|
188 |
|
189 /** |
|
190 * Get reference to file session |
|
191 * |
|
192 * @return reference to RFs |
|
193 */ |
|
194 inline RFs& FsSession() const; |
|
195 |
|
196 /** |
|
197 * Get reference to base mtm |
|
198 * |
|
199 * @return reference to CBaseMtm |
|
200 */ |
|
201 inline CBaseMtm& Mtm() const; |
|
202 |
|
203 /** |
|
204 * Returns object list owned by the model. Object list includes all |
|
205 * attachments that are referenced from the SMIL part (or if there is no |
|
206 * SMIL part attachments that are of supported media type). |
|
207 * |
|
208 * @return reference to the object list. |
|
209 */ |
|
210 inline CUniObjectList& ObjectList() const; |
|
211 |
|
212 /** |
|
213 * Returns attachment list owned by the model. Attachment list includes all |
|
214 * attachments that are NOT referenced from the SMIL part. |
|
215 * |
|
216 * @return reference to the attachment list. |
|
217 */ |
|
218 inline CUniObjectList& AttachmentList() const; |
|
219 |
|
220 /** |
|
221 * Returns SMIL list owned by the model. SMIL list includes all |
|
222 * attachments that are of type "application/smil". |
|
223 * |
|
224 * @return reference to the SMIL attachment list. |
|
225 */ |
|
226 inline CUniSmilList& SmilList() const; |
|
227 |
|
228 /** |
|
229 * Returns data utils object used by the model. |
|
230 * |
|
231 * @return reference to the data utils object. |
|
232 */ |
|
233 inline CUniDataUtils& DataUtils() const; |
|
234 |
|
235 /** |
|
236 * Returns SMIL type of the message. |
|
237 * @return Possible return values are: |
|
238 * -ENoSmil |
|
239 * -EMmsSmil |
|
240 * -EOtherSmil |
|
241 * -EMultipleSmil |
|
242 * -ETemplateSmil |
|
243 */ |
|
244 inline TUniSmilType SmilType(); |
|
245 |
|
246 /** |
|
247 * Returns SMIL type of the message. |
|
248 * @param aSmilType: |
|
249 * -ENoSmil |
|
250 * -EMmsSmil |
|
251 * -EOtherSmil |
|
252 * -EMultipleSmil |
|
253 * -ETemplateSmil |
|
254 */ |
|
255 inline void SetSmilType( TUniSmilType aSmilType ); |
|
256 |
|
257 /** |
|
258 * Get reference to SmilModel |
|
259 * |
|
260 * @return reference to SmilModel |
|
261 */ |
|
262 inline CUniSmilModel& SmilModel() const; |
|
263 |
|
264 /** |
|
265 * Get reference to MediaResolver |
|
266 * |
|
267 * @return reference to MediaResolver |
|
268 */ |
|
269 inline CMsgMediaResolver& MediaResolver() const; |
|
270 |
|
271 /** |
|
272 * Get reference to MmsConformance |
|
273 * |
|
274 * @return reference to MmsConformance |
|
275 */ |
|
276 inline CMmsConformance& MmsConformance() const; |
|
277 |
|
278 /** |
|
279 * Return SMIL DOM |
|
280 * |
|
281 * @return Pointer to SMIL DOM |
|
282 */ |
|
283 inline CMDXMLDocument* Dom(); |
|
284 |
|
285 /** |
|
286 * Set SMIL DOM |
|
287 * |
|
288 * @param Pointer to SMIL DOM, takes ownership |
|
289 */ |
|
290 inline void SetDom( CMDXMLDocument* aDom ); |
|
291 |
|
292 /* |
|
293 * Accessor |
|
294 * |
|
295 * @return parse result from CUniSmilModel::ParseL() |
|
296 */ |
|
297 inline TInt ParseResult() const; |
|
298 |
|
299 private: // New functions |
|
300 |
|
301 /** |
|
302 * CUniDataModel |
|
303 * Constructor. |
|
304 */ |
|
305 CUniDataModel( RFs& aFs, CBaseMtm& aMtm ); |
|
306 |
|
307 /** |
|
308 * ConstructL |
|
309 * 2nd phase constructor. |
|
310 */ |
|
311 void ConstructL(); |
|
312 |
|
313 private: // New Functions |
|
314 |
|
315 |
|
316 /** |
|
317 * DoParseFileCompleteL |
|
318 */ |
|
319 void DoParseFileCompleteL(); |
|
320 |
|
321 /** |
|
322 * FinalizeRestoreL |
|
323 */ |
|
324 void FinalizeRestoreL( TInt aError ); |
|
325 |
|
326 /** |
|
327 * Handles corrupted attachments. |
|
328 * |
|
329 * @param aRemoveCorrupted IN |
|
330 * - If ETrue tries to recover by removing corrupted attachments. |
|
331 * |
|
332 * Note: This means that SMIL parsing will fail with ESmil_Missing_Objects. |
|
333 * and object order is not maintained. But better to do it this |
|
334 * way so that message can be opened. |
|
335 * |
|
336 * - If EFalse leaves with KErrCorrupt if corrupted attachments detected. |
|
337 * Model not made caller should exit! |
|
338 */ |
|
339 void FindAndHandleCorruptL( TBool aRemoveCorrupted ); |
|
340 |
|
341 /** |
|
342 * Finds corrupted attachments from context message. |
|
343 */ |
|
344 CMsvEntrySelection* FindCorruptLC(); |
|
345 |
|
346 /** |
|
347 * FindAttachmentsL |
|
348 * Browses through SMIL and separates objects that are |
|
349 * referenced from attachments. |
|
350 */ |
|
351 void FindAttachmentsL(); |
|
352 |
|
353 /** |
|
354 * Creates an object from msg store attachment |
|
355 * @param aMimeType - mime type of new object. |
|
356 * @param aAttachmentId - ID to be used for searching |
|
357 * attachment from store |
|
358 */ |
|
359 CUniObject* CreateObjectFromAttachmentLC( |
|
360 const TPtrC8& aMimeType, |
|
361 RFile& aFile, |
|
362 MMsvAttachmentManager& aManager, |
|
363 CMsvAttachment& aAttachment ); |
|
364 |
|
365 /** |
|
366 * Browses through (non-MMS) SMIL and searches reference counts for objects and separates |
|
367 * objects and attachments in different lists. |
|
368 */ |
|
369 void FindDomObjectRefCountsL(); |
|
370 |
|
371 protected: // data |
|
372 |
|
373 RFs& iFs; |
|
374 CBaseMtm& iMtm; |
|
375 |
|
376 CMsgMediaResolver* iMediaResolver; |
|
377 CMmsConformance* iMmsConformance; |
|
378 CUniDataUtils* iDataUtils; |
|
379 CUniObjectList* iObjectList; |
|
380 CUniObjectList* iAttachmentList; |
|
381 CUniSmilList* iSmilList; |
|
382 |
|
383 CUniSmilModel* iSmilModel; |
|
384 TUniSmilType iSmilType; |
|
385 TInt iOrigAttachmentCount; |
|
386 TInt iCorruptedCount; // Number of attas detected to be corrupted when loading |
|
387 |
|
388 CMDXMLParser* iParser; |
|
389 CMDXMLDocument* iDom; |
|
390 |
|
391 MUniDataModelObserver* iObserver; |
|
392 TInt iParseResult; |
|
393 CActiveSchedulerWait iObjWait; |
|
394 CUniObject* iObjectToParse; |
|
395 }; |
|
396 |
|
397 #include <unidatamodel.inl> |
|
398 |
|
399 #endif // __UNIDATAMODEL_H |
|
400 |
|
401 // End of file |