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