drm_plat/drm_rights_api/inc/DRMPermission.h
changeset 0 95b198f216e5
equal deleted inserted replaced
-1:000000000000 0:95b198f216e5
       
     1 /*
       
     2 * Copyright (c) 2007-2009 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:  Interface for the DRM Rights database
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef DRMPERMISSION_H
       
    20 #define DRMPERMISSION_H
       
    21 
       
    22 // INCLUDES
       
    23 
       
    24 #include <e32base.h>
       
    25 #include <caf/caf.h>
       
    26 #include "DRMTypes.h"
       
    27 
       
    28 using namespace ContentAccess;
       
    29 // CONSTANTS
       
    30 
       
    31 // MACROS
       
    32 
       
    33 // DATA TYPES
       
    34 
       
    35 // FORWARD DECLARATIONS
       
    36 class RReadStream;
       
    37 class RWriteStream;
       
    38 class CDRMConstraint;
       
    39 
       
    40 
       
    41 // FUNCTION PROTOTYPES
       
    42 
       
    43 // CLASS DECLARATION
       
    44 
       
    45 /**
       
    46 *  CDRMPermission implements the permission for OMA DRM usage
       
    47 *
       
    48 *  @lib DrmRights.dll
       
    49 *  @since S60 3.0
       
    50 */
       
    51 
       
    52 class CDRMPermission : public CBase
       
    53     {
       
    54 public:
       
    55     enum TExportMode
       
    56         {
       
    57         ECopy,
       
    58         EMove
       
    59         };
       
    60     
       
    61 public: // CBase
       
    62 
       
    63     /**
       
    64     * NewLC
       
    65     *
       
    66     * Creates a new CDRMPermission object and returns a pointer to it.
       
    67     * The function leaves the object to the cleanup stack.
       
    68     *
       
    69     * @since    3.0
       
    70     * @return   a functional CDRMPermission object, The function leaves
       
    71     *           with SymbianOS error code if an error occurs.
       
    72     */
       
    73     IMPORT_C static CDRMPermission* NewLC();
       
    74 
       
    75     /**
       
    76     * NewL
       
    77     *
       
    78     * Creates a new CDRMPermission object and returns a pointer to it.
       
    79     *
       
    80     * @since    3.0
       
    81     * @return   a functional CDRMPermission object, The function leaves
       
    82     *           with SymbianOS error code if an error occurs.
       
    83     */
       
    84     IMPORT_C static CDRMPermission* NewL();
       
    85     
       
    86     /**
       
    87     * Destructor
       
    88     */
       
    89     IMPORT_C virtual ~CDRMPermission();
       
    90 
       
    91 public: // New functions    
       
    92     /**
       
    93     * ExternalizeL
       
    94     * 
       
    95     * Writes the data of the object into the stream
       
    96     *
       
    97     * @since    3.0
       
    98     * @param    aStream : the output stream to write to
       
    99     * @return   The function leaves with Symbian OS error code if an
       
   100     *           error occurs
       
   101     */
       
   102     IMPORT_C void ExternalizeL( RWriteStream& aStream ) const;
       
   103     
       
   104     /**
       
   105     * InternalizeL
       
   106     * 
       
   107     * Reads the data of the object from the stream
       
   108     *
       
   109     * @since    3.0
       
   110     * @param    aStream : the output stream to write to
       
   111     * @return   The function leaves with Symbian OS error code if an
       
   112     *           error occurs
       
   113     */
       
   114     IMPORT_C void InternalizeL( RReadStream& aStream );
       
   115     
       
   116     /**
       
   117     * Stateful() 
       
   118     *
       
   119     * Tells if the rights object is stateful or not
       
   120     *
       
   121     * @since    3.0
       
   122     * @return   returns ETrue if the rights object is stateful
       
   123     *                   EFalse if it is not    
       
   124     */
       
   125 	IMPORT_C TBool Stateful() const;
       
   126 	
       
   127 	/**
       
   128 	* Child()
       
   129 	*
       
   130 	* Tells if the rights object is a child or not
       
   131 	*
       
   132     * @since    3.0
       
   133     * @return   returns ETrue if the rights object is child
       
   134     *                   EFalse if it is not
       
   135     */
       
   136     IMPORT_C TBool Child() const;
       
   137 
       
   138     /**
       
   139     * Size
       
   140     *
       
   141     * returns the size of the externalized object
       
   142     *
       
   143     * @since    3.0
       
   144     * @return   returns the size of the constraint
       
   145     */   
       
   146     IMPORT_C TInt Size() const;
       
   147     
       
   148     /**
       
   149     * NULL or actual constraints.
       
   150     */
       
   151     IMPORT_C CDRMConstraint* ConstraintForIntent( const ContentAccess::TIntent aIntent );
       
   152     
       
   153     /**
       
   154     * NULL or actual constraint.
       
   155     */
       
   156     IMPORT_C CDRMConstraint* TopLevelConstraint(  );
       
   157 
       
   158     /**
       
   159     * Note: Top level constraint is always consumed if it exists.
       
   160     */
       
   161     IMPORT_C void ConsumeRights( const ContentAccess::TIntent aIntent, const TTime& aCurrentTime );
       
   162 
       
   163 
       
   164     /**
       
   165     * ImportL
       
   166     * 
       
   167     * Reads the data of the object from the descriptor and initialized the 
       
   168     * object accordingly
       
   169     *
       
   170     * @since    3.0
       
   171     * @param    aBuffer : the buffer containing the data of the imported object
       
   172     * @return   None, The function leaves with Symbian OS error code if an
       
   173     *           error occurs
       
   174     */
       
   175     IMPORT_C void ImportL( const TDesC8& aBuffer );
       
   176     
       
   177     /**
       
   178     * ExportL
       
   179     * 
       
   180     * Writes the data of the object into an HBufC8 and returns a pointer
       
   181     * to it. The caller is responsible for deleting the object.
       
   182     *
       
   183     * @since    3.0
       
   184     * @return   Returns an HBufC8* containing the data of the object,
       
   185     *           The function leaves with Symbian OS error code if an
       
   186     *           error occurs
       
   187     */
       
   188     IMPORT_C HBufC8* ExportL() const;
       
   189 
       
   190     /**
       
   191     * DuplicateL
       
   192     * 
       
   193     * Copies the data of the permission into the current one.
       
   194     *
       
   195     * @since    3.0
       
   196     * @param    aPermission : the permission to duplicate into this one
       
   197     * @return   None. The function leaves with Symbian OS error code if an
       
   198     *           error occurs
       
   199     */    
       
   200     IMPORT_C void DuplicateL( const CDRMPermission& aPermission );
       
   201     
       
   202     /**
       
   203     * Expired   
       
   204     *
       
   205     * Checks if the permission has expired
       
   206     *
       
   207     * @since	3.0
       
   208     * @param	aTime : The current secure time
       
   209     *                   if the time is Time::NullTTime() time based rights
       
   210     *                   will be ignored
       
   211     * @return   ETrue if the permission has expired
       
   212     * 			EFalse if it is still valid or has future rights 
       
   213     */
       
   214     IMPORT_C TBool Expired( const TTime& aTime );
       
   215     
       
   216     
       
   217     /**
       
   218     * Valid
       
   219     *
       
   220     * returns if the permission is valid/usable at this time
       
   221     *
       
   222     * If no second parameter is given all the constraints will
       
   223     * be checked for validity and if any of them is invalid
       
   224     * the permission is considered to be invalid.
       
   225     *
       
   226     * For ERightsPlay, ERightsDisplay, ERightsExecute, ERightsPrint
       
   227     * also the toplevel constraint will be checked for validity
       
   228     *
       
   229     * @since    3.0
       
   230     * @param	aTime : current secure time, if the time is
       
   231     *			        Time::NullTTime() time based constraints
       
   232     *					will be considered to be invalid
       
   233     * @param    aIndividual : the imsi of the phone
       
   234     * @param    aRejection : return value for why the content was rejected
       
   235     * @param	aConstraint : the constraint to check validity on
       
   236     *							
       
   237     * @return   returns ETrue if the constraint is valid
       
   238     *					EFalse if the constraint is not valid
       
   239     */ 
       
   240     IMPORT_C TBool Valid( const TTime& aTime,
       
   241                           const RPointerArray<HBufC8>& aIndividual, 
       
   242                           TUint32& aRejection,
       
   243                           const TRightsType aType = ERightsAll ) const;
       
   244                           
       
   245     /**
       
   246     * Merge permission with another permission
       
   247     *
       
   248     * @since	3.0
       
   249     * @param	aPermission permission to merge with
       
   250     */
       
   251     IMPORT_C void Merge( const CDRMPermission& aPermission );
       
   252     
       
   253     /**
       
   254     * Checks if the permission has software constaints
       
   255     *
       
   256     * @since	3.0
       
   257     * @return   ETrue if the permission has software constaints, EFalse otherwise
       
   258     */
       
   259     IMPORT_C TBool SoftwareConstrained() const;
       
   260     
       
   261     
       
   262 public:
       
   263 
       
   264     // synchronizing marker
       
   265     TInt32 iSyncMark;
       
   266    
       
   267     // Version number
       
   268     TInt32 iVersion;
       
   269     
       
   270     // Unique ID of the permission
       
   271     TDRMUniqueID iUniqueID;
       
   272     
       
   273     // The original insertion time
       
   274     TTime iOriginalInsertTime;
       
   275     
       
   276     // Top level constraint
       
   277     CDRMConstraint* iTopLevel;
       
   278     
       
   279     // Play constraint
       
   280     CDRMConstraint* iPlay;
       
   281     
       
   282     // Display constraint
       
   283     CDRMConstraint* iDisplay;
       
   284     
       
   285     // Execute constraint
       
   286     CDRMConstraint* iExecute;
       
   287     
       
   288     // Print constraint
       
   289     CDRMConstraint* iPrint;
       
   290     
       
   291     // Export constraint
       
   292     CDRMConstraint* iExport;
       
   293     
       
   294     // Export mode
       
   295     TExportMode iExportMode;
       
   296     
       
   297     // Content ID of the parent rights object
       
   298     HBufC8* iParentUID;
       
   299     
       
   300     // Rights Object ID of the rights delivery container
       
   301     HBufC8* iRoID;
       
   302     
       
   303     // Domain identifier
       
   304     HBufC8* iDomainID;
       
   305     
       
   306     // Available rights
       
   307     TUint16 iAvailableRights;	// Bitmask
       
   308     
       
   309     // Version number of the rights object
       
   310     TROVersion iRightsObjectVersion;
       
   311     
       
   312     // Additional information bitvector
       
   313     TInt32 iInfoBits;
       
   314     
       
   315     // Right issuer identifier
       
   316     TBuf8<KRiIdSize> iRiId;
       
   317     
       
   318     // URL to send HTTP GET on expiration of permission 
       
   319     HBufC8* iOnExpiredUrl;
       
   320 
       
   321 protected:
       
   322 
       
   323     /**
       
   324     * Default constructor
       
   325     */
       
   326     IMPORT_C CDRMPermission();
       
   327 
       
   328 private:
       
   329 
       
   330     /**
       
   331     * 2nd phase constructor
       
   332     */
       
   333     void ConstructL();
       
   334 
       
   335     /**
       
   336     * WriteInt64L
       
   337     * 
       
   338     * Writes the 64 bit integer to the stream
       
   339     *
       
   340     * @since    3.0
       
   341     * @param    aWrite : the 64 bit integer to write
       
   342     * @param    aStream : the output stream to write to
       
   343     * @return   The function leaves with Symbian OS error code if an
       
   344     *           error occurs
       
   345     */
       
   346     void WriteInt64L( const TInt64& aWrite, RWriteStream& aStream ) const;
       
   347 
       
   348     /**
       
   349     * ReadInt64L
       
   350     * 
       
   351     * Reads the 64 bit integer from the stream
       
   352     *
       
   353     * @since    3.0
       
   354     * @param    aRead : the 64 bit integer read
       
   355     * @param    aStream : the output stream to write to
       
   356     * @return   The function leaves with Symbian OS error code if an
       
   357     *           error occurs
       
   358     */
       
   359     void ReadInt64L( TInt64& aRead, RReadStream& aStream );    
       
   360 
       
   361     };
       
   362 
       
   363 #endif      // DRMPERMISSION_H   
       
   364             
       
   365 // End of File