17 |
17 |
18 |
18 |
19 // INCLUDE FILES |
19 // INCLUDE FILES |
20 #include <caf/caftypes.h> |
20 #include <caf/caftypes.h> |
21 #include <caf/data.h> |
21 #include <caf/data.h> |
22 #include <oma2agent.h> |
22 #include <Oma2Agent.h> |
23 #include <utf.h> |
23 #include <utf.h> |
24 #include <drmrights.h> |
24 #include <DRMRights.h> |
25 #include <drmagents.h> |
25 #include <drmagents.h> |
26 #include <e32cmn.h> |
26 #include <e32cmn.h> |
27 #include <drmutility.h> |
27 #include <drmutility.h> |
28 |
28 |
29 #include "drmautomatedusageimpl.h" |
29 #include "DrmAutomatedUsageImpl.h" |
30 #include "drmautomatedusagedata.h" |
30 #include "drmautomatedusagedata.h" |
31 #include "drmutilityui.h" |
31 #include "drmutilityui.h" |
32 |
32 |
33 // CONSTANTS |
33 // CONSTANTS |
34 _LIT( KAuClassificationRingingTone, "Ringtone" ); |
34 _LIT( KAuClassificationRingingTone, "Ringtone" ); |
66 |
66 |
67 LOCAL_C TBool IntervalsEqual( const CDRMConstraint *aFirst, |
67 LOCAL_C TBool IntervalsEqual( const CDRMConstraint *aFirst, |
68 const CDRMConstraint *aSecond ) |
68 const CDRMConstraint *aSecond ) |
69 { |
69 { |
70 TBool equal( EFalse ); |
70 TBool equal( EFalse ); |
71 TInt64 startDifference( |
71 TInt64 startDifference( |
72 aFirst->iIntervalStart.Int64() - aSecond->iIntervalStart.Int64() ); |
72 aFirst->iIntervalStart.Int64() - aSecond->iIntervalStart.Int64() ); |
73 |
73 |
74 if( aFirst->iInterval == aSecond->iInterval && |
74 if( aFirst->iInterval == aSecond->iInterval && |
75 -KTimeMarginal <= startDifference && |
75 -KTimeMarginal <= startDifference && |
76 startDifference <= KTimeMarginal ) |
76 startDifference <= KTimeMarginal ) |
77 { |
77 { |
78 equal = ETrue; |
78 equal = ETrue; |
79 } |
79 } |
80 return equal; |
80 return equal; |
81 } |
81 } |
82 |
82 |
83 |
83 |
84 LOCAL_C HBufC8* GetContentIdL( const ContentAccess::CData& aData ) |
84 LOCAL_C HBufC8* GetContentIdL( const ContentAccess::CData& aData ) |
85 { |
85 { |
103 LOCAL_C TBool HasCountOrAccumulated( const CDRMConstraint* aConstraint ) |
103 LOCAL_C TBool HasCountOrAccumulated( const CDRMConstraint* aConstraint ) |
104 { |
104 { |
105 // constraint has counters, timed counters or accumulated |
105 // constraint has counters, timed counters or accumulated |
106 if ( aConstraint->iActiveConstraints & ( EConstraintCounter | |
106 if ( aConstraint->iActiveConstraints & ( EConstraintCounter | |
107 EConstraintTimedCounter | |
107 EConstraintTimedCounter | |
108 EConstraintAccumulated ) ) |
108 EConstraintAccumulated ) ) |
109 { |
109 { |
110 return ETrue; |
110 return ETrue; |
111 } |
111 } |
112 return EFalse; |
112 return EFalse; |
113 } |
113 } |
126 DRM::CDrmUtility* aDrmUtility ): CActive( EPriorityStandard ), |
126 DRM::CDrmUtility* aDrmUtility ): CActive( EPriorityStandard ), |
127 iAuObserver( NULL ), |
127 iAuObserver( NULL ), |
128 iCoeEnv( aCoeEnv ), |
128 iCoeEnv( aCoeEnv ), |
129 iDrmUtility( aDrmUtility ) |
129 iDrmUtility( aDrmUtility ) |
130 { |
130 { |
131 |
131 |
132 } |
132 } |
133 |
133 |
134 // ----------------------------------------------------------------------------- |
134 // ----------------------------------------------------------------------------- |
135 // DRM::CDrmAutomatedUsageImpl::ConstructL |
135 // DRM::CDrmAutomatedUsageImpl::ConstructL |
136 // Symbian 2nd phase constructor can leave. |
136 // Symbian 2nd phase constructor can leave. |
153 // DRM::CDrmAutomatedUsageImpl::NewL |
153 // DRM::CDrmAutomatedUsageImpl::NewL |
154 // Two-phased constructor. |
154 // Two-phased constructor. |
155 // ----------------------------------------------------------------------------- |
155 // ----------------------------------------------------------------------------- |
156 // |
156 // |
157 EXPORT_C DRM::CDrmAutomatedUsageImpl* DRM::CDrmAutomatedUsageImpl::NewL( |
157 EXPORT_C DRM::CDrmAutomatedUsageImpl* DRM::CDrmAutomatedUsageImpl::NewL( |
158 CCoeEnv* aCoeEnv, |
158 CCoeEnv* aCoeEnv, |
159 DRM::CDrmUtility* aDrmUtility ) |
159 DRM::CDrmUtility* aDrmUtility ) |
160 { |
160 { |
161 DRM::CDrmAutomatedUsageImpl* self( |
161 DRM::CDrmAutomatedUsageImpl* self( |
162 DRM::CDrmAutomatedUsageImpl::NewLC( aCoeEnv, |
162 DRM::CDrmAutomatedUsageImpl::NewLC( aCoeEnv, |
163 aDrmUtility ) ); |
163 aDrmUtility ) ); |
164 CleanupStack::Pop( self ); |
164 CleanupStack::Pop( self ); |
165 return self; |
165 return self; |
166 } |
166 } |
167 |
167 |
173 // |
173 // |
174 EXPORT_C DRM::CDrmAutomatedUsageImpl* DRM::CDrmAutomatedUsageImpl::NewLC( |
174 EXPORT_C DRM::CDrmAutomatedUsageImpl* DRM::CDrmAutomatedUsageImpl::NewLC( |
175 CCoeEnv* aCoeEnv, DRM::CDrmUtility* aDrmUtility ) |
175 CCoeEnv* aCoeEnv, DRM::CDrmUtility* aDrmUtility ) |
176 { |
176 { |
177 DRM::CDrmAutomatedUsageImpl* self( |
177 DRM::CDrmAutomatedUsageImpl* self( |
178 new( ELeave ) DRM::CDrmAutomatedUsageImpl( aCoeEnv, |
178 new( ELeave ) DRM::CDrmAutomatedUsageImpl( aCoeEnv, |
179 aDrmUtility ) ); |
179 aDrmUtility ) ); |
180 CleanupStack::PushL( self ); |
180 CleanupStack::PushL( self ); |
181 self->ConstructL(); |
181 self->ConstructL(); |
182 return self; |
182 return self; |
183 } |
183 } |
185 |
185 |
186 // Destructor |
186 // Destructor |
187 DRM::CDrmAutomatedUsageImpl::~CDrmAutomatedUsageImpl() |
187 DRM::CDrmAutomatedUsageImpl::~CDrmAutomatedUsageImpl() |
188 { |
188 { |
189 DRM::CDrmAutomatedUsageData* data( iDrmQueue->PopFront() ); |
189 DRM::CDrmAutomatedUsageData* data( iDrmQueue->PopFront() ); |
190 |
190 |
191 // Empty the queue: |
191 // Empty the queue: |
192 while ( data ) |
192 while ( data ) |
193 { |
193 { |
194 // Complete the outstanding requestest with cancel |
194 // Complete the outstanding requestest with cancel |
195 data->iObserver->OperationCompleted( data->iOperationId, KErrCancel ); |
195 data->iObserver->OperationCompleted( data->iOperationId, KErrCancel ); |
196 delete data; |
196 delete data; |
197 data = iDrmQueue->PopFront(); |
197 data = iDrmQueue->PopFront(); |
198 } |
198 } |
199 |
199 |
200 delete iDrmQueue; |
200 delete iDrmQueue; |
201 |
201 |
202 delete iDrmUtilityUi; |
202 delete iDrmUtilityUi; |
203 |
203 |
204 iDrmHelperClient.Close(); |
204 iDrmHelperClient.Close(); |
205 |
205 |
206 //iWmClient.Close(); |
206 //iWmClient.Close(); |
207 |
207 |
208 iOmaClient.Close(); |
208 iOmaClient.Close(); |
209 |
209 |
210 // Remove the object from active scheduler etc. |
210 // Remove the object from active scheduler etc. |
211 if ( IsAdded() ) |
211 if ( IsAdded() ) |
212 { |
212 { |
213 Deque(); |
213 Deque(); |
214 } |
214 } |
242 { |
242 { |
243 //WMDRM not supported as automated. So no need to continue. |
243 //WMDRM not supported as automated. So no need to continue. |
244 return EFalse; |
244 return EFalse; |
245 } |
245 } |
246 |
246 |
247 ContentAccess::CData* data( |
247 ContentAccess::CData* data( |
248 ContentAccess::CData::NewLC( aFile, |
248 ContentAccess::CData::NewLC( aFile, |
249 ContentAccess::KDefaultContentObject, |
249 ContentAccess::KDefaultContentObject, |
250 ContentAccess::EPeek ) ); |
250 ContentAccess::EPeek ) ); |
251 |
251 |
252 returnValue = CanSetAutomatedL( *data, aIntent, aAutomatedType ); |
252 returnValue = CanSetAutomatedL( *data, aIntent, aAutomatedType ); |
253 CleanupStack::PopAndDestroy( data ); |
253 CleanupStack::PopAndDestroy( data ); |
254 return returnValue; |
254 return returnValue; |
255 } |
255 } |
256 |
256 |
270 TInt agentUid( 0 ); |
270 TInt agentUid( 0 ); |
271 HBufC8* uniqueId8( NULL ); |
271 HBufC8* uniqueId8( NULL ); |
272 TBool canSetAutomated( EFalse ); |
272 TBool canSetAutomated( EFalse ); |
273 TBool protectedFile( EFalse ); |
273 TBool protectedFile( EFalse ); |
274 |
274 |
275 User::LeaveIfError( aData.GetAttribute( ContentAccess::EIsProtected, |
275 User::LeaveIfError( aData.GetAttribute( ContentAccess::EIsProtected, |
276 protectedFile ) ); |
276 protectedFile ) ); |
277 if ( !protectedFile ) |
277 if ( !protectedFile ) |
278 { |
278 { |
279 // not protected. So can be set as automated. |
279 // not protected. So can be set as automated. |
280 return ETrue; |
280 return ETrue; |
281 } |
281 } |
282 |
282 |
283 User::LeaveIfError( aData.GetAttribute( DRM::EDrmAgentUid, agentUid ) ); |
283 User::LeaveIfError( aData.GetAttribute( DRM::EDrmAgentUid, agentUid ) ); |
284 |
284 |
285 if ( agentUid == DRM::EDrmWmAgent ) |
285 if ( agentUid == DRM::EDrmWmAgent ) |
286 { |
286 { |
287 //WMDRM not supported as automated. So no need to continue. |
287 //WMDRM not supported as automated. So no need to continue. |
288 return EFalse; |
288 return EFalse; |
289 } |
289 } |
290 |
290 |
291 uniqueId8 = GetContentIdL( aData ); |
291 uniqueId8 = GetContentIdL( aData ); |
292 CleanupStack::PushL( uniqueId8 ); |
292 CleanupStack::PushL( uniqueId8 ); |
293 |
293 |
294 // now check whether there is OMA RO |
294 // now check whether there is OMA RO |
295 // suitable for automated use |
295 // suitable for automated use |
341 const ContentAccess::TIntent aIntent, |
341 const ContentAccess::TIntent aIntent, |
342 const DRM::TDrmAutomatedType aAutomatedType, |
342 const DRM::TDrmAutomatedType aAutomatedType, |
343 const DRM::TDrmAutomatedServiceType aServiceType ) |
343 const DRM::TDrmAutomatedServiceType aServiceType ) |
344 { |
344 { |
345 ContentAccess::CData* data = |
345 ContentAccess::CData* data = |
346 ContentAccess::CData::NewLC( aFile, |
346 ContentAccess::CData::NewLC( aFile, |
347 ContentAccess::KDefaultContentObject, |
347 ContentAccess::KDefaultContentObject, |
348 ContentAccess::EPeek ); |
348 ContentAccess::EPeek ); |
349 SetAutomatedL( *data, aIntent, aAutomatedType, aServiceType); |
349 SetAutomatedL( *data, aIntent, aAutomatedType, aServiceType); |
350 CleanupStack::PopAndDestroy( data ); |
350 CleanupStack::PopAndDestroy( data ); |
351 } |
351 } |
352 |
352 |
364 const DRM::TDrmAutomatedServiceType aServiceType ) |
364 const DRM::TDrmAutomatedServiceType aServiceType ) |
365 { |
365 { |
366 TInt ret( KErrNone ); |
366 TInt ret( KErrNone ); |
367 |
367 |
368 ContentAccess::CData* data = |
368 ContentAccess::CData* data = |
369 ContentAccess::CData::NewLC( aFile, |
369 ContentAccess::CData::NewLC( aFile, |
370 ContentAccess::KDefaultContentObject, |
370 ContentAccess::KDefaultContentObject, |
371 ContentAccess::EPeek ); |
371 ContentAccess::EPeek ); |
372 |
372 |
373 ret = SetAutomatedAsyncL( *data, aIntent, aAutomatedType, aObserver, aServiceType ); |
373 ret = SetAutomatedAsyncL( *data, aIntent, aAutomatedType, aObserver, aServiceType ); |
374 |
374 |
375 CleanupStack::PopAndDestroy( data ); |
375 CleanupStack::PopAndDestroy( data ); |
376 |
376 |
377 return ret; |
377 return ret; |
378 } |
378 } |
379 |
379 |
380 // ----------------------------------------------------------------------------- |
380 // ----------------------------------------------------------------------------- |
381 // DRM::CDrmAutomatedUsageImpl::SetAutomatedL |
381 // DRM::CDrmAutomatedUsageImpl::SetAutomatedL |
392 if ( !CanSetAutomatedL( aData, aIntent, aAutomatedType ) ) |
392 if ( !CanSetAutomatedL( aData, aIntent, aAutomatedType ) ) |
393 { |
393 { |
394 User::Leave( KErrArgument ); |
394 User::Leave( KErrArgument ); |
395 } |
395 } |
396 |
396 |
397 DRM::CDrmAutomatedUsageData* data( |
397 DRM::CDrmAutomatedUsageData* data( |
398 DRM::CDrmAutomatedUsageData::NewLC( |
398 DRM::CDrmAutomatedUsageData::NewLC( |
399 aData, |
399 aData, |
400 aIntent, |
400 aIntent, |
401 aAutomatedType, |
401 aAutomatedType, |
402 NULL, |
402 NULL, |
403 aServiceType, |
403 aServiceType, |
404 DRM::CDrmAutomatedUsageData::ESetAutomated ) ); |
404 DRM::CDrmAutomatedUsageData::ESetAutomated ) ); |
405 |
405 |
406 User::LeaveIfError ( DoSetAutomatedL( data ) ); |
406 User::LeaveIfError ( DoSetAutomatedL( data ) ); |
407 |
407 |
408 CleanupStack::PopAndDestroy( data ); |
408 CleanupStack::PopAndDestroy( data ); |
409 } |
409 } |
410 |
410 |
411 // ----------------------------------------------------------------------------- |
411 // ----------------------------------------------------------------------------- |
412 // DRM::CDrmAutomatedUsageImpl::SetAutomatedAsyncL |
412 // DRM::CDrmAutomatedUsageImpl::SetAutomatedAsyncL |
424 if ( !CanSetAutomatedL( aData, aIntent, aAutomatedType ) ) |
424 if ( !CanSetAutomatedL( aData, aIntent, aAutomatedType ) ) |
425 { |
425 { |
426 User::Leave( KErrArgument ); |
426 User::Leave( KErrArgument ); |
427 } |
427 } |
428 |
428 |
429 DRM::CDrmAutomatedUsageData* data( |
429 DRM::CDrmAutomatedUsageData* data( |
430 DRM::CDrmAutomatedUsageData::NewL( |
430 DRM::CDrmAutomatedUsageData::NewL( |
431 aData, |
431 aData, |
432 aIntent, |
432 aIntent, |
433 aAutomatedType, |
433 aAutomatedType, |
434 &aObserver, |
434 &aObserver, |
435 aServiceType, |
435 aServiceType, |
436 DRM::CDrmAutomatedUsageData::ESetAutomated ) ); |
436 DRM::CDrmAutomatedUsageData::ESetAutomated ) ); |
437 |
437 |
438 iDrmQueue->AppendToQueueL( data ); |
438 iDrmQueue->AppendToQueueL( data ); |
439 |
439 |
440 TRequestStatus* status( &iStatus ); |
440 TRequestStatus* status( &iStatus ); |
441 |
441 |
442 Activate( status ); |
442 Activate( status ); |
443 |
443 |
444 return data->iOperationId; |
444 return data->iOperationId; |
445 } |
445 } |
446 |
446 |
447 #pragma mark - |
447 #pragma mark - |
448 // ----------------------------------------------------------------------------- |
448 // ----------------------------------------------------------------------------- |
455 RFile& aFile, |
455 RFile& aFile, |
456 const ContentAccess::TIntent aIntent, |
456 const ContentAccess::TIntent aIntent, |
457 const DRM::TDrmAutomatedType aAutomatedType, |
457 const DRM::TDrmAutomatedType aAutomatedType, |
458 const DRM::TDrmAutomatedServiceType aServiceType ) |
458 const DRM::TDrmAutomatedServiceType aServiceType ) |
459 { |
459 { |
460 ContentAccess::CData* data( |
460 ContentAccess::CData* data( |
461 ContentAccess::CData::NewLC( aFile, |
461 ContentAccess::CData::NewLC( aFile, |
462 ContentAccess::KDefaultContentObject, |
462 ContentAccess::KDefaultContentObject, |
463 ContentAccess::EPeek ) ); |
463 ContentAccess::EPeek ) ); |
464 |
464 |
465 RemoveAutomatedL( *data, aIntent, aAutomatedType, aServiceType ); |
465 RemoveAutomatedL( *data, aIntent, aAutomatedType, aServiceType ); |
466 CleanupStack::PopAndDestroy( data ); |
466 CleanupStack::PopAndDestroy( data ); |
467 } |
467 } |
478 const DRM::TDrmAutomatedType aAutomatedType, |
478 const DRM::TDrmAutomatedType aAutomatedType, |
479 DRM::MDrmAsyncObserver& aObserver, |
479 DRM::MDrmAsyncObserver& aObserver, |
480 const DRM::TDrmAutomatedServiceType aServiceType ) |
480 const DRM::TDrmAutomatedServiceType aServiceType ) |
481 { |
481 { |
482 TInt ret( KErrNone ); |
482 TInt ret( KErrNone ); |
483 |
483 |
484 ContentAccess::CData* data( |
484 ContentAccess::CData* data( |
485 ContentAccess::CData::NewLC( aFile, |
485 ContentAccess::CData::NewLC( aFile, |
486 ContentAccess::KDefaultContentObject, |
486 ContentAccess::KDefaultContentObject, |
487 ContentAccess::EPeek ) ); |
487 ContentAccess::EPeek ) ); |
488 |
488 |
489 ret = RemoveAutomatedAsyncL( *data, |
489 ret = RemoveAutomatedAsyncL( *data, |
490 aIntent, |
490 aIntent, |
491 aAutomatedType, |
491 aAutomatedType, |
492 aObserver, |
492 aObserver, |
493 aServiceType ); |
493 aServiceType ); |
494 |
494 |
495 CleanupStack::PopAndDestroy( data ); |
495 CleanupStack::PopAndDestroy( data ); |
496 return ret; |
496 return ret; |
497 } |
497 } |
498 |
498 |
499 // ----------------------------------------------------------------------------- |
499 // ----------------------------------------------------------------------------- |
506 const ContentAccess::CData& aData, |
506 const ContentAccess::CData& aData, |
507 const ContentAccess::TIntent aIntent, |
507 const ContentAccess::TIntent aIntent, |
508 const DRM::TDrmAutomatedType aAutomatedType, |
508 const DRM::TDrmAutomatedType aAutomatedType, |
509 const DRM::TDrmAutomatedServiceType aServiceType ) |
509 const DRM::TDrmAutomatedServiceType aServiceType ) |
510 { |
510 { |
511 DRM::CDrmAutomatedUsageData* data ( |
511 DRM::CDrmAutomatedUsageData* data ( |
512 DRM::CDrmAutomatedUsageData::NewLC( |
512 DRM::CDrmAutomatedUsageData::NewLC( |
513 aData, |
513 aData, |
514 aIntent, |
514 aIntent, |
515 aAutomatedType, |
515 aAutomatedType, |
516 NULL, |
516 NULL, |
517 aServiceType, |
517 aServiceType, |
518 DRM::CDrmAutomatedUsageData::ERemoveAutomated ) ); |
518 DRM::CDrmAutomatedUsageData::ERemoveAutomated ) ); |
519 |
519 |
520 User::LeaveIfError( DoRemoveAutomated( data ) ); |
520 User::LeaveIfError( DoRemoveAutomated( data ) ); |
521 |
521 |
522 CleanupStack::PopAndDestroy( data ); |
522 CleanupStack::PopAndDestroy( data ); |
523 } |
523 } |
524 |
524 |
525 // ----------------------------------------------------------------------------- |
525 // ----------------------------------------------------------------------------- |
526 // DRM::CDrmAutomatedUsageImpl::RemoveAutomatedAsyncL |
526 // DRM::CDrmAutomatedUsageImpl::RemoveAutomatedAsyncL |
533 const ContentAccess::TIntent aIntent, |
533 const ContentAccess::TIntent aIntent, |
534 const DRM::TDrmAutomatedType aAutomatedType, |
534 const DRM::TDrmAutomatedType aAutomatedType, |
535 DRM::MDrmAsyncObserver& aObserver, |
535 DRM::MDrmAsyncObserver& aObserver, |
536 const DRM::TDrmAutomatedServiceType aServiceType ) |
536 const DRM::TDrmAutomatedServiceType aServiceType ) |
537 { |
537 { |
538 DRM::CDrmAutomatedUsageData* data( |
538 DRM::CDrmAutomatedUsageData* data( |
539 DRM::CDrmAutomatedUsageData::NewL( |
539 DRM::CDrmAutomatedUsageData::NewL( |
540 aData, |
540 aData, |
541 aIntent, |
541 aIntent, |
542 aAutomatedType, |
542 aAutomatedType, |
543 &aObserver, |
543 &aObserver, |
544 aServiceType, |
544 aServiceType, |
545 DRM::CDrmAutomatedUsageData::ERemoveAutomated ) ); |
545 DRM::CDrmAutomatedUsageData::ERemoveAutomated ) ); |
546 |
546 |
547 iDrmQueue->AppendToQueueL( data ); |
547 iDrmQueue->AppendToQueueL( data ); |
548 |
548 |
549 TRequestStatus* status( &iStatus ); |
549 TRequestStatus* status( &iStatus ); |
550 |
550 |
551 Activate( status ); |
551 Activate( status ); |
552 |
552 |
553 return data->iOperationId; |
553 return data->iOperationId; |
554 } |
554 } |
555 |
555 |
556 // ----------------------------------------------------------------------------- |
556 // ----------------------------------------------------------------------------- |
557 // DRM::CDrmAutomatedUsageImpl::RemoveAutomatedL |
557 // DRM::CDrmAutomatedUsageImpl::RemoveAutomatedL |
563 const TDesC& aUniqueId, |
563 const TDesC& aUniqueId, |
564 const ContentAccess::TIntent aIntent, |
564 const ContentAccess::TIntent aIntent, |
565 const DRM::TDrmAutomatedType aAutomatedType, |
565 const DRM::TDrmAutomatedType aAutomatedType, |
566 const DRM::TDrmAutomatedServiceType aServiceType ) |
566 const DRM::TDrmAutomatedServiceType aServiceType ) |
567 { |
567 { |
568 DRM::CDrmAutomatedUsageData* data( |
568 DRM::CDrmAutomatedUsageData* data( |
569 DRM::CDrmAutomatedUsageData::NewLC( |
569 DRM::CDrmAutomatedUsageData::NewLC( |
570 aUniqueId, |
570 aUniqueId, |
571 aIntent, |
571 aIntent, |
572 aAutomatedType, |
572 aAutomatedType, |
573 NULL, |
573 NULL, |
574 aServiceType, |
574 aServiceType, |
575 DRM::CDrmAutomatedUsageData::ERemoveAutomated ) ); |
575 DRM::CDrmAutomatedUsageData::ERemoveAutomated ) ); |
576 |
576 |
577 User::LeaveIfError( DoRemoveAutomated( data ) ); |
577 User::LeaveIfError( DoRemoveAutomated( data ) ); |
578 |
578 |
579 CleanupStack::PopAndDestroy( data ); |
579 CleanupStack::PopAndDestroy( data ); |
580 } |
580 } |
581 |
581 |
582 // ----------------------------------------------------------------------------- |
582 // ----------------------------------------------------------------------------- |
583 // DRM::CDrmAutomatedUsageImpl::RemoveAutomatedAsyncL |
583 // DRM::CDrmAutomatedUsageImpl::RemoveAutomatedAsyncL |
590 const ContentAccess::TIntent aIntent, |
590 const ContentAccess::TIntent aIntent, |
591 const TDrmAutomatedType aAutomatedType, |
591 const TDrmAutomatedType aAutomatedType, |
592 MDrmAsyncObserver& aObserver, |
592 MDrmAsyncObserver& aObserver, |
593 const TDrmAutomatedServiceType aServiceType ) |
593 const TDrmAutomatedServiceType aServiceType ) |
594 { |
594 { |
595 DRM::CDrmAutomatedUsageData* data( |
595 DRM::CDrmAutomatedUsageData* data( |
596 DRM::CDrmAutomatedUsageData::NewL( |
596 DRM::CDrmAutomatedUsageData::NewL( |
597 aUniqueId, |
597 aUniqueId, |
598 aIntent, |
598 aIntent, |
599 aAutomatedType, |
599 aAutomatedType, |
600 &aObserver, |
600 &aObserver, |
601 aServiceType, |
601 aServiceType, |
602 DRM::CDrmAutomatedUsageData::ERemoveAutomated ) ); |
602 DRM::CDrmAutomatedUsageData::ERemoveAutomated ) ); |
603 |
603 |
604 iDrmQueue->AppendToQueueL( data ); |
604 iDrmQueue->AppendToQueueL( data ); |
605 |
605 |
606 TRequestStatus* status( &iStatus ); |
606 TRequestStatus* status( &iStatus ); |
607 |
607 |
608 Activate( status ); |
608 Activate( status ); |
609 |
609 |
610 return data->iOperationId; |
610 return data->iOperationId; |
611 } |
611 } |
612 |
612 |
613 #pragma mark - |
613 #pragma mark - |
614 // ----------------------------------------------------------------------------- |
614 // ----------------------------------------------------------------------------- |
649 // ----------------------------------------------------------------------------- |
649 // ----------------------------------------------------------------------------- |
650 EXPORT_C TInt DRM::CDrmAutomatedUsageImpl::CancelOperation( TInt aOperationId ) |
650 EXPORT_C TInt DRM::CDrmAutomatedUsageImpl::CancelOperation( TInt aOperationId ) |
651 { |
651 { |
652 TInt returnValue( KErrNotFound ); |
652 TInt returnValue( KErrNotFound ); |
653 DRM::CDrmAutomatedUsageData* data( iDrmQueue->PopItem( aOperationId ) ); |
653 DRM::CDrmAutomatedUsageData* data( iDrmQueue->PopItem( aOperationId ) ); |
654 |
654 |
655 if ( data ) |
655 if ( data ) |
656 { |
656 { |
657 data->iObserver->OperationCompleted( aOperationId, KErrCancel ); |
657 data->iObserver->OperationCompleted( aOperationId, KErrCancel ); |
658 delete data; |
658 delete data; |
659 returnValue = KErrNone; |
659 returnValue = KErrNone; |
660 } |
660 } |
661 |
661 |
662 return returnValue; |
662 return returnValue; |
663 } |
663 } |
664 #pragma mark - |
664 #pragma mark - |
665 // ----------------------------------------------------------------------------- |
665 // ----------------------------------------------------------------------------- |
666 // ----------------------------------------------------------------------------- |
666 // ----------------------------------------------------------------------------- |
946 // |
946 // |
947 void DRM::CDrmAutomatedUsageImpl::RunL() |
947 void DRM::CDrmAutomatedUsageImpl::RunL() |
948 { |
948 { |
949 DRM::CDrmAutomatedUsageData* data( iDrmQueue->PopFront() ); |
949 DRM::CDrmAutomatedUsageData* data( iDrmQueue->PopFront() ); |
950 TRequestStatus *status( &iStatus ); |
950 TRequestStatus *status( &iStatus ); |
951 |
951 |
952 if ( !data ) |
952 if ( !data ) |
953 { |
953 { |
954 return; |
954 return; |
955 } |
955 } |
956 |
956 |
957 CleanupStack::PushL( data ); |
957 CleanupStack::PushL( data ); |
958 |
958 |
959 // Take this into the "current" variable in case an error occurs |
959 // Take this into the "current" variable in case an error occurs |
960 iObserver = data->iObserver; |
960 iObserver = data->iObserver; |
961 iOperationId = data->iOperationId; |
961 iOperationId = data->iOperationId; |
962 |
962 |
963 TInt err( KErrNone ); |
963 TInt err( KErrNone ); |
964 |
964 |
965 switch ( data->iOperation ) |
965 switch ( data->iOperation ) |
966 { |
966 { |
967 case DRM::CDrmAutomatedUsageData::ESetAutomated: |
967 case DRM::CDrmAutomatedUsageData::ESetAutomated: |
968 |
968 |
969 err = DoSetAutomatedL( data ); |
969 err = DoSetAutomatedL( data ); |
970 |
970 |
971 break; |
971 break; |
972 |
972 |
973 case DRM::CDrmAutomatedUsageData::ERemoveAutomated: |
973 case DRM::CDrmAutomatedUsageData::ERemoveAutomated: |
974 |
974 |
975 err = DoRemoveAutomated( data ); |
975 err = DoRemoveAutomated( data ); |
976 |
976 |
977 break; |
977 break; |
978 |
978 |
979 default: |
979 default: |
980 |
980 |
981 err = KErrArgument; |
981 err = KErrArgument; |
982 |
982 |
983 break; |
983 break; |
984 } |
984 } |
985 |
985 |
986 iObserver->OperationCompleted( iOperationId, err ); |
986 iObserver->OperationCompleted( iOperationId, err ); |
987 |
987 |
988 CleanupStack::PopAndDestroy( data ); |
988 CleanupStack::PopAndDestroy( data ); |
989 |
989 |
990 // Get ready for another round: |
990 // Get ready for another round: |
991 SetActive(); |
991 SetActive(); |
992 |
992 |
993 // complete internal request: |
993 // complete internal request: |
994 User::RequestComplete( status, KErrNone ); |
994 User::RequestComplete( status, KErrNone ); |
995 } |
995 } |
996 |
996 |
997 // ----------------------------------------------------------------------------- |
997 // ----------------------------------------------------------------------------- |
998 // DRM::CDrmAutomatedUsageImpl::RunError |
998 // DRM::CDrmAutomatedUsageImpl::RunError |
999 // ----------------------------------------------------------------------------- |
999 // ----------------------------------------------------------------------------- |
1000 // |
1000 // |
1001 TInt DRM::CDrmAutomatedUsageImpl::RunError( |
1001 TInt DRM::CDrmAutomatedUsageImpl::RunError( |
1002 TInt aError ) |
1002 TInt aError ) |
1003 { |
1003 { |
1004 iObserver->OperationCompleted( iOperationId, aError ); |
1004 iObserver->OperationCompleted( iOperationId, aError ); |
1005 iObserver = NULL; |
1005 iObserver = NULL; |
1006 iOperationId = NULL; |
1006 iOperationId = NULL; |