199 DRMLOG( _L( "CDRMConsume::ConstructL" ) ); |
199 DRMLOG( _L( "CDRMConsume::ConstructL" ) ); |
200 CTimer::ConstructL(); |
200 CTimer::ConstructL(); |
201 iURI = aURI.AllocL(); |
201 iURI = aURI.AllocL(); |
202 if( aParentId ) |
202 if( aParentId ) |
203 { |
203 { |
204 iParentId = aParentId->AllocL(); |
204 iParentId = aParentId->AllocL(); |
205 } |
205 } |
206 } |
206 } |
207 |
207 |
208 // ------------------------------------------------------------------------ |
208 // ------------------------------------------------------------------------ |
209 // CDRMConsume::HandleL |
209 // CDRMConsume::HandleL |
210 // ------------------------------------------------------------------------ |
210 // ------------------------------------------------------------------------ |
211 // |
211 // |
212 void CDRMConsume::HandleL( ContentAccess::TIntent aIntent ) |
212 void CDRMConsume::HandleL( ContentAccess::TIntent aIntent ) |
213 { |
213 { |
214 DRMLOG( _L( "CDRMConsume::HandleL" ) ); |
214 DRMLOG( _L( "CDRMConsume::HandleL" ) ); |
215 |
215 |
216 TTime time; |
216 TTime time; |
217 TBool secure( SECURETIME( time ) ); |
217 TBool secure( SECURETIME( time ) ); |
218 InitializeL( aIntent, secure, time ); |
218 InitializeL( aIntent, secure, time ); |
219 |
219 |
220 DRMLOG( _L( "CDRMConsume::HandleL ok" ) ); |
220 DRMLOG( _L( "CDRMConsume::HandleL ok" ) ); |
221 } |
221 } |
222 |
222 |
223 // ------------------------------------------------------------------------ |
223 // ------------------------------------------------------------------------ |
224 // CDRMConsume:: Pause |
224 // CDRMConsume:: Pause |
225 // ------------------------------------------------------------------------ |
225 // ------------------------------------------------------------------------ |
226 // |
226 // |
227 void CDRMConsume::Pause() |
227 void CDRMConsume::Pause() |
228 { |
228 { |
229 DRMLOG( _L( "CDRMConsume::Pause" ) ); |
229 DRMLOG( _L( "CDRMConsume::Pause" ) ); |
230 |
230 |
231 Cancel(); |
231 Cancel(); |
232 |
232 |
233 DRMLOG( _L( "CDRMConsume::Pause ok" ) ); |
233 DRMLOG( _L( "CDRMConsume::Pause ok" ) ); |
234 } |
234 } |
235 |
235 |
236 // ------------------------------------------------------------------------ |
236 // ------------------------------------------------------------------------ |
237 // CDRMConsume:: ContinueL |
237 // CDRMConsume:: ContinueL |
238 // ------------------------------------------------------------------------ |
238 // ------------------------------------------------------------------------ |
239 // |
239 // |
240 void CDRMConsume::ContinueL() |
240 void CDRMConsume::ContinueL() |
241 { |
241 { |
242 DRMLOG( _L( "CDRMConsume::ContinueL" ) ); |
242 DRMLOG( _L( "CDRMConsume::ContinueL" ) ); |
243 |
243 |
244 Cancel(); |
244 Cancel(); |
245 |
245 |
246 TInt error = KErrNone; |
246 TInt error = KErrNone; |
247 TUint32 reason = 0; |
247 TUint32 reason = 0; |
248 |
248 |
249 CDRMPermission* child = NULL; |
249 CDRMPermission* child = NULL; |
250 HBufC8* parent = NULL; |
250 HBufC8* parent = NULL; |
251 |
251 |
252 // This got removed by Pause() |
252 // This got removed by Pause() |
253 if( iCountConstraintActive ) |
253 if( iCountConstraintActive ) |
254 { |
254 { |
255 SERVER->AddActiveCountConstraintL( *iURI ); |
255 SERVER->AddActiveCountConstraintL( *iURI ); |
256 DoContinueL(); |
256 DoContinueL(); |
257 return; |
257 return; |
258 } |
258 } |
259 |
259 |
260 /* Fetch the RO again in order to manage a situation when another |
260 /* Fetch the RO again in order to manage a situation when another |
261 instance has used the same RO (content has been consumed) while the |
261 instance has used the same RO (content has been consumed) while the |
262 other instance has not been used (player is paused) but will be |
262 other instance has not been used (player is paused) but will be |
263 used again (content consumption is to be continued). */ |
263 used again (content consumption is to be continued). */ |
264 error = iSession.FindRightsObject( iIntent, *iURI, child, parent, reason ); |
264 error = iSession.FindRightsObject( iIntent, *iURI, child, parent, reason ); |
265 |
265 |
266 /* Check if the RO found from the database matches with the one that was used |
266 /* Check if the RO found from the database matches with the one that was used |
267 in the original consumption of the content. If the ROs match, use the |
267 in the original consumption of the content. If the ROs match, use the |
268 (possibly updated) one from the database. */ |
268 (possibly updated) one from the database. */ |
269 if ( !error && child && iChild && |
269 if ( !error && child && iChild && |
270 ( iChild->iUniqueID == child->iUniqueID ) && |
270 ( iChild->iUniqueID == child->iUniqueID ) && |
271 ( iChild->iOriginalInsertTime == child->iOriginalInsertTime ) ) |
271 ( iChild->iOriginalInsertTime == child->iOriginalInsertTime ) ) |
272 { |
272 { |
273 if ( iParentId ) |
273 if ( iParentId ) |
274 { |
274 { |
275 delete iParentId; |
275 delete iParentId; |
276 iParentId = parent; |
276 iParentId = parent; |
277 } |
277 } |
278 |
278 |
279 delete iChild; |
279 delete iChild; |
280 iChild = child; |
280 iChild = child; |
281 } |
281 } |
282 else |
282 else |
283 { |
283 { |
284 /* The original RO was not found. Delete temporary objects and also |
284 /* The original RO was not found. Delete temporary objects and also |
285 delete the iChild and iCombined because the RO is no longer valid and |
285 delete the iChild and iCombined because the RO is no longer valid and |
286 need to be re-fetched using InitializeL method (in DoContinueL). |
286 need to be re-fetched using InitializeL method (in DoContinueL). |
287 (in DoContinueL). */ |
287 (in DoContinueL). */ |
288 if ( iChild ) |
288 if ( iChild ) |
289 { |
289 { |
290 delete iChild; |
290 delete iChild; |
291 iChild = NULL; |
291 iChild = NULL; |
292 } |
292 } |
293 |
293 |
294 if ( iCombined ) |
294 if ( iCombined ) |
295 { |
295 { |
296 delete iCombined; |
296 delete iCombined; |
297 iCombined = NULL; |
297 iCombined = NULL; |
298 } |
298 } |
299 |
299 |
300 if ( child ) |
300 if ( child ) |
301 { |
301 { |
302 delete child; |
302 delete child; |
303 child = NULL; |
303 child = NULL; |
304 } |
304 } |
305 if ( parent ) |
305 if ( parent ) |
306 { |
306 { |
307 delete parent; |
307 delete parent; |
308 parent = NULL; |
308 parent = NULL; |
309 } |
309 } |
310 } |
310 } |
311 |
311 |
312 DoContinueL(); |
312 DoContinueL(); |
313 |
313 |
314 //HandleL( iIntent ); |
314 //HandleL( iIntent ); |
315 |
315 |
316 DRMLOG( _L( "CDRMConsume::ContinueL ok" ) ); |
316 DRMLOG( _L( "CDRMConsume::ContinueL ok" ) ); |
317 } |
317 } |
318 |
318 |
319 // ------------------------------------------------------------------------ |
319 // ------------------------------------------------------------------------ |
320 // CDRMConsume:: Stop |
320 // CDRMConsume:: Stop |
321 // ------------------------------------------------------------------------ |
321 // ------------------------------------------------------------------------ |
322 // |
322 // |
323 void CDRMConsume::Stop() |
323 void CDRMConsume::Stop() |
324 { |
324 { |
325 DRMLOG( _L( "CDRMConsume::Stop" ) ); |
325 DRMLOG( _L( "CDRMConsume::Stop" ) ); |
326 |
326 |
327 Cancel(); |
327 Cancel(); |
328 |
328 |
329 DRMLOG( _L( "CDRMConsume::Stop ok" ) ); |
329 DRMLOG( _L( "CDRMConsume::Stop ok" ) ); |
330 } |
330 } |
331 |
331 |
332 // ------------------------------------------------------------------------ |
332 // ------------------------------------------------------------------------ |
333 // CDRMConsume:: ActivateL |
333 // CDRMConsume:: ActivateL |
334 // |
334 // |
335 // Calculate the smallest end time based on interval, end time, |
335 // Calculate the smallest end time based on interval, end time, |
336 // accumulated time & timed count. |
336 // accumulated time & timed count. |
337 // ------------------------------------------------------------------------ |
337 // ------------------------------------------------------------------------ |
338 // |
338 // |
339 void CDRMConsume::ActivateL( TBool aSecureTime, |
339 void CDRMConsume::ActivateL( TBool aSecureTime, |
340 const TTime& aTrustedTime ) |
340 const TTime& aTrustedTime ) |
341 { |
341 { |
342 DRMLOG( _L( "CDRMConsume::ActivateL" ) ); |
342 DRMLOG( _L( "CDRMConsume::ActivateL" ) ); |
343 |
343 |
344 __ASSERT_DEBUG( iChild && iCombined, User::Invariant() ); |
344 __ASSERT_DEBUG( iChild && iCombined, User::Invariant() ); |
345 TTime endTime( Time::MaxTTime() ); |
345 TTime endTime( Time::MaxTTime() ); |
346 TTimeIntervalSeconds timed( KMaxTInt32 ); |
346 TTimeIntervalSeconds timed( KMaxTInt32 ); |
347 TBool timeUsed( EFalse ); |
347 TBool timeUsed( EFalse ); |
348 TBool endTimeUsed( EFalse ); |
348 TBool endTimeUsed( EFalse ); |
349 |
349 |
350 iCurrentDelay = 0; |
350 iCurrentDelay = 0; |
351 |
351 |
352 if ( iCombined->iActiveConstraints & EConstraintTimedCounter ) |
352 if ( iCombined->iActiveConstraints & EConstraintTimedCounter ) |
353 { |
353 { |
354 // Take this, even if timed counts have been updated. |
354 // Take this, even if timed counts have been updated. |
355 // This might cause unnecessary RunL's to be called, but it |
355 // This might cause unnecessary RunL's to be called, but it |
356 // ensures both child & parent will be consumed when needed. |
356 // ensures both child & parent will be consumed when needed. |
357 // If e.g. it would be checked that iTimedCounts == 0xf, |
357 // If e.g. it would be checked that iTimedCounts == 0xf, |
358 // either one (child or parent) might not get updated in case of |
358 // either one (child or parent) might not get updated in case of |
359 // "Child expired, but parent didn't -> find new child". |
359 // "Child expired, but parent didn't -> find new child". |
360 PickSmaller( timed, iCombined->iTimedInterval ); |
360 PickSmaller( timed, iCombined->iTimedInterval ); |
361 timeUsed = ETrue; |
361 timeUsed = ETrue; |
362 } |
362 } |
363 |
363 |
364 if ( iCombined->iActiveConstraints & EConstraintAccumulated ) |
364 if ( iCombined->iActiveConstraints & EConstraintAccumulated ) |
365 { |
365 { |
366 PickSmaller( timed, iCombined->iAccumulatedTime ); |
366 PickSmaller( timed, iCombined->iAccumulatedTime ); |
367 timeUsed = ETrue; |
367 timeUsed = ETrue; |
368 } |
368 } |
369 |
369 |
370 if ( iCombined->iActiveConstraints & EConstraintInterval ) |
370 if ( iCombined->iActiveConstraints & EConstraintInterval ) |
371 { |
371 { |
372 if ( iCombined->iIntervalStart != Time::NullTTime() ) |
372 if ( iCombined->iIntervalStart != Time::NullTTime() ) |
373 { |
373 { |
374 endTime = iCombined->iIntervalStart; |
374 endTime = iCombined->iIntervalStart; |
376 endTimeUsed = ETrue; |
376 endTimeUsed = ETrue; |
377 } |
377 } |
378 else |
378 else |
379 { |
379 { |
380 TInt64 tmp( iCombined->iInterval.Int() ); |
380 TInt64 tmp( iCombined->iInterval.Int() ); |
381 |
381 |
382 PickSmaller( timed, tmp ); |
382 PickSmaller( timed, tmp ); |
383 timeUsed = ETrue; |
383 timeUsed = ETrue; |
384 } |
384 } |
385 } |
385 } |
386 |
386 |
387 if ( iCombined->iActiveConstraints & EConstraintEndTime ) |
387 if ( iCombined->iActiveConstraints & EConstraintEndTime ) |
388 { |
388 { |
389 PickSmaller( endTime, iCombined->iEndTime ); |
389 PickSmaller( endTime, iCombined->iEndTime ); |
390 endTimeUsed = ETrue; |
390 endTimeUsed = ETrue; |
391 } |
391 } |
392 |
392 |
393 // Put the "smallest time" information to "endTime". |
393 // Put the "smallest time" information to "endTime". |
394 if ( timeUsed ) |
394 if ( timeUsed ) |
395 { |
395 { |
396 TTime current( aTrustedTime ); |
396 TTime current( aTrustedTime ); |
397 |
397 |
398 current += timed; |
398 current += timed; |
399 |
399 |
400 PickSmaller( endTime, current ); |
400 PickSmaller( endTime, current ); |
401 endTimeUsed = ETrue; |
401 endTimeUsed = ETrue; |
402 } |
402 } |
403 |
403 |
404 // Interval gets initialised immediately, and so do count constraints. |
404 // Interval gets initialised immediately, and so do count constraints. |
405 // Timed/accumulated won't: those are consumed after the |
405 // Timed/accumulated won't: those are consumed after the |
406 // interval if secure time exists. |
406 // interval if secure time exists. |
407 Consume( ETrue, ETrue, EFalse, 0, |
407 Consume( ETrue, ETrue, EFalse, 0, |
408 aSecureTime, |
408 aSecureTime, |
409 aTrustedTime ); |
409 aTrustedTime ); |
410 |
410 |
411 // In case something was modified, update the db also. |
411 // In case something was modified, update the db also. |
412 UpdateDBL(); |
412 UpdateDBL(); |
413 |
413 |
414 if ( endTimeUsed ) |
414 if ( endTimeUsed ) |
415 { |
415 { |
416 // Something exists. |
416 // Something exists. |
417 TTimeIntervalSeconds secs( 0 ); |
417 TTimeIntervalSeconds secs( 0 ); |
418 TTime current( aTrustedTime ); |
418 TTime current( aTrustedTime ); |
419 TInt err( KErrNone ); |
419 TInt err( KErrNone ); |
420 |
420 |
421 // SecondsFrom returns an error if the difference is too great. |
421 // SecondsFrom returns an error if the difference is too great. |
422 err = endTime.SecondsFrom( current, secs ); |
422 err = endTime.SecondsFrom( current, secs ); |
423 if ( err ) |
423 if ( err ) |
424 { |
424 { |
425 iCurrentDelay = KConsumeDefaultTimer; |
425 iCurrentDelay = KConsumeDefaultTimer; |
434 } |
434 } |
435 else |
435 else |
436 { |
436 { |
437 iCurrentDelay = KConsumeDefaultTimer; |
437 iCurrentDelay = KConsumeDefaultTimer; |
438 } |
438 } |
439 |
439 |
440 if ( !IsAdded() ) |
440 if ( !IsAdded() ) |
441 { |
441 { |
442 CActiveScheduler::Add( this ); |
442 CActiveScheduler::Add( this ); |
443 } |
443 } |
444 |
444 |
445 DRMLOG2( _L( "CDRMConsume::ActivateL: using interval %d" ), |
445 DRMLOG2( _L( "CDRMConsume::ActivateL: using interval %d" ), |
446 ( TInt )iCurrentDelay ); |
446 ( TInt )iCurrentDelay ); |
447 |
447 |
448 // secs -> microsecs. The method sets the AO active. |
448 // secs -> microsecs. The method sets the AO active. |
449 After( TTimeIntervalMicroSeconds32( iCurrentDelay * 1000000 ) ); |
449 After( TTimeIntervalMicroSeconds32( iCurrentDelay * 1000000 ) ); |
450 |
450 |
451 iTime = current; |
451 iTime = current; |
452 |
452 |
453 // If we see timed things here, we also have secure time. |
453 // If we see timed things here, we also have secure time. |
454 //SETBIT( iMask, KConsumeHasSecureTime ); |
454 //SETBIT( iMask, KConsumeHasSecureTime ); |
455 } |
455 } |
456 else // For metering we always need to have this: |
456 else // For metering we always need to have this: |
457 { |
457 { |
458 iCurrentDelay = KConsumeDefaultTimer; |
458 iCurrentDelay = KConsumeDefaultTimer; |
459 iTime = aTrustedTime; |
459 iTime = aTrustedTime; |
460 |
460 |
461 if ( !IsAdded() ) |
461 if ( !IsAdded() ) |
462 { |
462 { |
463 CActiveScheduler::Add( this ); |
463 CActiveScheduler::Add( this ); |
464 } |
464 } |
465 |
465 |
466 DRMLOG2( _L( "CDRMConsume::ActivateL: using interval %d" ), |
466 DRMLOG2( _L( "CDRMConsume::ActivateL: using interval %d" ), |
467 ( TInt )iCurrentDelay ); |
467 ( TInt )iCurrentDelay ); |
468 |
468 |
469 // secs -> microsecs. The method sets the AO active. |
469 // secs -> microsecs. The method sets the AO active. |
470 After( TTimeIntervalMicroSeconds32( iCurrentDelay * 1000000 ) ); |
470 After( TTimeIntervalMicroSeconds32( iCurrentDelay * 1000000 ) ); |
471 } |
471 } |
472 |
472 |
473 // If we see timed things here, we also have secure time. |
473 // If we see timed things here, we also have secure time. |
474 if( aTrustedTime != Time::NullTTime()) |
474 if( aTrustedTime != Time::NullTTime()) |
475 { |
475 { |
476 SETBIT( iMask, KConsumeHasSecureTime ); |
476 SETBIT( iMask, KConsumeHasSecureTime ); |
477 } |
477 } |
478 DRMLOG( _L( "CDRMConsume::ActivateL ok" ) ); |
478 DRMLOG( _L( "CDRMConsume::ActivateL ok" ) ); |
479 } |
479 } |
480 |
480 |
481 // ------------------------------------------------------------------------ |
481 // ------------------------------------------------------------------------ |
482 // CDRMConsume:: Consume |
482 // CDRMConsume:: Consume |
483 // |
483 // |
484 // Consume child & parent. Whether to consume parent's explicit |
484 // Consume child & parent. Whether to consume parent's explicit |
485 // usage permission: the information is returned earlier by |
485 // usage permission: the information is returned earlier by |
486 // FindRightsObjectL. |
486 // FindRightsObjectL. |
487 // ------------------------------------------------------------------------ |
487 // ------------------------------------------------------------------------ |
488 // |
488 // |
489 void CDRMConsume::Consume( TBool aUpdateCounter, |
489 void CDRMConsume::Consume( TBool aUpdateCounter, |
490 TBool aInitInterval, |
490 TBool aInitInterval, |
603 // ------------------------------------------------------------------------ |
603 // ------------------------------------------------------------------------ |
604 // |
604 // |
605 void CDRMConsume::DoCancel() |
605 void CDRMConsume::DoCancel() |
606 { |
606 { |
607 DRMLOG( _L( "CDRMConsume::DoCancel" ) ); |
607 DRMLOG( _L( "CDRMConsume::DoCancel" ) ); |
608 |
608 |
609 TInt error( KErrNone ); |
609 TInt error( KErrNone ); |
610 TRAP( error, DoCancelL() ); |
610 TRAP( error, DoCancelL() ); |
611 |
611 |
612 DRMLOG2( _L( "CDRMConsume::DoCancel: %d" ), error ); |
612 DRMLOG2( _L( "CDRMConsume::DoCancel: %d" ), error ); |
613 } |
613 } |
614 |
614 |
615 // ------------------------------------------------------------------------ |
615 // ------------------------------------------------------------------------ |
616 // CDRMConsume::DoCancelL |
616 // CDRMConsume::DoCancelL |
617 // ------------------------------------------------------------------------ |
617 // ------------------------------------------------------------------------ |
618 // |
618 // |
619 void CDRMConsume::DoCancelL() |
619 void CDRMConsume::DoCancelL() |
620 { |
620 { |
621 DRMLOG( _L( "CDRMConsume::DoCancelL" ) ); |
621 DRMLOG( _L( "CDRMConsume::DoCancelL" ) ); |
622 |
622 |
623 if ( iCurrentDelay ) |
623 if ( iCurrentDelay ) |
624 { |
624 { |
625 TTimeIntervalSeconds secs; |
625 TTimeIntervalSeconds secs; |
626 TTime trustedTime; |
626 TTime trustedTime; |
627 TBool secureTime; |
627 TBool secureTime; |
628 |
628 |
629 CTimer::DoCancel(); |
629 CTimer::DoCancel(); |
630 |
630 |
631 secureTime = SECURETIME( trustedTime ); |
631 secureTime = SECURETIME( trustedTime ); |
632 trustedTime.SecondsFrom( iTime, secs ); |
632 trustedTime.SecondsFrom( iTime, secs ); |
633 |
633 |
634 #ifdef RD_DRM_METERING |
634 #ifdef RD_DRM_METERING |
635 // Update total cumulative time for content metering purposes |
635 // Update total cumulative time for content metering purposes |
636 iTotalCumulativeTime = iTotalCumulativeTime.Int() + secs.Int(); |
636 iTotalCumulativeTime = iTotalCumulativeTime.Int() + secs.Int(); |
637 #endif |
637 #endif |
638 |
638 |
639 // If the top level timed counter has not been activated yet |
639 // If the top level timed counter has not been activated yet |
640 // increment the counter |
640 // increment the counter |
641 if( ISSET( iTimedCounts, KChildToplevelCount ) ) |
641 if( ISSET( iTimedCounts, KChildToplevelCount ) ) |
642 { |
642 { |
643 iCumulativeDelayTop = iCumulativeDelayTop.Int() + secs.Int(); |
643 iCumulativeDelayTop = iCumulativeDelayTop.Int() + secs.Int(); |
644 } |
644 } |
645 |
645 |
646 // If the child timed counter has not been activated yet |
646 // If the child timed counter has not been activated yet |
647 // increment the counter |
647 // increment the counter |
648 if( ISSET( iTimedCounts, KChildPermCount ) ) |
648 if( ISSET( iTimedCounts, KChildPermCount ) ) |
649 { |
649 { |
650 iCumulativeDelayChild = iCumulativeDelayChild.Int() + secs.Int(); |
650 iCumulativeDelayChild = iCumulativeDelayChild.Int() + secs.Int(); |
651 } |
651 } |
652 |
652 |
653 // Always >= 0. |
653 // Always >= 0. |
654 ConsumeTimedItemsL( secs, |
654 ConsumeTimedItemsL( secs, |
655 secureTime, |
655 secureTime, |
656 trustedTime ); |
656 trustedTime ); |
657 iCurrentDelay = 0; |
657 iCurrentDelay = 0; |
658 } |
658 } |
659 |
659 |
660 UpdateDBL(); |
660 UpdateDBL(); |
661 |
661 |
662 if ( SERVER->HasActiveCountConstraint( *iURI ) ) |
662 if ( SERVER->HasActiveCountConstraint( *iURI ) ) |
663 { |
663 { |
664 SERVER->RemoveActiveCountConstraint( *iURI ); |
664 SERVER->RemoveActiveCountConstraint( *iURI ); |
665 } |
665 } |
666 |
666 |
667 DRMLOG( _L( "CDRMConsume::DoCancel ok" ) ); |
667 DRMLOG( _L( "CDRMConsume::DoCancel ok" ) ); |
668 } |
668 } |
669 |
669 |
670 // ------------------------------------------------------------------------ |
670 // ------------------------------------------------------------------------ |
671 // CDRMConsume::CombinePermissionsL |
671 // CDRMConsume::CombinePermissionsL |
702 // |
702 // |
703 void CDRMConsume::UpdateDBL() |
703 void CDRMConsume::UpdateDBL() |
704 { |
704 { |
705 DRMLOG( _L( "CDRMConsume::UpdateDBL" ) ); |
705 DRMLOG( _L( "CDRMConsume::UpdateDBL" ) ); |
706 // __ASSERT_DEBUG( iChild, User::Invariant() ); |
706 // __ASSERT_DEBUG( iChild, User::Invariant() ); |
707 |
707 |
708 CDRMEventModify* event = NULL; |
708 CDRMEventModify* event = NULL; |
709 TRequestStatus status; |
709 TRequestStatus status; |
710 |
710 |
711 if( ISSET( iMask, KConsumeChildModified ) ) |
711 if( ISSET( iMask, KConsumeChildModified ) ) |
712 { |
712 { |
713 event = CDRMEventModify::NewL(); |
713 event = CDRMEventModify::NewL(); |
714 } |
714 } |
715 CleanupStack::PushL( event ); |
715 CleanupStack::PushL( event ); |
716 |
716 |
717 if ( ISSET( iMask, KConsumeChildModified ) ) |
717 if ( ISSET( iMask, KConsumeChildModified ) ) |
718 { |
718 { |
719 DRMLOG( _L( "CDRMConsume: commiting child to DB" ) ); |
719 DRMLOG( _L( "CDRMConsume: commiting child to DB" ) ); |
720 |
720 |
721 if( iParentId ) |
721 if( iParentId ) |
722 { |
722 { |
723 DB.UpdateDBEntryL( *iParentId, *iChild ); |
723 DB.UpdateDBEntryL( *iParentId, *iChild ); |
724 // Notify |
724 // Notify |
725 event->SetContentIDL(*iParentId); |
725 event->SetContentIDL(*iParentId); |
726 event->SetUniqueID(iChild->iUniqueID); |
726 event->SetUniqueID(iChild->iUniqueID); |
727 } |
727 } |
728 else |
728 else |
729 { |
729 { |
730 DB.UpdateDBEntryL( *iURI, *iChild ); |
730 DB.UpdateDBEntryL( *iURI, *iChild ); |
731 // Notify |
731 // Notify |
732 event->SetContentIDL(*iURI); |
732 event->SetContentIDL(*iURI); |
733 event->SetUniqueID(iChild->iUniqueID); |
733 event->SetUniqueID(iChild->iUniqueID); |
734 } |
734 } |
735 |
735 |
736 // Notify |
736 // Notify |
737 event->SetContentIDL(*iURI); |
737 event->SetContentIDL(*iURI); |
738 event->SetUniqueID(iChild->iUniqueID); |
738 event->SetUniqueID(iChild->iUniqueID); |
739 |
739 |
740 NOTIFIER.SendEventL(*event,status); |
740 NOTIFIER.SendEventL(*event,status); |
741 User::WaitForRequest(status); |
741 User::WaitForRequest(status); |
742 |
742 |
743 CLRBIT( iMask, KConsumeChildModified ); |
743 CLRBIT( iMask, KConsumeChildModified ); |
744 } |
744 } |
745 |
745 |
746 CleanupStack::PopAndDestroy(); |
746 CleanupStack::PopAndDestroy(); |
747 DRMLOG( _L( "CDRMConsume::UpdateDBL ok" ) ); |
747 DRMLOG( _L( "CDRMConsume::UpdateDBL ok" ) ); |
748 } |
748 } |
749 // ------------------------------------------------------------------------ |
749 // ------------------------------------------------------------------------ |
750 // CDRMConsume::ConsumeConstraint |
750 // CDRMConsume::ConsumeConstraint |
751 // |
751 // |
752 // Consume child & parent. Whether to consume parent's explicit |
752 // Consume child & parent. Whether to consume parent's explicit |
753 // usage permission: the information is returned earlier by |
753 // usage permission: the information is returned earlier by |
754 // FindRightsObjectL. |
754 // FindRightsObjectL. |
755 // ------------------------------------------------------------------------ |
755 // ------------------------------------------------------------------------ |
756 // |
756 // |
757 TBool CDRMConsume::ConsumeConstraint( CDRMConstraint& aConstraint, |
757 TBool CDRMConsume::ConsumeConstraint( CDRMConstraint& aConstraint, |
758 TBool aUpdateCounter, |
758 TBool aUpdateCounter, |
762 TBool aSecureTime, |
762 TBool aSecureTime, |
763 const TTime& aTrustedTime, |
763 const TTime& aTrustedTime, |
764 TTimeIntervalSeconds& aCumulativeTime ) |
764 TTimeIntervalSeconds& aCumulativeTime ) |
765 { |
765 { |
766 DRMLOG( _L( "CDRMConsume::ConsumeConstraints" ) ); |
766 DRMLOG( _L( "CDRMConsume::ConsumeConstraints" ) ); |
767 |
767 |
768 TBool res( EFalse ); |
768 TBool res( EFalse ); |
769 |
769 |
770 if ( aUpdateCounter && |
770 if ( aUpdateCounter && |
771 ( aConstraint.iActiveConstraints & EConstraintCounter ) ) |
771 ( aConstraint.iActiveConstraints & EConstraintCounter ) ) |
772 { |
772 { |
773 --( aConstraint.iCounter); |
773 --( aConstraint.iCounter); |
774 res = ETrue; |
774 res = ETrue; |
775 iCountConstraintActive = ETrue; |
775 iCountConstraintActive = ETrue; |
776 TRAP_IGNORE( SERVER->AddActiveCountConstraintL( *iURI ) ); |
776 TRAP_IGNORE( SERVER->AddActiveCountConstraintL( *iURI ) ); |
777 } |
777 } |
778 |
778 |
779 if ( aInitInterval && |
779 if ( aInitInterval && |
780 ( aConstraint.iActiveConstraints & EConstraintInterval ) && |
780 ( aConstraint.iActiveConstraints & EConstraintInterval ) && |
781 aSecureTime && |
781 aSecureTime && |
782 aConstraint.iIntervalStart == Time::NullTTime() ) |
782 aConstraint.iIntervalStart == Time::NullTTime() ) |
783 { |
783 { |
784 aConstraint.iIntervalStart = aTrustedTime; |
784 aConstraint.iIntervalStart = aTrustedTime; |
785 res = ETrue; |
785 res = ETrue; |
786 } |
786 } |
787 |
787 |
788 /* change to timed counter, we don't check the latest time, we check the |
788 /* change to timed counter, we don't check the latest time, we check the |
789 cumulated time */ |
789 cumulated time */ |
790 |
790 |
791 if ( aUpdateTimedCount && |
791 if ( aUpdateTimedCount && |
792 ( aConstraint.iActiveConstraints & EConstraintTimedCounter && |
792 ( aConstraint.iActiveConstraints & EConstraintTimedCounter && |
793 ( aCumulativeTime >= aConstraint.iTimedInterval || |
793 ( aCumulativeTime >= aConstraint.iTimedInterval || |
794 aElapsedTime >= aConstraint.iTimedInterval ) ) ) |
794 aElapsedTime >= aConstraint.iTimedInterval ) ) ) |
795 { |
795 { |
796 --( aConstraint.iTimedCounter ); |
796 --( aConstraint.iTimedCounter ); |
797 res = ETrue; |
797 res = ETrue; |
798 iCountConstraintActive = ETrue; |
798 iCountConstraintActive = ETrue; |
799 TRAP_IGNORE( SERVER->AddActiveCountConstraintL( *iURI ) ); |
799 TRAP_IGNORE( SERVER->AddActiveCountConstraintL( *iURI ) ); |
800 aCumulativeTime = TTimeIntervalSeconds( 0 ); |
800 aCumulativeTime = TTimeIntervalSeconds( 0 ); |
801 } |
801 } |
802 else if ( aUpdateTimedCount && |
802 else if ( aUpdateTimedCount && |
803 ( aConstraint.iActiveConstraints & EConstraintTimedCounter ) ) |
803 ( aConstraint.iActiveConstraints & EConstraintTimedCounter ) ) |
804 { |
804 { |
805 iUsingTimedCount = ETrue; |
805 iUsingTimedCount = ETrue; |
806 } |
806 } |
807 |
807 |
808 |
808 |
809 if ( aElapsedTime.Int() != 0 && |
809 if ( aElapsedTime.Int() != 0 && |
810 ( aConstraint.iActiveConstraints & EConstraintAccumulated ) ) |
810 ( aConstraint.iActiveConstraints & EConstraintAccumulated ) ) |
811 { |
811 { |
812 __ASSERT_DEBUG( aElapsedTime.Int() > 0, User::Invariant() ); |
812 __ASSERT_DEBUG( aElapsedTime.Int() > 0, User::Invariant() ); |
813 |
813 |
814 if ( aConstraint.iAccumulatedTime < aElapsedTime ) |
814 if ( aConstraint.iAccumulatedTime < aElapsedTime ) |
815 { |
815 { |
816 aConstraint.iAccumulatedTime = 0; |
816 aConstraint.iAccumulatedTime = 0; |
817 } |
817 } |
818 else |
818 else |
819 { |
819 { |
820 aConstraint.iAccumulatedTime = aConstraint.iAccumulatedTime.Int() - |
820 aConstraint.iAccumulatedTime = aConstraint.iAccumulatedTime.Int() - |
821 aElapsedTime.Int(); |
821 aElapsedTime.Int(); |
822 } |
822 } |
823 |
823 |
824 res = ETrue; |
824 res = ETrue; |
825 } |
825 } |
826 |
826 |
827 if ( !iCountConstraintActive && aConstraint.Expired( aTrustedTime ) ) |
827 if ( !iCountConstraintActive && aConstraint.Expired( aTrustedTime ) ) |
828 { |
828 { |
829 iExpired = ETrue; |
829 iExpired = ETrue; |
830 } |
830 } |
831 else |
831 else |
832 { |
832 { |
833 iExpired = EFalse; |
833 iExpired = EFalse; |
834 } |
834 } |
835 |
835 |
836 DRMLOG2( |
836 DRMLOG2( |
837 _L( "CDRMConsume::ConsumeConstraints ok, returning %d" ), |
837 _L( "CDRMConsume::ConsumeConstraints ok, returning %d" ), |
838 ( TInt )res ); |
838 ( TInt )res ); |
839 |
839 |
840 return res; |
840 return res; |
841 } |
841 } |
842 |
842 |
843 // ------------------------------------------------------------------------ |
843 // ------------------------------------------------------------------------ |
844 // CDRMConsume::ConsumeTimedItemsL |
844 // CDRMConsume::ConsumeTimedItemsL |
847 void CDRMConsume::ConsumeTimedItemsL( TTimeIntervalSeconds aDelay, |
847 void CDRMConsume::ConsumeTimedItemsL( TTimeIntervalSeconds aDelay, |
848 TBool aSecureTime, |
848 TBool aSecureTime, |
849 const TTime& aTrustedTime ) |
849 const TTime& aTrustedTime ) |
850 { |
850 { |
851 DRMLOG( _L( "CDRMConsume::ConsumeTimedItemsL" ) ); |
851 DRMLOG( _L( "CDRMConsume::ConsumeTimedItemsL" ) ); |
852 |
852 |
853 // Update accumulated constraints & timed count. |
853 // Update accumulated constraints & timed count. |
854 Consume( EFalse, |
854 Consume( EFalse, |
855 ETrue, |
855 ETrue, |
856 ETrue, |
856 ETrue, |
857 aDelay, |
857 aDelay, |
858 aSecureTime, |
858 aSecureTime, |
859 aTrustedTime ); |
859 aTrustedTime ); |
860 |
860 |
861 DRMLOG( _L( "CDRMConsume::ConsumeTimedItems ok" ) ); |
861 DRMLOG( _L( "CDRMConsume::ConsumeTimedItems ok" ) ); |
862 } |
862 } |
863 |
863 |
864 // ------------------------------------------------------------------------ |
864 // ------------------------------------------------------------------------ |
865 // CDRMConsume::DoContinueL |
865 // CDRMConsume::DoContinueL |
866 // ------------------------------------------------------------------------ |
866 // ------------------------------------------------------------------------ |
867 // |
867 // |
868 void CDRMConsume::DoContinueL() |
868 void CDRMConsume::DoContinueL() |
869 { |
869 { |
870 DRMLOG( _L( "CDRMConsume::DoContinueL" ) ); |
870 DRMLOG( _L( "CDRMConsume::DoContinueL" ) ); |
871 |
871 |
872 TTime time; |
872 TTime time; |
873 TBool secureTime( EFalse ); |
873 TBool secureTime( EFalse ); |
874 secureTime = SECURETIME( time ); |
874 secureTime = SECURETIME( time ); |
875 |
875 |
876 if ( !iChild || !iCombined ) |
876 if ( !iChild || !iCombined ) |
877 { |
877 { |
878 InitializeL( iIntent, secureTime, time ); |
878 InitializeL( iIntent, secureTime, time ); |
879 // User::Leave( KErrCANoRights ); |
879 // User::Leave( KErrCANoRights ); |
880 return; |
880 return; |
881 } |
881 } |
882 |
882 |
883 ConsumeTimedItemsL( iCurrentDelay, secureTime, time ); |
883 ConsumeTimedItemsL( iCurrentDelay, secureTime, time ); |
884 UpdateDBL(); |
884 UpdateDBL(); |
885 iCurrentDelay = 0; |
885 iCurrentDelay = 0; |
886 |
886 |
887 CombinePermissionsL(); |
887 CombinePermissionsL(); |
888 |
888 |
889 // If the content has expired, find new permissions, unless the expired |
889 // If the content has expired, find new permissions, unless the expired |
890 // constraint was a timed count. In that case, the constraint |
890 // constraint was a timed count. In that case, the constraint |
891 // did not really expire. |
891 // did not really expire. |
892 if ( SecurityLevelChanged( secureTime ) || |
892 if ( SecurityLevelChanged( secureTime ) || |
893 ( iCombined->Expired( time ) && |
893 ( iCombined->Expired( time ) && |
894 !SERVER->HasActiveCountConstraint( *iURI ) ) ) |
894 !SERVER->HasActiveCountConstraint( *iURI ) ) ) |
895 { |
895 { |
896 InitializeL( iIntent, secureTime, time ); |
896 InitializeL( iIntent, secureTime, time ); |
897 } |
897 } |
898 else |
898 else |
899 { |
899 { |
900 ActivateL( secureTime, time ); |
900 ActivateL( secureTime, time ); |
901 } |
901 } |
902 |
902 |
903 DRMLOG( _L( "CDRMConsume::DoContinueL ok" ) ); |
903 DRMLOG( _L( "CDRMConsume::DoContinueL ok" ) ); |
904 } |
904 } |
905 |
905 |
906 // ------------------------------------------------------------------------ |
906 // ------------------------------------------------------------------------ |
907 // CDRMConsume::SecurityLevelChanged |
907 // CDRMConsume::SecurityLevelChanged |
908 // ------------------------------------------------------------------------ |
908 // ------------------------------------------------------------------------ |
909 // |
909 // |
910 TBool CDRMConsume::SecurityLevelChanged( TBool aSecureTime ) const |
910 TBool CDRMConsume::SecurityLevelChanged( TBool aSecureTime ) const |
911 { |
911 { |
912 DRMLOG( _L( "CDRMConsume::SecurityLevelChanged" ) ); |
912 DRMLOG( _L( "CDRMConsume::SecurityLevelChanged" ) ); |
913 |
913 |
914 if ( ( ISSET( iMask, KConsumeHasSecureTime ) && aSecureTime ) || |
914 if ( ( ISSET( iMask, KConsumeHasSecureTime ) && aSecureTime ) || |
915 !( ISSET( iMask, KConsumeHasSecureTime ) || aSecureTime ) ) |
915 !( ISSET( iMask, KConsumeHasSecureTime ) || aSecureTime ) ) |
916 { |
916 { |
917 return EFalse; |
917 return EFalse; |
918 } |
918 } |
919 |
919 |
920 return ETrue; |
920 return ETrue; |
921 } |
921 } |
922 |
922 |
923 // ------------------------------------------------------------------------ |
923 // ------------------------------------------------------------------------ |
924 // CDRMConsume::InitializeL |
924 // CDRMConsume::InitializeL |
927 void CDRMConsume::InitializeL( ContentAccess::TIntent aIntent, |
927 void CDRMConsume::InitializeL( ContentAccess::TIntent aIntent, |
928 TBool aSecureTime, |
928 TBool aSecureTime, |
929 const TTime& aTrustedTime ) |
929 const TTime& aTrustedTime ) |
930 { |
930 { |
931 DRMLOG( _L( "CDRMConsume::InitializeL" ) ); |
931 DRMLOG( _L( "CDRMConsume::InitializeL" ) ); |
932 |
932 |
933 // aIntent is either EPlay, EView, EExecute or EPrint. |
933 // aIntent is either EPlay, EView, EExecute or EPrint. |
934 // Store the old consumption information in case this is |
934 // Store the old consumption information in case this is |
935 // called in case of "ran out of permissions, find new ones" |
935 // called in case of "ran out of permissions, find new ones" |
936 CDRMPermission* child( iChild ); |
936 CDRMPermission* child( iChild ); |
937 TUint8 timedCounts( iTimedCounts ); |
937 TUint8 timedCounts( iTimedCounts ); |
938 TUint8 counters( iCounters ); |
938 TUint8 counters( iCounters ); |
939 TUint32 reason = 0; |
939 TUint32 reason = 0; |
940 |
940 |
941 // Reset. |
941 // Reset. |
942 iTimedCounts = 0xf; |
942 iTimedCounts = 0xf; |
943 iCounters = 0xf; |
943 iCounters = 0xf; |
944 iMask = 0x0; |
944 iMask = 0x0; |
945 iCurrentDelay = 0; |
945 iCurrentDelay = 0; |
946 |
946 |
947 iExpired = ETrue; |
947 iExpired = ETrue; |
948 |
948 |
949 delete iCombined; iCombined = NULL; |
949 delete iCombined; iCombined = NULL; |
950 |
950 |
951 // Previous child & parent need to be stored in case the internal |
951 // Previous child & parent need to be stored in case the internal |
952 // counter states need to be restored. |
952 // counter states need to be restored. |
953 if ( child ) |
953 if ( child ) |
954 { |
954 { |
955 CleanupStack::PushL( child ); |
955 CleanupStack::PushL( child ); |
956 iChild = NULL; |
956 iChild = NULL; |
957 } |
957 } |
958 |
958 |
959 // If the next call won't leave, we have permissions. |
959 // If the next call won't leave, we have permissions. |
960 User::LeaveIfError( iSession.FindRightsObject( aIntent, |
960 User::LeaveIfError( iSession.FindRightsObject( aIntent, |
961 *iURI, |
961 *iURI, |
962 iChild, |
962 iChild, |
963 iParentId, |
963 iParentId, |
964 reason ) ); |
964 reason ) ); |
965 |
965 |
966 User::LeaveIfError( iSession.VerifyCredentials( iURI, iChild, aIntent ) ); |
966 User::LeaveIfError( iSession.VerifyCredentials( iURI, iChild, aIntent ) ); |
967 |
967 |
968 iExpired = EFalse; |
968 iExpired = EFalse; |
969 |
969 |
970 // Check whether to restore the internal state. |
970 // Check whether to restore the internal state. |
971 if ( iIntent == aIntent ) |
971 if ( iIntent == aIntent ) |
972 { |
972 { |
973 if ( child && |
973 if ( child && |
974 ( child->iUniqueID == iChild->iUniqueID ) ) |
974 ( child->iUniqueID == iChild->iUniqueID ) ) |
975 { |
975 { |
976 DRMLOG( _L( "CDRMConsume: using the previous child" ) ); |
976 DRMLOG( _L( "CDRMConsume: using the previous child" ) ); |
977 |
977 |
978 CLRBIT( iTimedCounts, |
978 CLRBIT( iTimedCounts, |
979 ( KChildToplevelCount | KChildPermCount ) & ~timedCounts ); |
979 ( KChildToplevelCount | KChildPermCount ) & ~timedCounts ); |
980 |
980 |
981 CLRBIT( iCounters, |
981 CLRBIT( iCounters, |
982 ( KChildToplevelCount | KChildPermCount ) & ~counters ); |
982 ( KChildToplevelCount | KChildPermCount ) & ~counters ); |
983 } |
983 } |
984 } |
984 } |
985 |
985 |
986 if ( child ) |
986 if ( child ) |
987 { |
987 { |
988 CleanupStack::PopAndDestroy(); |
988 CleanupStack::PopAndDestroy(); |
989 } |
989 } |
990 |
990 |
991 iIntent = aIntent; |
991 iIntent = aIntent; |
992 |
992 |
993 CombinePermissionsL(); |
993 CombinePermissionsL(); |
994 ActivateL( aSecureTime, aTrustedTime ); |
994 ActivateL( aSecureTime, aTrustedTime ); |
995 |
995 |
996 DRMLOG( _L( "CDRMConsume::InitializeL ok" ) ); |
996 DRMLOG( _L( "CDRMConsume::InitializeL ok" ) ); |
997 } |
997 } |
998 |
998 |
999 // ------------------------------------------------------------------------ |
999 // ------------------------------------------------------------------------ |
1000 // CDRMConsume::CountConstraintActive |
1000 // CDRMConsume::CountConstraintActive |
1001 // ------------------------------------------------------------------------ |
1001 // ------------------------------------------------------------------------ |
1002 // |
1002 // |
1003 TBool CDRMConsume::CountConstraintActive() |
1003 TBool CDRMConsume::CountConstraintActive() |
1029 // CDRMConsume::UpdateMeteringDbL |
1029 // CDRMConsume::UpdateMeteringDbL |
1030 // ------------------------------------------------------------------------ |
1030 // ------------------------------------------------------------------------ |
1031 // |
1031 // |
1032 void CDRMConsume::UpdateMeteringDbL() |
1032 void CDRMConsume::UpdateMeteringDbL() |
1033 { |
1033 { |
1034 DRMLOG( _L( "CDRMConsume::UpdateMeteringDbL" ) ); |
1034 DRMLOG( _L( "CDRMConsume::UpdateMeteringDbL" ) ); |
1035 TTimeIntervalSeconds graceTime = 0; |
1035 TTimeIntervalSeconds graceTime = 0; |
1036 CDRMConstraint* constraint = NULL; |
1036 CDRMConstraint* constraint = NULL; |
1037 |
1037 |
1038 if ( iChild ) |
1038 if ( iChild ) |
1039 { |
1039 { |
1040 constraint = iChild->ConstraintForIntent( iIntent ); |
1040 constraint = iChild->ConstraintForIntent( iIntent ); |
1041 if ( constraint && constraint->iDrmMeteringInfo ) |
1041 if ( constraint && constraint->iDrmMeteringInfo ) |
1042 { |
1042 { |
1043 |
1043 |
1044 graceTime = constraint->iDrmMeteringInfo->iGraceTime; |
1044 graceTime = constraint->iDrmMeteringInfo->iGraceTime; |
1045 |
1045 |
1046 // Grace time exceeded, increase metering count and metering |
1046 // Grace time exceeded, increase metering count and metering |
1047 // accumulated time |
1047 // accumulated time |
1048 if ( iTotalCumulativeTime >= graceTime ) |
1048 if ( iTotalCumulativeTime >= graceTime ) |
1049 { |
1049 { |
1050 // Check Rights Issuer rights from Roap storage |
1050 // Check Rights Issuer rights from Roap storage |
1051 if ( !CheckRiContextRightsL( iChild->iRiId ) ) |
1051 if ( !CheckRiContextRightsL( iChild->iRiId ) ) |
1052 { |
1052 { |
1053 return; |
1053 return; |
1054 } |
1054 } |
1055 |
1055 |
1056 // Update database only if Rights Issuer Id is available |
1056 // Update database only if Rights Issuer Id is available |
1057 if ( ( iChild->iRiId.Length() > 0 ) && |
1057 if ( ( iChild->iRiId.Length() > 0 ) && |
1058 ( iChild->iRiId.Length() <= KRiIdSize ) ) |
1058 ( iChild->iRiId.Length() <= KRiIdSize ) ) |
1059 { |
1059 { |
1060 |
1060 |
1061 if ( iURI ) |
1061 if ( iURI ) |
1062 { |
1062 { |
1063 CDrmMeteringDbData* meteringData = |
1063 CDrmMeteringDbData* meteringData = |
1064 CDrmMeteringDbData::NewLC(); |
1064 CDrmMeteringDbData::NewLC(); |
1065 meteringData->iContentId = iURI->AllocL(); |
1065 meteringData->iContentId = iURI->AllocL(); |
1066 meteringData->iRiId = iChild->iRiId; |
1066 meteringData->iRiId = iChild->iRiId; |
1067 if( iUsingTimedCount && !iCountConstraintActive ) |
1067 if( iUsingTimedCount && !iCountConstraintActive ) |
1068 { |
1068 { |
1069 meteringData->iCount = 0; |
1069 meteringData->iCount = 0; |
1070 } |
1070 } |
1071 else |
1071 else |
1072 { |
1072 { |
1073 meteringData->iCount = 1; |
1073 meteringData->iCount = 1; |
1074 } |
1074 } |
1075 |
1075 |
1076 meteringData->iAccumulatedTime = iTotalCumulativeTime; |
1076 meteringData->iAccumulatedTime = iTotalCumulativeTime; |
1077 |
1077 |
1078 if ( iParentId ) |
1078 if ( iParentId ) |
1079 { |
1079 { |
1080 meteringData->iParentUid = iParentId->AllocL(); |
1080 meteringData->iParentUid = iParentId->AllocL(); |
1081 } |
1081 } |
1082 |
1082 |
1083 METERINGDB.AddL( meteringData ); |
1083 METERINGDB.AddL( meteringData ); |
1084 CleanupStack::PopAndDestroy(); // meteringData |
1084 CleanupStack::PopAndDestroy(); // meteringData |
1085 } |
1085 } |
1086 } |
1086 } |
1087 } |
1087 } |
1088 } |
1088 } |
1089 } |
1089 } |
1090 DRMLOG( _L( "CDRMConsume::UpdateMeteringDbL ok" ) ); |
1090 DRMLOG( _L( "CDRMConsume::UpdateMeteringDbL ok" ) ); |
1091 } |
1091 } |
1092 |
1092 |
1093 // ------------------------------------------------------------------------ |
1093 // ------------------------------------------------------------------------ |
1094 // CDRMConsume::CheckRiContextRightsL |
1094 // CDRMConsume::CheckRiContextRightsL |
1095 // ------------------------------------------------------------------------ |
1095 // ------------------------------------------------------------------------ |
1096 // |
1096 // |
1097 |
1097 |
1098 TBool CDRMConsume::CheckRiContextRightsL( const TDesC8& aRiId ) |
1098 TBool CDRMConsume::CheckRiContextRightsL( const TDesC8& aRiId ) |
1099 { |
1099 { |
1100 |
1100 |
1101 DRMLOG( _L( "CDRMConsume::CheckRiContextRightsL" ) ); |
1101 DRMLOG( _L( "CDRMConsume::CheckRiContextRightsL" ) ); |
1102 |
1102 |
1103 CDRMRIContext* riContext = NULL; |
1103 CDRMRIContext* riContext = NULL; |
1104 TBool haveRights = EFalse; |
1104 TBool haveRights = EFalse; |
1105 |
1105 |
1106 // Connect to the storage of the registered Rights Issuers |
1106 // Connect to the storage of the registered Rights Issuers |
1107 |
1107 |
1108 if( iSession.ConnectRoapClient() == KErrNone ) |
1108 if( iSession.ConnectRoapClient() == KErrNone ) |
1109 { |
1109 { |
1110 riContext = iSession.RoapClient().GetRIContextL( aRiId ); |
1110 riContext = iSession.RoapClient().GetRIContextL( aRiId ); |
1111 |
1111 |
1112 if ( riContext == NULL ) |
1112 if ( riContext == NULL ) |
1113 { |
1113 { |
1114 DRMLOG( _L ( "RI not registered" ) ); |
1114 DRMLOG( _L ( "RI not registered" ) ); |
1115 User::Leave( KErrRightsServerRiNotRegistered ); |
1115 User::Leave( KErrRightsServerRiNotRegistered ); |
1116 } |
1116 } |
1117 |
1117 |
1118 // Check (via the Rights Issuer context) whether Rights Issuer |
1118 // Check (via the Rights Issuer context) whether Rights Issuer |
1119 // is allowed to use metering or not |
1119 // is allowed to use metering or not |
1120 if ( riContext->IsMeteringAllowed() ) |
1120 if ( riContext->IsMeteringAllowed() ) |
1121 { |
1121 { |
1122 haveRights = ETrue; |
1122 haveRights = ETrue; |
1123 } |
1123 } |
1124 |
1124 |
1125 if ( riContext ) |
1125 if ( riContext ) |
1126 { |
1126 { |
1127 delete riContext; |
1127 delete riContext; |
1128 riContext = NULL; |
1128 riContext = NULL; |
1129 } |
1129 } |
1130 } |
1130 } |
1131 |
1131 |
1132 return haveRights; |
1132 return haveRights; |
1133 |
1133 |
1134 } |
1134 } |
1135 |
1135 |
1136 #endif |
1136 #endif |
1137 |
1137 |
1138 // EOF |
1138 // EOF |