84 // set auto create values from cenrep |
78 // set auto create values from cenrep |
85 CheckAutoCreateValuesL(); |
79 CheckAutoCreateValuesL(); |
86 |
80 |
87 iPeriodicTimer = CPeriodic::NewL(CActive::EPriorityIdle); |
81 iPeriodicTimer = CPeriodic::NewL(CActive::EPriorityIdle); |
88 |
82 |
89 //do some initializing async in RunL() |
83 SetForceRun( EFalse ); |
90 iInit = ETrue; |
|
91 iForceRun = EFalse; |
|
92 iActive = EFalse; |
84 iActive = EFalse; |
93 |
85 |
94 iFormatObserver = CTMFormatObserver::NewL( *this ); |
86 iFormatObserver = CTMFormatObserver::NewL( *this ); |
95 |
87 |
96 iFormatting = EFalse; |
88 iFormatting = EFalse; |
97 iSessionDied = EFalse; |
89 iSessionDied = EFalse; |
98 |
90 |
99 iCollectionUtility = NULL; |
91 iCollectionUtility = NULL; |
100 |
92 |
101 iLight = CHWRMLight::NewL(this); |
|
102 |
|
103 #ifdef _DEBUG |
|
104 if(iLight) |
|
105 { |
|
106 iLightMask = iLight->SupportedTargets(); |
|
107 TN_DEBUG2( "CThumbAGProcessor::ConstructL() - iLightMask == %d", iLightMask ); |
|
108 } |
|
109 #endif |
|
110 |
|
111 iActivityManager = CTMActivityManager::NewL( this, KBackgroundGenerationIdle); |
93 iActivityManager = CTMActivityManager::NewL( this, KBackgroundGenerationIdle); |
112 |
94 |
113 ActivateAO(); |
95 UpdatePSValues(ETrue); |
|
96 |
|
97 if(iForegroundGenerationObserver) |
|
98 { |
|
99 delete iForegroundGenerationObserver; |
|
100 iForegroundGenerationObserver = NULL; |
|
101 } |
|
102 |
|
103 RProperty::Define(KTAGDPSNotification, KMPXHarvesting, RProperty::EInt); |
|
104 |
|
105 //start foreground generation observer |
|
106 iForegroundGenerationObserver = CTMRPropertyObserver::NewL( *this, KTAGDPSNotification, KForceBackgroundGeneration, ETrue ); |
114 |
107 |
115 TN_DEBUG1( "CThumbAGProcessor::ConstructL() - end" ); |
108 TN_DEBUG1( "CThumbAGProcessor::ConstructL() - end" ); |
116 } |
109 } |
117 |
110 |
118 // --------------------------------------------------------------------------- |
111 // --------------------------------------------------------------------------- |
278 iQueryAllItems = NULL; |
277 iQueryAllItems = NULL; |
279 } |
278 } |
280 else if(&aQuery == iQuery ) |
279 else if(&aQuery == iQuery ) |
281 { |
280 { |
282 TN_DEBUG1( "CThumbAGProcessor::HandleQueryCompleted - Query completed"); |
281 TN_DEBUG1( "CThumbAGProcessor::HandleQueryCompleted - Query completed"); |
|
282 |
283 if(iQueryActive) |
283 if(iQueryActive) |
284 { |
284 { |
285 iQueryReady = ETrue; |
285 iQueryReady = ETrue; |
286 iQueryActive = EFalse; |
286 iQueryActive = EFalse; |
287 } |
287 } |
288 |
288 |
289 // if no errors in query |
289 // if no errors in query |
290 if (aError == KErrNone && iQuery) |
290 if (aError == KErrNone && iQuery) |
291 { |
291 { |
292 iProcessingCount = iQuery->Count(); |
292 iProcessingCount = iQuery->Count(); |
|
293 |
|
294 if( !iProcessingCount) |
|
295 { |
|
296 delete iQuery; |
|
297 iQuery = NULL; |
|
298 iProcessingCount = 0; |
|
299 iModify = EFalse; |
|
300 } |
293 } |
301 } |
294 else |
302 else |
295 { |
303 { |
|
304 TInt itemIndex(KErrNotFound); |
|
305 |
|
306 //cleanup current queue |
|
307 while(iQueryQueue.Count()) |
|
308 { |
|
309 itemIndex = iLastQueue->Find(iQueryQueue[0]); |
|
310 if(itemIndex >= 0) |
|
311 { |
|
312 iLastQueue->Remove( itemIndex ); |
|
313 } |
|
314 iQueryQueue.Remove(0); |
|
315 } |
|
316 |
296 delete iQuery; |
317 delete iQuery; |
297 iQuery = NULL; |
318 iQuery = NULL; |
298 iProcessingCount = 0; |
319 iProcessingCount = 0; |
299 TN_DEBUG1( "CThumbAGProcessor::HandleQueryCompleted() Query FAILED!"); |
320 TN_DEBUG1( "CThumbAGProcessor::HandleQueryCompleted() Query FAILED!"); |
300 } |
321 } |
359 void CThumbAGProcessor::SetMdESession( CMdESession* aMdESession ) |
388 void CThumbAGProcessor::SetMdESession( CMdESession* aMdESession ) |
360 { |
389 { |
361 TN_DEBUG1( "CThumbAGProcessor::SetMdESession() - begin" ); |
390 TN_DEBUG1( "CThumbAGProcessor::SetMdESession() - begin" ); |
362 |
391 |
363 iMdESession = aMdESession; |
392 iMdESession = aMdESession; |
|
393 |
|
394 __ASSERT_DEBUG((iMdESession), User::Panic(_L("CThumbAGProcessor::SetMdESession() !iMdESession "), KErrBadHandle)); |
364 |
395 |
365 TRAPD( err, iDefNamespace = &iMdESession->GetDefaultNamespaceDefL() ); |
396 TRAPD( err, iDefNamespace = &iMdESession->GetDefaultNamespaceDefL() ); |
366 if (err != KErrNone) |
397 if (err != KErrNone) |
367 { |
398 { |
368 TN_DEBUG1( "CThumbAGProcessor::SetMdESession - Error: GetDefaultNamespaceDefL leave" ); |
399 TN_DEBUG2( "CThumbAGProcessor::SetMdESession() GetDefaultNamespaceDefL() err = %d", err ); |
369 } |
400 } |
370 |
401 |
371 TRAP_IGNORE(QueryPlaceholdersL()); |
402 __ASSERT_DEBUG((iDefNamespace), User::Panic(_L("CThumbAGProcessor::SetMdESession() !iDefNamespace "), KErrBadHandle)); |
372 TRAP_IGNORE(QueryAllItemsL()); |
403 |
|
404 //do async init |
|
405 iInit = ETrue; |
373 |
406 |
374 ActivateAO(); |
407 ActivateAO(); |
375 } |
408 } |
376 |
409 |
377 // --------------------------------------------------------------------------- |
410 // --------------------------------------------------------------------------- |
378 // CThumbAGProcessor::AddToQueue() |
411 // CThumbAGProcessor::AddToQueue() |
379 // --------------------------------------------------------------------------- |
412 // --------------------------------------------------------------------------- |
380 // |
413 // |
381 void CThumbAGProcessor::AddToQueueL( TObserverNotificationType aType, |
414 void CThumbAGProcessor::AddToQueueL( TObserverNotificationType aType, |
382 const RArray<TItemId>& aIDArray, TBool /*aPresent*/ ) |
415 const RArray<TItemId>& aIDArray, |
|
416 const RPointerArray<HBufC>& aObjectUriArray, |
|
417 TBool /*aPresent*/ ) |
383 { |
418 { |
384 TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - begin" ); |
419 TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - begin" ); |
385 |
420 |
386 // update queues |
421 // update queues |
387 if (aType == ENotifyAdd) |
422 if (aType == ENotifyAdd) |
388 { |
423 { |
389 TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - ENotifyAdd" ); |
424 TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - ENotifyAdd" ); |
390 |
425 |
391 for (int i=0; i<aIDArray.Count(); i++) |
426 for (int i=0; i<aIDArray.Count(); i++) |
392 { |
427 { |
393 // only add to Add queue if not already in Add queue |
428 // do not to append to Add queue if exist already in Add or 2nd Add queue (just processed) |
394 if (iAddQueue.Find( aIDArray[i] ) == KErrNotFound) |
429 if (iAddQueue.Find( aIDArray[i] ) == KErrNotFound && i2ndRoundGenerateQueue.Find( aIDArray[i] ) == KErrNotFound) |
395 { |
430 { |
396 iAddQueue.AppendL(aIDArray[i]); |
431 iAddQueue.AppendL(aIDArray[i]); |
397 } |
432 } |
398 } |
433 } |
399 } |
434 } |
400 else if (aType == ENotifyModify) |
435 else if (aType == ENotifyModify) |
401 { |
436 { |
402 TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - ENotifyModify" ); |
437 TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - ENotifyModify" ); |
403 |
438 |
404 if(iPHHarvesting) |
439 if(iPHHarvesting) |
405 { |
440 { |
|
441 |
406 TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - PH harvesting active, treat like add" ); |
442 TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - PH harvesting active, treat like add" ); |
407 for (int i=0; i<aIDArray.Count(); i++) |
443 for (int i=0; i<aIDArray.Count(); i++) |
408 { |
444 { |
409 // only add to Add queue if not already in Add queue |
|
410 if (iAddQueue.Find( aIDArray[i] ) == KErrNotFound) |
|
411 { |
|
412 iAddQueue.AppendL(aIDArray[i]); |
|
413 } |
|
414 |
|
415 TInt itemIndex = iPlaceholderQueue.Find( aIDArray[i] ); |
445 TInt itemIndex = iPlaceholderQueue.Find( aIDArray[i] ); |
416 |
446 |
417 if (itemIndex >= 0) |
447 if (itemIndex >= 0) |
418 { |
448 { |
419 TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - remove from placeholder queue"); |
449 TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - remove from placeholder queue"); |
420 iPlaceholderQueue.Remove( itemIndex ); |
450 iPlaceholderQueue.Remove( itemIndex ); |
421 } |
451 } |
|
452 |
|
453 if(iAddQueue.Find( aIDArray[i]) == KErrNotFound && i2ndRoundGenerateQueue.Find( aIDArray[i])) |
|
454 { |
|
455 TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - append to add queue"); |
|
456 iAddQueue.Append( aIDArray[i]); |
|
457 } |
422 } |
458 } |
423 } |
459 } |
424 else |
460 else |
425 { |
461 { |
426 TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - PH harvesting finished, check is real modify!" ); |
462 TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - PH harvesting finished, check is real modify!" ); |
445 if (itemIndex >= 0) |
480 if (itemIndex >= 0) |
446 { |
481 { |
447 TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - remove from add queue"); |
482 TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - remove from add queue"); |
448 iAddQueue.Remove( itemIndex ); |
483 iAddQueue.Remove( itemIndex ); |
449 } |
484 } |
|
485 else |
|
486 { |
|
487 |
|
488 itemIndex = i2ndRoundGenerateQueue.Find( aIDArray[i] ); |
|
489 |
|
490 if (itemIndex >= 0) |
|
491 { |
|
492 TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - remove from 2nd round add queue"); |
|
493 i2ndRoundGenerateQueue.Remove( itemIndex ); |
|
494 } |
|
495 } |
450 |
496 |
451 if( iPlaceholderQueue.Find( aIDArray[i] ) == KErrNotFound ) |
497 TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - append to modify queue"); |
452 { |
498 iModifyQueue.AppendL(aIDArray[i]); |
453 TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - append to modify queue"); |
|
454 iModifyQueue.AppendL(aIDArray[i]); |
|
455 } |
|
456 |
499 |
457 SetForceRun( ETrue ); |
500 SetForceRun( ETrue ); |
458 } |
501 } |
459 } |
502 } |
460 } |
503 } |
461 } |
504 } |
462 else if (aType == ENotifyRemove) |
505 else if (aType == ENotifyRemove) |
463 { |
506 { |
464 TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - ENotifyRemove, remove IDs from all queues, append to Delete" ); |
507 TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - ENotifyRemove, remove IDs from all queues"); |
465 |
508 |
466 for (int i=0; i<aIDArray.Count(); i++) |
509 for (int i=0; i<aIDArray.Count(); i++) |
467 { |
510 { |
468 // can be removed from Add queue |
511 // can be removed from Add queue |
469 TInt itemIndex = iAddQueue.Find( aIDArray[i] ); |
512 TInt itemIndex = iAddQueue.Find( aIDArray[i] ); |
505 // --------------------------------------------------------------------------- |
549 // --------------------------------------------------------------------------- |
506 // |
550 // |
507 void CThumbAGProcessor::CreateThumbnailsL( const CMdEObject* aObject ) |
551 void CThumbAGProcessor::CreateThumbnailsL( const CMdEObject* aObject ) |
508 { |
552 { |
509 TN_DEBUG1( "CThumbAGProcessor::CreateThumbnailsL() - begin" ); |
553 TN_DEBUG1( "CThumbAGProcessor::CreateThumbnailsL() - begin" ); |
|
554 |
|
555 __ASSERT_DEBUG((iTMSession), User::Panic(_L("CThumbAGProcessor::CreateThumbnailsL() !iTMSession "), KErrBadHandle)); |
|
556 __ASSERT_DEBUG((iDefNamespace), User::Panic(_L("CThumbAGProcessor::CreateThumbnailsL() !iDefNamespace "), KErrBadHandle)); |
|
557 |
|
558 if(!iTMSession || !iDefNamespace) |
|
559 { |
|
560 return; |
|
561 } |
510 |
562 |
511 TInt orientationVal = 0; |
563 TInt orientationVal = 0; |
512 TInt64 modifiedVal = 0; |
564 TInt64 modifiedVal = 0; |
513 |
565 |
514 CMdEProperty* orientation = NULL; |
566 CMdEProperty* orientation = NULL; |
515 CMdEObjectDef& objDef = iDefNamespace->GetObjectDefL( MdeConstants::Image::KImageObject ); |
567 CMdEObjectDef& imageObjectDef = iDefNamespace->GetObjectDefL( MdeConstants::Image::KImageObject ); |
516 TInt orientErr = aObject->Property( objDef.GetPropertyDefL( MdeConstants::Image::KOrientationProperty ), orientation, 0 ); |
568 TInt orientErr = aObject->Property( imageObjectDef.GetPropertyDefL( MdeConstants::Image::KOrientationProperty ), orientation, 0 ); |
517 |
569 |
518 if (orientErr == KErrNone) |
570 if (orientErr == KErrNone) |
519 { |
571 { |
520 orientationVal = orientation->Uint16ValueL(); |
572 orientationVal = orientation->Uint16ValueL(); |
521 } |
573 } |
522 |
574 |
523 CMdEProperty* modified = NULL; |
575 CMdEProperty* modified = NULL; |
524 CMdEObjectDef& objDef2 = iDefNamespace->GetObjectDefL( MdeConstants::Object::KBaseObject ); |
576 CMdEObjectDef& baseObjDef = iDefNamespace->GetObjectDefL( MdeConstants::Object::KBaseObject ); |
525 TInt modifyErr = aObject->Property( objDef2.GetPropertyDefL( MdeConstants::Object::KLastModifiedDateProperty ), modified, 0 ); |
577 TInt modifyErr = aObject->Property( baseObjDef.GetPropertyDefL( MdeConstants::Object::KLastModifiedDateProperty ), modified, 0 ); |
526 |
578 |
527 if (modifyErr >= 0) |
579 if (modifyErr >= 0) |
528 { |
580 { |
529 modifiedVal = modified->TimeValueL().Int64(); |
581 modifiedVal = modified->TimeValueL().Int64(); |
530 } |
582 } |
531 |
583 |
532 // modify existing thumbs |
584 // update thumbs |
533 if (iTMSession) |
585 if (iTMSession) |
534 { |
586 { |
|
587 // 2nd round and modify updates both sizes if needed |
|
588 if( i2ndRound ) |
|
589 { |
|
590 //generate both if needed |
|
591 TN_DEBUG1( "CThumbAGProcessor::CreateThumbnailsL() EOptimizeForQuality "); |
|
592 iTMSession->SetQualityPreferenceL( CThumbnailManager::EOptimizeForQuality ); |
|
593 } |
|
594 // 1st roung generation |
|
595 else |
|
596 { |
|
597 //1st round |
|
598 TN_DEBUG1( "CThumbAGProcessor::CreateThumbnailsL() EOptimizeForQualityWithPreview"); |
|
599 iTMSession->SetQualityPreferenceL( CThumbnailManager::EOptimizeForQualityWithPreview ); |
|
600 |
|
601 CMdEObjectDef& videoObjectDef = iDefNamespace->GetObjectDefL( MdeConstants::Video::KVideoObject ); |
|
602 |
|
603 // add item to 2nd round queue |
|
604 if(iLastQueue == &iAddQueue || iLastQueue == &iModifyQueue) |
|
605 { |
|
606 TN_DEBUG2( "CThumbAGProcessor::CreateThumbnailsL() - 1st round add/modify, append to 2nd round queue", aObject->Id() ); |
|
607 if(i2ndRoundGenerateQueue.Find(aObject->Id()) == KErrNotFound) |
|
608 { |
|
609 i2ndRoundGenerateQueue.Append( aObject->Id() ); |
|
610 } |
|
611 } |
|
612 |
|
613 if( !(imageObjectDef.Id() == aObject->Def().Id() || videoObjectDef.Id() == aObject->Def().Id()) ) |
|
614 { |
|
615 TN_DEBUG1( "CThumbAGProcessor::CreateThumbnailsL() 1st round and not image or video, skip"); |
|
616 ActivateAO(); |
|
617 return; |
|
618 } |
|
619 } |
|
620 |
535 // run as lower priority than getting but higher that creating thumbnails |
621 // run as lower priority than getting but higher that creating thumbnails |
536 TRAPD(err, iTMSession->UpdateThumbnailsL(aObject->Id(), aObject->Uri(), orientationVal, modifiedVal, CActive::EPriorityIdle )); |
622 TRAPD(err, iTMSession->UpdateThumbnailsL(KNoId, aObject->Uri(), orientationVal, modifiedVal, CActive::EPriorityIdle )); |
537 |
623 |
538 if ( err != KErrNone ) |
624 if ( err != KErrNone ) |
539 { |
625 { |
540 TN_DEBUG2( "CThumbAGProcessor::UpdateThumbnailsL, iTMSession error == %d", err ); |
626 TN_DEBUG2( "CThumbAGProcessor::CreateThumbnailsL, iTMSession error == %d", err ); |
541 |
627 |
542 iSessionDied = ETrue; |
628 iSessionDied = ETrue; |
543 iActive = EFalse; |
629 iActive = EFalse; |
544 ActivateAO(); |
630 ActivateAO(); |
545 } |
631 } |
546 else |
632 else |
547 { |
633 { |
|
634 iActiveCount++; |
548 iActive = ETrue; |
635 iActive = ETrue; |
549 } |
636 } |
550 } |
637 } |
551 else |
638 else |
552 { |
639 { |
553 ActivateAO(); |
640 ActivateAO(); |
554 } |
641 } |
555 |
642 |
556 #ifdef _DEBUG |
|
557 if(iModify) |
|
558 { |
|
559 iModCounter++; |
|
560 } |
|
561 else |
|
562 { |
|
563 iAddCounter++; |
|
564 } |
|
565 #endif |
|
566 |
|
567 #ifdef _DEBUG |
|
568 TN_DEBUG3( "CThumbAGProcessor::OUT-COUNTERS----------, Add = %d Modify = %d", |
|
569 iAddCounter, iModCounter ); |
|
570 #endif |
|
571 |
|
572 TN_DEBUG1( "CThumbAGProcessor::CreateThumbnailsL() - end" ); |
643 TN_DEBUG1( "CThumbAGProcessor::CreateThumbnailsL() - end" ); |
573 } |
644 } |
574 |
645 |
575 // --------------------------------------------------------------------------- |
646 // --------------------------------------------------------------------------- |
576 // CThumbAGProcessor::QueryL() |
647 // CThumbAGProcessor::QueryL() |
577 // --------------------------------------------------------------------------- |
648 // --------------------------------------------------------------------------- |
578 // |
649 // |
579 void CThumbAGProcessor::QueryL( RArray<TItemId>& aIDArray ) |
650 void CThumbAGProcessor::QueryL( RArray<TItemId>& aIDArray ) |
580 { |
651 { |
581 TN_DEBUG1( "CThumbAGProcessor::QueryL() - begin" ); |
652 TN_DEBUG1( "CThumbAGProcessor::QueryL() - begin" ); |
|
653 |
|
654 __ASSERT_DEBUG((iMdESession), User::Panic(_L("CThumbAGProcessor::QueryL() !iMdeSession "), KErrBadHandle)); |
|
655 __ASSERT_DEBUG((iDefNamespace), User::Panic(_L("CThumbAGProcessor::QueryL() !iDefNamespace "), KErrBadHandle)); |
|
656 |
|
657 if(!iMdESession || !iDefNamespace) |
|
658 { |
|
659 return; |
|
660 } |
|
661 |
|
662 //reset query queue |
|
663 iQueryQueue.Reset(); |
|
664 //set reference to current pprocessing queue |
|
665 iLastQueue = &aIDArray; |
582 |
666 |
583 iQueryReady = EFalse; |
667 iQueryReady = EFalse; |
584 |
668 |
585 // delete old query |
669 // delete old query |
586 if (iQuery) |
670 if (iQuery) |
594 |
678 |
595 TN_DEBUG3( "CThumbAGProcessor::QueryL() - fill begin aIDArray == %d, iQueryQueue == %d", aIDArray.Count(), iQueryQueue.Count() ); |
679 TN_DEBUG3( "CThumbAGProcessor::QueryL() - fill begin aIDArray == %d, iQueryQueue == %d", aIDArray.Count(), iQueryQueue.Count() ); |
596 |
680 |
597 for(TInt i=0;i < KMaxQueryItems && i < maxCount; i++) |
681 for(TInt i=0;i < KMaxQueryItems && i < maxCount; i++) |
598 { |
682 { |
599 TN_DEBUG2( "CThumbAGProcessor::QueryL() - fill %d", aIDArray[0] ); |
683 TN_DEBUG2( "CThumbAGProcessor::QueryL() - fill %d", aIDArray[i] ); |
600 iQueryQueue.Append( aIDArray[0] ); |
684 iQueryQueue.Append( aIDArray[i] ); |
601 aIDArray.Remove( 0 ); |
|
602 } |
685 } |
603 |
686 |
604 TN_DEBUG3( "CThumbAGProcessor::QueryL() - fill end aIDArray == %d, iQueryQueue == %d", aIDArray.Count(), iQueryQueue.Count() ); |
687 TN_DEBUG3( "CThumbAGProcessor::QueryL() - fill end aIDArray == %d, iQueryQueue == %d", aIDArray.Count(), iQueryQueue.Count() ); |
605 |
688 |
606 CMdEObjectDef& objDef = iDefNamespace->GetObjectDefL( MdeConstants::Object::KBaseObject ); |
689 CMdEObjectDef& objDef = iDefNamespace->GetObjectDefL( MdeConstants::Object::KBaseObject ); |
712 { |
797 { |
713 TN_DEBUG1( "CThumbAGProcessor::RunL() - begin" ); |
798 TN_DEBUG1( "CThumbAGProcessor::RunL() - begin" ); |
714 |
799 |
715 if (iSessionDied) |
800 if (iSessionDied) |
716 { |
801 { |
|
802 TN_DEBUG1( "CThumbAGProcessor::RunL() - iSessionDied" ); |
717 delete iTMSession; |
803 delete iTMSession; |
718 iTMSession = NULL; |
804 iTMSession = NULL; |
719 } |
805 } |
720 |
806 |
721 if (iInit) |
807 if (iInit) |
722 { |
808 { |
723 TN_DEBUG1( "CThumbAGProcessor::RunL() - Do Initialisation" ); |
809 TN_DEBUG1( "CThumbAGProcessor::RunL() - Do Initialisation 1" ); |
|
810 |
724 iInit = EFalse; |
811 iInit = EFalse; |
725 TN_DEBUG1( "iHarvesterClient"); |
812 iInit2 = ETrue; |
726 if( iHarvesterClient.Connect() == KErrNone ) |
813 |
727 { |
814 iAddQueue.Reset(); |
728 TN_DEBUG1( "iHarvesterClient connected"); |
815 iModifyQueue.Reset(); |
729 iHarvesterClient.AddHarvesterEventObserver( *this, EHEObserverTypeOverall, KMaxTInt ); |
816 iRemoveQueue.ResetAndDestroy(); |
730 iHarvesterClient.AddHarvesterEventObserver( *this, EHEObserverTypePlaceholder, KMaxTInt ); |
817 iQueryQueue.Reset(); |
731 iHarvesterClient.AddHarvesterEventObserver( *this, EHEObserverTypeMMC, KMaxTInt ); |
818 iPlaceholderQueue.Reset(); |
732 TN_DEBUG1( "iHarvesterClient AddHarvesterEventObserver added"); |
819 |
733 } |
820 TRAP_IGNORE(QueryPlaceholdersL()); |
734 |
821 TN_DEBUG1( "CThumbAGProcessor::RunL() - Initialisation 1 done" ); |
735 TN_DEBUG1( "create MMPXCollectionUtility"); |
822 ActivateAO(); |
736 iCollectionUtility = MMPXCollectionUtility::NewL( this, KMcModeIsolated ); |
823 return; |
737 TN_DEBUG1( "CThumbAGProcessor::RunL() - Initialisation done" ); |
824 } |
738 |
825 |
739 iActivityManager->Start(); |
826 if(iInit2) |
740 |
827 { |
|
828 TN_DEBUG1( "CThumbAGProcessor::RunL() - Do Initialisation 2" ); |
|
829 |
|
830 iInit2 = EFalse; |
|
831 TInt err(KErrNone); |
|
832 /* |
|
833 TN_DEBUG1( "CThumbAGProcessor::RunL() do iHarvesterClient connect"); |
|
834 TInt err = iHarvesterClient.Connect(); |
|
835 TN_DEBUG2( "CThumbAGProcessor::RunL() iHarvesterClient connect err = %d", err); |
|
836 |
|
837 __ASSERT_DEBUG((err==KErrNone), User::Panic(_L("CThumbAGProcessor::RunL(), !iHarvesterClient "), err)); |
|
838 |
|
839 if( err == KErrNone ) |
|
840 { |
|
841 TN_DEBUG1( "CThumbAGProcessor::RunL() add iHarvesterClient observer"); |
|
842 err = iHarvesterClient.AddHarvesterEventObserver( *this, EHEObserverTypeOverall | EHEObserverTypePlaceholder, KMaxTInt ); |
|
843 TN_DEBUG2( "CThumbAGProcessor::RunL() iHarvesterClient observer err = %d", err); |
|
844 __ASSERT_DEBUG((err==KErrNone), User::Panic(_L("CThumbAGProcessor::RunL(), !iHarvesterClient "), err)); |
|
845 }*/ |
|
846 |
|
847 TN_DEBUG1( "CThumbAGProcessor::RunL() MMPXCollectionUtility"); |
|
848 TRAP( err, iCollectionUtility = MMPXCollectionUtility::NewL( this, KMcModeIsolated )); |
|
849 TN_DEBUG2( "CThumbAGProcessor::RunL() create MMPXCollectionUtility err = %d", err); |
|
850 __ASSERT_DEBUG((iCollectionUtility), User::Panic(_L("CThumbAGProcessor::RunL(), !iCollectionUtility "), err)); |
|
851 |
|
852 __ASSERT_DEBUG((iActivityManager), User::Panic(_L("CThumbAGProcessor::RunL(), !iActivityManager "), KErrBadHandle)); |
|
853 if(iActivityManager) |
|
854 { |
|
855 iActivityManager->Start(); |
|
856 } |
|
857 |
|
858 TRAP_IGNORE(QueryAllItemsL()); |
|
859 |
|
860 TN_DEBUG1( "CThumbAGProcessor::RunL() - Initialisation 2 done" ); |
741 return; |
861 return; |
742 } |
862 } |
743 |
863 |
744 // restart session if died |
864 // restart session if died |
745 if (!iTMSession) |
865 if (!iTMSession) |
761 } |
881 } |
762 |
882 |
763 // do not run if request is already issued to TNM server even if forced |
883 // do not run if request is already issued to TNM server even if forced |
764 if( iActive) |
884 if( iActive) |
765 { |
885 { |
766 if(iActiveCount <= KMaxDaemonRequests) |
886 if(iActiveCount >= KMaxDaemonRequests) |
767 { |
887 { |
768 iActiveCount++; |
|
769 TN_DEBUG1( "CThumbAGProcessor::RunL() - waiting for previous to complete, abort..." ); |
888 TN_DEBUG1( "CThumbAGProcessor::RunL() - waiting for previous to complete, abort..." ); |
770 return; |
889 return; |
771 } |
890 } |
772 else |
|
773 { |
|
774 TN_DEBUG1( "CThumbAGProcessor::RunL() - iActive jammed - resetted" ); |
|
775 iActive = EFalse; |
|
776 iActiveCount = 0; |
|
777 } |
|
778 } |
891 } |
779 else |
892 else |
780 { |
893 { |
781 iActiveCount = 0; |
894 iActiveCount = 0; |
782 } |
895 } |
783 |
896 |
|
897 |
784 //force run can proceed from this point |
898 //force run can proceed from this point |
785 if( iForceRun ) |
899 #ifdef _DEBUG |
|
900 if( iForegroundRun ) |
|
901 { |
|
902 TN_DEBUG1( "void CThumbAGProcessor::RunL() KForceBackgroundGeneration enabled"); |
|
903 } |
|
904 |
|
905 if( iForceRun ) |
|
906 { |
|
907 TN_DEBUG1( "CThumbAGProcessor::RunL() - *** FORCED RUN ***"); |
|
908 } |
|
909 #endif |
|
910 |
|
911 if( /*iForceRun || */iForegroundRun ) |
|
912 { |
|
913 TN_DEBUG1( "void CThumbAGProcessor::RunL() skip idle detection!"); |
|
914 CancelTimeout(); |
|
915 } |
|
916 else |
786 { |
917 { |
787 CancelTimeout(); |
918 if(iActivityManager) |
788 TN_DEBUG1( "void CThumbAGProcessor::RunL() forced run, continue!"); |
919 { |
789 } |
920 iIdle = iActivityManager->IsInactive(); |
790 else |
921 } |
791 { |
922 |
792 if( !iLights) |
|
793 { |
|
794 iIdle = ETrue; |
|
795 } |
|
796 else |
|
797 { |
|
798 iIdle = IsInactive(); |
|
799 } |
|
800 |
|
801 if( !iIdle || iHarvesting || iMPXHarvesting || iPeriodicTimer->IsActive() ) |
923 if( !iIdle || iHarvesting || iMPXHarvesting || iPeriodicTimer->IsActive() ) |
802 { |
924 { |
803 #ifdef _DEBUG |
|
804 TN_DEBUG5( "iIdle = %d, iHarvesting = %d, iMPXHarvesting = %d, iPeriodicTimer->IsActive() = %d", |
|
805 iIdle, iHarvesting, iMPXHarvesting, iPeriodicTimer->IsActive()); |
|
806 #endif |
|
807 TN_DEBUG1( "void CThumbAGProcessor::RunL() device not idle"); |
925 TN_DEBUG1( "void CThumbAGProcessor::RunL() device not idle"); |
808 return; |
926 return; |
809 } |
927 } |
810 else |
928 else |
811 { |
929 { |
830 //Handle completed MDS Query |
948 //Handle completed MDS Query |
831 if( iQueryReady && iProcessingCount) |
949 if( iQueryReady && iProcessingCount) |
832 { |
950 { |
833 TInt err(KErrNone); |
951 TInt err(KErrNone); |
834 //if force or non forced |
952 //if force or non forced |
835 if((iForceRun && iModify) || (!iForceRun && !iModify)) |
953 if((iForceRun && iModify ) || (!iForceRun && !iModify )) |
836 { |
954 { |
837 TN_DEBUG1( "CThumbAGProcessor::RunL() - iQueryReady START" ); |
955 TN_DEBUG1( "CThumbAGProcessor::RunL() - iQueryReady START" ); |
838 |
956 |
839 const CMdEObject* object = &iQuery->Result( iProcessingCount-1 ); |
957 const CMdEObject* object = &iQuery->Result( iProcessingCount-1 ); |
840 iProcessingCount--; |
958 iProcessingCount--; |
841 |
959 |
|
960 TInt itemIndex = iLastQueue->Find( object->Id()); |
|
961 if(itemIndex >= 0) |
|
962 { |
|
963 iLastQueue->Remove(itemIndex); |
|
964 } |
|
965 |
842 // process one item at once |
966 // process one item at once |
843 if ( object ) |
967 if ( object ) |
844 { |
968 { |
|
969 //remove item from queryQueue when request is issued |
|
970 itemIndex = iQueryQueue.Find( object->Id()); |
|
971 if(itemIndex >= 0) |
|
972 { |
|
973 iQueryQueue.Remove(itemIndex); |
|
974 } |
|
975 |
845 TRAP( err, CreateThumbnailsL(object) ); |
976 TRAP( err, CreateThumbnailsL(object) ); |
846 |
977 TN_DEBUG2( "CThumbAGProcessor::RunL(), CreateThumbnailsL error == %d", err ); |
847 if ( err != KErrNone ) |
978 __ASSERT_DEBUG((err==KErrNone), User::Panic(_L("CThumbAGProcessor::RunL(), CreateThumbnailsL() "), err)); |
848 { |
|
849 TN_DEBUG2( "CThumbAGProcessor::RunL(), CreateThumbnailsL error == %d", err ); |
|
850 } |
|
851 } |
979 } |
852 } |
980 } |
853 //force is coming, but executing non-forced query complete-> cancel old |
981 //force is coming, but executing non-forced query complete-> cancel old |
854 else |
982 else |
855 { |
983 { |
856 TN_DEBUG1( "CThumbAGProcessor::RunL() - deleting query" ); |
984 TN_DEBUG1( "CThumbAGProcessor::RunL() - deleting query 1" ); |
857 delete iQuery; |
985 delete iQuery; |
858 iQuery = NULL; |
986 iQuery = NULL; |
859 iQueryReady = EFalse; |
987 iQueryReady = EFalse; |
860 iProcessingCount = 0; |
988 iProcessingCount = 0; |
|
989 |
|
990 //move remainig IDs in query queue back to original queue |
|
991 while(iQueryQueue.Count()) |
|
992 { |
|
993 if(iLastQueue) |
|
994 { |
|
995 if(iLastQueue->Find( iQueryQueue[0]) == KErrNotFound) |
|
996 { |
|
997 iLastQueue->Append(iQueryQueue[0]); |
|
998 } |
|
999 } |
|
1000 iQueryQueue.Remove(0); |
|
1001 } |
|
1002 iLastQueue = NULL; |
861 ActivateAO(); |
1003 ActivateAO(); |
862 return; |
1004 return; |
863 } |
1005 } |
864 |
1006 |
865 //is last query item |
1007 //is last query item |
889 //waiting for MDS query to complete |
1031 //waiting for MDS query to complete |
890 else if( iQueryActive ) |
1032 else if( iQueryActive ) |
891 { |
1033 { |
892 if(iForceRun && !iModify) |
1034 if(iForceRun && !iModify) |
893 { |
1035 { |
894 iQuery->Cancel(); |
1036 if(iQuery) |
895 delete iQuery; |
1037 { |
896 iQuery = NULL; |
1038 TN_DEBUG1( "CThumbAGProcessor::RunL() - deleting query 2" ); |
897 TN_DEBUG1( "CThumbAGProcessor::RunL() - canceling query..." ); |
1039 iQuery->Cancel(); |
|
1040 delete iQuery; |
|
1041 iQuery = NULL; |
|
1042 } |
|
1043 |
898 iQueryReady = EFalse; |
1044 iQueryReady = EFalse; |
899 iQueryActive = EFalse; |
1045 iQueryActive = EFalse; |
|
1046 |
|
1047 //move remainig IDs in query queue back to original queue |
|
1048 while(iQueryQueue.Count()) |
|
1049 { |
|
1050 if(iLastQueue) |
|
1051 { |
|
1052 if(iLastQueue->Find( iQueryQueue[0]) == KErrNotFound) |
|
1053 { |
|
1054 iLastQueue->Append(iQueryQueue[0]); |
|
1055 } |
|
1056 } |
|
1057 iQueryQueue.Remove(0); |
|
1058 } |
|
1059 iLastQueue = NULL; |
|
1060 |
900 ActivateAO(); |
1061 ActivateAO(); |
901 } |
1062 } |
902 else |
1063 else |
903 { |
1064 { |
904 TN_DEBUG1( "CThumbAGProcessor::RunL() - waiting for query to complete, abort..." ); |
1065 TN_DEBUG1( "CThumbAGProcessor::RunL() - waiting for query to complete, abort..." ); |
905 } |
1066 } |
906 } |
1067 } |
907 |
1068 |
908 // select queue to process, priority by type. Process modify events before new images |
1069 // no items in query queue, start new |
|
1070 // select queue to process, priority by type |
909 else if ( iModifyQueue.Count() > 0 ) |
1071 else if ( iModifyQueue.Count() > 0 ) |
910 { |
1072 { |
911 TN_DEBUG1( "void CThumbAGProcessor::RunL() update thumbnails"); |
1073 TN_DEBUG1( "void CThumbAGProcessor::RunL() update thumbnails"); |
|
1074 |
|
1075 i2ndRound = EFalse; |
912 |
1076 |
913 // query for object info |
1077 // query for object info |
914 iQueryActive = ETrue; |
1078 iQueryActive = ETrue; |
915 iModify = ETrue; |
1079 iModify = ETrue; |
916 QueryL( iModifyQueue ); |
1080 QueryL( iModifyQueue ); |
917 } |
1081 } |
918 else if ( iRemoveQueue.Count() > 0 ) |
|
919 { |
|
920 TN_DEBUG1( "void CThumbAGProcessor::RunL() delete thumbnails"); |
|
921 |
|
922 // delete thumbs by ID |
|
923 if (iTMSession) |
|
924 { |
|
925 iTMSession->DeleteThumbnails( iRemoveQueue[0] ); |
|
926 } |
|
927 iRemoveQueue.Remove( 0 ); |
|
928 |
|
929 #ifdef _DEBUG |
|
930 iDelCounter++; |
|
931 TN_DEBUG2( "CThumbAGProcessor::OUT-COUNTERS----------, Delete = %d", iDelCounter ); |
|
932 #endif |
|
933 ActivateAO(); |
|
934 } |
|
935 else if ( iAddQueue.Count() > 0 ) |
1082 else if ( iAddQueue.Count() > 0 ) |
936 { |
1083 { |
937 TN_DEBUG1( "void CThumbAGProcessor::RunL() create thumbnails"); |
1084 TN_DEBUG1( "void CThumbAGProcessor::RunL() update 1st round thumbnails"); |
|
1085 |
|
1086 i2ndRound = EFalse; |
938 |
1087 |
939 // query for object info |
1088 // query for object info |
940 iQueryActive = ETrue; |
1089 iQueryActive = ETrue; |
941 |
1090 |
942 QueryL( iAddQueue ); |
1091 QueryL( iAddQueue ); |
|
1092 } |
|
1093 else if ( iRemoveQueue.Count() > 0 ) |
|
1094 { |
|
1095 TN_DEBUG1( "void CThumbAGProcessor::RunL() delete thumbnails"); |
|
1096 |
|
1097 i2ndRound = EFalse; |
|
1098 |
|
1099 // delete thumbs by URI |
|
1100 __ASSERT_DEBUG((iTMSession), User::Panic(_L("CThumbAGProcessor::RunL() !iTMSession "), KErrBadHandle)); |
|
1101 if(iTMSession) |
|
1102 { |
|
1103 HBufC* uri = iRemoveQueue[0]; |
|
1104 TN_DEBUG2( "void CThumbAGProcessor::RunL() delete %S", uri); |
|
1105 CThumbnailObjectSource* source = NULL; |
|
1106 TRAPD(err, source = CThumbnailObjectSource::NewL( *uri, KNullDesC)); |
|
1107 |
|
1108 if(err == KErrNone) |
|
1109 { |
|
1110 iTMSession->DeleteThumbnails( *source ); |
|
1111 } |
|
1112 iRemoveQueue.Remove( 0 ); |
|
1113 delete source; |
|
1114 delete uri; |
|
1115 } |
|
1116 |
|
1117 ActivateAO(); |
|
1118 } |
|
1119 else if( i2ndRoundGenerateQueue.Count() > 0) |
|
1120 { |
|
1121 TN_DEBUG1( "void CThumbAGProcessor::RunL() update 2nd round thumbnails"); |
|
1122 |
|
1123 // query for object info |
|
1124 iQueryActive = ETrue; |
|
1125 i2ndRound = ETrue; |
|
1126 QueryL( i2ndRoundGenerateQueue ); |
943 } |
1127 } |
944 |
1128 |
945 TN_DEBUG1( "CThumbAGProcessor::RunL() - end" ); |
1129 TN_DEBUG1( "CThumbAGProcessor::RunL() - end" ); |
946 } |
1130 } |
947 |
1131 |
1120 // --------------------------------------------------------------------------- |
1295 // --------------------------------------------------------------------------- |
1121 // |
1296 // |
1122 void CThumbAGProcessor::ActivateAO() |
1297 void CThumbAGProcessor::ActivateAO() |
1123 { |
1298 { |
1124 #ifdef _DEBUG |
1299 #ifdef _DEBUG |
1125 TN_DEBUG6( "CThumbAGProcessor::Items in queue Add = %d, Mod = %d, Del = %d, Query = %d, iPlaceholder = %d", iAddQueue.Count(), iModifyQueue.Count(), iRemoveQueue.Count(), iQueryQueue.Count(), iPlaceholderQueue.Count()); |
1300 TN_DEBUG6( "CThumbAGProcessor::ActivateAO() items in queue Add = %d, Mod = %d, Del = %d, Query = %d, iPlaceholder = %d", iAddQueue.Count(), iModifyQueue.Count(), iRemoveQueue.Count(), iQueryQueue.Count(), iPlaceholderQueue.Count()); |
|
1301 TN_DEBUG2( "CThumbAGProcessor::ActivateAO() items in queue 2nd Add = %d", i2ndRoundGenerateQueue.Count()); |
|
1302 TN_DEBUG3( "CThumbAGProcessor::ActivateAO() iActive = %d, iActiveCount = %d", iActive, iActiveCount); |
|
1303 TN_DEBUG3( "CThumbAGProcessor::ActivateAO() iHarvesting == %d, iMPXHarvesting == %d", iHarvesting, iMPXHarvesting); |
|
1304 TN_DEBUG4( "CThumbAGProcessor::ActivateAO() iIdle = %d, timer = %d, iForceRun = %d", iIdle, iPeriodicTimer->IsActive(), iForceRun); |
|
1305 TN_DEBUG4( "CThumbAGProcessor::ActivateAO() iModify = %d, iQueryReady = %d, iProcessingCount = %d", iModify, iQueryReady, iProcessingCount); |
1126 #endif |
1306 #endif |
1127 |
1307 |
1128 if(iFormatting) |
1308 if(iFormatting) |
1129 { |
1309 { |
1130 TN_DEBUG1( "CThumbAGProcessor::ActivateAO() - FORMATTING - DAEMON ON PAUSE"); |
1310 TN_DEBUG1( "CThumbAGProcessor::ActivateAO() - FORMATTING - DAEMON ON PAUSE"); |
1131 return; |
1311 return; |
1132 } |
1312 } |
1133 |
1313 |
1134 if( !IsActive() ) |
1314 if( !IsActive() ) |
1135 { |
1315 { |
1136 #ifdef _DEBUG |
|
1137 if( iForceRun ) |
|
1138 { |
|
1139 TN_DEBUG1( "CThumbAGProcessor::ActivateAO() - *** FORCED RUN ***"); |
|
1140 } |
|
1141 #endif |
|
1142 SetActive(); |
1316 SetActive(); |
1143 TRequestStatus* statusPtr = &iStatus; |
1317 TRequestStatus* statusPtr = &iStatus; |
1144 User::RequestComplete( statusPtr, KErrNone ); |
1318 User::RequestComplete( statusPtr, KErrNone ); |
1145 } |
1319 } |
|
1320 |
|
1321 UpdatePSValues(); |
1146 } |
1322 } |
1147 |
1323 |
1148 // --------------------------------------------------------------------------- |
1324 // --------------------------------------------------------------------------- |
1149 // CThumbAGProcessor::PeriodicTimerCallBack() |
1325 // CThumbAGProcessor::PeriodicTimerCallBack() |
1150 // --------------------------------------------------------------------------- |
1326 // --------------------------------------------------------------------------- |
1221 |
1397 |
1222 // --------------------------------------------------------------------------- |
1398 // --------------------------------------------------------------------------- |
1223 // CThumbAGProcessor::RemoveFromQueues() |
1399 // CThumbAGProcessor::RemoveFromQueues() |
1224 // --------------------------------------------------------------------------- |
1400 // --------------------------------------------------------------------------- |
1225 // |
1401 // |
|
1402 #ifdef _DEBUG |
1226 void CThumbAGProcessor::RemoveFromQueues( const RArray<TItemId>& aIDArray, const TBool aRemoveFromDelete ) |
1403 void CThumbAGProcessor::RemoveFromQueues( const RArray<TItemId>& aIDArray, const TBool aRemoveFromDelete ) |
|
1404 #else |
|
1405 void CThumbAGProcessor::RemoveFromQueues( const RArray<TItemId>& aIDArray, const TBool /*aRemoveFromDelete*/ ) |
|
1406 #endif |
1227 { |
1407 { |
1228 TN_DEBUG2( "CThumbAGProcessor::RemoveFromQueues() aRemoveFromDelete == %d - begin", aRemoveFromDelete ); |
1408 TN_DEBUG2( "CThumbAGProcessor::RemoveFromQueues() aRemoveFromDelete == %d - begin", aRemoveFromDelete ); |
1229 |
1409 |
1230 TInt itemIndex = KErrNotFound; |
1410 TInt itemIndex = KErrNotFound; |
1231 |
1411 |
1232 for (int i=0; i< aIDArray.Count(); i++) |
1412 for (int i=0; i< aIDArray.Count(); i++) |
1233 { |
1413 { |
1234 TN_DEBUG2( "CThumbAGProcessor::RemoveFromQueues() - %d", aIDArray[i]); |
1414 TN_DEBUG2( "CThumbAGProcessor::RemoveFromQueues() - %d", aIDArray[i]); |
1235 |
1415 |
1236 itemIndex = iPlaceholderQueue.Find( aIDArray[i] ); |
1416 itemIndex = iPlaceholderQueue.Find( aIDArray[i] ); |
1237 |
1417 |
1238 if(itemIndex >= 0) |
1418 if(itemIndex >= 0) |
1239 { |
1419 { |
1240 iPlaceholderQueue.Remove(itemIndex); |
1420 iPlaceholderQueue.Remove(itemIndex); |
1428 void CThumbAGProcessor::HandleCollectionMediaL( const CMPXMedia& /*aMedia*/, |
1629 void CThumbAGProcessor::HandleCollectionMediaL( const CMPXMedia& /*aMedia*/, |
1429 TInt /*aError*/ ) |
1630 TInt /*aError*/ ) |
1430 { |
1631 { |
1431 // not needed here |
1632 // not needed here |
1432 } |
1633 } |
1433 |
1634 |
1434 // ----------------------------------------------------------------------------- |
1635 // ----------------------------------------------------------------------------- |
1435 // LightStatusChanged() |
1636 // ActivityChanged() |
1436 // ----------------------------------------------------------------------------- |
1637 // ----------------------------------------------------------------------------- |
1437 // |
1638 // |
1438 void CThumbAGProcessor::LightStatusChanged(TInt aTarget, CHWRMLight::TLightStatus aStatus) |
1639 void CThumbAGProcessor::ActivityChanged(const TBool aActive) |
1439 { |
1640 { |
1440 TN_DEBUG3( "void CThumbAGProcessor::LightStatusChanged() aTarget == %d, aStatus == %d", aTarget, aStatus); |
1641 TN_DEBUG2( "void CThumbAGProcessor::ActivityChanged() aActive == %d", aActive); |
1441 |
1642 if(aActive) |
1442 if( aStatus == CHWRMLight::ELightOff) |
1643 { |
1443 { |
1644 iIdle = EFalse; |
1444 TN_DEBUG1( "void CThumbAGProcessor::LightStatusChanged() -- OFF"); |
1645 } |
1445 iLights = EFalse; |
1646 else |
1446 |
1647 { |
1447 if(iAddQueue.Count() + iModifyQueue.Count() + iRemoveQueue.Count() > 0 ) |
1648 iIdle = ETrue; |
|
1649 |
|
1650 if(iAddQueue.Count() + iModifyQueue.Count() + iRemoveQueue.Count() + i2ndRoundGenerateQueue.Count() > 0 ) |
1448 { |
1651 { |
1449 ActivateAO(); |
1652 ActivateAO(); |
1450 } |
1653 } |
1451 } |
1654 } |
1452 else |
1655 } |
1453 { |
1656 |
1454 TN_DEBUG1( "void CThumbAGProcessor::LightStatusChanged() -- ON"); |
|
1455 iLights = ETrue; |
|
1456 } |
|
1457 } |
|
1458 |
|
1459 // ----------------------------------------------------------------------------- |
|
1460 // IsInactive() |
|
1461 // ----------------------------------------------------------------------------- |
|
1462 // |
|
1463 TBool CThumbAGProcessor::IsInactive() |
|
1464 { |
|
1465 #ifdef _DEBUG |
|
1466 TN_DEBUG2( "CThumbAGProcessor::IsInactive()= %d", User::InactivityTime().Int()); |
|
1467 #endif |
|
1468 |
|
1469 if( User::InactivityTime() < TTimeIntervalSeconds(KBackgroundGenerationIdle) ) |
|
1470 { |
|
1471 return EFalse; |
|
1472 } |
|
1473 return ETrue; |
|
1474 } |
|
1475 |
|
1476 // ----------------------------------------------------------------------------- |
|
1477 // ActivityDetected() |
|
1478 // ----------------------------------------------------------------------------- |
|
1479 // |
|
1480 void CThumbAGProcessor::ActivityDetected() |
|
1481 { |
|
1482 iIdle = EFalse; |
|
1483 } |
|
1484 |
|
1485 // ----------------------------------------------------------------------------- |
|
1486 // InactivityDetected() |
|
1487 // ----------------------------------------------------------------------------- |
|
1488 // |
|
1489 void CThumbAGProcessor::InactivityDetected() |
|
1490 { |
|
1491 iIdle = ETrue; |
|
1492 |
|
1493 if(iAddQueue.Count() + iModifyQueue.Count() + iRemoveQueue.Count() > 0 ) |
|
1494 { |
|
1495 ActivateAO(); |
|
1496 } |
|
1497 } |
|
1498 |
1657 |
1499 // --------------------------------------------------------------------------- |
1658 // --------------------------------------------------------------------------- |
1500 // CThumbAGProcessor::FormatNotification |
1659 // CThumbAGProcessor::FormatNotification |
1501 // Handles a format operation |
1660 // Handles a format operation |
1502 // --------------------------------------------------------------------------- |
1661 // --------------------------------------------------------------------------- |
1510 { |
1669 { |
1511 ActivateAO(); |
1670 ActivateAO(); |
1512 } |
1671 } |
1513 } |
1672 } |
1514 |
1673 |
|
1674 // --------------------------------------------------------------------------- |
|
1675 // CThumbAGProcessor::RPropertyNotification |
|
1676 // Handles a RProperty changed operation |
|
1677 // --------------------------------------------------------------------------- |
|
1678 // |
|
1679 void CThumbAGProcessor::RPropertyNotification(const TInt aError, const TUid aKeyCategory, const TUint aPropertyKey, const TInt aValue) |
|
1680 { |
|
1681 TN_DEBUG5( "CThumbAGProcessor::RPropertyNotification() aError = %d, aPropertyKey = %d, aKeyCategory = %d, aValue = %d", aError, aPropertyKey, aKeyCategory, aValue ); |
|
1682 |
|
1683 if(aPropertyKey == KForceBackgroundGeneration && aKeyCategory == KTAGDPSNotification ) |
|
1684 { |
|
1685 if( aValue == 1 && aError == KErrNone ) |
|
1686 { |
|
1687 iForegroundRun = ETrue; |
|
1688 ActivateAO(); |
|
1689 } |
|
1690 else |
|
1691 { |
|
1692 iForegroundRun = EFalse; |
|
1693 } |
|
1694 } |
|
1695 } |
|
1696 |
|
1697 // --------------------------------------------------------------------------- |
|
1698 // CThumbAGProcessor::UpdateItemsLeft |
|
1699 // Update KItemsleft PS value if changed |
|
1700 // --------------------------------------------------------------------------- |
|
1701 // |
|
1702 void CThumbAGProcessor::UpdatePSValues(const TBool aDefine) |
|
1703 { |
|
1704 TInt itemsLeft = iModifyQueue.Count() + iAddQueue.Count(); |
|
1705 TBool daemonProcessing = EFalse; |
|
1706 |
|
1707 if(itemsLeft + i2ndRoundGenerateQueue.Count() + iRemoveQueue.Count() > 0 ) |
|
1708 { |
|
1709 daemonProcessing = ETrue; |
|
1710 } |
|
1711 |
|
1712 if(aDefine) |
|
1713 { |
|
1714 TN_DEBUG1( "CThumbAGProcessor::UpdatePSValues() define"); |
|
1715 RProperty::Define(KTAGDPSNotification, KDaemonProcessing, RProperty::EInt); |
|
1716 RProperty::Set(KTAGDPSNotification, KDaemonProcessing, 0); |
|
1717 daemonProcessing = EFalse; |
|
1718 RProperty::Define(KTAGDPSNotification, KItemsleft, RProperty::EInt); |
|
1719 RProperty::Set(KTAGDPSNotification, KItemsleft, 0); |
|
1720 iPreviousItemsLeft = 0; |
|
1721 } |
|
1722 |
|
1723 if( daemonProcessing != iPreviousDaemonProcessing) |
|
1724 { |
|
1725 TN_DEBUG2( "CThumbAGProcessor::UpdatePSValues() update KDaemonProcessing == %d", daemonProcessing); |
|
1726 iPreviousDaemonProcessing = daemonProcessing; |
|
1727 RProperty::Set(KTAGDPSNotification, KDaemonProcessing, daemonProcessing); |
|
1728 } |
|
1729 |
|
1730 if( itemsLeft != iPreviousItemsLeft) |
|
1731 { |
|
1732 TN_DEBUG2( "CThumbAGProcessor::UpdatePSValues() update KItemsleft == %d", itemsLeft); |
|
1733 iPreviousItemsLeft = itemsLeft; |
|
1734 RProperty::Set(KTAGDPSNotification, KItemsleft, itemsLeft ); |
|
1735 } |
|
1736 } |
1515 |
1737 |
1516 // End of file |
1738 // End of file |