2 * Copyright (c) 2003, 2004 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: Class to show miscellaneous DRM related error notes and
15 * details about rights
21 #ifndef __DRMHELPER_H__
22 #define __DRMHELPER_H__
26 #include <ConeResLoader.h>
28 #include <rdrmhelper.h>
29 #include <aknserverapp.h>
31 #include <caf/content.h>
35 using namespace ContentAccess;
38 const TInt KDRMHelperDefaultCountThreshold = 3;
39 const TInt KDRMHelperDefaultTimeThreshold = 7;
40 const TInt KDRMHelperDefaultPercentageThreshold = 10;
41 const TInt KDRMHelperNoteMaxSize ( 256 );
46 enum TDRMHelperPreviewMediaType
51 // FUNCTION PROTOTYPES
53 // FORWARD DECLARATIONS
55 class CDRMRightsConstraints;
57 class CStringResourceReader;
65 class CDRMHelperInfoNoteWrapper;
67 class CMediatorEventProvider;
72 * Helper class for wrapping CDRMRightsConstraints.
75 * @since Series 60 2.1
77 class CDRMHelperRightsConstraints : public CBase
79 public: // Constructors and destructor
82 * Two-phased constructor.
84 static CDRMHelperRightsConstraints* NewL(
85 CDRMRightsConstraints* aConstraints );
86 static CDRMHelperRightsConstraints* NewLC(
87 CDRMRightsConstraints* aConstraints );
92 IMPORT_C ~CDRMHelperRightsConstraints();
94 public: // New functions
97 * checks if the object contains any restrictions
98 * or if usage is unconstrained.
99 * @return ETrue if usage is unconstrained
101 IMPORT_C TBool FullRights();
104 * checks if the object contains only preview rights
105 * @return ETrue if object contains only preview rights
107 IMPORT_C TBool IsPreview();
110 * Gets number of counts left and number of original counts.
111 * Leaves with KErrNotFound if object doesn't have count based rights.
112 * @param aCounter: (out) counts left
113 * @param aOriginalCounter: (out) number of counts when stored to
117 IMPORT_C void GetCountersL( TUint32& aCounter,
118 TUint32& aOriginalCounter );
121 * Gets start time of time based rights.
122 * Leaves with KErrNotFound if object doesn't have time based rights.
123 * @param aStartTime: (out) start time
126 IMPORT_C void GetStartTimeL( TTime& aStartTime );
129 * Gets end time of time based rights.
130 * Leaves with KErrNotFound if object doesn't have time based rights.
131 * @param aEndTime: (out) start time
134 IMPORT_C void GetEndTimeL( TTime& aEndTime );
137 * Gets interval time constraint.
138 * Leaves with KErrNotFound if object doesn't have interval constraint.
139 * @param aInterval: (out) interval
142 IMPORT_C void GetIntervalL( TTimeIntervalSeconds& aInterval );
145 * Gets start time of activated interval constraint.
146 * Leaves with KErrNotFound if interval has not been started yet.
147 * @param aStartTime: (out) start time of activated interval
151 IMPORT_C void GetIntervalStartL( TTime& aStartTime );
153 * Gets number of counts left, number of original counts and timer
154 * value for timed-count constraint.
155 * Leaves with KErrNotFound if object doesn't have timed-count
157 * @param aCounter: (out) counts left
158 * @param aOriginalCounter: Invalid, value returned same as aCounter
159 * @param aTimer: (out) timer value
161 * @since Series 60 3.0
163 IMPORT_C void GetTimedCountL( TUint32& aCounter,
164 TUint32& aOriginalCounter, TTimeIntervalSeconds& aTimer );
167 * Gets accumulated time left.
168 * Leaves with KErrNotFound if object doesn't have accumulated time
170 * @param aAccumulatedTime: (out) accumulated time left
172 * @since Series 60 3.0
174 IMPORT_C void GetAccumulatedTimeL( TTimeIntervalSeconds& aAccumulatedTime );
179 * C++ default constructor.
181 CDRMHelperRightsConstraints( CDRMRightsConstraints* aConstrains );
184 * By default Symbian 2nd phase constructor is private.
189 // pointer to CDRMRightsConstraints object
190 CDRMRightsConstraints* iConstraints;
195 * Handles some error situations DRM-aware applications may encounter.
198 * @since Series 60 2.1
200 class CDRMHelper : public CBase, public MAknServerAppExitObserver
204 enum TDRMHelperNotificationID
206 ETActivateTextId = 1,
207 ETCountBasedErrorTextId = 2 ,
208 ETCountUsageReduceId = 3,
209 ETCountUsageReduceMediaId = 4
212 enum TDRMHelperConsumeAction
220 enum TDRMHelperOMALevel
227 enum TDRMHelperPreviewType
234 enum TDRMHelperAutomatedType
236 EAutomatedTypeRingingTone,
237 EAutomatedTypeMessageAlert,
238 EAutomatedTypeEmailAlert,
239 EAutomatedTypeIMAlert,
240 EAutomatedTypeCalendarAlarm,
241 EAutomatedTypeScreenSaver,
242 EAutomatedTypeWallpaper,
244 EAutomatedTypeClockAlarm,
245 EAutomatedTypeOther = KMaxTUint8
248 enum TDRMHelperDRMMethods
250 EForwardLock = 0x0001,
251 ECombinedDelivery = 0x0002,
252 ESeparateDelivery = 0x0004,
253 ESuperDistribution = 0x0008
256 public: // Constructors and destructor
259 * Two-phased constructor.
261 IMPORT_C static CDRMHelper* NewL( CCoeEnv& aCoeEnv );
262 IMPORT_C static CDRMHelper* NewLC( CCoeEnv& aCoeEnv );
265 * Two-phased constructor.
266 * @since Series 60 2.6
268 IMPORT_C static CDRMHelper* NewL();
269 IMPORT_C static CDRMHelper* NewLC();
272 * Two-phased constructor.
273 * @since Series 60 3.0
275 IMPORT_C static CDRMHelper* NewL( CCoeEnv& aCoeEnv, RFs& aFs );
276 IMPORT_C static CDRMHelper* NewLC( CCoeEnv& aCoeEnv, RFs& aFs );
279 * Two-phased constructor.
280 * @since Series 60 3.0
282 IMPORT_C static CDRMHelper* NewL( RFs& aFs );
283 IMPORT_C static CDRMHelper* NewLC( RFs& aFs );
288 IMPORT_C ~CDRMHelper();
294 * Displays appropriate error note depending on error code.
295 * @param aError: error code returned by DRM engine
296 * @param aURI: URI of the file
298 * - Button code, if user selected "buy rights" or "launch rights
300 * - 0 if user selected "No", "Back" or "Cancel" (or whatever which
301 * just dismiss the query)
302 * - 0 if just a simple error note is displayed
304 IMPORT_C TInt HandleErrorL( TInt aError,
305 const TDesC8& aURI );
310 * Handles error situations 'rights expired', 'no rights' and
311 * 'rights database corrupted'.
312 * @param aError: error code returned by DRM engine
313 * @param aFileName: full path to file
315 * - Button code, if user selected "buy rights" or "launch rights
317 * - 0 if user selected "No", "Back" or "Cancel" (or whatever which
318 * just dismiss the query)
319 * - 0 if just a simple error note is displayed
321 IMPORT_C TInt HandleErrorL( TInt aError,
322 const TDesC& aFileName );
327 * Handles error situations 'rights expired', 'no rights' and
328 * 'rights database corrupted'.
329 * @param aError: error code returned by DRM engine
330 * @param aFileHandle: file handle to the file
332 * - Button code, if user selected "buy rights" or "launch rights
334 * - 0 if user selected "No", "Back" or "Cancel" (or anything that
335 * just dismisses the query)
336 * - 0 if just a simple error note is displayed
339 IMPORT_C TInt HandleErrorL( TInt aError,
340 RFile& aFileHandle );
343 * Handles DRM-specific error situations. Should be called instead of
344 * HandleErrorL if user should be asked to play embedded preview or get
345 * preview/silent rights if there is no valid rights and either embedded preview or
346 * preview rights are available.
347 * @param aError: error code to be handled.
348 * @param aFile: handle of file for which error was received.
349 * @param aEmbeddedPreviewUri: contain URI of embedded preview part
350 * upon return if caller should play the embedded preview. If embedded
351 * preview should not be played this is NULL. Must be freed by caller.
352 * @return KErrNone if the content is now usable (e.g. silent rights or preview rights were gotten). If
353 * the return code is KErrNone and the aEmbeddedPreviewUri parameter is not NULL,
354 * the player should use embedded preview
355 * KErrCancel if the user cancelled any of the actions within the function
356 * KErrCANoRights and KErrCANoPermission if after the function call, still no rights exist
357 * KErrCompletion if the user did launch the browser, but it is not clear whether the content
361 IMPORT_C TInt HandleErrorOrPreviewL(
364 HBufC8*& aEmbeddedPreviewUri );
367 * Handles DRM specific error situations. Should be called instead of
368 * HandleErrorL if user should be asked to play embedded preview or get
369 * preview/silent rights if there is no valid rights and either embedded preview or
370 * preview rights are available.
371 * @param aError: error code to be handled.
372 * @param aFileName: name of file for which error was received.
373 * @param aEmbeddedPreviewUri: contain URI of embedded preview part
374 * upon return if caller should play the embedded preview. If embedded
375 * preview should not be played this is NULL. Must be freed by caller.
376 * @return KErrNone if the content is now usable (e.g. silent rights or preview rights were gotten). If
377 * the return code is KErrNone and the aEmbeddedPreviewUri parameter is not NULL,
378 * the player should use embedded preview
379 * KErrCancel if the user cancelled any of the actions within the function
380 * KErrCANoRights and KErrCANoPermission if after the function call, still no rights exist
381 * KErrCompletion if the user did launch the browser, but it is not clear whether the content
385 IMPORT_C TInt HandleErrorOrPreviewL(
387 const TDesC& aFileName,
388 HBufC8*& aEmbeddedPreviewUri );
391 * Check rights for the content. If there is less than given amount
392 * of usage time/count left, appropriate note is displayed
393 * depending on situation.
394 * @param aURI: URI of the file
395 * @return Button code
397 // causes conflict with other CheckRightsAmount method, removed for now...
398 // IMPORT_C TInt CheckRightsAmountL( const TDesC8& aURI );
402 * Check rights for the file. If there is less than given amount
403 * of usage time/count/percentage left, appropriate note is displayed
404 * depending on situation.
405 * @param aFileName: Full path to file
406 * @return Button code
408 // causes conflict with other CheckRightsAmount method, removed for now...
409 // IMPORT_C TInt CheckRightsAmountL( const TDesC& aFileName );
413 * Check rights for the file. If there is less than given amount
414 * of usage time/count/percentage left, appropriate note is displayed
415 * depending on situation.
416 * @param aFileHandle: file handle to the file
417 * @return Button code
420 // causes conflict with other CheckRightsAmount method, removed for now...
421 // IMPORT_C TInt CheckRightsAmountL( RFile& aFileHandle );
425 * Check rights for the file. If there is less than given amount
426 * of usage time/count left, one of the following note is displayed
427 * depending on situation:
428 * 'Usage rights about to expire. View details?'
429 * 'Usage rights about to expire. %N days left. View details?'
430 * 'Usage rights about to expire. 1 day left. View details?'
431 * 'Usage rights about to expire. %N counts left. View details?'
432 * 'Usage rights about to expire. 1 count left. View details?'
433 * It also checks that rights are valid and displays appropriate note,
435 * @param aFileName: Full path to file
436 * @param aCount: Threshold value for count limit
437 * @param aDays: Threshold value for time limit in days
438 * @return Button code
440 IMPORT_C TInt CheckRightsAmountL( const TDesC& aFileName,
441 TInt aCount = KDRMHelperDefaultCountThreshold,
442 TInt aDays = KDRMHelperDefaultTimeThreshold );
446 * Check rights for the file. If there is less than given amount
447 * of usage time/count left, one of the following note is displayed
448 * depending on situation:
449 * 'Usage rights about to expire. View details?'
450 * 'Usage rights about to expire. %N days left. View details?'
451 * 'Usage rights about to expire. 1 day left. View details?'
452 * 'Usage rights about to expire. %N counts left. View details?'
453 * 'Usage rights about to expire. 1 count left. View details?'
454 * It also checks that rights are valid and displays appropriate note,
456 * @param aFileHandle: file handle to the file
457 * @param aCount: Threshold value for count limit
458 * @param aDays: Threshold value for time limit in days
459 * @return Button code
462 IMPORT_C TInt CheckRightsAmountL( RFile& aFileHandle,
463 TInt aCount = KDRMHelperDefaultCountThreshold,
464 TInt aDays = KDRMHelperDefaultTimeThreshold );
468 * Check rights for the file. If there is less than given amount
469 * of usage time/count left, one of the following note is displayed
470 * depending on situation:
471 * 'Usage rights about to expire. View details?'
472 * 'Usage rights about to expire. %N days left. View details?'
473 * 'Usage rights about to expire. 1 day left. View details?'
474 * 'Usage rights about to expire. %N counts left. View details?'
475 * 'Usage rights about to expire. 1 count left. View details?'
476 * It also checks that rights are valid and displays appropriate note,
478 * @param aUri: Content URI
479 * @param aCount: Threshold value for count limit
480 * @param aDays: Threshold value for time limit in days
481 * @return Button code
483 IMPORT_C TInt CheckRightsAmountL( const TDesC8& aUri,
484 TInt aCount = KDRMHelperDefaultCountThreshold,
485 TInt aDays = KDRMHelperDefaultTimeThreshold );
489 * Check rights for the file. If there is less than aThreshold percent
490 * of usage time/count left, one of the following note is displayed
491 * depending on situation:
492 * 'Usage rights about to expire. View details?'
493 * 'Usage rights about to expire. %N days left. View details?'
494 * 'Usage rights about to expire. 1 day left. View details?'
495 * 'Usage rights about to expire. %N counts left. View details?'
496 * 'Usage rights about to expire. 1 count left. View details?'
497 * It also checks that rights are valid and displays appropriate note,
499 * @param aFileName: Full path to file
500 * @param aThreshold: Threshold value in percents for displaying the note
501 * @return Button code
503 IMPORT_C TInt CheckRightsPercentL( const TDesC& aFileName,
504 TInt aThreshold = KDRMHelperDefaultPercentageThreshold );
508 * Check rights for the file. If there is less than aThreshold percent
509 * of usage time/count left, one of the following note is displayed
510 * depending on situation:
511 * 'Usage rights about to expire. View details?'
512 * 'Usage rights about to expire. %N days left. View details?'
513 * 'Usage rights about to expire. 1 day left. View details?'
514 * 'Usage rights about to expire. %N counts left. View details?'
515 * 'Usage rights about to expire. 1 count left. View details?'
516 * It also checks that rights are valid and displays appropriate note,
518 * @param aFileHandle: file handle to the file
519 * @param aThreshold: Threshold value in percents for displaying the note
520 * @return Button code
523 IMPORT_C TInt CheckRightsPercentL( RFile& aFileHandle,
524 TInt aThreshold = KDRMHelperDefaultPercentageThreshold );
528 * Launches DRM Rights Manager UI embedded with details view related
530 * @param aURI: URI of the file
533 IMPORT_C void LaunchDetailsViewEmbeddedL(
534 const TDesC8& aURI );
538 * Launches DRM Rights Manager UI embedded with details view related
540 * @param aFileName: Full path to file
543 IMPORT_C void LaunchDetailsViewEmbeddedL(
544 const TDesC& aFileName );
548 * Launches DRM Rights Manager UI embedded with details view related
550 * @param aFileHandle: file handle to the file
554 IMPORT_C void LaunchDetailsViewEmbeddedL(
555 RFile& aFileHandle );
559 * Launches DRM Rights Manager UI embedded with details view related
561 * @param aContentURI: URI of the content
564 IMPORT_C void LaunchDetailsViewEmbeddedL(
565 const HBufC8* aContentURI );
569 * Gets details of rights object associated of given file.
571 * @param[in] aFileName Full path to file
572 * @param[in] aIntent ContentAccess::EPlay, ContentAccess::EView,
573 * ContentAccess::EPrint or ContentAccess::EExecute
574 * @param[out] aExpired ETrue if rights are not valid. If this is ETrue
575 * and some constraints are returned, rights will become valid in future
576 * @param[out] aSendingAllowed ETrue if content can be sent
577 * @param[out] aPlay play constraints, must be deleted by caller
578 * @param[out] aDisplay display constraints, must be deleted by caller
579 * @param[out] aExecute execute constraints, must be deleted by caller
580 * @param[out] aPrint print constraints, must be deleted by caller
582 * @leave KErrArgument file is not DRM-protected.
583 * @leave KErrCANoRights no rights
587 IMPORT_C void GetRightsDetailsL( const TDesC& aFileName,
588 TUint32 aIntent, TBool& aExpired, TBool& aSendingAllowed,
589 CDRMHelperRightsConstraints*& aPlay,
590 CDRMHelperRightsConstraints*& aDisplay,
591 CDRMHelperRightsConstraints*& aExecute,
592 CDRMHelperRightsConstraints*& aPrint );
596 * Gets details of rights object associated of given file.
598 * @param[in] aFileHandle file handle to the file
599 * @param[in] aIntent ContentAccess::EPlay, ContentAccess::EView,
600 * ContentAccess::EPrint or ContentAccess::EExecute
601 * @param[out] aExpired ETrue if rights are not valid. If this is ETrue
602 * and some constraints are returned, rights will become valid in future
603 * @param[out] aSendingAllowed ETrue if content can be sent
604 * @param[out] aPlay play constraints, must be deleted by caller
605 * @param[out] aDisplay display constraints, must be deleted by caller
606 * @param[out] aExecute execute constraints, must be deleted by caller
607 * @param[out] aPrint print constraints, must be deleted by caller
609 * @leave KErrArgument file is not DRM-protected.
610 * @leave KErrCANoRights no rights
616 IMPORT_C void GetRightsDetailsL( RFile& aFileHandle,
617 TUint32 aIntent, TBool& aExpired, TBool& aSendingAllowed,
618 CDRMHelperRightsConstraints*& aPlay,
619 CDRMHelperRightsConstraints*& aDisplay,
620 CDRMHelperRightsConstraints*& aExecute,
621 CDRMHelperRightsConstraints*& aPrint );
625 * Gets details of rights object associated of given file.
627 * @param[in] aFileName Full path to file
628 * @param[in] aIntent ContentAccess::EPlay, ContentAccess::EView,
629 * ContentAccess::EPrint or ContentAccess::EExecute
630 * @param[out] aExpired ETrue if rights are not valid. If this is ETrue
631 * and some constraints are returned, rights will become valid in future
632 * @param[out] aSendingAllowed ETrue if content can be sent
633 * @param[out] aPlay play constraints, must be deleted by caller
634 * @param[out] aDisplay display constraints, must be deleted by caller
635 * @param[out] aExecute execute constraints, must be deleted by caller
636 * @param[out] aPrint print constraints, must be deleted by caller
638 * @leave KErrArgument file is not DRM-protected.
639 * @leave KErrCANoRights no rights
643 IMPORT_C void GetRightsDetailsL( const TDesC& aFileName,
644 TUint32 aIntent, TBool& aExpired, TBool& aSendingAllowed,
645 CDRMRightsConstraints*& aPlay,
646 CDRMRightsConstraints*& aDisplay,
647 CDRMRightsConstraints*& aExecute,
648 CDRMRightsConstraints*& aPrint );
652 * Gets details of rights object associated of given file.
654 * @param[in] aFileHandle file handle to the file
655 * @param[in] aIntent ContentAccess::EPlay, ContentAccess::EView,
656 * ContentAccess::EPrint or ContentAccess::EExecute
657 * @param[out] aExpired ETrue if rights are not valid. If this is ETrue
658 * and some constraints are returned, rights will become valid in future
659 * @param[out] aSendingAllowed ETrue if content can be sent
660 * @param[out] aPlay play constraints, must be deleted by caller
661 * @param[out] aDisplay display constraints, must be deleted by caller
662 * @param[out] aExecute execute constraints, must be deleted by caller
663 * @param[out] aPrint print constraints, must be deleted by caller
665 * @leave KErrArgument file is not DRM-protected.
666 * @leave KErrCANoRights no rights
672 IMPORT_C void GetRightsDetailsL( RFile& aFileHandle,
673 TUint32 aIntent, TBool& aExpired, TBool& aSendingAllowed,
674 CDRMRightsConstraints*& aPlay,
675 CDRMRightsConstraints*& aDisplay,
676 CDRMRightsConstraints*& aExecute,
677 CDRMRightsConstraints*& aPrint );
681 * Registers given content to be used as an automated content. This
682 * function is used when registering application listens expiry
683 * notifications itself
684 * @param aURI: content URI
685 * @return System wide error code (KErrCancel if user pressed no to
687 * @since Series 60 2.6
689 IMPORT_C TInt SetAutomated( const TDesC8& aURI );
693 * Registers given content to be used as an automated content. This
694 * function is used when registering application listens expiry
695 * notifications itself.
696 * @param aFileName: Full path to file
697 * @return System wide error code (KErrCancel if user pressed no to
699 * @since Series 60 2.6
701 IMPORT_C TInt SetAutomated( const TDesC& aFilename );
705 * Registers given content to be used as an automated content. This
706 * function is used when registering application listens expiry
707 * @param aFileHandle: file handle to the file
708 * @return System wide error code (KErrCancel if user pressed no to
712 IMPORT_C TInt SetAutomated( RFile& aFileHandle );
716 * Displays the confirmation query about setting given content as an
717 * automated content. Note that this function does not actually
718 * register content, just displays the note
719 * @param aURI: content URI
720 * @return System wide error code (KErrCancel if user pressed no to
722 * @since Series 60 2.6
724 IMPORT_C TInt ShowAutomatedNote( const TDesC8& aURI );
728 * Displays the confirmation query about setting given content as an
729 * automated content. Note that this function does not actually
730 * register content, just displays the note
731 * @param aFileName: Full path to file
732 * @return System wide error code (KErrCancel if user pressed no to
734 * @since Series 60 2.6
736 IMPORT_C TInt ShowAutomatedNote( const TDesC& aFilename );
740 * Displays the confirmation query about setting given content as an
741 * automated content. Note that this function does not actually
742 * register content, just displays the note
743 * @param aFileHandle: file handle to the file
744 * @return System wide error code (KErrCancel if user pressed no to
748 IMPORT_C TInt ShowAutomatedNote( RFile& aFileHandle );
752 * Registers given content to be used as an automated content. This
753 * function is used when phone application listens to expiry notifications.
754 * @param aURI: content URI
755 * @return System wide error code (KErrCancel if user pressed no to
757 * @since Series 60 2.6
759 IMPORT_C TInt SetAutomatedPassive( const TDesC8& aURI );
763 * Registers given content to be used as an automated content. This
764 * function is used when phone application listens to expiry notifications.
765 * @param aFileName: Full path to file
766 * @return System wide error code (KErrCancel if user pressed no to
768 * @since Series 60 2.6
770 IMPORT_C TInt SetAutomatedPassive( const TDesC& aFilename );
774 * Registers given content to be used as an automated content. This
775 * function is used when phone application listens to expiry notifications.
776 * @param aFileHandle: file handle to the file
777 * @return System wide error code (KErrCancel if user pressed no to
781 IMPORT_C TInt SetAutomatedPassive( RFile& aFileHandle );
785 * Registers given content to be used as an automated content without
786 * confirmation query.
787 * @param aURI: content URI
788 * @param aActive: ETrue if registering application itself listens
789 * expiry notifications
790 * @return System wide error code (KErrCancel if user pressed no to
792 * @since Series 60 2.6
794 IMPORT_C TInt SetAutomatedSilent( const TDesC8& aURI, TBool aActive );
798 * Registers given content to be used as an automated content without
799 * confirmation query.
800 * @param aFileName: Full path to file
801 * @param aActive: ETrue if registering application itself listens
802 * expiry notifications
803 * @return System wide error code (KErrCancel if user pressed no to
805 * @since Series 60 2.6
807 IMPORT_C TInt SetAutomatedSilent( const TDesC& aFilename,
812 * Registers given content to be used as an automated content without
813 * confirmation query.
814 * @param aFileHandle: file handle to the file
815 * @param aActive: ETrue if registering application itself listens
816 * expiry notifications
817 * @return System wide error code (KErrCancel if user pressed no to
821 IMPORT_C TInt SetAutomatedSilent( RFile& aFileHandle,
826 * Unregisters given content to be used as an automated content.
827 * @param aURI: content URI
828 * @return System wide error code.
829 * @since Series 60 2.6
831 IMPORT_C TInt RemoveAutomated( const TDesC8& aURI );
835 * Unregisters given content to be used as an automated content.
836 * @param aFileName: Full path to file
837 * @return System wide error code.
838 * @since Series 60 2.6
840 IMPORT_C TInt RemoveAutomated( const TDesC& aFilename );
844 * Unregisters given content to be used as an automated content.
845 * @param aFileHandle: file handle to the file
846 * @return System wide error code.
849 IMPORT_C TInt RemoveAutomated( RFile& aFileHandle );
853 * Unregisters given content to be used as an automated content.
854 * This function must be used when content was registered using
855 * SetAutomatedPassive.
856 * @param aURI: content URI
857 * @return System wide error code.
858 * @since Series 60 2.6
860 IMPORT_C TInt RemoveAutomatedPassive( const TDesC8& aURI );
864 * Unregisters given content to be used as an automated content.
865 * This function must be used when content was registered using
866 * SetAutomatedPassive.
867 * @param aFileName: Full path to file
868 * @return System wide error code.
869 * @since Series 60 2.6
871 IMPORT_C TInt RemoveAutomatedPassive( const TDesC& aFilename );
875 * Unregisters given content to be used as an automated content.
876 * This function must be used when content was registered using
877 * SetAutomatedPassive.
878 * @param aFileHandle: file handle to the file
879 * @return System wide error code.
882 IMPORT_C TInt RemoveAutomatedPassive( RFile& aFileHandle );
886 * Checks if given content can be set as an automated content.
887 * @param aURI: content URI
888 * @param aValue: ETrue if content can be set as automated.
889 * @return System wide or DRM specific error code.
890 * @since Series 60 2.6
892 IMPORT_C TInt CanSetAutomated( const TDesC8& aURI,
897 * Checks if given content can be set as an automated content.
898 * @param aFileName: Full path to file
899 * @param aValue: ETrue if content can be set as automated.
900 * @return System wide or DRM specific error code.
901 * @since Series 60 2.6
903 IMPORT_C TInt CanSetAutomated( const TDesC& aFilename,
908 * Checks if given content can be set as an automated content.
909 * @param aFileHandle: file handle to the file
910 * @param aValue: ETrue if content can be set as automated.
911 * @return System wide or DRM specific error code.
914 IMPORT_C TInt CanSetAutomated( RFile& aFileHandle,
919 * Informs DRMHelper that idle-screen has been activated.
921 * @since Series 60 2.6
923 IMPORT_C void IndicateIdle();
926 * Handle the general UI based error notes
928 * @param aTextId The code for DRM general notification note.
929 * @param aURI The DRM files URI, that caused the DRM error.
930 * @return KErrnone if everything went ok, else wide scale of Symbian errors
932 IMPORT_C TInt ShowDRMUINotification2L( TDRMHelperNotificationID aTextId,
933 const TDesC8& aURI );
937 * Handle the general UI based error notes
939 * @param aTextId The code for DRM general notification note.
940 * @param aFileName The DRM file's name and path, that caused the DRM error.
941 * @return KErrnone if everything went ok, else wide scale of Symbian errors
943 IMPORT_C TInt ShowDRMUINotification2L( TDRMHelperNotificationID aTextId,
944 const TDesC& aFileName );
948 * Set count limit for CheckRightsAmountL
949 * @param aCounts: new count limit for displaying the note.
952 IMPORT_C void SetCountLimitL( TUint aCounts );
956 * Set time limit in days for CheckRightsAmountL
957 * @param aDays: new time limit for displaying the note.
960 IMPORT_C void SetTimeLimitL( TUint aDays );
964 * Set percentage limit for CheckRightsAmountL. Applies to both counts and time.
965 * @param aPercentage: new limit for displaying the note.
968 IMPORT_C void SetPercentageLimitL( TUint aPercentage );
974 * Returns a list of all content URIs that have rights in the rights
978 * @param aURIList: Out parameter for the URI list.
979 * @return Ok if the URI list could be retreived.
981 IMPORT_C TInt GetContentURIList(
982 RPointerArray<HBufC8>*& aURIList);
988 * Returns the number of previously registered datatypes which are
989 * supported by the DRM system and associated applications.
992 * @param aCount: Out parameter for the datatype count
993 * @return EOk if the number of datatypes has been returned correctly
995 IMPORT_C TInt DataTypesCount(
1002 * Returns a specific datatype which has been registered before by giving an index
1005 * @param aIndex: Number of the datatype to return
1006 * @param aDataType: Out parameter for the datatype
1007 * @return EOk if the datatype was returned correctly
1009 IMPORT_C TInt SupportedDataType(
1010 const TInt aIndex, TDataType& aDataType);
1016 * Registers a datatype as a supported datatype.
1019 * @param aDataType: Datatype to register
1020 * @return EOk if the datatype has been registered
1022 IMPORT_C TInt RegisterDataType(
1023 const TDataType& aDataType);
1027 * UnRegisterDataType
1029 * Unregisters a datatype via its index.
1032 * @param aIndex: Number of the datatype to unregister
1033 * @return EOk if the datatype has been unregistered
1035 IMPORT_C TInt UnRegisterDataType(
1040 * SupportedDRMMethods
1042 * Returns the supported DRM protection methods and the OMA compliance
1043 * level of the DRM engine
1046 * @param aDRMMethod: Out parameter, bit mask containing any
1047 * combination of EForwardLock, ECombinedDelivery,
1048 * ESeparateDelivery etc.
1049 * @param aOMALevel: OMA compliance of the DRM engine
1050 * @return DRMCommon error code
1053 IMPORT_C TInt SupportedDRMMethods2(
1054 TInt& aDRMMethod, TDRMHelperOMALevel& aOMALevel);
1060 * Overrides any rights consumption. This function must only be used by
1061 * applications with user interaction and not by intermediate components.
1062 * The main use cases are signalling that content is to be installed
1063 * (including thumbnail generation), or that content is to be consumed.
1064 * They are characterized as calls to this function with the correct
1065 * intent (i.e. EPlay or EInstall) and the corresponding action (i.e.
1066 * telling whether the indicated intent is started or finished).
1067 * Calls to this function must be the result of a user interaction or
1068 * otherwise high level event.
1071 * @param aContentURI: URI of the content which will be consumed
1072 * @param aRightsSpec: the consumption intent (EPlay, EDisplay, EPrint,
1073 * EExecute or EInstall)
1074 * @param anAction: the consumption action, telling whether the
1075 * content consumption starts or finishes.
1076 * @return EOk if consume action was successfully signalled to the engine.
1078 IMPORT_C TInt Consume2(
1079 const TDesC8& aContentURI,
1080 TUint32 aRightsSpec,
1081 TDRMHelperConsumeAction anAction);
1087 * Overrides any rights consumption. This function must only be used by
1088 * applications with user interaction and not by intermediate components.
1089 * The main use cases are signalling that content is to be installed
1090 * (including thumbnail generation), or that content is to be consumed.
1091 * They are characterized as calls to this function with the correct
1092 * intent (i.e. EPlay or EInstall) and the corresponding action (i.e.
1093 * telling whether the indicated intent is started or finished).
1094 * Calls to this function must be the result of a user interaction or
1095 * otherwise high level event.
1099 * @param aRightsSpec: the consumption intent (EPlay, EDisplay, EPrint,
1100 * EExecute or EInstall)
1101 * @param anAction: the consumption action, telling whether the
1102 * content consumption starts or finishes.
1103 * @return EOk if consume action was successfully signalled to the engine.
1105 IMPORT_C TInt ConsumeFile2(
1106 const TDesC& aFileName,
1107 TUint32 aRightsSpec,
1108 TDRMHelperConsumeAction anAction);
1114 * Overrides any rights consumption. This function must only be used by
1115 * applications with user interaction and not by intermediate components.
1116 * The main use cases are signalling that content is to be installed
1117 * (including thumbnail generation), or that content is to be consumed.
1118 * They are characterized as calls to this function with the correct
1119 * intent (i.e. EPlay or EInstall) and the corresponding action (i.e.
1120 * telling whether the indicated intent is started or finished).
1121 * Calls to this function must be the result of a user interaction or
1122 * otherwise high level event.
1125 * @param aFileHandle: file handle to the file
1126 * @param aRightsSpec: the consumption intent (EPlay, EDisplay, EPrint,
1127 * EExecute or EInstall)
1128 * @param anAction: the consumption action, telling whether the
1129 * content consumption starts or finishes.
1130 * @return EOk if consume action was successfully signalled to the engine.
1132 IMPORT_C TInt ConsumeFile2(
1134 TUint32 aRightsSpec,
1135 TDRMHelperConsumeAction anAction);
1138 * Acquires rights for given content if rights have been expired or rights are missing.
1139 * If content already has valid or future rights, does nothing.
1140 * This function should be called when user selects activate from options menu.
1141 * Leaves with system-wide error code in case of error.
1142 * @param aContent: Content object
1144 IMPORT_C void ActivateContentL(CData& aContent);
1147 * Acquires rights for given content if rights have been expired or rights are missing.
1148 * If content already has valid or future rights, does nothing.
1149 * This function should be called when user selects activate from options menu.
1150 * Leaves with system-wide error code in case of error.
1151 * @param aFileName: Full path to file
1153 IMPORT_C void ActivateContentL(TDesC& aFileName);
1156 * Checks if given content has embedded preview or if it is possible to get preview rights for it.
1157 * Leaves with system-wide error code in case of error.
1158 * @param aContent: Content object
1159 * @param aPreviewUri: Out: URI of the embedded preview or PreviewRights URL. Must be freed by caller
1160 * @return preview type
1162 IMPORT_C TDRMHelperPreviewType HasPreviewL(CData& aContent, HBufC8*& aPreviewUri);
1165 * Checks if given content has embedded preview or if it is possible to get preview rights for it.
1166 * Leaves with system-wide error code in case of error.
1167 * @param aFileName: Full path to file.
1168 * @param aPreviewUri: Out: URI of the embedded preview or PreviewRights URL. Must be freed by caller
1169 * @return preview type
1171 IMPORT_C TDRMHelperPreviewType HasPreviewL(TDesC& aFileName, HBufC8*& aPreviewUri);
1174 * Acquires preview rights for given content.
1175 * Leaves with system-wide error code in case of error.
1176 * @param aContent: Content object
1178 IMPORT_C void GetPreviewRightsL(CData& aContent);
1181 * Acquires preview rights for given content.
1182 * Leaves with system-wide error code in case of error.
1183 * @param aFileName: Full path to file.
1185 IMPORT_C void GetPreviewRightsL(TDesC& aFileName);
1188 * This method should be called after embedded preview has been played.
1189 * It asks from user if he/she wants to buy rights and acquires those if user agrees.
1190 * Leaves with system-wide error code in case of error.
1191 * @param aContent: Content object.
1192 * @return ETrue if user selects to buy rights.
1194 IMPORT_C TBool EmbeddedPreviewCompletedL(CData& aContent);
1197 * This method should be called after embedded preview has been played.
1198 * It asks from user if he/she wants to buy rights and acquires those if user agrees.
1199 * Leaves with system-wide error code in case of error.
1200 * @param aFileName: Full path to file.
1201 * @return ETrue if user selects to buy rights.
1203 IMPORT_C TBool EmbeddedPreviewCompletedL(TDesC& aFileName);
1206 * Checks if given content has InfoUrl.
1207 * Leaves with system-wide error code in case of error.
1208 * @param aContent: Content object.
1209 * @param aInfoUrl: Out: InfoUrl. Must be freed by caller.
1210 * @return ETrue if content has InfoUrl.
1212 IMPORT_C TBool HasInfoUrlL(CData& aContent, HBufC8*& aInfoUrl);
1215 * Checks if given content has InfoUrl.
1216 * Leaves with system-wide error code in case of error.
1217 * @param aFileName: Full path to file.
1218 * @param aInfoUrl: Out: InfoUrl. Must be freed by caller.
1219 * @return ETrue if content has InfoUrl.
1221 IMPORT_C TBool HasInfoUrlL(TDesC& aFileName, HBufC8*& aInfoUrl);
1224 * Opens browser with InfoUrl of the content.
1225 * Leaves with system-wide error code in case of error.
1226 * @param aContent: Content object.
1228 IMPORT_C void OpenInfoUrlL(CData& aContent);
1231 * Opens browser with InfoUrl of the content.
1232 * Leaves with system-wide error code in case of error.
1233 * @param aFileName: Full path to file.
1235 IMPORT_C void OpenInfoUrlL(TDesC& aFileName);
1238 * Sets the type of automated content to be registered. This method
1239 * should be called before calling any of SetAutomated* methods.
1240 * @param aAutomatedType: type of automated content
1241 * @return System wide error code
1242 * @since Series 60 3.0
1244 IMPORT_C TInt SetAutomatedType( TDRMHelperAutomatedType aAutomatedType );
1247 * Sets media type of content for preview. Should be called prior to
1248 * calling HandleErrorOrPreviewL or EmbeddedPreviewCompletedL.
1249 * @param aMediaType: media type of content.
1250 * @return System wide error code
1253 IMPORT_C TInt SetPreviewMediaType(
1254 TDRMHelperPreviewMediaType aMediaType );
1256 protected: // New functions
1259 * ?member_description.
1260 * @since ?Series60_version
1261 * @param ?arg1 ?description
1262 * @return ?description
1264 //?type ?member_function( ?type ?arg1 );
1266 protected: // Functions from base classes
1269 * From ?base_class ?member_description
1271 //?type ?member_function();
1277 * C++ default constructor.
1279 CDRMHelper( CCoeEnv& aCoeEnv );
1283 * By default Symbian 2nd phase constructor is private.
1285 void ConstructL( RFs* aFs );
1287 // Prohibit copy constructor if not deriving from CBase.
1288 // ?classname( const ?classname& );
1289 // Prohibit assigment operator if not deriving from CBase.
1290 // ?classname& operator=( const ?classname& );
1293 * Display query dialog
1295 TInt DisplayQueryWithIdL( TInt aTextResourceId, TInt aQueryResourceId );
1296 TInt DisplayQueryWithIdValueL( TInt aTextResourceId, TInt aQueryResourceId,
1297 const TDesC& aString );
1298 TInt DisplayQueryL( TInt aTextResourceId, TInt aValue );
1299 TInt DisplayQueryL( TInt aTextResourceId, const TDesC& aString );
1301 TInt aTextResourceId,
1302 const TDesC& aString,
1304 TInt aStringPos = -1,
1305 TInt aValuePos = -1 );
1306 TInt DisplayQueryL( TDesC& aPromptText, TInt aQueryResourceId );
1309 * Display information note
1311 void DisplayInfoNoteL( TInt aTextResourceId );
1312 void DisplayInfoNoteL( TInt aTextResourceId, const TDesC& aString );
1313 void DisplayInfoNoteL( TInt aTextResourceId, TInt aValue );
1314 void DisplayInfoNoteL( TDesC& aPromptText, TInt aResourceId,
1315 const TDesC& aString = KNullDesC, TInt aValue = -1 );
1318 * Launch browser embedded
1320 void LaunchBrowserL( HBufC8* aUrl );
1321 void LaunchBrowserL( HBufC* aUrl );
1324 * Get rights-issuer URI from DCF file
1326 void GetRightsIssuerL( const CData& aContent, HBufC*& aIssuer );
1329 * Get time and count based constraints
1331 TInt GetCounts( CDRMRightsConstraints* aConstraint,
1332 TUint32& aOriginalCount, TTimeIntervalDays& aDuration );
1334 TInt GetCounts( CDRMRightsConstraints* aConstraint,
1335 TUint32& aCountLeft, TTime& aEndTime );
1337 TInt GetCounts( CDRMConstraint* aConstraint,
1338 TUint32& aOriginalCount, TTimeIntervalDays& aDuration );
1340 TInt GetCounts( CDRMConstraint* aConstraint,
1341 TUint32& aCountLeft, TTime& aEndTime );
1344 * Launch rights manager UI
1346 void LaunchRightsManagerUiL( const TDesC& aParam16 );
1349 * Form string needed to launch rights manager UI embedded.
1351 void CreateLaunchParamL( TUint32 aLocalId, const HBufC8* aUrl,
1352 HBufC*& aLaunchParam );
1355 * Strip path and extension from given filename.
1356 * Caller is responsible for freeing returned buffer
1358 TPtrC StripPathAndExtension( const TDesC& aFileName );
1361 * Get expiration details of file.
1362 * Returns DRMCommon::ENoRights if no rights object found or
1363 * CDRMRights::TExpiration value
1365 TInt GetExpirationDetails( HBufC8* aContentUri, TInt aIntent,
1366 CDRMRights*& aRightsObject );
1369 * Get expiration time of given rights object
1371 TInt CalculateEndTime( CDRMRights* aRights, TInt aIntent,
1372 TTime& aEndTime, TBool& aInactive );
1375 * Get end time of given constraint
1377 TInt GetEndTime( CDRMRightsConstraints* aConstraint,
1378 TTime& aEndTime, TBool& aInactive );
1381 * Register content as automated
1383 TInt PerformSetAutomatedL( const CData& aContent, TBool aActive );
1384 TInt DoSetAutomatedL( const TDesC8& aURI, TBool aActive,
1385 const HBufC* aMimeType );
1388 * Display confirmation query about setting as automated. Does not
1389 * actually register.
1391 TInt PerformShowAutomatedNoteL( const CData& aContent );
1392 TInt DoShowAutomatedNoteL( const TDesC8& aURI,
1393 const HBufC* aMimeType );
1396 * Register content as automated without showing any queries
1398 TInt PerformSetAutomatedSilentL( const CData& aContent, TBool aActive );
1399 TInt DoSetAutomatedSilent( const TDesC8& aURI, TBool aActive, TInt aIntent );
1402 * Returns default intent for the mimetype
1404 TInt Intent( const HBufC* aMimeType );
1407 * Checks if content can be used as automated content
1409 TInt PerformCanSetAutomatedL( const CData& aContent,TBool& aValue );
1410 TInt DoCanSetAutomated( const TDesC8& aURI, const HBufC* aMimeType,
1412 TBool DoCheckSkinCanSetAutomated(CDRMRights* aRights);
1415 * Gets mimetype based on content URI
1417 HBufC* MimeTypeFromURIL( const TDesC8& aURI );
1420 * Gets corresponding filename (including full path) based on content
1423 TInt GetFileHandleFromURIL( const TDesC8& aURI, RFile& aFileHandle );
1426 * Get start time of given rights object
1428 TInt GetStartTime( CDRMRights* aRights, TInt aIntent,
1429 TTime& aStartTime );
1432 * Displays info note of rights that are not yet valid
1434 TInt ShowFutureNoteL( const HBufC* aMimeType, CDRMRights* aRightsObject );
1437 * Handles error by displaying appropriate note to user.
1439 TInt DoHandleErrorL( TInt aError, HBufC8* aContentUri, HBufC* aMimeType,
1440 HBufC* aRIUrl, HBufC* aDomainRoUrl, HBufC* aEta, HBufC8* aRiId8,
1441 HBufC8* aDomainId8, const TDesC& aFileName );
1444 * Checks if rights are about to expire.
1446 TInt DoCheckRightsPercentL( HBufC8* aContentUri, HBufC* aMimeType,
1447 HBufC* aRIUrl, const TDesC& aFileName, TInt aThreshold );
1449 TInt DoCheckRightsAmountL( HBufC8* aContentUri, HBufC* aMimeType,
1450 HBufC* aRIUrl, const TDesC& aFileName, TInt aCount, TInt aDays );
1453 * Gets rights details.
1455 void DoGetRightsDetailsL( HBufC8* aContentUri, TUint32 aIntent,
1456 TBool& aExpired, CDRMHelperRightsConstraints*& aPlay,
1457 CDRMHelperRightsConstraints*& aDisplay,
1458 CDRMHelperRightsConstraints*& aExecute,
1459 CDRMHelperRightsConstraints*& aPrint );
1461 void DoGetRightsDetailsL( CData* aContent, TUint32 aIntent,
1462 TBool& aExpired, TBool& aSendingAllowed, CDRMRightsConstraints*& aPlay,
1463 CDRMRightsConstraints*& aDisplay,
1464 CDRMRightsConstraints*& aExecute,
1465 CDRMRightsConstraints*& aPrint );
1468 * Get constraints for given rights
1470 void GetConstraintsL(
1471 CDRMRights& aRights,
1472 CDRMHelperRightsConstraints*& aPlay,
1473 CDRMHelperRightsConstraints*& aDisplay,
1474 CDRMHelperRightsConstraints*& aExecute,
1475 CDRMHelperRightsConstraints*& aPrint );
1478 * Unregisters automated content.
1480 TInt PerformRemoveAutomatedL( const CData& aContent, TBool aActive );
1482 void HandleServerAppExit(TInt aReason);
1484 void CheckPreviewUriL(
1485 const CData* aContent,
1486 HBufC*& aEmbeddedPreviewUri,
1487 TInt& aPreviewType );
1489 TInt DisplayPopupWindowsForPreviewL(TInt aPreviewType);
1492 * Returns correct resource id for automated content notes.
1493 * If aExpired is ETrue, aSecondParameter indicates if RI URL exists
1494 * If aExpired is EFalse, aSecondParameter indicates if there is one day left
1495 * aRejectReason tells the constraints which are invalid.
1497 TInt AutomatedResIdL( TBool aExpired, TBool aSecondParameter, TUint32 aRejectReason );
1500 * Returns the correct resource id for expired and no rights notes
1502 TInt ErrorResIdL( const TDesC8& aContentUri, TInt aIntent,
1503 TBool aRightsIssuer, TBool aExpired );
1506 * Returns the constraints which are invalid
1508 TUint32 RejectReasonL( TInt aIntent, const TDesC8& aContentUri );
1511 * Prepares secondary display for DRM notes
1513 void PrepareSecondaryDisplayL( CEikDialog& aDialog, TInt aResourceId,
1514 const TDesC& aString = KNullDesC, TInt aValue = -1 );
1517 * Cancels secondary display for DRM notes
1519 void CancelSecondaryDisplayL( TInt aResourceId );
1522 * Check whether a file as a silent rights URL which can be used, i.e the URL is valid
1523 * and on the white list.
1525 HBufC8* HasSilentRightsUrlL( CData* aContent );
1528 * Get rights silently
1530 TInt GetSilentRightsL( const TDesC8& aUrl );
1533 * Check if the user has allowed silent rights
1535 TBool SilentRightsAllowedL();
1538 * Check if browser AP has been defined
1540 TBool BrowserAPDefinedL();
1543 // ?one_line_short_description_of_data
1544 //?data_declaration;
1550 DRMCommon* iDRMCommon;
1552 // used to make launching rights manager ui synchronous
1553 CActiveSchedulerWait iWait;
1555 RDRMHelper iHelperServer;
1560 // Used to read resources when CoeEnv is not available
1561 CStringResourceReader* iStringResourceReader;
1565 RPointerArray<CConsumeData> iConsumeList;
1567 TInt iAutomatedType;
1573 TInt iPreviewMediaType;
1575 // Used to queue up global notes
1576 RPointerArray<CDRMHelperInfoNoteWrapper> iNoteList;
1578 CSchemeHandler* iSchemeHandler;
1580 TBool iReturnCancel;
1582 // Used to send cancel events to cover ui
1583 CMediatorEventProvider* iEventProvider;
1585 public: // Friend classes
1586 protected: // Friend classes
1587 private: // Friend classes
1591 #endif // __DRMHELPER_H__