|
1 /* |
|
2 * Copyright (c) 2007-2008 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: Implementation of the Metering database |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 |
|
21 #include <f32file.h> |
|
22 #include <S32FILE.H> |
|
23 #include <BAUTILS.H> |
|
24 #include "drmlog.h" |
|
25 #include "drmmeteringdb.h" |
|
26 #ifdef RD_DRM_METERING |
|
27 #include "drmmeteringdbdata.h" |
|
28 #endif |
|
29 #include "DRMTypes.h" |
|
30 |
|
31 // EXTERNAL DATA STRUCTURES |
|
32 |
|
33 // EXTERNAL FUNCTION PROTOTYPES |
|
34 |
|
35 // CONSTANTS |
|
36 |
|
37 // MACROS |
|
38 |
|
39 // LOCAL CONSTANTS AND MACROS |
|
40 |
|
41 #ifdef RD_DRM_METERING |
|
42 |
|
43 _LIT( KCIDColName, "cid" ); |
|
44 _LIT( KRightIssuerColName, "riid" ); |
|
45 _LIT( KCountColName, "count" ); |
|
46 _LIT( KAccumulatedTimeColName, "time" ); |
|
47 _LIT( KMeteringDataTable, "metering" ); |
|
48 _LIT( KParentUIDColName, "parent" ); |
|
49 _LIT( KViewInitQuery, "SELECT * FROM metering ORDER BY riid" ); |
|
50 |
|
51 LOCAL_C const TUint8 KDbViewCIDOrdinal = 1; |
|
52 LOCAL_C const TUint8 KDbViewRIIDOrdinal = 2; |
|
53 LOCAL_C const TUint8 KDbViewCountOrdinal = 3; |
|
54 LOCAL_C const TUint8 KDbViewAccumulatedTimeOrdinal = 4; |
|
55 LOCAL_C const TUint8 KDbViewParentUIDOrdinal = 5; |
|
56 |
|
57 // MODULE DATA STRUCTURES |
|
58 NONSHARABLE_STRUCT( TDoDeleteFile ) |
|
59 { |
|
60 RFs* iFs; |
|
61 const TDesC* iFile; |
|
62 }; |
|
63 |
|
64 // LOCAL FUNCTION PROTOTYPES |
|
65 LOCAL_C void DoRollBack( TAny* aAny ); |
|
66 LOCAL_C void DoDeleteFile( TAny* aAny ); |
|
67 |
|
68 // FORWARD DECLARATIONS |
|
69 |
|
70 // ============================= LOCAL FUNCTIONS =============================== |
|
71 // ----------------------------------------------------------------------------- |
|
72 // DoRollBack |
|
73 // |
|
74 // Do a rollback operation to the RDbDatabase* |
|
75 // ----------------------------------------------------------------------------- |
|
76 // |
|
77 LOCAL_C void DoRollBack( TAny* aAny ) |
|
78 { |
|
79 reinterpret_cast< RDbDatabase* >( aAny )->Rollback(); |
|
80 } |
|
81 |
|
82 // ----------------------------------------------------------------------------- |
|
83 // DoDeleteFile |
|
84 // |
|
85 // Delete the file presented by TDoDeleteFile* |
|
86 // ----------------------------------------------------------------------------- |
|
87 // |
|
88 LOCAL_C void DoDeleteFile( TAny* aAny ) |
|
89 { |
|
90 TDoDeleteFile* s = reinterpret_cast< TDoDeleteFile* >( aAny ); |
|
91 |
|
92 s->iFs->Delete( *( s->iFile ) ); |
|
93 } |
|
94 |
|
95 #endif |
|
96 |
|
97 // ============================ MEMBER FUNCTIONS =============================== |
|
98 |
|
99 // ----------------------------------------------------------------------------- |
|
100 // RDrmMeteringDb::RDrmMeteringDb |
|
101 // |
|
102 // Default constructor |
|
103 // ----------------------------------------------------------------------------- |
|
104 // |
|
105 RDrmMeteringDb::RDrmMeteringDb(): |
|
106 iFs( NULL ), |
|
107 iDb() |
|
108 { |
|
109 // Nothing |
|
110 } |
|
111 |
|
112 // ----------------------------------------------------------------------------- |
|
113 // RDrmMeteringDb::~RDrmMeteringDb |
|
114 // |
|
115 // Destructor |
|
116 // ----------------------------------------------------------------------------- |
|
117 // |
|
118 RDrmMeteringDb::~RDrmMeteringDb() |
|
119 { |
|
120 } |
|
121 |
|
122 // ----------------------------------------------------------------------------- |
|
123 // RDRMMeteringDb::Close |
|
124 // |
|
125 // Closes the databases. |
|
126 // ----------------------------------------------------------------------------- |
|
127 // |
|
128 void RDrmMeteringDb::Close() |
|
129 { |
|
130 // Atomic operations only at the moment, but what about the future. |
|
131 iDb.Close(); |
|
132 } |
|
133 |
|
134 #ifdef RD_DRM_METERING |
|
135 |
|
136 // ----------------------------------------------------------------------------- |
|
137 // RDrmMeteringDb::RDrmMeteringDb |
|
138 // |
|
139 // Constructor |
|
140 // ----------------------------------------------------------------------------- |
|
141 // |
|
142 RDrmMeteringDb::RDrmMeteringDb( RFs& aFs ) : |
|
143 iFs( &aFs ), |
|
144 iDb() |
|
145 { |
|
146 } |
|
147 |
|
148 // ----------------------------------------------------------------------------- |
|
149 // RDrmMeteringDb::Set |
|
150 // |
|
151 // Set iFs to given aFs. |
|
152 // ----------------------------------------------------------------------------- |
|
153 // |
|
154 void RDrmMeteringDb::Set( RFs& aFs ) |
|
155 { |
|
156 iFs = &aFs; |
|
157 } |
|
158 |
|
159 // ----------------------------------------------------------------------------- |
|
160 // RDrmMeteringDb::InitL |
|
161 // |
|
162 // Initialize the databases. |
|
163 // ----------------------------------------------------------------------------- |
|
164 // |
|
165 void RDrmMeteringDb::InitL( const TDesC& aFileName ) |
|
166 { |
|
167 |
|
168 DRMLOG( _L( "RDrmMeteringDb::InitL" ) ); |
|
169 TInt error = KErrNone; |
|
170 TBool exists = BaflUtils::FileExists( *iFs, aFileName ); |
|
171 |
|
172 if ( exists ) |
|
173 { |
|
174 TRAP( error, OpenDbL( iDb, aFileName ) ); |
|
175 } |
|
176 if ( error || !exists ) |
|
177 { |
|
178 ReplaceDbL( iDb, aFileName ); |
|
179 } |
|
180 DRMLOG( _L( "RDrmMeteringDb::InitL ok" ) ); |
|
181 } |
|
182 |
|
183 // ----------------------------------------------------------------------------- |
|
184 // RDrmMeteringDb::AddL |
|
185 // |
|
186 // Add an entry to the database. The method checks whether an entry matching |
|
187 // the given Content Id and Rights Issuer Id already exists or not. A new row |
|
188 // is added to the database if one does not already exist. |
|
189 // ----------------------------------------------------------------------------- |
|
190 // |
|
191 void RDrmMeteringDb::AddL( const CDrmMeteringDbData* aMeteringData ) |
|
192 { |
|
193 |
|
194 DRMLOG( _L( "RDrmMeteringDb::AddL" ) ); |
|
195 |
|
196 __ASSERT_DEBUG( aMeteringData, User::Invariant() ); |
|
197 |
|
198 RDbView view; |
|
199 TBool res = EFalse; |
|
200 |
|
201 PushL( iDb ); |
|
202 |
|
203 InitViewLC( view ); |
|
204 |
|
205 User::LeaveIfError( iDb.Begin() ); |
|
206 |
|
207 for ( view.FirstL(); view.AtRow() && !res ; view.NextL() ) |
|
208 { |
|
209 view.GetL(); |
|
210 |
|
211 // Check whether an entry already exists or not. |
|
212 if ( CompareIDL( view, *( aMeteringData->iContentId ), |
|
213 aMeteringData->iRiId ) ) |
|
214 { |
|
215 |
|
216 view.UpdateL(); // Update count and accumulated time of the rowset |
|
217 |
|
218 // Get the structure of rowset |
|
219 CDbColSet* colset = view.ColSetL(); |
|
220 CleanupStack::PushL( colset ); |
|
221 |
|
222 TInt count = 0; |
|
223 TTimeIntervalSeconds accumulatedTime = |
|
224 aMeteringData->iAccumulatedTime.Int(); |
|
225 |
|
226 count = aMeteringData->iCount + |
|
227 view.ColUint32( KDbViewCountOrdinal ); |
|
228 |
|
229 view.SetColL( colset->ColNo( KCountColName ), count ); |
|
230 |
|
231 accumulatedTime = accumulatedTime.Int() + |
|
232 view.ColInt32( KDbViewAccumulatedTimeOrdinal ); |
|
233 |
|
234 view.SetColL( colset->ColNo( KAccumulatedTimeColName ), |
|
235 accumulatedTime.Int() ); |
|
236 |
|
237 if ( aMeteringData->iParentUid ) |
|
238 { |
|
239 view.SetColL( KDbViewParentUIDOrdinal, |
|
240 *( aMeteringData->iParentUid ) ); |
|
241 } |
|
242 |
|
243 view.PutL(); |
|
244 iDb.Compact(); |
|
245 |
|
246 res = ETrue; |
|
247 CleanupStack::PopAndDestroy( colset ); |
|
248 } |
|
249 |
|
250 } |
|
251 |
|
252 // No existing entry was found. Make a new entry to the database. |
|
253 if ( !res ) |
|
254 { |
|
255 view.InsertL(); // Add new row to the database |
|
256 |
|
257 view.SetColL( KDbViewCIDOrdinal, *( aMeteringData->iContentId ) ); |
|
258 view.SetColL( KDbViewRIIDOrdinal, aMeteringData->iRiId ); |
|
259 view.SetColL( KDbViewCountOrdinal, aMeteringData->iCount ); |
|
260 view.SetColL( KDbViewAccumulatedTimeOrdinal, |
|
261 aMeteringData->iAccumulatedTime.Int() ); |
|
262 |
|
263 if ( aMeteringData->iParentUid ) |
|
264 { |
|
265 view.SetColL( KDbViewParentUIDOrdinal, |
|
266 *( aMeteringData->iParentUid ) ); |
|
267 } |
|
268 |
|
269 view.PutL(); |
|
270 } |
|
271 |
|
272 CleanupStack::PopAndDestroy(); // view |
|
273 |
|
274 User::LeaveIfError( iDb.Commit() ); |
|
275 |
|
276 Pop(); // iDb |
|
277 DRMLOG( _L( "RDrmMeteringDb::AddL ok" ) ); |
|
278 |
|
279 } |
|
280 |
|
281 |
|
282 // ----------------------------------------------------------------------------- |
|
283 // RDrmMeteringDb::GetL |
|
284 // |
|
285 // Get the metering data list of a Rights Issuer from the database. Return value |
|
286 // is ETrue if at least one entry was found. return value is EFalse if no entry |
|
287 // was found. Function will leave if an error happens when accessing the |
|
288 // database or if the given Rights Issuer Id is either empty or too long. |
|
289 // ----------------------------------------------------------------------------- |
|
290 // |
|
291 |
|
292 TBool RDrmMeteringDb::GetL( const TDesC8& aRiId, |
|
293 CDRMPointerArray< CDrmMeteringDbData >& |
|
294 aMeteringDataList ) |
|
295 { |
|
296 |
|
297 DRMLOG( _L( "RDrmMeteringDb::GetL" ) ); |
|
298 |
|
299 // If Rights Issuer Id not available or is too long |
|
300 if ( ( aRiId.Length() == 0 ) || ( aRiId.Length() > KRiIdSize ) ) |
|
301 { |
|
302 User::Leave( KErrArgument ); |
|
303 } |
|
304 |
|
305 TBool found = EFalse; |
|
306 |
|
307 RDbView view; |
|
308 |
|
309 PushL( iDb ); |
|
310 |
|
311 InitViewLC( view ); |
|
312 |
|
313 User::LeaveIfError( iDb.Begin() ); |
|
314 |
|
315 // Examine the whole database for possible entries matching the Rights |
|
316 // Issuer Id |
|
317 for ( view.FirstL(); view.AtRow(); view.NextL() ) |
|
318 { |
|
319 |
|
320 view.GetL(); |
|
321 |
|
322 // Check whether the Rights Issuer Id in the current row matches |
|
323 // the given Rights Issuer Id or not. |
|
324 if ( CompareIDL( view, aRiId ) ) |
|
325 { |
|
326 |
|
327 found = ETrue; |
|
328 |
|
329 CDbColSet* colset = view.ColSetL(); |
|
330 CleanupStack::PushL( colset ); |
|
331 |
|
332 // Create a new instance of the Metering information storage |
|
333 // class to be included in the given Metering data pointer |
|
334 // array |
|
335 CDrmMeteringDbData* meteringdata = CDrmMeteringDbData::NewLC(); |
|
336 TPtrC8 cid = view.ColDes8( colset->ColNo( KCIDColName ) ); |
|
337 |
|
338 meteringdata->iContentId = cid.AllocL(); |
|
339 meteringdata->iRiId.Copy( aRiId ); |
|
340 meteringdata->iCount = view.ColUint32( KDbViewCountOrdinal ); |
|
341 |
|
342 meteringdata->iAccumulatedTime = |
|
343 static_cast< TTimeIntervalSeconds >\ |
|
344 ( view.ColInt32( KDbViewAccumulatedTimeOrdinal ) ); |
|
345 |
|
346 TPtrC8 parentuid = |
|
347 view.ColDes8( colset->ColNo( KParentUIDColName ) ); |
|
348 |
|
349 // Alloc has been used instead of AllocL in order not to leave |
|
350 // if an error happens in the memory allocation. |
|
351 meteringdata->iParentUid = parentuid.Alloc(); |
|
352 |
|
353 // Insert the instance to the Metering data pointer array |
|
354 aMeteringDataList.AppendL( meteringdata ); |
|
355 |
|
356 CleanupStack::Pop( meteringdata ); |
|
357 CleanupStack::PopAndDestroy( colset ); |
|
358 } |
|
359 |
|
360 } |
|
361 |
|
362 User::LeaveIfError( iDb.Commit() ); |
|
363 |
|
364 CleanupStack::PopAndDestroy(); // view |
|
365 |
|
366 Pop(); // iDb |
|
367 |
|
368 DRMLOG( _L( "RDrmMeteringDb::GetL ok" ) ); |
|
369 |
|
370 return found; |
|
371 |
|
372 } |
|
373 |
|
374 // ----------------------------------------------------------------------------- |
|
375 // RDrmMeteringDb::DeleteL |
|
376 // |
|
377 // Delete all the metering data associated to a Rights Issuer from the database. |
|
378 // Return value is ETrue if at least one entry was found. Return value is EFalse |
|
379 // if no entry was found. Function will leave if an error happens when accessing |
|
380 // the database or if the given Rights Issuer Id is either empty or too long. |
|
381 // ----------------------------------------------------------------------------- |
|
382 // |
|
383 TBool RDrmMeteringDb::DeleteL( const TDesC8& aRiId ) |
|
384 { |
|
385 |
|
386 DRMLOG( _L( "RDrmMeteringDb::DeleteL" ) ); |
|
387 |
|
388 // If Rights Issuer Id is empty or is not available |
|
389 if ( ( aRiId.Length() == 0 ) || ( aRiId.Length() > KRiIdSize ) ) |
|
390 { |
|
391 User::Leave( KErrArgument ); |
|
392 } |
|
393 |
|
394 TBool found = EFalse; |
|
395 |
|
396 RDbView view; |
|
397 |
|
398 PushL( iDb ); |
|
399 |
|
400 InitViewLC( view ); |
|
401 |
|
402 User::LeaveIfError( iDb.Begin() ); |
|
403 |
|
404 for ( view.FirstL(); view.AtRow(); view.NextL() ) |
|
405 { |
|
406 |
|
407 view.GetL(); |
|
408 |
|
409 if ( CompareIDL( view, aRiId ) ) |
|
410 { |
|
411 found = ETrue; |
|
412 view.DeleteL(); |
|
413 } |
|
414 |
|
415 } |
|
416 |
|
417 if ( found ) |
|
418 { |
|
419 iDb.Compact(); |
|
420 } |
|
421 |
|
422 User::LeaveIfError( iDb.Commit() ); |
|
423 |
|
424 CleanupStack::PopAndDestroy(); // view |
|
425 |
|
426 Pop(); // iDb |
|
427 |
|
428 DRMLOG( _L( "RDrmMeteringDb::DeleteL ok" ) ); |
|
429 |
|
430 return found; |
|
431 |
|
432 } |
|
433 |
|
434 // ----------------------------------------------------------------------------- |
|
435 // RDrmMeteringDb::OpenDbL |
|
436 // |
|
437 // Open the database. |
|
438 // ----------------------------------------------------------------------------- |
|
439 // |
|
440 void RDrmMeteringDb::OpenDbL( RDbNamedDatabase& aDb, |
|
441 const TDesC& aFileName ) |
|
442 { |
|
443 |
|
444 DRMLOG( _L( "RDrmMeteringDb::OpenDbL" ) ); |
|
445 CDbTableNames* tables = NULL; |
|
446 |
|
447 User::LeaveIfError( aDb.Open( *iFs, aFileName ) ); |
|
448 CleanupClosePushL( aDb ); |
|
449 |
|
450 if ( aDb.IsDamaged() ) |
|
451 { |
|
452 User::LeaveIfError( aDb.Recover() ); |
|
453 } |
|
454 |
|
455 // Sanity check |
|
456 tables = aDb.TableNamesL(); |
|
457 CleanupStack::PushL( tables ); |
|
458 |
|
459 if ( tables->Count() != 1 || |
|
460 ( *tables )[ 0 ].Compare( KMeteringDataTable ) ) |
|
461 { |
|
462 User::Leave( KErrCorrupt ); |
|
463 } |
|
464 |
|
465 CleanupStack::PopAndDestroy( tables ); |
|
466 CleanupStack::Pop(); // aDb |
|
467 DRMLOG( _L( "RDrmMeteringDb::OpenDbL ok" ) ); |
|
468 |
|
469 } |
|
470 |
|
471 // ----------------------------------------------------------------------------- |
|
472 // RDrmMeteringDb::ReplaceDbL |
|
473 // |
|
474 // Replace the database. |
|
475 // ----------------------------------------------------------------------------- |
|
476 // |
|
477 void RDrmMeteringDb::ReplaceDbL( RDbNamedDatabase& aDb, |
|
478 const TDesC& aFileName ) |
|
479 { |
|
480 DRMLOG( _L( "RDrmMeteringDb::ReplaceDbL" ) ); |
|
481 |
|
482 CDbColSet* colSet = NULL; |
|
483 |
|
484 // Define column names and their data types |
|
485 TDbCol cidCol( KCIDColName, EDbColText8 ); |
|
486 TDbCol riidCol( KRightIssuerColName, EDbColText8 ); |
|
487 TDbCol countCol( KCountColName, EDbColUint32 ); |
|
488 TDbCol accumulatedTimeCol( KAccumulatedTimeColName, EDbColInt32 ); |
|
489 TDbCol parentUIDCol( KParentUIDColName, EDbColText8 ); |
|
490 |
|
491 TDoDeleteFile deletefile = { iFs, &aFileName }; |
|
492 |
|
493 TCleanupItem item( DoDeleteFile, &deletefile ); |
|
494 CleanupStack::PushL( item ); |
|
495 |
|
496 User::LeaveIfError( aDb.Replace( *iFs, aFileName ) ); |
|
497 CleanupClosePushL( aDb ); |
|
498 |
|
499 // Add columns |
|
500 colSet = CDbColSet::NewLC(); |
|
501 colSet->AddL( cidCol ); |
|
502 colSet->AddL( riidCol ); |
|
503 colSet->AddL( countCol ); |
|
504 colSet->AddL( accumulatedTimeCol ); |
|
505 colSet->AddL( parentUIDCol); |
|
506 |
|
507 // Create indices |
|
508 TDbKeyCol cidKeyCol( KCIDColName ); |
|
509 TDbKeyCol riidKeyCol( KRightIssuerColName ); |
|
510 |
|
511 CDbKey* key = CDbKey::NewLC(); |
|
512 key->AddL( cidKeyCol ); |
|
513 key->AddL( riidKeyCol ); |
|
514 key->MakeUnique(); |
|
515 |
|
516 User::LeaveIfError( aDb.Begin() ); |
|
517 User::LeaveIfError( aDb.CreateTable( KMeteringDataTable, *colSet ) ); |
|
518 |
|
519 User::LeaveIfError( aDb.CreateIndex( KMeteringDataTable, |
|
520 KMeteringDataTable, |
|
521 *key ) ); |
|
522 |
|
523 User::LeaveIfError( aDb.Commit() ); |
|
524 |
|
525 CleanupStack::PopAndDestroy( 2, colSet ); // key, colset |
|
526 CleanupStack::Pop(); // aDb |
|
527 CleanupStack::Pop(); // item |
|
528 |
|
529 DRMLOG( _L( "RDrmMeteringDb::ReplaceDbL ok" ) ); |
|
530 |
|
531 } |
|
532 |
|
533 // ----------------------------------------------------------------------------- |
|
534 // RDrmMeteringDb::InitViewLC |
|
535 // |
|
536 // Initialize the view. |
|
537 // ----------------------------------------------------------------------------- |
|
538 // |
|
539 void RDrmMeteringDb::InitViewLC( RDbView& aView ) |
|
540 { |
|
541 |
|
542 DRMLOG( _L( "RDrmMeteringDb::InitViewLC" ) ); |
|
543 |
|
544 User::LeaveIfError( |
|
545 aView.Prepare( iDb, |
|
546 TDbQuery( KViewInitQuery, EDbCompareCollated ), |
|
547 RDbRowSet::EUpdatable ) ); |
|
548 |
|
549 CleanupClosePushL( aView ); |
|
550 |
|
551 User::LeaveIfError( aView.EvaluateAll() ); |
|
552 |
|
553 DRMLOG( _L( "RDrmMeteringDb::InitViewLC ok" ) ); |
|
554 |
|
555 } |
|
556 |
|
557 // ----------------------------------------------------------------------------- |
|
558 // RDrmMeteringDb::CompareIDL |
|
559 // |
|
560 // Compare the Rights Issuer Id and Content Id to their counterparts in the current |
|
561 // row of the view. Return value is ETrue only if both the Content Id and the Rights |
|
562 // Issuer Id match their counterpart Ids in the view. |
|
563 // ----------------------------------------------------------------------------- |
|
564 // |
|
565 TBool RDrmMeteringDb::CompareIDL( RDbRowSet& aView, |
|
566 const TDesC8& aCID, |
|
567 const TDesC8& aRiId ) |
|
568 { |
|
569 |
|
570 DRMLOG( _L( "RDrmMeteringDb::CompareIDL" ) ); |
|
571 |
|
572 TBool res = EFalse; |
|
573 |
|
574 CDbColSet* colset = aView.ColSetL(); |
|
575 CleanupStack::PushL( colset ); |
|
576 |
|
577 TPtrC8 riid = aView.ColDes8( colset->ColNo( KRightIssuerColName ) ); |
|
578 TBuf8< KRiIdSize > buf = riid; |
|
579 |
|
580 TPtrC8 cid = aView.ColDes8( colset->ColNo( KCIDColName ) ); |
|
581 HBufC8* des = cid.AllocLC(); |
|
582 |
|
583 if ( ( aRiId.CompareC( buf ) == 0 ) && ( aCID.CompareC( *des ) == 0 ) ) |
|
584 { |
|
585 res = ETrue; |
|
586 } |
|
587 |
|
588 CleanupStack::PopAndDestroy( des ); |
|
589 CleanupStack::PopAndDestroy( colset ); |
|
590 |
|
591 DRMLOG( _L( "RDrmMeteringDb::CompareIDL ok" ) ); |
|
592 |
|
593 return res; |
|
594 } |
|
595 |
|
596 // ----------------------------------------------------------------------------- |
|
597 // RDrmMeteringDb::CompareIDL |
|
598 // |
|
599 // Compare whether the rowset's ID matches the given ID. For comparison of |
|
600 // Rights Issuer ID. Overloaded. |
|
601 // ----------------------------------------------------------------------------- |
|
602 // |
|
603 TBool RDrmMeteringDb::CompareIDL( RDbRowSet& aView, |
|
604 const TDesC8& aRiId ) |
|
605 { |
|
606 |
|
607 DRMLOG( _L( "RDrmMeteringDb::CompareIDL" ) ); |
|
608 |
|
609 TBool res = EFalse; |
|
610 |
|
611 CDbColSet* colset = aView.ColSetL(); |
|
612 CleanupStack::PushL( colset ); |
|
613 |
|
614 TPtrC8 riid = aView.ColDes8( colset->ColNo( KRightIssuerColName ) ); |
|
615 TBuf8< KRiIdSize > buf = riid; |
|
616 |
|
617 if ( aRiId.CompareC( buf ) == 0 ) |
|
618 { |
|
619 res = ETrue; |
|
620 } |
|
621 |
|
622 CleanupStack::PopAndDestroy( colset ); |
|
623 |
|
624 DRMLOG( _L( "RDrmMeteringDb::CompareIDL ok" ) ); |
|
625 |
|
626 return res; |
|
627 } |
|
628 |
|
629 |
|
630 // ----------------------------------------------------------------------------- |
|
631 // RDrmMeteringDb::PushL |
|
632 // |
|
633 // Push a cleanup item to cleanup stack. |
|
634 // ----------------------------------------------------------------------------- |
|
635 // |
|
636 void RDrmMeteringDb::PushL( RDbDatabase& aDb ) |
|
637 { |
|
638 TCleanupItem item( DoRollBack, &aDb ); |
|
639 CleanupStack::PushL( item ); |
|
640 } |
|
641 |
|
642 // ----------------------------------------------------------------------------- |
|
643 // RDrmMeteringDB::Pop |
|
644 // |
|
645 // Pop a cleanup item pushed in by PushL. |
|
646 // ----------------------------------------------------------------------------- |
|
647 // |
|
648 void RDrmMeteringDb::Pop() |
|
649 { |
|
650 CleanupStack::Pop(); |
|
651 } |
|
652 |
|
653 #endif |
|
654 |
|
655 // End of File |