omadrm/drmengine/server/inc/DRMRightsData.h
changeset 0 95b198f216e5
equal deleted inserted replaced
-1:000000000000 0:95b198f216e5
       
     1 /*
       
     2 * Copyright (c) 2003 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:  Datatype for Rights Constraint
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef DRMRIGHTSDATA_H
       
    20 #define DRMRIGHTSDATA_H
       
    21 
       
    22 // INCLUDES
       
    23 
       
    24 #include <e32base.h>
       
    25 #include "DRMTypes.h"
       
    26 
       
    27 // CONSTANTS
       
    28 
       
    29 // MACROS
       
    30 
       
    31 // DATA TYPES
       
    32 
       
    33 // FORWARD DECLARATIONS
       
    34 class CDRMPermission;
       
    35 class CDRMCommonData;
       
    36 class CPermanentFileStore;
       
    37 class RWriteStream;
       
    38 class TStreamId;
       
    39 
       
    40 // TYPE DEFINITIONS
       
    41 
       
    42 // FUNCTION PROTOTYPES
       
    43 
       
    44 // CLASS DECLARATION
       
    45 
       
    46 /**
       
    47 *  CDRMRightsData implements the rights database required by DRM Engine
       
    48 *
       
    49 *  @lib RightsServer.dll
       
    50 *  @since 3.0
       
    51 */
       
    52 
       
    53 NONSHARABLE_CLASS( CDRMRightsData ) : public CBase 
       
    54     {
       
    55 public: // Constructors and destructor
       
    56     /**
       
    57     * NewLC
       
    58     *
       
    59     * Creates an instance of the CDRMRightsData class and returns a pointer 
       
    60     * to it. The function leaves the object into the cleanup stack
       
    61     *
       
    62     * @since  3.0
       
    63     * @param    aData : The common data to store takes possession of the data
       
    64     * @param    aKey : Key of the content
       
    65     * @param    aRightsFile : Full pathname of the rights store
       
    66     * @param    aFileServer : File server instance to use
       
    67     * @return   Functional CDRMRightsData object, Function leaves if an error 
       
    68     *           occurs.
       
    69     */
       
    70     static CDRMRightsData* NewLC( CDRMCommonData* aData,
       
    71                                   const TDesC8& aKey, 
       
    72                                   const TFileName& aRightsFile,
       
    73                                   RFs& aFileServer );
       
    74     
       
    75     /**
       
    76     * NewL
       
    77     *
       
    78     * Creates an instance of the CDRMRightsData class and returns a pointer 
       
    79     * to it.
       
    80     *
       
    81     * @since  3.0
       
    82     * @param    aData : The common data to store takes possession of the data
       
    83     * @param    aKey : Key of the content
       
    84     * @param    aRightsFile : Full pathname of the rights store
       
    85     * @param    aFileServer : File server instance to use    
       
    86     * @return   Functional CDRMRightsData object, Function leaves if an error 
       
    87     *           occurs.
       
    88     */
       
    89     static CDRMRightsData* NewL( CDRMCommonData* aData, 
       
    90                                  const TDesC8& aKey,
       
    91                                  const TFileName& aRightsFile,
       
    92                                  RFs& aFileServer );
       
    93     /**
       
    94     * OpenLC
       
    95     *
       
    96     * Opens the store and creates an instance of the CDRMRightsData class and returns
       
    97     * a pointer to it. The function leaves the object into the cleanup stack
       
    98     *
       
    99     * @since  3.0
       
   100     * @param  aRightsFile : Full pathname of the rights store
       
   101     * @param    aFileServer : File server instance to use    
       
   102     * @return Functional CDRMRightsData object, Function leaves if an error 
       
   103     *         occurs.
       
   104     */
       
   105     static CDRMRightsData* OpenLC( const TFileName& aRightsFile,
       
   106                                    RFs& aFileServer );
       
   107     /**
       
   108     * OpenL
       
   109     *
       
   110     * Opens the store and creates an instance of the CDRMRightsData class and returns
       
   111     * a pointer to it.
       
   112     *
       
   113     * @since  3.0
       
   114     * @param  aRightsFile : Full pathname of the rights store
       
   115     * @param    aFileServer : File server instance to use    
       
   116     * @return Functional CDRMRightsData object, Function leaves if an error 
       
   117     *         occurs.
       
   118     */
       
   119     static CDRMRightsData* OpenL( const TFileName& aRightsFile,
       
   120                                   RFs& aFileServer );
       
   121 
       
   122     /*
       
   123     * Destructor
       
   124     */ 
       
   125     virtual ~CDRMRightsData(); 
       
   126 
       
   127 
       
   128 public: // New functions
       
   129 
       
   130     /**
       
   131     * GetCommonDataL
       
   132     * 
       
   133     * returns a pointer a common data object
       
   134     *
       
   135     * @since    3.0
       
   136     * @return   The function leaves with Symbian OS error code if an
       
   137     *           error occurs
       
   138     */
       
   139     const CDRMCommonData* GetCommonDataL() const;
       
   140 
       
   141     /**
       
   142     * UpdateCommonDataL
       
   143     * 
       
   144     * Updates the common data part
       
   145     *
       
   146     * @since    3.0
       
   147     * @return   The function leaves with Symbian OS error code if an
       
   148     *           error occurs
       
   149     */
       
   150     void UpdateCommonDataL( CDRMCommonData *aData );        
       
   151     
       
   152     /**
       
   153     * StoreNewPermissionL
       
   154     * 
       
   155     * Writes the data of the permission to the store and returns
       
   156     * the stream id
       
   157     *
       
   158     * @since    3.0
       
   159     * @param    aPermission : CDRMPermission class to externalize
       
   160     * @param    aStream : the output stream to write to
       
   161     * @return   The function leaves with Symbian OS error code if an
       
   162     *           error occurs
       
   163     */
       
   164     void StoreNewPermissionL( CDRMPermission& aPermission,
       
   165                               TDRMUniqueID& aStream );    
       
   166     
       
   167     /**
       
   168     * UpdatePermissionL
       
   169     * 
       
   170     * Writes the data of the object into the stream
       
   171     *
       
   172     * @since    3.0
       
   173     * @param    aPermission : CDRMPermission class to externalize
       
   174     * @return   The function leaves with Symbian OS error code if an
       
   175     *           error occurs
       
   176     */
       
   177     void UpdatePermissionL( const CDRMPermission& aPermission );
       
   178     
       
   179     /**
       
   180     * FetchPermissionL
       
   181     * 
       
   182     * Reads the data of the object from the stream
       
   183     *
       
   184     * @since    3.0
       
   185     * @param    aPermission : a CDRMPermission class to internalize to
       
   186     * @param    aStream : the stream id to write the permission to
       
   187     * @return   The function leaves with Symbian OS error code if an
       
   188     *           error occurs
       
   189     */
       
   190     void FetchPermissionL( CDRMPermission& aPermission,
       
   191                            const TDRMUniqueID& aStream ) const;
       
   192 
       
   193     /**
       
   194     * DeletePermissionL
       
   195     * 
       
   196     * Deletes the data of the object from the stream
       
   197     *
       
   198     * @since    3.0
       
   199     * @param    aStream : the stream id to write the permission to
       
   200     * @return   The function leaves with Symbian OS error code if an
       
   201     *           error occurs
       
   202     */
       
   203     void DeletePermissionL( const TDRMUniqueID& aStream );
       
   204                            
       
   205     /**
       
   206     * FetchPermissionsL
       
   207     * 
       
   208     * Reads all the permissions and puts the data into the pointer array
       
   209     *
       
   210     * @since    3.0
       
   211     * @param    aPointerArray : return value pointer array of the permissions
       
   212     * @return   The function leaves with Symbian OS error code if an
       
   213     *           error occurs
       
   214     */
       
   215     void FetchAllPermissionsL( RPointerArray<CDRMPermission>& 
       
   216                                aPointerArray );
       
   217 
       
   218     /**
       
   219     * DeleteAllPermissionsL
       
   220     * 
       
   221     * Deletes the data of the object from the stream
       
   222     *
       
   223     * @since    3.0
       
   224     * @return   The function leaves with Symbian OS error code if an
       
   225     *           error occurs
       
   226     */
       
   227     void DeleteAllPermissionsL();
       
   228 
       
   229 
       
   230     /**
       
   231     * DeleteExpiredPermissionsL
       
   232     * 
       
   233     * Deletes the data of the object from the stream
       
   234     *
       
   235     * @since    3.0
       
   236     * @param	aTime : Current secure time for checking the expiration
       
   237     *				    if the time is Time::NullTTime() then only
       
   238     *				    expired non time based rights are deleted
       
   239     * @param    aParents : ETrue if any Ro's have parents otherwise EFalse
       
   240     * @return   The amount of permissions left in the file
       
   241     * @leave    The function leaves with Symbian OS error code if an
       
   242     *           error occurs
       
   243     */   
       
   244 	TInt DeleteExpiredPermissionsL( const TTime& aTime, TBool& aParents );   
       
   245                            
       
   246                            
       
   247     /**
       
   248     * StoreKeyL
       
   249     * 
       
   250     * Writes the key to the store
       
   251     *
       
   252     * @since    3.0
       
   253     * @return   The function leaves with Symbian OS error code if an
       
   254     *           error occurs
       
   255     */
       
   256     void StoreKeyL();
       
   257     
       
   258     /**
       
   259     * GetKeyL
       
   260     * 
       
   261     * Returns the key
       
   262     *
       
   263     * @since    3.0
       
   264     * @return   The function leaves with Symbian OS error code if an
       
   265     *           error occurs
       
   266     */
       
   267     HBufC8* GetKeyL() const;
       
   268 
       
   269 
       
   270 public:
       
   271 
       
   272 private:
       
   273 
       
   274     /**
       
   275     * CreateAndInitializeStoreL
       
   276     * 
       
   277     * Writes the data of index into the store root
       
   278     *
       
   279     * @since    3.0
       
   280     * @param    aRightsStore : Full path filename of the rights store    
       
   281     * @return   The function leaves with Symbian OS error code if an
       
   282     *           error occurs
       
   283     */
       
   284     void CreateAndInitializeStoreL( const TFileName& aRightsStore );
       
   285 
       
   286     /**
       
   287     * ExternalizeIndexL
       
   288     * 
       
   289     * Writes the data of index into the store root
       
   290     *
       
   291     * @since    3.0
       
   292     * @return   The function leaves with Symbian OS error code if an
       
   293     *           error occurs
       
   294     */
       
   295     void StoreIndexL( RWriteStream& aStream ) const;
       
   296     
       
   297     /**
       
   298     * InternalizeIndexL
       
   299     * 
       
   300     * Reads the data of the index from the store root
       
   301     *
       
   302     * @since    3.0
       
   303     * @return   The function leaves with Symbian OS error code if an
       
   304     *           error occurs
       
   305     */
       
   306     void FetchIndexL();
       
   307     
       
   308     /**
       
   309     * FetchCommonDataL();
       
   310     *
       
   311     * Reads the common data from the store
       
   312     *
       
   313     */
       
   314     void FetchCommonDataL();
       
   315     
       
   316     /**
       
   317     * FetchKeyL
       
   318     * 
       
   319     * Reads the key from the store
       
   320     *
       
   321     * @since    3.0
       
   322     * @return   The function leaves with Symbian OS error code if an
       
   323     *           error occurs
       
   324     */
       
   325     void FetchKeyL();
       
   326     
       
   327     /*
       
   328     * Default Constructor
       
   329     */ 
       
   330     CDRMRightsData( CDRMCommonData* aData, RFs& aFileServer );
       
   331 
       
   332     /*
       
   333     * 2nd phase Constructor
       
   334     *
       
   335     * @param    aRightsStore : Full path filename of the rights store
       
   336     */ 
       
   337     void ConstructL( const TFileName& aRightsStore );
       
   338 
       
   339     /*
       
   340     * 2nd phase Constructor
       
   341     *
       
   342     * @param    aRightsStore : Full path filename of the rights store
       
   343     */ 
       
   344     void ConstructL( const TFileName& aRightsStore,
       
   345                      const TDesC8& aKey );
       
   346 
       
   347 private:
       
   348     RFs& iFileServer;
       
   349 
       
   350     CPermanentFileStore* iStore;
       
   351     
       
   352     TBool iKeyExists;    
       
   353     TBuf8<16> iKey;
       
   354     RArray<TDRMUniqueID> iArray;
       
   355     CDRMCommonData* iData;
       
   356     TStreamId iCommonId;
       
   357     TStreamId iKeyId;
       
   358    
       
   359     // Some index data
       
   360     };
       
   361 
       
   362 #endif      // DRMRIGHTSDATA_H
       
   363             
       
   364 // End of File