omadrm/drmengine/server/inc/DRMReplayCache.h
changeset 23 493788a4a8a4
parent 0 95b198f216e5
equal deleted inserted replaced
5:79d62d1d7957 23:493788a4a8a4
    19 #ifndef DRMREPLAYCACHE_H
    19 #ifndef DRMREPLAYCACHE_H
    20 #define DRMREPLAYCACHE_H
    20 #define DRMREPLAYCACHE_H
    21 
    21 
    22 //  INCLUDES
    22 //  INCLUDES
    23 #include <e32std.h>
    23 #include <e32std.h>
    24 #include <D32DBMS.H>
    24 #include <d32dbms.h>
    25 
    25 
    26 // CONSTANTS
    26 // CONSTANTS
    27 // MACROS
    27 // MACROS
    28 // FUNCTION PROTOTYPES
    28 // FUNCTION PROTOTYPES
    29 // FORWARD DECLARATIONS
    29 // FORWARD DECLARATIONS
    41 *  @since S60Rel3.0
    41 *  @since S60Rel3.0
    42 */
    42 */
    43 NONSHARABLE_CLASS( RDRMReplayCache )
    43 NONSHARABLE_CLASS( RDRMReplayCache )
    44     {
    44     {
    45     public: // Constructors and destructor
    45     public: // Constructors and destructor
    46     
    46 
    47     /**
    47     /**
    48     * Constructor.
    48     * Constructor.
    49     * @since S60Rel3.0
    49     * @since S60Rel3.0
    50     */
    50     */
    51     RDRMReplayCache( RFs& aFs );
    51     RDRMReplayCache( RFs& aFs );
    52     
    52 
    53     /**
    53     /**
    54     * Default constructor.
    54     * Default constructor.
    55     * @since S60Rel3.0
    55     * @since S60Rel3.0
    56     */
    56     */
    57     RDRMReplayCache();
    57     RDRMReplayCache();
    58     
    58 
    59     public: // New functions
    59     public: // New functions
    60     
    60 
    61     /**
    61     /**
    62     * Sets the ifs according to this reference.
    62     * Sets the ifs according to this reference.
    63     *
    63     *
    64     * @since S60Rel3.0
    64     * @since S60Rel3.0
    65     * @param aFs Reference to open file server session. 
    65     * @param aFs Reference to open file server session.
    66     */
    66     */
    67     void Set( RFs& aFs );
    67     void Set( RFs& aFs );
    68     
    68 
    69     /**
    69     /**
    70     * Closes the cache.
    70     * Closes the cache.
    71     * @since S60Rel3.0
    71     * @since S60Rel3.0
    72     */
    72     */
    73     void Close();
    73     void Close();
    74     
    74 
    75     /**
    75     /**
    76     * Initializes the view.
    76     * Initializes the view.
    77     * @since S60Rel3.0
    77     * @since S60Rel3.0
    78     * @param aTimedDb File name of the db with timestamped permissions.
    78     * @param aTimedDb File name of the db with timestamped permissions.
    79     * @param aPlainDb File name of the db with permissions without timestamps.
    79     * @param aPlainDb File name of the db with permissions without timestamps.
    80     */
    80     */
    81     void InitL( const TDesC& aTimedDb,
    81     void InitL( const TDesC& aTimedDb,
    82                 const TDesC& aPlainDb );
    82                 const TDesC& aPlainDb );
    83                 
    83 
    84     /**
    84     /**
    85     * Destructor.
    85     * Destructor.
    86     * @since S60Rel3.0
    86     * @since S60Rel3.0
    87     */
    87     */
    88     ~RDRMReplayCache();
    88     ~RDRMReplayCache();
    89     
    89 
    90     /**
    90     /**
    91     * Add an entry to the DB. Overloaded.
    91     * Add an entry to the DB. Overloaded.
    92     * @since S60Rel3.0
    92     * @since S60Rel3.0
    93     * @param aID    Content-ID.
    93     * @param aID    Content-ID.
    94     * @param aaTime Timestamp of the permission.
    94     * @param aaTime Timestamp of the permission.
    95     * @param aaTime Insertion time.
    95     * @param aaTime Insertion time.
    96     */
    96     */
    97     void AddL( const TDesC8& aID, 
    97     void AddL( const TDesC8& aID,
    98                const TTime& aTime,
    98                const TTime& aTime,
    99                const TTime& aInsertionTime  );
    99                const TTime& aInsertionTime  );
   100 
   100 
   101     /**
   101     /**
   102     * Add an entry to the DB. Overloaded.
   102     * Add an entry to the DB. Overloaded.
   103     * @since S60Rel3.0
   103     * @since S60Rel3.0
   104     * @param aID    Content-ID.
   104     * @param aID    Content-ID.
   105     * @param aaTime Insertion time.
   105     * @param aaTime Insertion time.
   106     */
   106     */
   107     void AddL( const TDesC8& aID, 
   107     void AddL( const TDesC8& aID,
   108                const TTime& aInsertionTime  );
   108                const TTime& aInsertionTime  );
   109 
   109 
   110     /**
   110     /**
   111     * Checks whether an entry is in cache. Overloaded.
   111     * Checks whether an entry is in cache. Overloaded.
   112     * @since S60Rel3.0
   112     * @since S60Rel3.0
   113     * @param aID    Content-ID.
   113     * @param aID    Content-ID.
   114     * @param aaTime Timestamp of the permission.
   114     * @param aaTime Timestamp of the permission.
   115     * @return Boolean.
   115     * @return Boolean.
   116     */
   116     */
   117     TBool InCacheL( const TDesC8& aCID, 
   117     TBool InCacheL( const TDesC8& aCID,
   118                     const TTime& aTime );
   118                     const TTime& aTime );
   119     
   119 
   120     /**
   120     /**
   121     * Checks whether an entry is in cache. Overloaded.
   121     * Checks whether an entry is in cache. Overloaded.
   122     * @since S60Rel3.0
   122     * @since S60Rel3.0
   123     * @param aID    Content-ID.
   123     * @param aID    Content-ID.
   124     * @return Boolean.
   124     * @return Boolean.
   129     enum TDatabaseId
   129     enum TDatabaseId
   130         {
   130         {
   131         ETimeDb,
   131         ETimeDb,
   132         EPlainDb
   132         EPlainDb
   133         };
   133         };
   134         
   134 
   135     private: // Private functions
   135     private: // Private functions
   136     
   136 
   137     /**
   137     /**
   138     * Initializes the database.
   138     * Initializes the database.
   139     * @since S60Rel3.0
   139     * @since S60Rel3.0
   140     * @param aDb Database.
   140     * @param aDb Database.
   141     * @param aFileName File name.
   141     * @param aFileName File name.
   142     * @param aId Database ID.
   142     * @param aId Database ID.
   143     */
   143     */
   144     void InitDbL( RDbNamedDatabase& aDb, 
   144     void InitDbL( RDbNamedDatabase& aDb,
   145                   const TDesC& aFileName,
   145                   const TDesC& aFileName,
   146                   TDatabaseId aId );
   146                   TDatabaseId aId );
   147 
   147 
   148     /**
   148     /**
   149     * Opens a database.
   149     * Opens a database.
   150     * @since S60Rel3.0
   150     * @since S60Rel3.0
   151     * @param aDb Database.
   151     * @param aDb Database.
   152     * @param aFileName File name.
   152     * @param aFileName File name.
   153     */
   153     */
   154     void OpenDbL( RDbNamedDatabase& aDb, 
   154     void OpenDbL( RDbNamedDatabase& aDb,
   155                   const TDesC& aFileName );
   155                   const TDesC& aFileName );
   156 
   156 
   157     /**
   157     /**
   158     * Replace an existing database.
   158     * Replace an existing database.
   159     * @since S60Rel3.0
   159     * @since S60Rel3.0
   160     * @param aDb Database.
   160     * @param aDb Database.
   161     * @param aFileName File name.
   161     * @param aFileName File name.
   162     * @param aId Database ID.
   162     * @param aId Database ID.
   163     */
   163     */
   164     void ReplaceDbL( RDbNamedDatabase& aDb,
   164     void ReplaceDbL( RDbNamedDatabase& aDb,
   165                      const TDesC& aFileName, 
   165                      const TDesC& aFileName,
   166                      TDatabaseId aId );
   166                      TDatabaseId aId );
   167 
   167 
   168     /**
   168     /**
   169     * Initializes the view.
   169     * Initializes the view.
   170     * @since S60Rel3.0
   170     * @since S60Rel3.0
   171     * @param aView View to initialize.
   171     * @param aView View to initialize.
   172     * @param aDb Database ID.
   172     * @param aDb Database ID.
   173     */
   173     */
   174     void InitViewLC( RDbView& aView, 
   174     void InitViewLC( RDbView& aView,
   175                      TDatabaseId aDb,
   175                      TDatabaseId aDb,
   176                      TBool aUpdate );
   176                      TBool aUpdate );
   177     
   177 
   178     /**
   178     /**
   179     * Compare the given ID to the ID in the current position of the view.
   179     * Compare the given ID to the ID in the current position of the view.
   180     * @since S60Rel3.0
   180     * @since S60Rel3.0
   181     * @param aView View.
   181     * @param aView View.
   182     * @param aCID Content-ID to check.
   182     * @param aCID Content-ID to check.
   183     * @return Boolean.
   183     * @return Boolean.
   184     */
   184     */
   185     TBool CompareCIDL( RDbRowSet& aView, const TDesC8& aCID );
   185     TBool CompareCIDL( RDbRowSet& aView, const TDesC8& aCID );
   186     
   186 
   187     /**
   187     /**
   188     * Push a cleanup item to the cleanup stack in order to rollback
   188     * Push a cleanup item to the cleanup stack in order to rollback
   189     * the database.
   189     * the database.
   190     * @since S60Rel3.0
   190     * @since S60Rel3.0
   191     * @param aDb Database.
   191     * @param aDb Database.
   192     */
   192     */
   193     void PushL( RDbDatabase& aDb );
   193     void PushL( RDbDatabase& aDb );
   194     
   194 
   195     /**
   195     /**
   196     * Pop the cleanup item pushed in by PushL
   196     * Pop the cleanup item pushed in by PushL
   197     * @since S60Rel3.0
   197     * @since S60Rel3.0
   198     */
   198     */
   199     void Pop();
   199     void Pop();
   200 
   200 
   201     /**
   201     /**
   202     * Delete items starting from the oldest one.
   202     * Delete items starting from the oldest one.
   203     * @since S60Rel3.0
   203     * @since S60Rel3.0
   204     * @param aView View.
   204     * @param aView View.
   205     * @param aHowMany How many items to delete. 
   205     * @param aHowMany How many items to delete.
   206     */
   206     */
   207     void DeleteOldestsL( RDbRowSet& aView, TInt16 aHowMany );
   207     void DeleteOldestsL( RDbRowSet& aView, TInt16 aHowMany );
   208     
   208 
   209     /**
   209     /**
   210     * Compacts the view to the upper limit of the view capacity.
   210     * Compacts the view to the upper limit of the view capacity.
   211     * @since S60Rel3.0
   211     * @since S60Rel3.0
   212     * @param aView View to compact.
   212     * @param aView View to compact.
   213     */
   213     */
   214     void CompactViewL( RDbRowSet& aView );
   214     void CompactViewL( RDbRowSet& aView );
   215     
   215 
   216     /**
   216     /**
   217     * Insert a content-id to the current position in the view.
   217     * Insert a content-id to the current position in the view.
   218     * @since S60Rel3.0
   218     * @since S60Rel3.0
   219     * @param aView View to which the insertion is made.
   219     * @param aView View to which the insertion is made.
   220     * @param aId ID to add.    
   220     * @param aId ID to add.
   221     */
   221     */
   222     void InsertIdL( RDbRowSet& aView, 
   222     void InsertIdL( RDbRowSet& aView,
   223                     const TDesC8& aId );
   223                     const TDesC8& aId );
   224     
   224 
   225     private: // Data
   225     private: // Data
   226     // File server session handle. Not owned by this object.
   226     // File server session handle. Not owned by this object.
   227     RFs* iFs;
   227     RFs* iFs;
   228     
   228 
   229     // Database for timestamped items.
   229     // Database for timestamped items.
   230     RDbNamedDatabase iTimeDb;
   230     RDbNamedDatabase iTimeDb;
   231     
   231 
   232     // Database for the items without timestamp.
   232     // Database for the items without timestamp.
   233     RDbNamedDatabase iPlainDb;
   233     RDbNamedDatabase iPlainDb;
   234     // RDbView iView;
   234     // RDbView iView;
   235     };
   235     };
   236 
   236 
   237 #endif //DRMREPLAYCACHE_H   
   237 #endif //DRMREPLAYCACHE_H