302 // if no errors in query |
349 // if no errors in query |
303 if (aError == KErrNone && iQuery) |
350 if (aError == KErrNone && iQuery) |
304 { |
351 { |
305 iProcessingCount = iQuery->Count(); |
352 iProcessingCount = iQuery->Count(); |
306 |
353 |
307 if(iProcessingCount != iQueryQueue.Count()) |
354 if(iProcessingCount != iQueryQueue.Count() ) |
308 { |
355 { |
309 TN_DEBUG1( "CThumbAGProcessor::HandleQueryCompleted() some result items missing"); |
356 TN_DEBUG1( "CThumbAGProcessor::HandleQueryCompleted() some result items missing"); |
310 |
357 |
311 RArray<TItemId> queryQueueDelta; |
358 RArray<TItemId> queryQueueDelta; |
312 |
359 |
313 TInt itemIndex(KErrNotFound); |
360 //search delta items which were queried, but not found |
314 |
361 for(TInt queryItem =0; queryItem < iQueryQueue.Count();queryItem++) |
315 //search delta items which were queried, but not found |
362 { |
316 for(TInt queryItem =0; queryItem < iQueryQueue.Count();queryItem++) |
363 TBool found(EFalse); |
317 { |
364 for(TInt queryResult = 0; queryResult < iQuery->Count(); queryResult++) |
318 TBool found(EFalse); |
365 { |
319 for(TInt queryResult = 0; queryResult < iQuery->Count(); queryResult++) |
366 const CMdEObject* object = &iQuery->Result(queryResult); |
320 { |
367 |
321 const CMdEObject* object = &iQuery->Result(queryResult); |
368 if( iQueryQueue[queryItem] == object->Id()) |
322 |
369 { |
323 if( iQueryQueue[queryItem] == object->Id()) |
370 found = ETrue; |
|
371 break; |
|
372 } |
|
373 } |
|
374 |
|
375 if(!found) |
|
376 { |
|
377 TN_DEBUG2( "CThumbAGProcessor::HandleQueryCompleted() %d missing from query results", iQueryQueue[queryItem] ); |
|
378 |
|
379 // ignore if fails |
|
380 queryQueueDelta.InsertInOrder(iQueryQueue[queryItem], CompareId); |
|
381 } |
|
382 } |
|
383 |
|
384 TN_DEBUG2( "CThumbAGProcessor::HandleQueryCompleted() missing items found %d", queryQueueDelta.Count()); |
|
385 //cleanup from previous queue it item is not found from MDS |
|
386 while(queryQueueDelta.Count()) |
|
387 { |
|
388 TThumbnailGenerationItem item; |
|
389 item.iItemId = queryQueueDelta[0]; |
|
390 TInt itemIndex = iQueryQueue.FindInOrder(item.iItemId, CompareId); |
|
391 |
|
392 if(itemIndex >= 0) |
|
393 { |
|
394 TN_DEBUG2( "CThumbAGProcessor::HandleQueryCompleted() remove %d from iQueryQueue", queryQueueDelta[0]); |
|
395 iQueryQueue.Remove( itemIndex ); |
|
396 |
|
397 //remove from procesing queue |
|
398 itemIndex = iGenerationQueue.FindInOrder(item, Compare); |
|
399 |
|
400 if(itemIndex >= 0) |
|
401 { |
|
402 |
|
403 if( iUnknown ) |
|
404 { |
|
405 TN_DEBUG2( "CThumbAGProcessor::HandleQueryCompleted() mark %d as EGenerationItemTypeNotFound in iGenerationQueue", queryQueueDelta[0]); |
|
406 //mark to be removed, cleanup is done below |
|
407 iGenerationQueue[itemIndex].iItemType = EGenerationItemTypeNotFound; |
|
408 } |
|
409 else |
|
410 { |
|
411 TN_DEBUG2( "CThumbAGProcessor::HandleQueryCompleted() remove %d from iGenerationQueue", queryQueueDelta[0]); |
|
412 iGenerationQueue.Remove( itemIndex ); |
|
413 } |
|
414 } |
|
415 } |
|
416 queryQueueDelta.Remove(0); |
|
417 } |
|
418 queryQueueDelta.Close(); |
|
419 } |
|
420 |
|
421 if(iUnknown) |
|
422 { |
|
423 for(TInt i = 0; i < iQuery->Count(); i++) |
|
424 { |
|
425 const CMdEObject* object = &iQuery->Result(i); |
|
426 |
|
427 if(!object) |
|
428 { |
|
429 continue; |
|
430 } |
|
431 |
|
432 TThumbnailGenerationItem tempItem; |
|
433 tempItem.iItemId = object->Id(); |
|
434 TInt itemIndex = iGenerationQueue.FindInOrder(tempItem, Compare); |
|
435 |
|
436 if(itemIndex >= 0) |
324 { |
437 { |
325 found = ETrue; |
438 TThumbnailGenerationItem& item = iGenerationQueue[itemIndex]; |
326 break; |
439 |
|
440 if(iGenerationQueue[itemIndex].iItemType == EGenerationItemTypeNotFound) |
|
441 { |
|
442 TN_DEBUG2( "CThumbAGProcessor::HandleQueryCompleted() remove EGenerationItemTypeNotFound %d item from iGenerationQueue", item.iItemId); |
|
443 iGenerationQueue.Remove(itemIndex); |
|
444 continue; |
|
445 } |
|
446 |
|
447 SetGenerationItemType(item, object->Def().Id()); |
|
448 |
|
449 if(item.iItemType == EGenerationItemTypeUnknown ) |
|
450 { |
|
451 TN_DEBUG2( "CThumbAGProcessor::HandleQueryCompleted() remove unknown item %d", item.iItemId); |
|
452 iGenerationQueue.Remove(itemIndex); |
|
453 continue; |
|
454 } |
|
455 |
|
456 item.iPlaceholder = object->Placeholder(); |
|
457 |
327 } |
458 } |
328 } |
459 } |
329 |
460 |
330 if(!found) |
461 iQueryQueue.Reset(); |
331 { |
462 iProcessingCount = 0; |
332 TN_DEBUG2( "CThumbAGProcessor::HandleQueryCompleted() missing from results item %d", iQueryQueue[queryItem] ); |
463 iUnknown = EFalse; |
333 |
464 } |
334 // ignore if fails |
|
335 queryQueueDelta.InsertInOrder(iQueryQueue[queryItem], Compare); |
|
336 } |
|
337 } |
|
338 |
|
339 TN_DEBUG2( "CThumbAGProcessor::HandleQueryCompleted() missing items total count %d", queryQueueDelta.Count()); |
|
340 //cleanup from previous queue it item is not found from MDS |
|
341 while(queryQueueDelta.Count()) |
|
342 { |
|
343 itemIndex = iLastQueue->FindInOrder(queryQueueDelta[0], Compare); |
|
344 |
|
345 if(itemIndex >= 0) |
|
346 { |
|
347 TN_DEBUG2( "CThumbAGProcessor::HandleQueryCompleted() remove items %d", iQueryQueue[0]); |
|
348 iLastQueue->Remove( itemIndex ); |
|
349 } |
|
350 queryQueueDelta.Remove(0); |
|
351 } |
|
352 queryQueueDelta.Close(); |
|
353 } |
|
354 |
465 |
355 // no results, reset query |
466 // no results, reset query |
356 if( !iProcessingCount) |
467 if( !iProcessingCount ) |
357 { |
468 { |
358 delete iQuery; |
469 delete iQuery; |
359 iQuery = NULL; |
470 iQuery = NULL; |
360 iProcessingCount = 0; |
|
361 iModify = EFalse; |
471 iModify = EFalse; |
362 } |
472 } |
363 } |
473 } |
364 else |
474 else |
365 { |
475 { |
466 |
564 |
467 TRAPD( err, iDefNamespace = &iMdESession->GetDefaultNamespaceDefL() ); |
565 TRAPD( err, iDefNamespace = &iMdESession->GetDefaultNamespaceDefL() ); |
468 if (err != KErrNone) |
566 if (err != KErrNone) |
469 { |
567 { |
470 TN_DEBUG2( "CThumbAGProcessor::SetMdESession() GetDefaultNamespaceDefL() err = %d", err ); |
568 TN_DEBUG2( "CThumbAGProcessor::SetMdESession() GetDefaultNamespaceDefL() err = %d", err ); |
471 } |
569 __ASSERT_DEBUG((iDefNamespace), User::Panic(_L("CThumbAGProcessor::SetMdESession() !iDefNamespace "), KErrBadHandle)); |
472 |
570 } |
473 __ASSERT_DEBUG((iDefNamespace), User::Panic(_L("CThumbAGProcessor::SetMdESession() !iDefNamespace "), KErrBadHandle)); |
571 else |
474 |
572 { |
475 //do async init |
573 iImageObjectDef = &iDefNamespace->GetObjectDefL( MdeConstants::Image::KImageObject ); |
476 iInit = ETrue; |
574 __ASSERT_DEBUG((iImageObjectDef), User::Panic(_L("CThumbAGProcessor::SetMdESession() !iDefNamespace "), KErrBadHandle)); |
477 |
575 iVideoObjectDef = &iDefNamespace->GetObjectDefL( MdeConstants::Video::KVideoObject ); |
478 ActivateAO(); |
576 __ASSERT_DEBUG((iVideoObjectDef), User::Panic(_L("CThumbAGProcessor::SetMdESession() !iVideoObjectDef "), KErrBadHandle)); |
|
577 iAudioObjectDef = &iDefNamespace->GetObjectDefL( MdeConstants::Audio::KAudioObject ); |
|
578 __ASSERT_DEBUG((iAudioObjectDef), User::Panic(_L("CThumbAGProcessor::SetMdESession() !iAudioObjectDef "), KErrBadHandle)); |
|
579 |
|
580 //do async init |
|
581 iInit = ETrue; |
|
582 |
|
583 ActivateAO(); |
|
584 } |
479 } |
585 } |
480 |
586 |
481 // --------------------------------------------------------------------------- |
587 // --------------------------------------------------------------------------- |
482 // CThumbAGProcessor::AddToQueue() |
588 // CThumbAGProcessor::AddToQueue() |
483 // --------------------------------------------------------------------------- |
589 // --------------------------------------------------------------------------- |
484 // |
590 // |
485 void CThumbAGProcessor::AddToQueueL( TObserverNotificationType aType, |
591 void CThumbAGProcessor::AddToQueueL( TObserverNotificationType aType, |
|
592 TThumbnailGenerationItemType aItemType, |
486 const RArray<TItemId>& aIDArray, |
593 const RArray<TItemId>& aIDArray, |
487 const RPointerArray<HBufC>& aObjectUriArray, |
594 const RPointerArray<HBufC>& aObjectUriArray, |
488 TBool /*aPresent*/ ) |
595 TBool /*aPresent*/ ) |
489 { |
596 { |
490 TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - begin" ); |
597 TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - begin" ); |
|
598 |
491 |
599 |
492 // update queues |
600 // update queues |
493 if (aType == ENotifyAdd) |
601 if (aType == ENotifyAdd) |
494 { |
602 { |
495 TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - ENotifyAdd" ); |
603 TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - ENotifyAdd" ); |
496 |
604 |
497 for (int i=0; i<aIDArray.Count(); i++) |
605 for (int i=0; i<aIDArray.Count(); i++) |
498 { |
606 { |
499 // do not to append to Add queue if exist already in Add or 2nd Add queue (just processed) |
607 TThumbnailGenerationItem item; |
500 if (iAddQueue.FindInOrder(aIDArray[i], Compare) == KErrNotFound && |
608 item.iItemId = aIDArray[i]; |
501 i2ndRoundGenerateQueue.FindInOrder(aIDArray[i], Compare) == KErrNotFound) |
609 item.iItemType = aItemType; |
502 { |
610 |
503 User::LeaveIfError(iAddQueue.InsertInOrder(aIDArray[i], Compare)); |
611 SetGenerationItemType(item, aItemType); |
504 } |
612 |
|
613 if(iPHHarvesting) |
|
614 { |
|
615 item.iPlaceholder = ETrue; |
|
616 } |
|
617 |
|
618 AppendProcessingQueue( item ); |
505 } |
619 } |
506 } |
620 } |
507 else if (aType == ENotifyModify) |
621 else if (aType == ENotifyModify) |
508 { |
622 { |
509 TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - ENotifyModify" ); |
623 TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - ENotifyModify" ); |
511 if(iPHHarvesting) |
625 if(iPHHarvesting) |
512 { |
626 { |
513 TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - PH harvesting active, treat like add" ); |
627 TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - PH harvesting active, treat like add" ); |
514 for (int i=0; i<aIDArray.Count(); i++) |
628 for (int i=0; i<aIDArray.Count(); i++) |
515 { |
629 { |
516 TInt itemIndex = iPlaceholderQueue.FindInOrder(aIDArray[i], Compare); |
630 TThumbnailGenerationItem item; |
|
631 item.iItemId = aIDArray[i]; |
|
632 |
|
633 TInt itemIndex = iGenerationQueue.FindInOrder(item, Compare); |
517 |
634 |
518 if (itemIndex >= 0) |
635 if (itemIndex >= 0) |
519 { |
636 { |
520 TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - remove from placeholder queue"); |
637 TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - set as non-placeholder"); |
521 iPlaceholderQueue.Remove( itemIndex ); |
638 iGenerationQueue[itemIndex].iPlaceholder = EFalse; |
522 } |
639 } |
|
640 else |
|
641 { |
|
642 TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - append"); |
|
643 |
|
644 item.iPlaceholder = EFalse; |
|
645 SetGenerationItemType( item, 0 ); |
|
646 AppendProcessingQueue( item ); |
|
647 } |
|
648 } |
|
649 } |
|
650 else |
|
651 { |
|
652 TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - PH harvesting finished, check is real modify!" ); |
|
653 |
|
654 TInt itemIndex(KErrNotFound); |
|
655 |
|
656 for (int i=0; i<aIDArray.Count(); i++) |
|
657 { |
|
658 TThumbnailGenerationItem item; |
|
659 item.iItemId = aIDArray[i]; |
523 |
660 |
524 if(iAddQueue.FindInOrder(aIDArray[i], Compare) == KErrNotFound && |
661 itemIndex = iGenerationQueue.FindInOrder(item, Compare); |
525 i2ndRoundGenerateQueue.FindInOrder(aIDArray[i], Compare) == KErrNotFound) |
|
526 { |
|
527 TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - append to add queue"); |
|
528 User::LeaveIfError(iAddQueue.InsertInOrder(aIDArray[i], Compare)); |
|
529 } |
|
530 } |
|
531 } |
|
532 else |
|
533 { |
|
534 TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - PH harvesting finished, check is real modify!" ); |
|
535 |
|
536 TInt itemIndex(KErrNotFound); |
|
537 |
|
538 for (int i=0; i<aIDArray.Count(); i++) |
|
539 { |
|
540 itemIndex = iPlaceholderQueue.FindInOrder(aIDArray[i], Compare); |
|
541 |
662 |
542 if (itemIndex >= 0) |
663 if (itemIndex >= 0) |
543 { |
664 { |
544 TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - placeholder modify, remove from placeholder queue"); |
665 if( iGenerationQueue[itemIndex].iPlaceholder ) |
545 iPlaceholderQueue.Remove( itemIndex ); |
666 { |
|
667 TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - placeholder modify"); |
|
668 iGenerationQueue[itemIndex].iPlaceholder = EFalse; |
|
669 } |
|
670 else |
|
671 { |
|
672 TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - real modify"); |
|
673 iGenerationQueue[itemIndex].iItemAction = EGenerationItemActionModify; |
|
674 SetForceRun( ETrue ); |
|
675 } |
546 } |
676 } |
547 else |
677 else |
548 { |
678 { |
549 TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - real modify"); |
679 TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - append"); |
550 itemIndex = iAddQueue.FindInOrder(aIDArray[i], Compare); |
680 SetGenerationItemType( item, 0 ); |
551 |
681 item.iPlaceholder = EFalse; |
552 if (itemIndex >= 0) |
682 AppendProcessingQueue( item ); |
553 { |
683 } |
554 TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - remove from add queue"); |
684 } |
555 iAddQueue.Remove( itemIndex ); |
685 } |
556 } |
686 } |
557 else |
687 else if (aType == ENotifyRemove && aItemType == EGenerationItemTypeAny) |
558 { |
|
559 itemIndex = i2ndRoundGenerateQueue.FindInOrder(aIDArray[i], Compare); |
|
560 |
|
561 if (itemIndex >= 0) |
|
562 { |
|
563 TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - remove from 2nd round add queue"); |
|
564 i2ndRoundGenerateQueue.Remove( itemIndex ); |
|
565 } |
|
566 } |
|
567 |
|
568 TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - append to modify queue"); |
|
569 User::LeaveIfError(iModifyQueue.InsertInOrder(aIDArray[i], Compare)); |
|
570 |
|
571 SetForceRun( ETrue ); |
|
572 } |
|
573 } |
|
574 } |
|
575 } |
|
576 else if (aType == ENotifyRemove) |
|
577 { |
688 { |
578 TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - ENotifyRemove, remove IDs from all queues"); |
689 TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - ENotifyRemove, remove IDs from all queues"); |
579 |
690 |
580 for (int i=0; i<aIDArray.Count(); i++) |
691 for (int i=0; i<aIDArray.Count(); i++) |
581 { |
692 { |
582 // can be removed from Add queue |
693 TThumbnailGenerationItem item; |
583 TInt itemIndex = iAddQueue.FindInOrder(aIDArray[i], Compare); |
694 item.iItemId = aIDArray[i]; |
|
695 |
|
696 TInt itemIndex = iGenerationQueue.FindInOrder(item, Compare); |
|
697 |
584 if(itemIndex >= 0) |
698 if(itemIndex >= 0) |
585 { |
699 { |
586 iAddQueue.Remove(itemIndex); |
700 iGenerationQueue[itemIndex].iItemAction = EGenerationItemActionDelete; |
|
701 delete iGenerationQueue[itemIndex].iUri; |
|
702 iGenerationQueue[itemIndex].iUri = NULL; |
|
703 |
|
704 if( aObjectUriArray[i]) |
|
705 { |
|
706 iGenerationQueue[itemIndex].iUri = aObjectUriArray[i]->AllocL(); |
|
707 } |
|
708 else |
|
709 { |
|
710 //invalid URI remove from processing queue |
|
711 iGenerationQueue.Remove(itemIndex); |
|
712 } |
587 } |
713 } |
588 |
714 else |
589 // ..and Modify Queue |
|
590 itemIndex = iModifyQueue.FindInOrder(aIDArray[i], Compare); |
|
591 if(itemIndex >= 0) |
|
592 { |
715 { |
593 iModifyQueue.Remove(itemIndex); |
716 TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - append"); |
|
717 item.iItemAction = EGenerationItemActionDelete; |
|
718 delete item.iUri; |
|
719 item.iUri = NULL; |
|
720 |
|
721 if( aObjectUriArray[i]) |
|
722 { |
|
723 item.iUri = aObjectUriArray[i]->AllocL(); |
|
724 CleanupStack::PushL( item.iUri ); |
|
725 User::LeaveIfError( iGenerationQueue.InsertInOrder(item, Compare) ); |
|
726 CleanupStack::Pop(); |
|
727 } |
|
728 |
|
729 //owned by item |
|
730 item.iUri = NULL; |
594 } |
731 } |
595 } |
732 |
596 |
733 TN_DEBUG2( "CThumbAGProcessor::AddToQueueL() - %S", aObjectUriArray[i]); |
597 TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - ENotifyRemove append URIs to remove queue"); |
|
598 for (int i=0; i<aObjectUriArray.Count(); i++) |
|
599 { |
|
600 HBufC* temp = aObjectUriArray[i]->AllocL(); |
|
601 iRemoveQueue.Append( temp ); |
|
602 TN_DEBUG2( "CThumbAGProcessor::AddToQueueL() - %S", temp); |
|
603 } |
734 } |
604 } |
735 } |
605 #ifdef _DEBUG |
736 #ifdef _DEBUG |
606 else |
737 else |
607 { |
738 { |
608 TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - should not come here" ); |
739 TN_DEBUG1( "CThumbAGProcessor::AddToQueueL() - should not come here" ); |
|
740 __ASSERT_DEBUG((EFalse), User::Panic(_L("CThumbAGProcessor::AddToQueueL()"), KErrArgument)); |
609 User::Leave( KErrArgument ); |
741 User::Leave( KErrArgument ); |
610 } |
742 } |
611 #endif |
743 #endif |
612 |
744 |
613 ActivateAO(); |
745 ActivateAO(); |
659 if( i2ndRound ) |
791 if( i2ndRound ) |
660 { |
792 { |
661 //generate both if needed |
793 //generate both if needed |
662 TN_DEBUG1( "CThumbAGProcessor::CreateThumbnailsL() EOptimizeForQuality "); |
794 TN_DEBUG1( "CThumbAGProcessor::CreateThumbnailsL() EOptimizeForQuality "); |
663 iTMSession->SetQualityPreferenceL( CThumbnailManager::EOptimizeForQuality ); |
795 iTMSession->SetQualityPreferenceL( CThumbnailManager::EOptimizeForQuality ); |
|
796 |
|
797 TN_DEBUG2( "CThumbAGProcessor::CreateThumbnailsL() - 2nd round add remove from queue", aObject->Id() ); |
|
798 |
|
799 TThumbnailGenerationItem item; |
|
800 item.iItemId = aObject->Id(); |
|
801 TInt itemIndex = iGenerationQueue.FindInOrder(item, Compare); |
|
802 |
|
803 if(itemIndex >=0 ) |
|
804 { |
|
805 if(iGenerationQueue[itemIndex].iItemAction == EGenerationItemAction2ndAdd) |
|
806 { |
|
807 iGenerationQueue.Remove(itemIndex); |
|
808 } |
|
809 } |
664 } |
810 } |
665 // 1st roung generation |
811 // 1st roung generation |
666 else |
812 else |
667 { |
813 { |
668 //1st round |
814 //1st round |
669 TN_DEBUG1( "CThumbAGProcessor::CreateThumbnailsL() EOptimizeForQualityWithPreview"); |
815 TN_DEBUG1( "CThumbAGProcessor::CreateThumbnailsL() EOptimizeForQualityWithPreview"); |
670 iTMSession->SetQualityPreferenceL( CThumbnailManager::EOptimizeForQualityWithPreview ); |
816 iTMSession->SetQualityPreferenceL( CThumbnailManager::EOptimizeForQualityWithPreview ); |
671 |
817 |
672 CMdEObjectDef& videoObjectDef = iDefNamespace->GetObjectDefL( MdeConstants::Video::KVideoObject ); |
|
673 |
|
674 // add item to 2nd round queue |
818 // add item to 2nd round queue |
675 if(iLastQueue == &iAddQueue || iLastQueue == &iModifyQueue) |
819 TN_DEBUG2( "CThumbAGProcessor::CreateThumbnailsL() - 1st round add/modify, append to 2nd round queue", aObject->Id() ); |
676 { |
820 |
677 TN_DEBUG2( "CThumbAGProcessor::CreateThumbnailsL() - 1st round add/modify, append to 2nd round queue", aObject->Id() ); |
821 TThumbnailGenerationItem item; |
678 if(i2ndRoundGenerateQueue.FindInOrder(aObject->Id(), Compare) == KErrNotFound) |
822 item.iItemId = aObject->Id(); |
|
823 TInt itemIndex = iGenerationQueue.FindInOrder(item, Compare); |
|
824 |
|
825 if(itemIndex >=0 ) |
|
826 { |
|
827 if(iGenerationQueue[itemIndex].iItemAction == EGenerationItemActionModify) |
679 { |
828 { |
680 // ignore if fails |
829 iGenerationQueue.Remove(itemIndex); |
681 i2ndRoundGenerateQueue.InsertInOrder(aObject->Id(), Compare); |
|
682 } |
830 } |
683 } |
831 //change 1st round item for 2nd round processing |
684 |
832 //2nd round item can be deleted |
685 // Symbian^4 specific ---> |
833 else if(iGenerationQueue[itemIndex].iItemAction == EGenerationItemActionAdd) |
686 if( imageObjectDef.Id() != aObject->Def().Id() ) |
834 { |
687 { |
835 iGenerationQueue[itemIndex].iItemAction = EGenerationItemAction2ndAdd; |
688 TN_DEBUG1( "CThumbAGProcessor::CreateThumbnailsL() 1st round not image"); |
836 } |
689 ActivateAO(); |
837 else |
690 return; |
838 { |
691 } |
839 iGenerationQueue.Remove(itemIndex); |
692 //Symbian^4 specific <--- |
840 } |
|
841 } |
693 } |
842 } |
694 |
843 |
695 // run as lower priority than getting but higher that creating thumbnails |
844 // run as lower priority than getting but higher that creating thumbnails |
696 TRAPD(err, iTMSession->UpdateThumbnailsL(KNoId, aObject->Uri(), orientationVal, modifiedVal, CActive::EPriorityIdle )); |
845 TRAPD(err, iTMSession->UpdateThumbnailsL(KNoId, aObject->Uri(), orientationVal, modifiedVal, CActive::EPriorityIdle )); |
697 |
846 |
698 if ( err != KErrNone ) |
847 if ( err != KErrNone ) |
699 { |
848 { |
700 TN_DEBUG2( "CThumbAGProcessor::CreateThumbnailsL, iTMSession error == %d", err ); |
849 TN_DEBUG2( "CThumbAGProcessor::CreateThumbnailsL, iTMSession error == %d", err ); |
701 |
850 |
702 iSessionDied = ETrue; |
851 iSessionDied = ETrue; |
703 iActive = EFalse; |
|
704 ActivateAO(); |
852 ActivateAO(); |
705 } |
853 } |
706 else |
854 else |
707 { |
855 { |
708 iActiveCount++; |
856 iActiveCount++; |
709 iActive = ETrue; |
|
710 } |
857 } |
711 } |
858 } |
712 else |
859 else |
713 { |
860 { |
714 ActivateAO(); |
861 ActivateAO(); |
746 delete iQuery; |
892 delete iQuery; |
747 iQuery = NULL; |
893 iQuery = NULL; |
748 } |
894 } |
749 |
895 |
750 //move ID from source queue to Query queue |
896 //move ID from source queue to Query queue |
751 TInt maxCount = aIDArray.Count(); |
897 TInt maxCount = iGenerationQueue.Count(); |
752 |
898 |
753 TN_DEBUG3( "CThumbAGProcessor::QueryL() - fill begin aIDArray == %d, iQueryQueue == %d", aIDArray.Count(), iQueryQueue.Count() ); |
899 TN_DEBUG3( "CThumbAGProcessor::QueryL() - fill begin iGenerationQueue == %d, iQueryQueue == %d", iGenerationQueue.Count(), iQueryQueue.Count() ); |
754 |
900 |
755 for(TInt i=0; i < KMaxQueryItems && i < maxCount; i++) |
901 |
756 { |
902 TInt itemCount(0); |
757 TN_DEBUG2( "CThumbAGProcessor::QueryL() - fill %d", aIDArray[0] ); |
903 for(TInt i=0; itemCount < KMaxQueryItems && i < maxCount; i++) |
758 iQueryQueue.InsertInOrder(aIDArray[0], Compare); |
904 { |
759 aIDArray.Remove(0); |
905 TInt itemIndex(KErrNotFound); |
760 } |
906 switch(aAction) |
761 |
907 { |
762 TN_DEBUG3( "CThumbAGProcessor::QueryL() - fill end aIDArray == %d, iQueryQueue == %d", aIDArray.Count(), iQueryQueue.Count() ); |
908 //1st round items |
|
909 case EGenerationItemActionAdd: |
|
910 if(iGenerationQueue[i].iItemAction == aAction ) |
|
911 { |
|
912 itemIndex = i; |
|
913 } |
|
914 break; |
|
915 case EGenerationItemActionModify: |
|
916 if( iGenerationQueue[i].iItemAction == aAction ) |
|
917 { |
|
918 itemIndex = i; |
|
919 } |
|
920 break; |
|
921 case EGenerationItemAction2ndAdd: |
|
922 if( iGenerationQueue[i].iItemAction == aAction ) |
|
923 { |
|
924 itemIndex = i; |
|
925 } |
|
926 break; |
|
927 //unknown stuff |
|
928 case EGenerationItemActionResolveType: |
|
929 if( iGenerationQueue[i].iItemType == EGenerationItemTypeUnknown ) |
|
930 { |
|
931 itemIndex = i; |
|
932 } |
|
933 break; |
|
934 default: |
|
935 break; |
|
936 }; |
|
937 |
|
938 if( itemIndex >= 0 ) |
|
939 { |
|
940 TN_DEBUG2( "CThumbAGProcessor::QueryL() - fill %d", iGenerationQueue[itemIndex].iItemId ); |
|
941 iQueryQueue.InsertInOrder(iGenerationQueue[itemIndex].iItemId, CompareId); |
|
942 itemCount++; |
|
943 } |
|
944 } |
|
945 |
|
946 if(!itemCount) |
|
947 { |
|
948 TN_DEBUG1( "CThumbAGProcessor::QueryL() - empty query, cancel?!"); |
|
949 iQueryActive = EFalse; |
|
950 __ASSERT_DEBUG((iMdESession), User::Panic(_L("CThumbAGProcessor::QueryL() empty! "), KErrNotFound)); |
|
951 return; |
|
952 } |
|
953 |
|
954 TN_DEBUG3( "CThumbAGProcessor::QueryL() - fill end iGenerationQueue == %d, iQueryQueue == %d", iGenerationQueue.Count(), iQueryQueue.Count() ); |
763 |
955 |
764 CMdEObjectDef& objDef = iDefNamespace->GetObjectDefL( MdeConstants::Object::KBaseObject ); |
956 CMdEObjectDef& objDef = iDefNamespace->GetObjectDefL( MdeConstants::Object::KBaseObject ); |
765 iQuery = iMdESession->NewObjectQueryL( *iDefNamespace, objDef, this ); |
957 iQuery = iMdESession->NewObjectQueryL( *iDefNamespace, objDef, this ); |
766 iQuery->SetResultMode( EQueryResultModeItem ); |
958 iQuery->SetResultMode( EQueryResultModeItem ); |
767 |
959 |
1069 } |
1257 } |
1070 //waiting for MDS query to complete |
1258 //waiting for MDS query to complete |
1071 else if( iQueryActive ) |
1259 else if( iQueryActive ) |
1072 { |
1260 { |
1073 //state mismatch |
1261 //state mismatch |
1074 if(iForceRun && !iModify) |
1262 if(iForceRun && !(iModify || iUnknown)) |
1075 { |
1263 { |
1076 //cancel query and move items back to original processing queue |
1264 //cancel query and move items back to original processing queue |
1077 DeleteAndCancelQuery(ETrue); |
1265 DeleteAndCancelQuery(ETrue); |
1078 ActivateAO(); |
1266 ActivateAO(); |
1079 } |
1267 } |
1080 else |
1268 else |
1081 { |
1269 { |
1082 TN_DEBUG1( "CThumbAGProcessor::RunL() - waiting for query to complete, abort..." ); |
1270 TN_DEBUG1( "CThumbAGProcessor::RunL() - waiting for query to complete, abort..." ); |
1083 } |
1271 } |
1084 } |
1272 } |
1085 |
1273 else if ( iUnknownItemCount > 0 ) |
|
1274 { |
|
1275 TN_DEBUG1( "void CThumbAGProcessor::RunL() unknown items in queue"); |
|
1276 |
|
1277 i2ndRound = EFalse; |
|
1278 iModify = EFalse; |
|
1279 iUnknown = ETrue; |
|
1280 iQueryActive = ETrue; |
|
1281 |
|
1282 QueryL( EGenerationItemActionResolveType ); |
|
1283 } |
1086 // no items in query queue, start new |
1284 // no items in query queue, start new |
1087 // select queue to process, priority by type |
1285 // select queue to process, priority by type |
1088 else if ( iModifyQueue.Count() > 0 ) |
1286 else if ( iModifyItemCount > 0 ) |
1089 { |
1287 { |
1090 TN_DEBUG1( "void CThumbAGProcessor::RunL() update thumbnails"); |
1288 TN_DEBUG1( "void CThumbAGProcessor::RunL() update thumbnails"); |
1091 |
1289 |
1092 i2ndRound = EFalse; |
1290 i2ndRound = EFalse; |
1093 |
1291 |
1094 // query for object info |
1292 // query for object info |
1095 iQueryActive = ETrue; |
1293 iQueryActive = ETrue; |
1096 iModify = ETrue; |
1294 iModify = ETrue; |
1097 QueryL( iModifyQueue ); |
1295 iUnknown = EFalse; |
|
1296 QueryL( EGenerationItemActionModify ); |
1098 } |
1297 } |
1099 else if ( iAddQueue.Count() > 0 ) |
1298 else if ( iAddItemCount > 0 ) |
1100 { |
1299 { |
1101 TN_DEBUG1( "void CThumbAGProcessor::RunL() update 1st round thumbnails"); |
1300 TN_DEBUG1( "void CThumbAGProcessor::RunL() update 1st round thumbnails"); |
1102 |
1301 |
1103 i2ndRound = EFalse; |
1302 i2ndRound = EFalse; |
1104 |
1303 iUnknown = EFalse; |
1105 // query for object info |
1304 // query for object info |
1106 iQueryActive = ETrue; |
1305 iQueryActive = ETrue; |
1107 |
1306 |
1108 QueryL( iAddQueue ); |
1307 QueryL( EGenerationItemActionAdd ); |
1109 } |
1308 } |
1110 else if ( iRemoveQueue.Count() > 0 ) |
1309 else if ( iDeleteItemCount > 0 ) |
1111 { |
1310 { |
1112 TN_DEBUG1( "void CThumbAGProcessor::RunL() delete thumbnails"); |
1311 TN_DEBUG1( "void CThumbAGProcessor::RunL() delete thumbnails"); |
1113 |
|
1114 i2ndRound = EFalse; |
1312 i2ndRound = EFalse; |
1115 |
1313 iUnknown = EFalse; |
1116 // delete thumbs by URI |
1314 // delete thumbs by URI |
1117 __ASSERT_DEBUG((iTMSession), User::Panic(_L("CThumbAGProcessor::RunL() !iTMSession "), KErrBadHandle)); |
1315 __ASSERT_DEBUG((iTMSession), User::Panic(_L("CThumbAGProcessor::RunL() !iTMSession "), KErrBadHandle)); |
1118 if(iTMSession) |
1316 if(iTMSession) |
1119 { |
1317 { |
1120 HBufC* uri = iRemoveQueue[0]; |
1318 TInt itemIndex(KErrNotFound); |
1121 TN_DEBUG2( "void CThumbAGProcessor::RunL() delete %S", uri); |
1319 |
1122 CThumbnailObjectSource* source = NULL; |
1320 for(TInt i=0;i<iGenerationQueue.Count() || itemIndex == KErrNotFound;i++) |
1123 TRAPD(err, source = CThumbnailObjectSource::NewL( *uri, KNullDesC)); |
1321 { |
1124 |
1322 if(iGenerationQueue[i].iItemAction == EGenerationItemActionDelete) |
1125 if(err == KErrNone) |
1323 { |
1126 { |
1324 itemIndex = i; |
1127 iTMSession->DeleteThumbnails( *source ); |
1325 } |
1128 } |
1326 } |
1129 iRemoveQueue.Remove( 0 ); |
1327 |
1130 delete source; |
1328 if(itemIndex >= 0) |
1131 delete uri; |
1329 { |
1132 |
1330 if(!iGenerationQueue[itemIndex].iUri) |
1133 iActiveCount++; |
1331 { |
1134 iActive = ETrue; |
1332 //URI is invalid |
1135 } |
1333 TN_DEBUG1( "void CThumbAGProcessor::RunL() unable to delete URI inbalid"); |
1136 } |
1334 iGenerationQueue.Remove( itemIndex ); |
1137 else if( i2ndRoundGenerateQueue.Count() > 0) |
1335 ActivateAO(); |
|
1336 return; |
|
1337 } |
|
1338 |
|
1339 TN_DEBUG2( "void CThumbAGProcessor::RunL() delete %S", iGenerationQueue[itemIndex].iUri); |
|
1340 CThumbnailObjectSource* source = NULL; |
|
1341 TRAPD(err, source = CThumbnailObjectSource::NewL( *iGenerationQueue[itemIndex].iUri, KNullDesC)); |
|
1342 |
|
1343 if(err == KErrNone) |
|
1344 { |
|
1345 iTMSession->DeleteThumbnails( *source ); |
|
1346 } |
|
1347 delete source; |
|
1348 |
|
1349 delete iGenerationQueue[itemIndex].iUri; |
|
1350 iGenerationQueue[itemIndex].iUri = NULL; |
|
1351 iGenerationQueue.Remove( itemIndex ); |
|
1352 |
|
1353 iActiveCount++; |
|
1354 } |
|
1355 } |
|
1356 } |
|
1357 else if( i2ndAddItemCount > 0) |
1138 { |
1358 { |
1139 TN_DEBUG1( "void CThumbAGProcessor::RunL() update 2nd round thumbnails"); |
1359 TN_DEBUG1( "void CThumbAGProcessor::RunL() update 2nd round thumbnails"); |
1140 |
1360 |
1141 // query for object info |
1361 // query for object info |
1142 iQueryActive = ETrue; |
1362 iQueryActive = ETrue; |
1143 i2ndRound = ETrue; |
1363 i2ndRound = ETrue; |
1144 QueryL( i2ndRoundGenerateQueue ); |
1364 iUnknown = EFalse; |
|
1365 QueryL( EGenerationItemAction2ndAdd ); |
1145 } |
1366 } |
1146 |
1367 |
1147 TN_DEBUG1( "CThumbAGProcessor::RunL() - end" ); |
1368 TN_DEBUG1( "CThumbAGProcessor::RunL() - end" ); |
1148 } |
1369 } |
1149 |
1370 |
1390 // CThumbAGProcessor::ActivateAO() |
1661 // CThumbAGProcessor::ActivateAO() |
1391 // --------------------------------------------------------------------------- |
1662 // --------------------------------------------------------------------------- |
1392 // |
1663 // |
1393 void CThumbAGProcessor::ActivateAO() |
1664 void CThumbAGProcessor::ActivateAO() |
1394 { |
1665 { |
1395 #ifdef _DEBUG |
1666 UpdateItemCounts(); |
1396 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()); |
|
1397 TN_DEBUG2( "CThumbAGProcessor::ActivateAO() items in queue 2nd Add = %d", i2ndRoundGenerateQueue.Count()); |
|
1398 TN_DEBUG3( "CThumbAGProcessor::ActivateAO() iActive = %d, iActiveCount = %d", iActive, iActiveCount); |
|
1399 TN_DEBUG3( "CThumbAGProcessor::ActivateAO() iHarvesting == %d, iMPXHarvesting == %d", iHarvesting, iMPXHarvesting); |
|
1400 TN_DEBUG4( "CThumbAGProcessor::ActivateAO() iIdle = %d, timer = %d, iForceRun = %d", iIdle, iPeriodicTimer->IsActive(), iForceRun); |
|
1401 TN_DEBUG4( "CThumbAGProcessor::ActivateAO() iModify = %d, iQueryReady = %d, iProcessingCount = %d", iModify, iQueryReady, iProcessingCount); |
|
1402 #endif |
|
1403 |
1667 |
1404 if(iFormatting) |
1668 if(iFormatting) |
1405 { |
1669 { |
1406 TN_DEBUG1( "CThumbAGProcessor::ActivateAO() - FORMATTING - DAEMON ON PAUSE"); |
1670 TN_DEBUG1( "CThumbAGProcessor::ActivateAO() - FORMATTING - DAEMON ON PAUSE"); |
1407 return; |
1671 return; |
1408 } |
1672 } |
|
1673 |
1409 |
1674 |
1410 //check if forced run needs to continue |
1675 //check if forced run needs to continue |
1411 if (iModifyQueue.Count()) |
1676 if ( iModifyItemCount || iUnknownItemCount > 0 ) |
1412 { |
1677 { |
1413 SetForceRun( ETrue ); |
1678 SetForceRun( ETrue ); |
1414 } |
1679 } |
1415 else |
1680 else |
1416 { |
1681 { |
1417 iModify = EFalse; |
1682 iModify = EFalse; |
1418 SetForceRun( EFalse ); |
1683 SetForceRun( EFalse ); |
1419 } |
1684 } |
1420 |
1685 |
1421 if( !IsActive() && ((!iActive && !iQueryActive) || iForceRun )) |
1686 if( !IsActive() && !iShutdown && ((iActiveCount == 0 && !iQueryActive) || iForceRun )) |
1422 { |
1687 { |
1423 TN_DEBUG1( "CThumbAGProcessor::ActivateAO() - Activated"); |
1688 TN_DEBUG1( "CThumbAGProcessor::ActivateAO() - Activated"); |
1424 SetActive(); |
1689 SetActive(); |
1425 TRequestStatus* statusPtr = &iStatus; |
1690 TRequestStatus* statusPtr = &iStatus; |
1426 User::RequestComplete( statusPtr, KErrNone ); |
1691 User::RequestComplete( statusPtr, KErrNone ); |
1427 } |
1692 } |
1428 |
1693 |
1429 UpdatePSValues(); |
1694 UpdatePSValues(EFalse, EFalse); |
1430 } |
1695 } |
1431 |
1696 |
1432 // --------------------------------------------------------------------------- |
1697 // --------------------------------------------------------------------------- |
1433 // CThumbAGProcessor::PeriodicTimerCallBack() |
1698 // CThumbAGProcessor::PeriodicTimerCallBack() |
1434 // --------------------------------------------------------------------------- |
1699 // --------------------------------------------------------------------------- |
1513 void CThumbAGProcessor::RemoveFromQueues( const RArray<TItemId>& aIDArray, const TBool /*aRemoveFromDelete*/ ) |
1778 void CThumbAGProcessor::RemoveFromQueues( const RArray<TItemId>& aIDArray, const TBool /*aRemoveFromDelete*/ ) |
1514 #endif |
1779 #endif |
1515 { |
1780 { |
1516 TN_DEBUG2( "CThumbAGProcessor::RemoveFromQueues() aRemoveFromDelete == %d - begin", aRemoveFromDelete ); |
1781 TN_DEBUG2( "CThumbAGProcessor::RemoveFromQueues() aRemoveFromDelete == %d - begin", aRemoveFromDelete ); |
1517 |
1782 |
1518 TInt itemIndex = KErrNotFound; |
1783 TInt itemIndex(KErrNotFound); |
1519 |
1784 |
1520 for (int i=0; i< aIDArray.Count(); i++) |
1785 for (int i=0; i< aIDArray.Count(); i++) |
1521 { |
1786 { |
|
1787 TThumbnailGenerationItem item; |
|
1788 item.iItemId = aIDArray[i]; |
1522 TN_DEBUG2( "CThumbAGProcessor::RemoveFromQueues() - %d", aIDArray[i]); |
1789 TN_DEBUG2( "CThumbAGProcessor::RemoveFromQueues() - %d", aIDArray[i]); |
1523 |
1790 |
1524 itemIndex = iPlaceholderQueue.FindInOrder(aIDArray[i], Compare); |
1791 itemIndex = iGenerationQueue.FindInOrder(item, Compare); |
1525 if(itemIndex >= 0) |
1792 if(itemIndex >= 0) |
1526 { |
1793 { |
1527 iPlaceholderQueue.Remove(itemIndex); |
1794 delete iGenerationQueue[itemIndex].iUri; |
1528 TN_DEBUG1( "CThumbAGProcessor::RemoveFromQueues() - iPlaceholderQueue" ); |
1795 iGenerationQueue[itemIndex].iUri = NULL; |
|
1796 iGenerationQueue.Remove(itemIndex); |
|
1797 TN_DEBUG1( "CThumbAGProcessor::RemoveFromQueues() - iGenerationQueue" ); |
1529 } |
1798 } |
1530 |
1799 |
1531 itemIndex = iAddQueue.FindInOrder(aIDArray[i], Compare); |
1800 itemIndex = iQueryQueue.FindInOrder(aIDArray[i], CompareId); |
1532 if(itemIndex >= 0) |
|
1533 { |
|
1534 iAddQueue.Remove(itemIndex); |
|
1535 TN_DEBUG1( "CThumbAGProcessor::RemoveFromQueues() - iAddQueue" ); |
|
1536 } |
|
1537 |
|
1538 itemIndex = i2ndRoundGenerateQueue.FindInOrder(aIDArray[i], Compare); |
|
1539 if(itemIndex >= 0) |
|
1540 { |
|
1541 i2ndRoundGenerateQueue.Remove(itemIndex); |
|
1542 TN_DEBUG1( "CThumbAGProcessor::RemoveFromQueues() - i2ndRoundGenerateQueue" ); |
|
1543 } |
|
1544 |
|
1545 itemIndex = iModifyQueue.FindInOrder(aIDArray[i], Compare); |
|
1546 if(itemIndex >= 0) |
|
1547 { |
|
1548 iModifyQueue.Remove(itemIndex); |
|
1549 TN_DEBUG1( "CThumbAGProcessor::RemoveFromQueues() - iModifyQueue" ); |
|
1550 |
|
1551 if( iModifyQueue.Count() == 0) |
|
1552 { |
|
1553 SetForceRun( EFalse ); |
|
1554 } |
|
1555 } |
|
1556 |
|
1557 itemIndex = iQueryQueue.FindInOrder(aIDArray[i], Compare); |
|
1558 if(itemIndex >= 0) |
1801 if(itemIndex >= 0) |
1559 { |
1802 { |
1560 iQueryQueue.Remove(itemIndex); |
1803 iQueryQueue.Remove(itemIndex); |
1561 TN_DEBUG1( "CThumbAGProcessor::RemoveFromQueues() - iQueryQueue" ); |
1804 TN_DEBUG1( "CThumbAGProcessor::RemoveFromQueues() - iQueryQueue" ); |
1562 } |
1805 } |
1563 |
1806 } |
1564 itemIndex = iPlaceholderQueue.FindInOrder(aIDArray[i], Compare); |
1807 |
1565 if(itemIndex >= 0) |
1808 ActivateAO(); |
1566 { |
|
1567 iPlaceholderQueue.Remove(itemIndex); |
|
1568 TN_DEBUG1( "CThumbAGProcessor::RemoveFromQueues() - iPlaceholderQueue" ); |
|
1569 } |
|
1570 } |
|
1571 |
1809 |
1572 TN_DEBUG1( "CThumbAGProcessor::RemoveFromQueues() - end" ); |
1810 TN_DEBUG1( "CThumbAGProcessor::RemoveFromQueues() - end" ); |
1573 } |
1811 } |
1574 |
1812 |
1575 // --------------------------------------------------------------------------- |
1813 // --------------------------------------------------------------------------- |
1799 // --------------------------------------------------------------------------- |
2036 // --------------------------------------------------------------------------- |
1800 // CThumbAGProcessor::UpdateItemsLeft |
2037 // CThumbAGProcessor::UpdateItemsLeft |
1801 // Update KItemsleft PS value if changed |
2038 // Update KItemsleft PS value if changed |
1802 // --------------------------------------------------------------------------- |
2039 // --------------------------------------------------------------------------- |
1803 // |
2040 // |
1804 void CThumbAGProcessor::UpdatePSValues(const TBool aDefine) |
2041 void CThumbAGProcessor::UpdatePSValues(const TBool aDefine, const TBool aForce) |
1805 { |
2042 { |
1806 TInt itemsLeft = iModifyQueue.Count() + iAddQueue.Count(); |
2043 TInt itemsLeft(KErrNotReady); |
1807 TBool daemonProcessing = EFalse; |
2044 TBool daemonProcessing = ETrue; |
1808 |
2045 |
1809 if(itemsLeft + i2ndRoundGenerateQueue.Count() + iRemoveQueue.Count() > 0 ) |
2046 if(iShutdown) |
1810 { |
2047 { |
1811 daemonProcessing = ETrue; |
2048 RProperty::Set(KTAGDPSNotification, KDaemonProcessing, EFalse); |
1812 } |
2049 RProperty::Set(KTAGDPSNotification, KItemsleft, 0 ); |
1813 |
2050 return; |
1814 //adjust items left to containing also items not yet processed but removed from queue under processing |
2051 } |
1815 if((iLastQueue == &iModifyQueue || iLastQueue == &iAddQueue) && !i2ndRound) |
2052 |
1816 { |
|
1817 itemsLeft +=iQueryQueue.Count(); |
|
1818 } |
|
1819 |
|
1820 //cancel 2nd round generarion when there is items in 1st round queues |
|
1821 if(itemsLeft && i2ndRound) |
|
1822 { |
|
1823 DeleteAndCancelQuery(ETrue); |
|
1824 i2ndRound = EFalse; |
|
1825 } |
|
1826 |
|
1827 TN_DEBUG2( "CThumbAGProcessor::UpdatePSValues() KItemsleft == %d", itemsLeft); |
|
1828 |
|
1829 if(aDefine) |
2053 if(aDefine) |
1830 { |
2054 { |
1831 TN_DEBUG1( "CThumbAGProcessor::UpdatePSValues() define"); |
2055 TInt ret = RProperty::Define(KTAGDPSNotification, KDaemonProcessing, RProperty::EInt); |
1832 RProperty::Define(KTAGDPSNotification, KDaemonProcessing, RProperty::EInt); |
2056 |
1833 RProperty::Set(KTAGDPSNotification, KDaemonProcessing, 0); |
2057 if( ret != KErrNone ) |
1834 daemonProcessing = EFalse; |
2058 { |
1835 RProperty::Define(KTAGDPSNotification, KItemsleft, RProperty::EInt); |
2059 TN_DEBUG2( "CThumbAGProcessor::UpdatePSValues() define KDaemonProcessing ret = %d", ret); |
1836 RProperty::Set(KTAGDPSNotification, KItemsleft, 0); |
2060 } |
1837 iPreviousItemsLeft = 0; |
2061 |
1838 } |
2062 ret = RProperty::Define(KTAGDPSNotification, KItemsleft, RProperty::EInt); |
1839 |
2063 |
1840 if( daemonProcessing != iPreviousDaemonProcessing) |
2064 if( ret != KErrNone ) |
1841 { |
2065 { |
1842 TN_DEBUG2( "CThumbAGProcessor::UpdatePSValues() update KDaemonProcessing == %d", daemonProcessing); |
2066 TN_DEBUG2( "CThumbAGProcessor::UpdatePSValues() define KItemsleft ret = %d", ret); |
1843 iPreviousDaemonProcessing = daemonProcessing; |
2067 } |
1844 RProperty::Set(KTAGDPSNotification, KDaemonProcessing, daemonProcessing); |
2068 } |
1845 } |
2069 |
1846 |
2070 // set itemsleft = KErrNotReady (-18) and daemonProcessing = ETrue if |
1847 if( itemsLeft != iPreviousItemsLeft) |
2071 // - key is initalized |
1848 { |
2072 // - mount timer is pending |
1849 TN_DEBUG2( "CThumbAGProcessor::UpdatePSValues() update KItemsleft == %d", itemsLeft); |
2073 // - harvester observer is not yet activated |
1850 iPreviousItemsLeft = itemsLeft; |
2074 // - single unknown item exists in processing queue |
1851 RProperty::Set(KTAGDPSNotification, KItemsleft, itemsLeft ); |
2075 // - forced |
1852 } |
2076 if( iMountTimer->IsActive() || aForce || aDefine || iUnknownItemCount |
|
2077 || !iHarvesterActivated ) |
|
2078 { |
|
2079 daemonProcessing = ETrue; |
|
2080 itemsLeft = KErrNotReady; |
|
2081 } |
|
2082 else |
|
2083 { |
|
2084 itemsLeft = iAddItemCount + iModifyItemCount; |
|
2085 } |
|
2086 |
|
2087 TN_DEBUG2( "CThumbAGProcessor::UpdatePSValues() KItemsleft == %d", itemsLeft); |
|
2088 |
|
2089 //cancel 2nd round generarion when there is items in 1st round queues |
|
2090 if(iAddItemCount && i2ndRound) |
|
2091 { |
|
2092 DeleteAndCancelQuery(ETrue); |
|
2093 i2ndRound = EFalse; |
|
2094 } |
|
2095 |
|
2096 if( iGenerationQueue.Count() ) |
|
2097 { |
|
2098 daemonProcessing = ETrue; |
|
2099 } |
|
2100 |
|
2101 if( daemonProcessing != iPreviousDaemonProcessing) |
|
2102 { |
|
2103 TN_DEBUG2( "CThumbAGProcessor::UpdatePSValues() update KDaemonProcessing == %d", daemonProcessing); |
|
2104 iPreviousDaemonProcessing = daemonProcessing; |
|
2105 TInt ret = RProperty::Set(KTAGDPSNotification, KDaemonProcessing, daemonProcessing); |
|
2106 |
|
2107 if(ret != KErrNone ) |
|
2108 { |
|
2109 TN_DEBUG3( "CThumbAGProcessor::UpdatePSValues() set KDaemonProcessing %d failed %d", daemonProcessing, ret); |
|
2110 } |
|
2111 } |
|
2112 |
|
2113 if( itemsLeft != iPreviousItemsLeft) |
|
2114 { |
|
2115 TN_DEBUG2( "CThumbAGProcessor::UpdatePSValues() update KItemsleft == %d", itemsLeft); |
|
2116 iPreviousItemsLeft = itemsLeft; |
|
2117 TInt ret = RProperty::Set(KTAGDPSNotification, KItemsleft, itemsLeft ); |
|
2118 |
|
2119 if(ret != KErrNone ) |
|
2120 { |
|
2121 TN_DEBUG3( "CThumbAGProcessor::UpdatePSValues() set KItemsleft %d failed %d", itemsLeft, ret); |
|
2122 } |
|
2123 } |
|
2124 |
1853 } |
2125 } |
1854 |
2126 |
1855 // --------------------------------------------------------------------------- |
2127 // --------------------------------------------------------------------------- |
1856 // CThumbAGProcessor::Compare |
2128 // CThumbAGProcessor::Compare |
1857 // Comparison function for logaritmic use of queue arrays |
2129 // Comparison function for logaritmic use of queue arrays |
1858 // --------------------------------------------------------------------------- |
2130 // --------------------------------------------------------------------------- |
1859 // |
2131 // |
1860 TInt CThumbAGProcessor::Compare(const TItemId& aLeft, const TItemId& aRight) |
2132 |
|
2133 TInt CThumbAGProcessor::Compare(const TThumbnailGenerationItem& aLeft, const TThumbnailGenerationItem& aRight) |
|
2134 { |
|
2135 return (aLeft.iItemId - aRight.iItemId); |
|
2136 } |
|
2137 |
|
2138 TInt CThumbAGProcessor::CompareId(const TItemId& aLeft, const TItemId& aRight) |
1861 { |
2139 { |
1862 return (aLeft - aRight); |
2140 return (aLeft - aRight); |
1863 } |
2141 } |
1864 |
2142 |
|
2143 void CThumbAGProcessor::UpdateItemCounts() |
|
2144 { |
|
2145 TN_DEBUG1( "CThumbAGProcessor::UpdateItemCounts()"); |
|
2146 iModifyItemCount = 0; |
|
2147 iDeleteItemCount = 0; |
|
2148 iAddItemCount = 0; |
|
2149 iUnknownItemCount = 0; |
|
2150 i2ndAddItemCount = 0; |
|
2151 iPlaceholderItemCount=0; |
|
2152 iCameraItemCount =0; |
|
2153 iImageItemCount=0; |
|
2154 iVideoItemCount=0; |
|
2155 iAudioItemCount=0; |
|
2156 |
|
2157 for(TInt i=0; i < iGenerationQueue.Count(); i++) |
|
2158 { |
|
2159 TThumbnailGenerationItem& item = iGenerationQueue[i]; |
|
2160 |
|
2161 if(item.iItemAction == EGenerationItemActionModify) |
|
2162 { |
|
2163 iModifyItemCount++; |
|
2164 } |
|
2165 |
|
2166 if(item.iItemAction == EGenerationItemActionDelete) |
|
2167 { |
|
2168 iDeleteItemCount++; |
|
2169 } |
|
2170 |
|
2171 if(item.iItemType == EGenerationItemTypeUnknown) |
|
2172 { |
|
2173 iUnknownItemCount++; |
|
2174 } |
|
2175 if(item.iItemAction == EGenerationItemAction2ndAdd) |
|
2176 { |
|
2177 i2ndAddItemCount++; |
|
2178 } |
|
2179 if(item.iPlaceholder) |
|
2180 { |
|
2181 iPlaceholderItemCount++; |
|
2182 } |
|
2183 if(item.iItemType == EGenerationItemTypeCamera) |
|
2184 { |
|
2185 iCameraItemCount++; |
|
2186 } |
|
2187 if(item.iItemAction == EGenerationItemActionAdd ) |
|
2188 { |
|
2189 iAddItemCount++; |
|
2190 } |
|
2191 if(item.iItemType == EGenerationItemTypeAudio) |
|
2192 { |
|
2193 iAudioItemCount++; |
|
2194 } |
|
2195 if(item.iItemType == EGenerationItemTypeVideo) |
|
2196 { |
|
2197 iVideoItemCount++; |
|
2198 } |
|
2199 if(item.iItemType == EGenerationItemTypeImage) |
|
2200 { |
|
2201 iImageItemCount++; |
|
2202 } |
|
2203 } |
|
2204 |
|
2205 TN_DEBUG2( "CThumbAGProcessor::UpdateItemCounts() iActiveCount = %d", |
|
2206 iActiveCount); |
|
2207 TN_DEBUG5( "CThumbAGProcessor::UpdateItemCounts() iHarvesting == %d, iMMCHarvesting == %d, iPHHarvesting == %d, iMPXHarvesting == %d", |
|
2208 iHarvesting, iMMCHarvesting, iPHHarvesting, iMPXHarvesting); |
|
2209 TN_DEBUG5( "CThumbAGProcessor::UpdateItemCounts() iIdle = %d, iForegroundRun = %d, timer = %d, iForceRun = %d", |
|
2210 iIdle, iForegroundRun, iPeriodicTimer->IsActive(), iForceRun); |
|
2211 TN_DEBUG4( "CThumbAGProcessor::UpdateItemCounts() iModify = %d, iQueryReady = %d, iProcessingCount = %d", |
|
2212 iModify, iQueryReady, iProcessingCount); |
|
2213 TN_DEBUG2( "CThumbAGProcessor::UpdateItemCounts() iMountTimer = %d", iMountTimer->IsActive()); |
|
2214 TN_DEBUG3( "CThumbAGProcessor::UpdateItemCounts() ProcessingQueue = %d, iQueryQueue = %d", |
|
2215 iGenerationQueue.Count(), iQueryQueue.Count()); |
|
2216 TN_DEBUG5( "CThumbAGProcessor::UpdateItemCounts() iAddItemCount=%d, i2ndAddItemCount=%d, iModifyItemCount=%d, iDeleteItemCount=%d", |
|
2217 iAddItemCount, i2ndAddItemCount, iModifyItemCount, iDeleteItemCount ); |
|
2218 TN_DEBUG3( "CThumbAGProcessor::UpdateItemCounts() iUnknownItemCount=%d, iPlaceholderItemCount=%d", |
|
2219 iUnknownItemCount, iPlaceholderItemCount); |
|
2220 TN_DEBUG4( "CThumbAGProcessor::UpdateItemCounts() iAudioItemCount=%d, iVideoItemCount=%d, iImageItemCount=%d", |
|
2221 iAudioItemCount, iVideoItemCount, iImageItemCount); |
|
2222 TN_DEBUG2( "CThumbAGProcessor::UpdateItemCounts() iCameraItemCount=%d", iCameraItemCount); |
|
2223 } |
|
2224 |
|
2225 |
|
2226 // --------------------------------------------------------------------------- |
|
2227 // CThumbAGProcessor::MountTimerCallBack() |
|
2228 // --------------------------------------------------------------------------- |
|
2229 // |
|
2230 TInt CThumbAGProcessor::MountTimerCallBack(TAny* aAny) |
|
2231 { |
|
2232 TN_DEBUG1( "CThumbAGProcessor::MountTimerCallBack()"); |
|
2233 CThumbAGProcessor* self = static_cast<CThumbAGProcessor*>( aAny ); |
|
2234 |
|
2235 self->iMountTimer->Cancel(); |
|
2236 |
|
2237 return KErrNone; // Return value ignored by CPeriodic |
|
2238 } |
|
2239 |
|
2240 // --------------------------------------------------------------------------- |
|
2241 // CThumbAGProcessor::SetGenerationItemAction() |
|
2242 // --------------------------------------------------------------------------- |
|
2243 // |
|
2244 void CThumbAGProcessor::SetGenerationItemAction( TThumbnailGenerationItem& aGenerationItem, TThumbnailGenerationItemType aItemType ) |
|
2245 { |
|
2246 switch( aItemType ) |
|
2247 { |
|
2248 case EGenerationItemTypeAudio: |
|
2249 aGenerationItem.iItemAction = EGenerationItemAction2ndAdd; |
|
2250 break; |
|
2251 case EGenerationItemTypeCamera: |
|
2252 aGenerationItem.iItemAction = EGenerationItemAction2ndAdd; |
|
2253 aGenerationItem.iPlaceholder = ETrue; |
|
2254 break; |
|
2255 case EGenerationItemTypeImage: |
|
2256 aGenerationItem.iItemAction = EGenerationItemActionAdd; |
|
2257 break; |
|
2258 case EGenerationItemTypeVideo: |
|
2259 //S^3 EGenerationItemActionAdd |
|
2260 //S^4 EGenerationItemAction2ndAdd |
|
2261 aGenerationItem.iItemAction = EGenerationItemAction2ndAdd; |
|
2262 break; |
|
2263 default: |
|
2264 aGenerationItem.iItemAction = EGenerationItemActionResolveType; |
|
2265 } |
|
2266 } |
|
2267 |
|
2268 // --------------------------------------------------------------------------- |
|
2269 // CThumbAGProcessor::SetGenerationItemType() |
|
2270 // --------------------------------------------------------------------------- |
|
2271 // |
|
2272 void CThumbAGProcessor::SetGenerationItemType( TThumbnailGenerationItem& aGenerationItem, const TDefId aDefId ) |
|
2273 { |
|
2274 if(aDefId == iImageObjectDef->Id()) |
|
2275 { |
|
2276 aGenerationItem.iItemType = EGenerationItemTypeImage; |
|
2277 } |
|
2278 else if(aDefId == iAudioObjectDef->Id()) |
|
2279 { |
|
2280 aGenerationItem.iItemType = EGenerationItemTypeAudio; |
|
2281 } |
|
2282 else if(aDefId == iVideoObjectDef->Id()) |
|
2283 { |
|
2284 aGenerationItem.iItemType = EGenerationItemTypeVideo; |
|
2285 } |
|
2286 else |
|
2287 { |
|
2288 aGenerationItem.iItemType = EGenerationItemTypeUnknown; |
|
2289 } |
|
2290 |
|
2291 SetGenerationItemAction( aGenerationItem, aGenerationItem.iItemType ); |
|
2292 } |
|
2293 |
|
2294 |
|
2295 // ----------------------------------------------------------------------------- |
|
2296 // CThumbAGProcessor::AppendProcessingQueue() |
|
2297 // ----------------------------------------------------------------------------- |
|
2298 // |
|
2299 void CThumbAGProcessor::AppendProcessingQueue( TThumbnailGenerationItem& item ) |
|
2300 { |
|
2301 |
|
2302 TInt itemIndex = iGenerationQueue.FindInOrder( item, Compare ); |
|
2303 |
|
2304 if(itemIndex >= 0) |
|
2305 { |
|
2306 iGenerationQueue[itemIndex].iPlaceholder = item.iPlaceholder; |
|
2307 iGenerationQueue[itemIndex].iItemType = item.iItemType; |
|
2308 iGenerationQueue[itemIndex].iItemAction = item.iItemAction; |
|
2309 } |
|
2310 else |
|
2311 { |
|
2312 iGenerationQueue.InsertInOrder(item, Compare); |
|
2313 } |
|
2314 } |
|
2315 |
1865 |
2316 |
1866 // End of file |
2317 // End of file |