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