omadrm/drmengine/server/inc/drmmeteringdb.h
changeset 0 95b198f216e5
child 12 8a03a285ab14
equal deleted inserted replaced
-1:000000000000 0:95b198f216e5
       
     1 /*
       
     2 * Copyright (c) 2007 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 Metering database
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef DRMMETERINGDB_H
       
    20 #define DRMMETERINGDB_H
       
    21 
       
    22 //  INCLUDES
       
    23 #include <e32std.h>
       
    24 #include <caf/caf.h>
       
    25 #include <D32DBMS.H>
       
    26 #include "DRMPointerArray.h"
       
    27 
       
    28 // CONSTANTS
       
    29 // MACROS
       
    30 // FUNCTION PROTOTYPES
       
    31 // FORWARD DECLARATIONS
       
    32 class CPersistentStore;
       
    33 class CDrmMeteringDbData;
       
    34 
       
    35 // DATA TYPES
       
    36 
       
    37 // CLASS DECLARATION
       
    38 
       
    39 /**
       
    40 *  Content metering information database. This class manages storing 
       
    41 *  information of Content ID, Rights Issuer ID, metered count and metered 
       
    42 *  accumulated time. 
       
    43 *
       
    44 *  @lib RightsServer.exe
       
    45 *  @since 3.2
       
    46 */
       
    47 NONSHARABLE_CLASS( RDrmMeteringDb )
       
    48     {
       
    49         
       
    50     public: // Constructors and destructor
       
    51     
       
    52         /**
       
    53         * Constructor.
       
    54         * @since S60 3.2
       
    55         */
       
    56         RDrmMeteringDb( RFs& aFs );
       
    57     
       
    58         /**
       
    59         * Default constructor.
       
    60         * @since S60 3.2
       
    61         */
       
    62         RDrmMeteringDb();
       
    63     
       
    64         public: // New functions
       
    65     
       
    66         /**
       
    67         * Sets the iFs according to this reference.
       
    68         *
       
    69         * @since S60 3.2
       
    70         * @param aFs Reference to open file server session. 
       
    71         */
       
    72         void Set( RFs& aFs );
       
    73     
       
    74         /**
       
    75         * Closes the database.
       
    76         * @since S60 3.2
       
    77         */
       
    78         void Close();
       
    79     
       
    80         /**
       
    81         * Initializes the database.
       
    82         * @since S60 3.2
       
    83         * @param aFileName File name of the database
       
    84         */
       
    85         void InitL( const TDesC& aFileName );
       
    86                 
       
    87         /**
       
    88         * Destructor.
       
    89         * @since S60 3.2
       
    90         */
       
    91         ~RDrmMeteringDb();
       
    92     
       
    93         /**
       
    94         * Add a metering data entry to the database.
       
    95         * @since S60 3.2
       
    96         * @param aMeteringData One metering data entry
       
    97         */
       
    98         void AddL( const CDrmMeteringDbData* aMeteringData );
       
    99         
       
   100         /**  
       
   101         * Get the metering data list based on the Rights Issuer Id from the 
       
   102         * metering database. Return value is ETrue if at least one entry was 
       
   103         * found corresponding to the given Rights Issuer Id. Return value is 
       
   104         * EFalse if no entry was found. The function will leave if an error 
       
   105         * happens in the handling of the database or if the Rights Issuer Id 
       
   106         * is empty or too long.
       
   107         * @since S60 3.2
       
   108         * @param aRiId Rights Issuer Id
       
   109         * @param aMeteringDataList Metering data list for a Rights Issuer
       
   110         * @return Boolean
       
   111         */
       
   112         TBool GetL( const TDesC8& aRiId, 
       
   113                     CDRMPointerArray< CDrmMeteringDbData >& aMeteringDataList );
       
   114         
       
   115         /**
       
   116         * Delete all the metering data information associated to the given 
       
   117         * Rights Issuer Id from the metering database. Return value is ETrue
       
   118         * if at least one entry was found corresponding to the given Rights 
       
   119         * Issuer Id. Return value is EFalse if no entry was found. The function 
       
   120         * will leave if an error happens in the handling of the database or if 
       
   121         * the Rights Issuer Id is empty or too long. 
       
   122         * @since S60 3.2
       
   123         * @param aRiId Rights Issuer Id 
       
   124         * @return Boolean
       
   125         */
       
   126         TBool DeleteL( const TDesC8& aRiId );
       
   127         
       
   128     private: // Private functions
       
   129     
       
   130         /**
       
   131         * Opens a database.
       
   132         * @since S60 3.2
       
   133         * @param aDb Database.
       
   134         * @param aFileName File name.
       
   135         */
       
   136         void OpenDbL( RDbNamedDatabase& aDb, 
       
   137                       const TDesC& aFileName );
       
   138 
       
   139         /**
       
   140         * Replace an existing database.
       
   141         * @since S60 3.2
       
   142         * @param aDb Database.
       
   143         * @param aFileName File name.
       
   144         */
       
   145         void ReplaceDbL( RDbNamedDatabase& aDb,
       
   146                          const TDesC& aFileName );
       
   147 
       
   148         /**
       
   149         * Initializes the view.
       
   150         * @since S60 3.2
       
   151         * @param aView View to initialize.
       
   152         */
       
   153         void InitViewLC( RDbView& aView );
       
   154     
       
   155         /**
       
   156         * Compare the Rights Issuer Id and Content Id to their counterparts in
       
   157         * the current row of the view. Return value is ETrue only if both the 
       
   158         * Content Id and the Rights Issuer Id match their counterpart Ids in
       
   159         * the view. Overloaded.  
       
   160         * 
       
   161         * @since S60 3.2
       
   162         * @param aView View.
       
   163         * @param aCID Content Id
       
   164         * @param aRiId Rights Issuer Id
       
   165         * @return Boolean
       
   166         */
       
   167         TBool CompareIDL( RDbRowSet& aView, 
       
   168                           const TDesC8& aCID, 
       
   169                           const TDesC8& aRiId );
       
   170         
       
   171         /**
       
   172         * Compare the Rights Issuer Id to its counterpart in the current row 
       
   173         * of the view. Overloaded.  
       
   174         * 
       
   175         * @since S60 3.2
       
   176         * @param aView View.
       
   177         * @param aRiId Rights Issuer Id
       
   178         * @return Boolean
       
   179         */
       
   180         TBool CompareIDL( RDbRowSet& aView, const TDesC8& aRiId );
       
   181             
       
   182         /**
       
   183         * Push a cleanup item to the cleanup stack in order to rollback
       
   184         * the database.
       
   185         * @since S60 3.2
       
   186         * @param aDb Database.
       
   187         */
       
   188         void PushL( RDbDatabase& aDb );
       
   189     
       
   190         /**
       
   191         * Pop the cleanup item pushed in by PushL
       
   192         * @since S60 3.2
       
   193         */
       
   194         void Pop();
       
   195 
       
   196     private: // Data
       
   197         // File server session handle. Not owned by this object.
       
   198         RFs* iFs;
       
   199     
       
   200         // Metering database 
       
   201         RDbNamedDatabase iDb;
       
   202     
       
   203     };
       
   204 
       
   205 #endif //DRMMETERINGDB_H