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 * CUniObject, Storage for single attachment in presentation. |
|
16 * |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 #ifndef __UNIOBJECT_H |
|
22 #define __UNIOBJECT_H |
|
23 |
|
24 // INCLUDES |
|
25 |
|
26 #include <e32std.h> |
|
27 #include <msvstd.h> // for TMsvId |
|
28 #include <cmsvattachment.h> |
|
29 |
|
30 #include <DRMEvent.h> |
|
31 #include <DRMEventObserver.h> |
|
32 |
|
33 #include <MsgMedia.hrh> |
|
34 |
|
35 #include <UniModelConst.h> |
|
36 |
|
37 |
|
38 // CONSTANTS |
|
39 const TUid KUidAttachmentIndication = {0x10282CB0}; |
|
40 |
|
41 // MACROS |
|
42 |
|
43 // FORWARD DECLARATIONS |
|
44 class CUniMimeInfo; |
|
45 class CMsgMediaInfo; |
|
46 class CUniDrmInfo; |
|
47 class CBaseMtm; |
|
48 class CUniDataUtils; |
|
49 class CMsvStore; |
|
50 class MMsvAttachmentManager; |
|
51 class CUniObject; |
|
52 class CDRMNotifier; |
|
53 // DATA TYPES |
|
54 |
|
55 // FUNCTION PROTOTYPES |
|
56 |
|
57 // CLASS DECLARATION |
|
58 |
|
59 /** |
|
60 * MUniObjectSaveObserver - Callback API for object saving. |
|
61 * |
|
62 * @since 3.1 |
|
63 */ |
|
64 class MUniObjectSaveObserver |
|
65 { |
|
66 public: |
|
67 virtual void ObjectSaveReady( TInt aError ) = 0; |
|
68 }; |
|
69 |
|
70 enum TUniObjectEvent |
|
71 { |
|
72 EUniObjectEventDrmRightsChanged = 0 |
|
73 }; |
|
74 |
|
75 class MUniObjectObserver |
|
76 { |
|
77 public: |
|
78 virtual void HandleUniObjectEvent( CUniObject& aUniObject, |
|
79 TUniObjectEvent aUniEvent ) = 0; |
|
80 }; |
|
81 |
|
82 /** |
|
83 * CUniObject - Representation of a single attachment of a message. |
|
84 * |
|
85 * @lib UniDataModel.lib |
|
86 * @since 3.1 |
|
87 */ |
|
88 class CUniObject : public CActive, |
|
89 public MDRMEventObserver |
|
90 |
|
91 { |
|
92 |
|
93 public: // New methods |
|
94 |
|
95 /** |
|
96 * Factory method that creates this object |
|
97 * from an attachment. |
|
98 * |
|
99 * @since 3.1 |
|
100 * @param aMtm IN reference to client mtm |
|
101 * @param aMedia IN initialized media info object - takes ownership! |
|
102 * @param aManager IN reference to attachment manager |
|
103 * @param aAttachmentId IN id of the attachment from |
|
104 * which to create the object |
|
105 * @return Pointer to instance in cleanup stack |
|
106 */ |
|
107 static CUniObject* NewLC( |
|
108 RFs& aFs, |
|
109 CBaseMtm& aMtm, |
|
110 CUniDataUtils& aData, |
|
111 CMsgMediaInfo* aMedia, |
|
112 MMsvAttachmentManager& aManager, |
|
113 CMsvAttachment& aAttachment ); |
|
114 |
|
115 /** |
|
116 * Factory method that creates this object |
|
117 * from an attachment. |
|
118 * |
|
119 * @since 3.1 |
|
120 * @param aMtm IN reference to client mtm |
|
121 * @param aMedia IN initialized media info object - takes ownership! |
|
122 * @param aAttachmentId IN id of the attachment from |
|
123 * which to create the object |
|
124 * @return Pointer to instance |
|
125 */ |
|
126 static CUniObject* NewL( |
|
127 RFs& aFs, |
|
128 CBaseMtm& aMtm, |
|
129 CUniDataUtils& aData, |
|
130 CMsgMediaInfo* aMedia, |
|
131 MMsvAttachmentManager& aManager, |
|
132 CMsvAttachment& aAttachment ); |
|
133 |
|
134 /** |
|
135 * Factory method that creates this object |
|
136 * from a file. |
|
137 * |
|
138 * @since 3.1 |
|
139 * @param aData IN reference to MsgData object |
|
140 * @param aMedia IN initialized media info object - takes ownership! |
|
141 * @return Pointer to instance in cleanup stack |
|
142 */ |
|
143 static CUniObject* NewLC( |
|
144 RFs& aFs, |
|
145 CBaseMtm& aMtm, |
|
146 CUniDataUtils& aData, |
|
147 CMsgMediaInfo* aMedia ); |
|
148 |
|
149 /** |
|
150 * Factory method that creates this object |
|
151 * from a file. |
|
152 * |
|
153 * @since 3.1 |
|
154 * @param aData IN reference to MsgData object |
|
155 * @param aMedia IN initialized media info object - takes ownership! |
|
156 * @return Pointer to instance |
|
157 */ |
|
158 static CUniObject* NewL( |
|
159 RFs& aFs, |
|
160 CBaseMtm& aMtm, |
|
161 CUniDataUtils& aData, |
|
162 CMsgMediaInfo* aMedia ); |
|
163 |
|
164 /** |
|
165 * Destructor |
|
166 * |
|
167 * @since 3.1 |
|
168 */ |
|
169 virtual ~CUniObject(); |
|
170 |
|
171 /** |
|
172 * Save |
|
173 * Save the object to message store. |
|
174 * If leave occurs, attachment is cleaned up from the |
|
175 * message store. |
|
176 * |
|
177 * @since 3.1 |
|
178 * @param aObserver IN operation observer |
|
179 * @param aSaveType IN save type |
|
180 */ |
|
181 virtual void Save( |
|
182 MUniObjectSaveObserver& aObserver, |
|
183 CMsvAttachment::TMsvAttachmentType aSaveType ); |
|
184 |
|
185 /** |
|
186 * Remove from store |
|
187 * Removes attachment from message store. |
|
188 * |
|
189 * @since 3.1 |
|
190 * @param aMtm IN reference to MMS client mtm |
|
191 */ |
|
192 virtual void RemoveFromStoreL(); |
|
193 |
|
194 /** |
|
195 * AttachmentId |
|
196 * Accessor. |
|
197 * |
|
198 * @since 3.1 |
|
199 * @return Attachment id of the object |
|
200 */ |
|
201 inline TMsvAttachmentId AttachmentId() const; |
|
202 |
|
203 /** |
|
204 * MimeInfo |
|
205 * Accessor. |
|
206 * |
|
207 * @since 3.1 |
|
208 * @return Pointer to the object's mime header class |
|
209 */ |
|
210 inline CUniMimeInfo* MimeInfo() const; |
|
211 |
|
212 /** |
|
213 * DrmInfo |
|
214 * Accessor. |
|
215 * |
|
216 * @since 3.1 |
|
217 * @return Pointer to the object's mime header class |
|
218 */ |
|
219 inline CUniDrmInfo* DrmInfo() const; |
|
220 |
|
221 /** |
|
222 * MimeType |
|
223 * Returns the mime type of the object. Use this instead |
|
224 * of MimeInfo's or MediaInfo's mime type unless you are |
|
225 * absolutely sure what you are doing. |
|
226 * |
|
227 * @since 3.1 |
|
228 * @return Mime type of the object. |
|
229 */ |
|
230 TPtrC8 MimeType() const; |
|
231 |
|
232 /** |
|
233 * MediaInfo |
|
234 * Accessor. |
|
235 * |
|
236 * @since 3.1 |
|
237 * @return Pointer to the object's media info class |
|
238 */ |
|
239 inline CMsgMediaInfo* MediaInfo() const; |
|
240 |
|
241 /** |
|
242 * MediaType |
|
243 * Returns the media type of the object. Use this instead |
|
244 * of MediaInfo's media type unless you are absolutely |
|
245 * sure what you are doing. |
|
246 * |
|
247 * @since 3.1 |
|
248 * @return Media type of the object. |
|
249 */ |
|
250 TMsgMediaType MediaType() const; |
|
251 |
|
252 /* |
|
253 * Size |
|
254 * |
|
255 * @since 3.1 |
|
256 * @param aWithoutHeaders IN if ETrue include MIME headers' sizes |
|
257 * if EFalse count only file sizes |
|
258 * @return Size of the object in bytes |
|
259 */ |
|
260 virtual TInt Size( TBool aWithoutHeaders = ETrue ); |
|
261 |
|
262 /** |
|
263 * Corrupted |
|
264 * Accessor. |
|
265 * |
|
266 * @since 3.1 |
|
267 * @return ETrue, if object corrupted, |
|
268 * EFalse otherwise |
|
269 */ |
|
270 inline TBool Corrupted() const; |
|
271 |
|
272 /** |
|
273 * SetCorrupted |
|
274 * Mutator. |
|
275 * |
|
276 * @since 3.1 |
|
277 * @param aCorrupted IN ETrue to mark object corrupted |
|
278 */ |
|
279 inline void SetCorrupted( TBool aCorrupted ); |
|
280 |
|
281 /** |
|
282 * StoreState |
|
283 * Accessor. |
|
284 * |
|
285 * @since 3.1 |
|
286 * @return Store state of the object: |
|
287 * EStoreStateAttachment if object is stored into message store and "visible" |
|
288 * EStoreStateTemporary if is not yet in message store |
|
289 * EStoreStateHidden if object is stored into message store and "hidden" |
|
290 */ |
|
291 //inline TMsgObjectStoreState StoreState() const; |
|
292 |
|
293 /** |
|
294 * SetReferenceCount |
|
295 * Mutator. |
|
296 * |
|
297 * @since 3.1 |
|
298 * @param aCount IN number of times the object is referenced in |
|
299 * the message (normally in the SMIL). |
|
300 */ |
|
301 inline void SetReferenceCount( TInt aCount ); |
|
302 |
|
303 /** |
|
304 * ReferenceCount |
|
305 * Accessor. |
|
306 * |
|
307 * @since 3.1 |
|
308 * @return Number of times the object is referenced in |
|
309 * the message (normally in the SMIL). |
|
310 */ |
|
311 inline TInt ReferenceCount() const; |
|
312 |
|
313 /** |
|
314 * SetRegion |
|
315 * Mutator. |
|
316 * |
|
317 * @since 3.1 |
|
318 * @param region object is in SMIL |
|
319 */ |
|
320 inline void SetRegion( TUniRegion aRegion ); |
|
321 |
|
322 /** |
|
323 * Region |
|
324 * Accessor. |
|
325 * |
|
326 * @since 3.1 |
|
327 * @return region object is in SMIL |
|
328 */ |
|
329 inline TUniRegion Region() const; |
|
330 |
|
331 /** |
|
332 * SetMediaTypeBySmilTag |
|
333 * Mutator. |
|
334 * |
|
335 * @since 3.1 |
|
336 * @param media type by SMIL media tag |
|
337 */ |
|
338 inline void SetMediaTypeBySmilTag( TMsgMediaType aMediaType ); |
|
339 |
|
340 /** |
|
341 * ReferenceCount |
|
342 * Accessor. |
|
343 * |
|
344 * @since 3.1 |
|
345 * @return media type by SMIL media tag |
|
346 */ |
|
347 inline TMsgMediaType MediaTypeBySmilTag() const; |
|
348 |
|
349 /** |
|
350 * SetUniqueControlHandle |
|
351 * Mutator. |
|
352 * |
|
353 * @since 3.2 |
|
354 * @param UniqueControlHandle, -1 for "resetting". |
|
355 */ |
|
356 inline void SetUniqueControlHandle( TInt aUniqueControlHandle ); |
|
357 |
|
358 /** |
|
359 * UniqueControlHandle |
|
360 * Accessor. |
|
361 * |
|
362 * @since 3.2 |
|
363 * @return UniqueControlHandle, -1 if not set. |
|
364 */ |
|
365 inline TInt UniqueControlHandle() const; |
|
366 |
|
367 /** |
|
368 * SetAttachment |
|
369 * Mutator. |
|
370 * |
|
371 * @since 3.2 |
|
372 * @param aObjectAttachment ETrue if object is attachment, otherwise EFalse |
|
373 */ |
|
374 inline void SetAttachment( TBool aObjectAttachment ); |
|
375 |
|
376 /** |
|
377 * Attachment |
|
378 * Accessor. |
|
379 * |
|
380 * @since 3.2 |
|
381 * @return ETrue if object is attachment, otherwise EFalse |
|
382 */ |
|
383 inline TBool Attachment() const; |
|
384 |
|
385 /** |
|
386 * IsSaved |
|
387 * Accessor. |
|
388 * |
|
389 * @since 3.2 |
|
390 * @return Information whether this object has been saved into file system |
|
391 * in Viewer. |
|
392 */ |
|
393 inline TBool IsSaved( ); |
|
394 |
|
395 /** |
|
396 * IsSaved |
|
397 * Mutator. |
|
398 * |
|
399 * @since 3.2 |
|
400 * @param aSaved ETrue attachment has been saved |
|
401 * EFalse attachment has not been saved |
|
402 */ |
|
403 inline void SetSaved( TBool aSaved ); |
|
404 |
|
405 /** |
|
406 * IsDrmRightsWhenLoaded. Function is applicable only, if DrmInfo exists. |
|
407 * Accessor. |
|
408 * |
|
409 * @since 5.0 |
|
410 * @return Checks whether object had DRM rights when this object was loaded |
|
411 * into screen. If last DRM rights were consumed during loading, |
|
412 * it returns ETrue. |
|
413 * |
|
414 */ |
|
415 inline TBool IsDrmRightsWhenLoaded( ) const; |
|
416 |
|
417 /** |
|
418 * ResolveDrmRightsWhenLoadedL. Saves information whether this object had DRM |
|
419 * rights when slide having the object was loaded. Uses |
|
420 * CDrmInfo::EvaluateRights() to resolve status |
|
421 * Mutator. |
|
422 * |
|
423 * @since 5.0 |
|
424 * |
|
425 */ |
|
426 void ResolveDrmRightsWhenLoadedL( ); |
|
427 |
|
428 /** |
|
429 * SetDrmRightsWhenLoadedL. Saves information whether this object had DRM |
|
430 * rights when slide having the object was loaded. |
|
431 * Mutator. |
|
432 * |
|
433 * @since 5.0 |
|
434 * @param aRights ETrue: objects had rights, which were already consumed or if not consumed, |
|
435 * have still rights left |
|
436 * EFalse: rights have not been consumed and they are not left |
|
437 * |
|
438 */ |
|
439 void SetDrmRightsWhenLoaded( TBool aRights ); |
|
440 |
|
441 /** |
|
442 * IsDrmRightsWhenLoadedObjects. Function is applicable only, if DrmInfo exists. |
|
443 * Accessor. |
|
444 * |
|
445 * @since 5.0 |
|
446 * @return Checks whether object had DRM rights when this object was loaded |
|
447 * into screen in the Objects view. If last DRM rights were consumed during loading, |
|
448 * it returns ETrue. |
|
449 * |
|
450 */ |
|
451 inline TBool IsDrmRightsWhenLoadedObjects( ) const; |
|
452 |
|
453 /** |
|
454 * SetDrmRightsWhenLoadedObjects. Saves information whether this object had DRM |
|
455 * rights when slide having the object was loaded into screen in the |
|
456 * Objects view. |
|
457 * Mutator. |
|
458 * |
|
459 * @since 5.0 |
|
460 * @param aRights ETrue: objects had rights, which were already consumed or if not consumed, |
|
461 * have still rights left |
|
462 * EFalse: rights have not been consumed and they are not left |
|
463 * |
|
464 */ |
|
465 void SetDrmRightsWhenLoadedObjects( TBool aRights ); |
|
466 |
|
467 /** |
|
468 * Sets observer of UniObject events. Several observers are supported at the same time. |
|
469 * Mutator. |
|
470 * |
|
471 * @since 5.0 |
|
472 * @param aObserver observer |
|
473 * |
|
474 */ |
|
475 void SetObserverL( MUniObjectObserver* aObserver ); |
|
476 |
|
477 /** |
|
478 * Removes observer of UniObject events. |
|
479 * Accessor. |
|
480 * |
|
481 * @since 5.0 |
|
482 * |
|
483 */ |
|
484 void RemoveObserver( MUniObjectObserver* aObserver ); |
|
485 |
|
486 protected: |
|
487 |
|
488 /** |
|
489 * From CActive |
|
490 */ |
|
491 void DoCancel(); |
|
492 |
|
493 /** |
|
494 * From CActive |
|
495 */ |
|
496 void RunL(); |
|
497 |
|
498 /** |
|
499 * From CActive |
|
500 */ |
|
501 TInt RunError( TInt aError ); |
|
502 |
|
503 protected: |
|
504 |
|
505 /** |
|
506 * Constructor. |
|
507 * |
|
508 * @since 3.1 |
|
509 */ |
|
510 CUniObject( |
|
511 RFs& aFs, |
|
512 CBaseMtm& aMtm, |
|
513 CUniDataUtils& aData, |
|
514 CMsgMediaInfo* aMedia ); |
|
515 |
|
516 /** |
|
517 * 2nd phase constructor. |
|
518 * |
|
519 * @since 3.1 |
|
520 */ |
|
521 void ConstructL(); |
|
522 |
|
523 /** |
|
524 * 2nd phase constructor. |
|
525 * |
|
526 * @since 3.1 |
|
527 * @param aManager IN reference to attachment manager |
|
528 * @param aAttachmentId IN id of the attachment from |
|
529 * which to create the object |
|
530 */ |
|
531 void ConstructFromAttachmentL( |
|
532 MMsvAttachmentManager& aManager, |
|
533 CMsvAttachment& aAttachment ); |
|
534 |
|
535 /** |
|
536 * CreateMimeInfoL |
|
537 * Create mime info for the object from the file information |
|
538 * and in-parameters. |
|
539 * |
|
540 * @since 3.1 |
|
541 */ |
|
542 void CreateMimeInfoL(); |
|
543 |
|
544 /** |
|
545 * CreateAttachmentL |
|
546 * Creates an attachment to message store. |
|
547 * If leave occurs, attachment is cleaned up from the |
|
548 * message store. |
|
549 * |
|
550 * @since 3.1 |
|
551 */ |
|
552 void CreateAttachmentL( ); |
|
553 |
|
554 /** |
|
555 * SetHiddenL |
|
556 * Sets attachment "hidden" or "visible" |
|
557 * "Hidden" means InPreparation flag is set on and |
|
558 * "visible" means InPreparation flag is set off |
|
559 * Not to be called for "temporary" object |
|
560 * |
|
561 * @since 3.1 |
|
562 * @param aHidden IN ETrue for "hidden", EFalse for "visible" |
|
563 */ |
|
564 //void SetHiddenL( TBool aHidden ); |
|
565 |
|
566 virtual void DoSaveL(); |
|
567 |
|
568 void StartObjectSaveL(); |
|
569 void FinalizeObjectSaveL(); |
|
570 |
|
571 void CompleteSelf(); |
|
572 |
|
573 /// From MDRMEventObserver |
|
574 virtual void HandleEventL( MDRMEvent* aEvent ); |
|
575 |
|
576 |
|
577 protected: // data |
|
578 |
|
579 enum TMsgObjectSaveState |
|
580 { |
|
581 EObjectSavingIdle, |
|
582 EObjectCreatingAttachment |
|
583 }; |
|
584 |
|
585 enum TMsgObjectFlags |
|
586 { |
|
587 EObjectCorrupted = 0x1, |
|
588 EObjectAttachment = 0x2, |
|
589 EObjectDrmRightsWhenLoaded = 0x4, |
|
590 EObjectDrmRightsWhenLoadedObjects = 0x8 |
|
591 }; |
|
592 |
|
593 RFs& iFs; |
|
594 CBaseMtm& iMtm; |
|
595 CUniDataUtils& iData; |
|
596 |
|
597 TInt iSupportedFeatures; |
|
598 |
|
599 TMsvAttachmentId iAttachmentId; // Attachment id of object. Can be id to Link file in store or to real atta. |
|
600 |
|
601 CUniMimeInfo* iMimeInfo; // Contains objects mime headers. |
|
602 CMsgMediaInfo* iMediaInfo; // Contains objects media information. |
|
603 CUniDrmInfo* iDrmInfo; |
|
604 TInt iObjectFlags; |
|
605 TInt iReferenceCount; |
|
606 //TMsgObjectStoreState iStoreState; |
|
607 TUniRegion iRegion; |
|
608 TMsgMediaType iMediaTypeBySmilTag; |
|
609 TInt iUniqueControlHandle; |
|
610 |
|
611 MUniObjectSaveObserver* iObserver; |
|
612 CMsvAttachment::TMsvAttachmentType iSaveType; |
|
613 |
|
614 MMsvAttachmentManager* iManager; |
|
615 CMsvAttachment* iAttachment; |
|
616 CMsvStore* iEditStore; |
|
617 TInt iSaveState; |
|
618 |
|
619 TBool iSavedToFs; |
|
620 RFile iFileHandle; |
|
621 |
|
622 CDRMNotifier* iDrmNotifier; |
|
623 CArrayPtrFlat<MUniObjectObserver>* iObservers; |
|
624 |
|
625 }; |
|
626 |
|
627 #include <UniObject.inl> |
|
628 |
|
629 #endif // __UNIOBJECT_H |
|