00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef __DRMHELPER_H__
00024 #define __DRMHELPER_H__
00025
00026
00027 #include <e32base.h>
00028 #include <ConeResLoader.h>
00029 #include <apparc.h>
00030 #include <rdrmhelper.h>
00031 #include <aknserverapp.h>
00032 #include <caf\caf.h>
00033 #include <caf\content.h>
00034 #include <caf\data.h>
00035 #include <eikdialg.h>
00036
00037 using namespace ContentAccess;
00038
00039
00040 const TInt KDRMHelperDefaultCountThreshold = 3;
00041 const TInt KDRMHelperDefaultTimeThreshold = 7;
00042 const TInt KDRMHelperDefaultPercentageThreshold = 10;
00043 const TInt KDRMHelperNoteMaxSize ( 256 );
00044
00045
00046
00047
00048 enum TDRMHelperPreviewMediaType
00049 {
00050 EPreviewTypeAudio,
00051 EPreviewTypeVideo
00052 };
00053
00054
00055
00056 class DRMCommon;
00057 class CDRMRightsConstraints;
00058 class CDRMRights;
00059 class CStringResourceReader;
00060 class TDataType;
00061 class CCoeEnv;
00062 class CConsumeData;
00063 class CDRMPermission;
00064 class CDRMConstraint;
00065 class CAknGlobalNote;
00066 class CAknWaitDialog;
00067 class CDRMHelperInfoNoteWrapper;
00068 class CSchemeHandler;
00069 class CMediatorEventProvider;
00070
00071
00072
00079 class CDRMHelperRightsConstraints : public CBase
00080 {
00081 public:
00082
00086 static CDRMHelperRightsConstraints* NewL(
00087 CDRMRightsConstraints* aConstraints );
00088 static CDRMHelperRightsConstraints* NewLC(
00089 CDRMRightsConstraints* aConstraints );
00090
00094 IMPORT_C ~CDRMHelperRightsConstraints();
00095
00096 public:
00097
00103 IMPORT_C TBool FullRights();
00104
00109 IMPORT_C TBool IsPreview();
00110
00119 IMPORT_C void GetCountersL( TUint32& aCounter,
00120 TUint32& aOriginalCounter );
00121
00128 IMPORT_C void GetStartTimeL( TTime& aStartTime );
00129
00136 IMPORT_C void GetEndTimeL( TTime& aEndTime );
00137
00144 IMPORT_C void GetIntervalL( TTimeIntervalSeconds& aInterval );
00145
00153 IMPORT_C void GetIntervalStartL( TTime& aStartTime );
00165 IMPORT_C void GetTimedCountL( TUint32& aCounter,
00166 TUint32& aOriginalCounter, TTimeIntervalSeconds& aTimer );
00167
00176 IMPORT_C void GetAccumulatedTimeL( TTimeIntervalSeconds& aAccumulatedTime );
00177
00178 private:
00179
00183 CDRMHelperRightsConstraints( CDRMRightsConstraints* aConstrains );
00184
00188 void ConstructL();
00189
00190 private:
00191
00192 CDRMRightsConstraints* iConstraints;
00193 };
00194
00195
00202 class CDRMHelper : public CBase, public MAknServerAppExitObserver
00203 {
00204 public:
00205
00206 enum TDRMHelperNotificationID
00207 {
00208 ETActivateTextId = 1,
00209 ETCountBasedErrorTextId = 2 ,
00210 ETCountUsageReduceId = 3,
00211 ETCountUsageReduceMediaId = 4
00212 };
00213
00214 enum TDRMHelperConsumeAction
00215 {
00216 EStart,
00217 EFinish,
00218 EPause,
00219 EContinue
00220 };
00221
00222 enum TDRMHelperOMALevel
00223 {
00224 EOMA_None,
00225 EOMA_1_0,
00226 EOMA_2_0
00227 };
00228
00229 enum TDRMHelperPreviewType
00230 {
00231 ENoPreview,
00232 EEmbeddedPreview,
00233 EPreviewRights
00234 };
00235
00236 enum TDRMHelperAutomatedType
00237 {
00238 EAutomatedTypeRingingTone,
00239 EAutomatedTypeMessageAlert,
00240 EAutomatedTypeEmailAlert,
00241 EAutomatedTypeIMAlert,
00242 EAutomatedTypeCalendarAlarm,
00243 EAutomatedTypeScreenSaver,
00244 EAutomatedTypeWallpaper,
00245 EAutomatedTypeTheme,
00246 EAutomatedTypeClockAlarm,
00247 EAutomatedTypeOther = KMaxTUint8
00248 };
00249
00250 enum TDRMHelperDRMMethods
00251 {
00252 EForwardLock = 0x0001,
00253 ECombinedDelivery = 0x0002,
00254 ESeparateDelivery = 0x0004,
00255 ESuperDistribution = 0x0008
00256 };
00257
00258 public:
00259
00263 IMPORT_C static CDRMHelper* NewL( CCoeEnv& aCoeEnv );
00264 IMPORT_C static CDRMHelper* NewLC( CCoeEnv& aCoeEnv );
00265
00270 IMPORT_C static CDRMHelper* NewL();
00271 IMPORT_C static CDRMHelper* NewLC();
00272
00277 IMPORT_C static CDRMHelper* NewL( CCoeEnv& aCoeEnv, RFs& aFs );
00278 IMPORT_C static CDRMHelper* NewLC( CCoeEnv& aCoeEnv, RFs& aFs );
00279
00284 IMPORT_C static CDRMHelper* NewL( RFs& aFs );
00285 IMPORT_C static CDRMHelper* NewLC( RFs& aFs );
00286
00290 IMPORT_C ~CDRMHelper();
00291
00292
00293 public:
00294
00306 IMPORT_C TInt HandleErrorL( TInt aError,
00307 const TDesC8& aURI );
00308
00309
00323 IMPORT_C TInt HandleErrorL( TInt aError,
00324 const TDesC& aFileName );
00325
00326
00341 IMPORT_C TInt HandleErrorL( TInt aError,
00342 RFile& aFileHandle );
00343
00363 IMPORT_C TInt HandleErrorOrPreviewL(
00364 TInt aError,
00365 RFile& aFile,
00366 HBufC8*& aEmbeddedPreviewUri );
00367
00387 IMPORT_C TInt HandleErrorOrPreviewL(
00388 TInt aError,
00389 const TDesC& aFileName,
00390 HBufC8*& aEmbeddedPreviewUri );
00391
00399
00400
00401
00402
00410
00411
00412
00413
00422
00423
00424
00425
00442 IMPORT_C TInt CheckRightsAmountL( const TDesC& aFileName,
00443 TInt aCount = KDRMHelperDefaultCountThreshold,
00444 TInt aDays = KDRMHelperDefaultTimeThreshold );
00445
00446
00464 IMPORT_C TInt CheckRightsAmountL( RFile& aFileHandle,
00465 TInt aCount = KDRMHelperDefaultCountThreshold,
00466 TInt aDays = KDRMHelperDefaultTimeThreshold );
00467
00468
00485 IMPORT_C TInt CheckRightsAmountL( const TDesC8& aUri,
00486 TInt aCount = KDRMHelperDefaultCountThreshold,
00487 TInt aDays = KDRMHelperDefaultTimeThreshold );
00488
00489
00505 IMPORT_C TInt CheckRightsPercentL( const TDesC& aFileName,
00506 TInt aThreshold = KDRMHelperDefaultPercentageThreshold );
00507
00508
00525 IMPORT_C TInt CheckRightsPercentL( RFile& aFileHandle,
00526 TInt aThreshold = KDRMHelperDefaultPercentageThreshold );
00527
00528
00535 IMPORT_C void LaunchDetailsViewEmbeddedL(
00536 const TDesC8& aURI );
00537
00538
00545 IMPORT_C void LaunchDetailsViewEmbeddedL(
00546 const TDesC& aFileName );
00547
00548
00556 IMPORT_C void LaunchDetailsViewEmbeddedL(
00557 RFile& aFileHandle );
00558
00559
00566 IMPORT_C void LaunchDetailsViewEmbeddedL(
00567 const HBufC8* aContentURI );
00568
00569
00589 IMPORT_C void GetRightsDetailsL( const TDesC& aFileName,
00590 TUint32 aIntent, TBool& aExpired, TBool& aSendingAllowed,
00591 CDRMHelperRightsConstraints*& aPlay,
00592 CDRMHelperRightsConstraints*& aDisplay,
00593 CDRMHelperRightsConstraints*& aExecute,
00594 CDRMHelperRightsConstraints*& aPrint );
00595
00596
00618 IMPORT_C void GetRightsDetailsL( RFile& aFileHandle,
00619 TUint32 aIntent, TBool& aExpired, TBool& aSendingAllowed,
00620 CDRMHelperRightsConstraints*& aPlay,
00621 CDRMHelperRightsConstraints*& aDisplay,
00622 CDRMHelperRightsConstraints*& aExecute,
00623 CDRMHelperRightsConstraints*& aPrint );
00624
00625
00645 IMPORT_C void GetRightsDetailsL( const TDesC& aFileName,
00646 TUint32 aIntent, TBool& aExpired, TBool& aSendingAllowed,
00647 CDRMRightsConstraints*& aPlay,
00648 CDRMRightsConstraints*& aDisplay,
00649 CDRMRightsConstraints*& aExecute,
00650 CDRMRightsConstraints*& aPrint );
00651
00652
00674 IMPORT_C void GetRightsDetailsL( RFile& aFileHandle,
00675 TUint32 aIntent, TBool& aExpired, TBool& aSendingAllowed,
00676 CDRMRightsConstraints*& aPlay,
00677 CDRMRightsConstraints*& aDisplay,
00678 CDRMRightsConstraints*& aExecute,
00679 CDRMRightsConstraints*& aPrint );
00680
00681
00691 IMPORT_C TInt SetAutomated( const TDesC8& aURI );
00692
00693
00703 IMPORT_C TInt SetAutomated( const TDesC& aFilename );
00704
00705
00714 IMPORT_C TInt SetAutomated( RFile& aFileHandle );
00715
00716
00726 IMPORT_C TInt ShowAutomatedNote( const TDesC8& aURI );
00727
00728
00738 IMPORT_C TInt ShowAutomatedNote( const TDesC& aFilename );
00739
00740
00750 IMPORT_C TInt ShowAutomatedNote( RFile& aFileHandle );
00751
00752
00761 IMPORT_C TInt SetAutomatedPassive( const TDesC8& aURI );
00762
00763
00772 IMPORT_C TInt SetAutomatedPassive( const TDesC& aFilename );
00773
00774
00783 IMPORT_C TInt SetAutomatedPassive( RFile& aFileHandle );
00784
00785
00796 IMPORT_C TInt SetAutomatedSilent( const TDesC8& aURI, TBool aActive );
00797
00798
00809 IMPORT_C TInt SetAutomatedSilent( const TDesC& aFilename,
00810 TBool aActive );
00811
00812
00823 IMPORT_C TInt SetAutomatedSilent( RFile& aFileHandle,
00824 TBool aActive );
00825
00826
00833 IMPORT_C TInt RemoveAutomated( const TDesC8& aURI );
00834
00835
00842 IMPORT_C TInt RemoveAutomated( const TDesC& aFilename );
00843
00844
00851 IMPORT_C TInt RemoveAutomated( RFile& aFileHandle );
00852
00853
00862 IMPORT_C TInt RemoveAutomatedPassive( const TDesC8& aURI );
00863
00864
00873 IMPORT_C TInt RemoveAutomatedPassive( const TDesC& aFilename );
00874
00875
00884 IMPORT_C TInt RemoveAutomatedPassive( RFile& aFileHandle );
00885
00886
00894 IMPORT_C TInt CanSetAutomated( const TDesC8& aURI,
00895 TBool& aValue );
00896
00897
00905 IMPORT_C TInt CanSetAutomated( const TDesC& aFilename,
00906 TBool& aValue );
00907
00908
00916 IMPORT_C TInt CanSetAutomated( RFile& aFileHandle,
00917 TBool& aValue );
00918
00919
00925 IMPORT_C void IndicateIdle();
00926
00934 IMPORT_C TInt ShowDRMUINotification2L( TDRMHelperNotificationID aTextId,
00935 const TDesC8& aURI );
00936
00937
00945 IMPORT_C TInt ShowDRMUINotification2L( TDRMHelperNotificationID aTextId,
00946 const TDesC& aFileName );
00947
00948
00954 IMPORT_C void SetCountLimitL( TUint aCounts );
00955
00956
00962 IMPORT_C void SetTimeLimitL( TUint aDays );
00963
00964
00970 IMPORT_C void SetPercentageLimitL( TUint aPercentage );
00971
00972
00983 IMPORT_C TInt GetContentURIList(
00984 RPointerArray<HBufC8>*& aURIList);
00985
00986
00997 IMPORT_C TInt DataTypesCount(
00998 TInt& aCount);
00999
01000
01011 IMPORT_C TInt SupportedDataType(
01012 const TInt aIndex, TDataType& aDataType);
01013
01014
01024 IMPORT_C TInt RegisterDataType(
01025 const TDataType& aDataType);
01026
01027
01037 IMPORT_C TInt UnRegisterDataType(
01038 const TInt aIndex);
01039
01040
01055 IMPORT_C TInt SupportedDRMMethods2(
01056 TInt& aDRMMethod, TDRMHelperOMALevel& aOMALevel);
01057
01058
01080 IMPORT_C TInt Consume2(
01081 const TDesC8& aContentURI,
01082 TUint32 aRightsSpec,
01083 TDRMHelperConsumeAction anAction);
01084
01085
01107 IMPORT_C TInt ConsumeFile2(
01108 const TDesC& aFileName,
01109 TUint32 aRightsSpec,
01110 TDRMHelperConsumeAction anAction);
01111
01112
01134 IMPORT_C TInt ConsumeFile2(
01135 RFile& aFileHandle,
01136 TUint32 aRightsSpec,
01137 TDRMHelperConsumeAction anAction);
01138
01146 IMPORT_C void ActivateContentL(CData& aContent);
01147
01155 IMPORT_C void ActivateContentL(TDesC& aFileName);
01156
01164 IMPORT_C TDRMHelperPreviewType HasPreviewL(CData& aContent, HBufC8*& aPreviewUri);
01165
01173 IMPORT_C TDRMHelperPreviewType HasPreviewL(TDesC& aFileName, HBufC8*& aPreviewUri);
01174
01180 IMPORT_C void GetPreviewRightsL(CData& aContent);
01181
01187 IMPORT_C void GetPreviewRightsL(TDesC& aFileName);
01188
01196 IMPORT_C TBool EmbeddedPreviewCompletedL(CData& aContent);
01197
01205 IMPORT_C TBool EmbeddedPreviewCompletedL(TDesC& aFileName);
01206
01214 IMPORT_C TBool HasInfoUrlL(CData& aContent, HBufC8*& aInfoUrl);
01215
01223 IMPORT_C TBool HasInfoUrlL(TDesC& aFileName, HBufC8*& aInfoUrl);
01224
01230 IMPORT_C void OpenInfoUrlL(CData& aContent);
01231
01237 IMPORT_C void OpenInfoUrlL(TDesC& aFileName);
01238
01246 IMPORT_C TInt SetAutomatedType( TDRMHelperAutomatedType aAutomatedType );
01247
01255 IMPORT_C TInt SetPreviewMediaType(
01256 TDRMHelperPreviewMediaType aMediaType );
01257
01258 protected:
01259
01266
01267
01268 protected:
01269
01273
01274
01275
01276 private:
01277
01281 CDRMHelper( CCoeEnv& aCoeEnv );
01282 CDRMHelper();
01283
01287 void ConstructL( RFs* aFs );
01288
01289
01290
01291
01292
01293
01297 TInt DisplayQueryWithIdL( TInt aTextResourceId, TInt aQueryResourceId );
01298 TInt DisplayQueryWithIdValueL( TInt aTextResourceId, TInt aQueryResourceId,
01299 const TDesC& aString );
01300 TInt DisplayQueryL( TInt aTextResourceId, TInt aValue );
01301 TInt DisplayQueryL( TInt aTextResourceId, const TDesC& aString );
01302 TInt DisplayQueryL(
01303 TInt aTextResourceId,
01304 const TDesC& aString,
01305 TInt aValue,
01306 TInt aStringPos = -1,
01307 TInt aValuePos = -1 );
01308 TInt DisplayQueryL( TDesC& aPromptText, TInt aQueryResourceId );
01309
01313 void DisplayInfoNoteL( TInt aTextResourceId );
01314 void DisplayInfoNoteL( TInt aTextResourceId, const TDesC& aString );
01315 void DisplayInfoNoteL( TInt aTextResourceId, TInt aValue );
01316 void DisplayInfoNoteL( TDesC& aPromptText, TInt aResourceId,
01317 const TDesC& aString = KNullDesC, TInt aValue = -1 );
01318
01322 void LaunchBrowserL( HBufC8* aUrl );
01323 void LaunchBrowserL( HBufC* aUrl );
01324
01328 void GetRightsIssuerL( const CData& aContent, HBufC*& aIssuer );
01329
01333 TInt GetCounts( CDRMRightsConstraints* aConstraint,
01334 TUint32& aOriginalCount, TTimeIntervalDays& aDuration );
01335
01336 TInt GetCounts( CDRMRightsConstraints* aConstraint,
01337 TUint32& aCountLeft, TTime& aEndTime );
01338
01339 TInt GetCounts( CDRMConstraint* aConstraint,
01340 TUint32& aOriginalCount, TTimeIntervalDays& aDuration );
01341
01342 TInt GetCounts( CDRMConstraint* aConstraint,
01343 TUint32& aCountLeft, TTime& aEndTime );
01344
01348 void LaunchRightsManagerUiL( const TDesC& aParam16 );
01349
01353 void CreateLaunchParamL( TUint32 aLocalId, const HBufC8* aUrl,
01354 HBufC*& aLaunchParam );
01355
01360 TPtrC StripPathAndExtension( const TDesC& aFileName );
01361
01367 TInt GetExpirationDetails( HBufC8* aContentUri, TInt aIntent,
01368 CDRMRights*& aRightsObject );
01369
01373 TInt CalculateEndTime( CDRMRights* aRights, TInt aIntent,
01374 TTime& aEndTime, TBool& aInactive );
01375
01379 TInt GetEndTime( CDRMRightsConstraints* aConstraint,
01380 TTime& aEndTime, TBool& aInactive );
01381
01385 TInt PerformSetAutomatedL( const CData& aContent, TBool aActive );
01386 TInt DoSetAutomatedL( const TDesC8& aURI, TBool aActive,
01387 const HBufC* aMimeType );
01388
01393 TInt PerformShowAutomatedNoteL( const CData& aContent );
01394 TInt DoShowAutomatedNoteL( const TDesC8& aURI,
01395 const HBufC* aMimeType );
01396
01400 TInt PerformSetAutomatedSilentL( const CData& aContent, TBool aActive );
01401 TInt DoSetAutomatedSilent( const TDesC8& aURI, TBool aActive, TInt aIntent );
01402
01406 TInt Intent( const HBufC* aMimeType );
01407
01411 TInt PerformCanSetAutomatedL( const CData& aContent,TBool& aValue );
01412 TInt DoCanSetAutomated( const TDesC8& aURI, const HBufC* aMimeType,
01413 TBool& aValue );
01414 TBool DoCheckSkinCanSetAutomated(CDRMRights* aRights);
01415
01419 HBufC* MimeTypeFromURIL( const TDesC8& aURI );
01420
01425 TInt GetFileHandleFromURIL( const TDesC8& aURI, RFile& aFileHandle );
01426
01430 TInt GetStartTime( CDRMRights* aRights, TInt aIntent,
01431 TTime& aStartTime );
01432
01436 TInt ShowFutureNoteL( const HBufC* aMimeType, CDRMRights* aRightsObject );
01437
01441 TInt DoHandleErrorL( TInt aError, HBufC8* aContentUri, HBufC* aMimeType,
01442 HBufC* aRIUrl, HBufC* aDomainRoUrl, HBufC* aEta, HBufC8* aRiId8,
01443 HBufC8* aDomainId8, const TDesC& aFileName );
01444
01448 TInt DoCheckRightsPercentL( HBufC8* aContentUri, HBufC* aMimeType,
01449 HBufC* aRIUrl, const TDesC& aFileName, TInt aThreshold );
01450
01451 TInt DoCheckRightsAmountL( HBufC8* aContentUri, HBufC* aMimeType,
01452 HBufC* aRIUrl, const TDesC& aFileName, TInt aCount, TInt aDays );
01453
01457 void DoGetRightsDetailsL( HBufC8* aContentUri, TUint32 aIntent,
01458 TBool& aExpired, CDRMHelperRightsConstraints*& aPlay,
01459 CDRMHelperRightsConstraints*& aDisplay,
01460 CDRMHelperRightsConstraints*& aExecute,
01461 CDRMHelperRightsConstraints*& aPrint );
01462
01463 void DoGetRightsDetailsL( CData* aContent, TUint32 aIntent,
01464 TBool& aExpired, TBool& aSendingAllowed, CDRMRightsConstraints*& aPlay,
01465 CDRMRightsConstraints*& aDisplay,
01466 CDRMRightsConstraints*& aExecute,
01467 CDRMRightsConstraints*& aPrint );
01468
01472 void GetConstraintsL(
01473 CDRMRights& aRights,
01474 CDRMHelperRightsConstraints*& aPlay,
01475 CDRMHelperRightsConstraints*& aDisplay,
01476 CDRMHelperRightsConstraints*& aExecute,
01477 CDRMHelperRightsConstraints*& aPrint );
01478
01482 TInt PerformRemoveAutomatedL( const CData& aContent, TBool aActive );
01483
01484 void HandleServerAppExit(TInt aReason);
01485
01486 void CheckPreviewUriL(
01487 const CData* aContent,
01488 HBufC*& aEmbeddedPreviewUri,
01489 TInt& aPreviewType );
01490
01491 TInt DisplayPopupWindowsForPreviewL(TInt aPreviewType);
01492
01499 TInt AutomatedResIdL( TBool aExpired, TBool aSecondParameter, TUint32 aRejectReason );
01500
01504 TInt ErrorResIdL( const TDesC8& aContentUri, TInt aIntent,
01505 TBool aRightsIssuer, TBool aExpired );
01506
01510 TUint32 RejectReasonL( TInt aIntent, const TDesC8& aContentUri );
01511
01515 void PrepareSecondaryDisplayL( CEikDialog& aDialog, TInt aResourceId,
01516 const TDesC& aString = KNullDesC, TInt aValue = -1 );
01517
01521 void CancelSecondaryDisplayL( TInt aResourceId );
01522
01527 HBufC8* HasSilentRightsUrlL( CData* aContent );
01528
01532 TInt GetSilentRightsL( const TDesC8& aUrl );
01533
01537 TBool SilentRightsAllowedL();
01538
01542 TBool BrowserAPDefinedL();
01543
01544 protected:
01545
01546
01547
01548 private:
01549 CCoeEnv* iCoeEnv;
01550
01551
01552 DRMCommon* iDRMCommon;
01553
01554
01555 CActiveSchedulerWait iWait;
01556
01557 RDRMHelper iHelperServer;
01558
01559
01560 TBool iUseCoeEnv;
01561
01562
01563 CStringResourceReader* iStringResourceReader;
01564
01565 TBool iOma2;
01566
01567 RPointerArray<CConsumeData> iConsumeList;
01568
01569 TInt iAutomatedType;
01570
01571 RFs iFs;
01572
01573 TBool iFsOwned;
01574
01575 TInt iPreviewMediaType;
01576
01577
01578 RPointerArray<CDRMHelperInfoNoteWrapper> iNoteList;
01579
01580 CSchemeHandler* iSchemeHandler;
01581
01582 TBool iReturnCancel;
01583
01584
01585 CMediatorEventProvider* iEventProvider;
01586
01587 public:
01588 protected:
01589 private:
01590
01591 };
01592
01593
01594 #endif
01595
01596
01597