harvester/server/src/harvesterao.cpp
changeset 1 acef663c1218
parent 0 c53acadfccc6
child 2 b73a2e62868f
equal deleted inserted replaced
0:c53acadfccc6 1:acef663c1218
    45 
    45 
    46 const TInt KPlaceholderQueueSize = 99;
    46 const TInt KPlaceholderQueueSize = 99;
    47 const TInt KContainerPlaceholderQueueSize = 10;
    47 const TInt KContainerPlaceholderQueueSize = 10;
    48 const TInt KObjectDefStrSize = 20;
    48 const TInt KObjectDefStrSize = 20;
    49 
    49 
    50 const TInt KCacheItemCountForEventCaching = 1;
    50 const TInt KHarvesterAOCustomPriority = 5;
    51 
    51 
    52 _LIT( KTAGDaemonName, "ThumbAGDaemon" );
    52 _LIT( KTAGDaemonName, "ThumbAGDaemon" );
    53 _LIT( KTAGDaemonExe, "thumbagdaemon.exe" );
    53 _LIT( KTAGDaemonExe, "thumbagdaemon.exe" );
    54 
    54 
    55 _LIT(KInUse, "InUse");
    55 _LIT(KInUse, "InUse");
   112 
   112 
   113 // ---------------------------------------------------------------------------
   113 // ---------------------------------------------------------------------------
   114 // CHarvesterAO
   114 // CHarvesterAO
   115 // ---------------------------------------------------------------------------
   115 // ---------------------------------------------------------------------------
   116 //
   116 //
   117 CHarvesterAO::CHarvesterAO() : CActive( CActive::EPriorityStandard )
   117 CHarvesterAO::CHarvesterAO() : CActive( KHarvesterAOCustomPriority)
   118     {
   118     {
   119     WRITELOG( "CHarvesterAO::CHarvesterAO() - begin" );
   119     WRITELOG( "CHarvesterAO::CHarvesterAO() - begin" );
   120     
   120     
   121     iServerPaused = ETrue;
   121     iServerPaused = ETrue;
   122     iNextRequest = ERequestIdle;
   122     iNextRequest = ERequestIdle;
   123     
   123     
   124     iContextEngineInitialized = EFalse;
   124     iContextEngineInitialized = EFalse;
   125     iMdeSessionInitialized = EFalse;
   125     iMdeSessionInitialized = EFalse;
   126     iHarvesting = EFalse;
       
   127     }
   126     }
   128      
   127      
   129 // ---------------------------------------------------------------------------
   128 // ---------------------------------------------------------------------------
   130 // ~CHarvesterAO
   129 // ~CHarvesterAO
   131 // ---------------------------------------------------------------------------
   130 // ---------------------------------------------------------------------------
   318 //
   317 //
   319 void CHarvesterAO::StartMonitoring()
   318 void CHarvesterAO::StartMonitoring()
   320     {
   319     {
   321     WRITELOG( "CHarvesterAO::StartMonitoring()" );
   320     WRITELOG( "CHarvesterAO::StartMonitoring()" );
   322 
   321 
   323     TInt count( iMonitorPluginArray.Count() );  
   322     const TInt count( iMonitorPluginArray.Count() );  
   324     
   323     
   325     for ( TInt i = 0; i < count; i++ )
   324     for ( TInt i = 0; i < count; i++ )
   326         {
   325         {
   327         iMonitorPluginArray[i]->StartMonitoring( *iQueue, iMdESession, NULL, 
   326         iMonitorPluginArray[i]->StartMonitoring( *iQueue, iMdESession, NULL, 
   328         		iHarvesterPluginFactory );
   327         		iHarvesterPluginFactory );
   335 //
   334 //
   336 void CHarvesterAO::StopMonitoring()
   335 void CHarvesterAO::StopMonitoring()
   337     {
   336     {
   338     WRITELOG( "CHarvesterAO::StopMonitoring()" );
   337     WRITELOG( "CHarvesterAO::StopMonitoring()" );
   339 
   338 
   340     TInt count( iMonitorPluginArray.Count() );
   339     const TInt count( iMonitorPluginArray.Count() );
   341     
   340     
   342     for ( TInt i = 0; i < count; i++ )
   341     for ( TInt i = 0; i < count; i++ )
   343         {
   342         {
   344         iMonitorPluginArray[i]->StopMonitoring();
   343         iMonitorPluginArray[i]->StopMonitoring();
   345         }
   344         }
   350 // ---------------------------------------------------------------------------
   349 // ---------------------------------------------------------------------------
   351 //
   350 //
   352 void CHarvesterAO::PauseMonitoring()
   351 void CHarvesterAO::PauseMonitoring()
   353     {
   352     {
   354     WRITELOG( "CHarvesterAO::PauseMonitoring()" );
   353     WRITELOG( "CHarvesterAO::PauseMonitoring()" );
   355     TInt count( iMonitorPluginArray.Count() );
   354     const TInt count( iMonitorPluginArray.Count() );
   356     
   355     
   357     for ( TInt i = 0; i<count; i++ )
   356     for ( TInt i = 0; i<count; i++ )
   358         {
   357         {
   359         iMonitorPluginArray[i]->PauseMonitoring();
   358         iMonitorPluginArray[i]->PauseMonitoring();
   360         }
   359         }
   367 //
   366 //
   368 void CHarvesterAO::ResumeMonitoring()
   367 void CHarvesterAO::ResumeMonitoring()
   369     {
   368     {
   370     WRITELOG( "CHarvesterAO::ResumeMonitoring()" );
   369     WRITELOG( "CHarvesterAO::ResumeMonitoring()" );
   371     
   370     
   372     TInt count( iMonitorPluginArray.Count() );
   371     const TInt count( iMonitorPluginArray.Count() );
   373     
   372     
   374     for ( TInt i=0; i < count; i++ )
   373     for ( TInt i=0; i < count; i++ )
   375         {
   374         {
   376         iMonitorPluginArray[i]->ResumeMonitoring( *iQueue, iMdESession, NULL,
   375         iMonitorPluginArray[i]->ResumeMonitoring( *iQueue, iMdESession, NULL,
   377         		iHarvesterPluginFactory );
   376         		iHarvesterPluginFactory );
   387 	{
   386 	{
   388 	WRITELOG1( "CHarvesterAO::HandleUnmount(%d)", aMediaId );
   387 	WRITELOG1( "CHarvesterAO::HandleUnmount(%d)", aMediaId );
   389 	
   388 	
   390     TUint32 mediaId(0);
   389     TUint32 mediaId(0);
   391     TUint removed(0);
   390     TUint removed(0);
   392     TInt err(0);
       
   393     CHarvesterData* hd = NULL;
   391     CHarvesterData* hd = NULL;
   394     
   392     
   395 #ifdef _DEBUG
   393 #ifdef _DEBUG
   396     WRITELOG1( "CHarvesterAO::HandleUnmount() iReadyPHArray.Count() = %d", iReadyPHArray.Count() );
   394     WRITELOG1( "CHarvesterAO::HandleUnmount() iReadyPHArray.Count() = %d", iReadyPHArray.Count() );
   397 #endif
   395 #endif
   400 		TRAP_IGNORE( iHarvesterEventManager->DecreaseItemCountL( EHEObserverTypePlaceholder, iReadyPHArray.Count() ) );
   398 		TRAP_IGNORE( iHarvesterEventManager->DecreaseItemCountL( EHEObserverTypePlaceholder, iReadyPHArray.Count() ) );
   401 		TRAP_IGNORE( iHarvesterEventManager->DecreaseItemCountL( EHEObserverTypeMMC, iReadyPHArray.Count()) );
   399 		TRAP_IGNORE( iHarvesterEventManager->DecreaseItemCountL( EHEObserverTypeMMC, iReadyPHArray.Count()) );
   402 		iReadyPHArray.ResetAndDestroy();
   400 		iReadyPHArray.ResetAndDestroy();
   403 		}
   401 		}
   404 
   402 
       
   403     TInt err( KErrNone );
       
   404 	
   405 #ifdef _DEBUG
   405 #ifdef _DEBUG
   406 	WRITELOG1( "CHarvesterAO::HandleUnmount() iPHArray.Count() = %d", iPHArray.Count() );
   406 	WRITELOG1( "CHarvesterAO::HandleUnmount() iPHArray.Count() = %d", iPHArray.Count() );
   407 #endif
   407 #endif
   408    if( iPHArray.Count() > 0 )
   408    if( iPHArray.Count() > 0 )
   409         {
   409         {
   464 	iMediaIdUtil->RemoveMediaId( aMediaId );
   464 	iMediaIdUtil->RemoveMediaId( aMediaId );
   465 	
   465 	
   466 	removed = 0;
   466 	removed = 0;
   467 	
   467 	
   468 	RPointerArray<CHarvesterPluginInfo>& hpiArray = iHarvesterPluginFactory->GetPluginInfos();
   468 	RPointerArray<CHarvesterPluginInfo>& hpiArray = iHarvesterPluginFactory->GetPluginInfos();
   469 	if( hpiArray.Count() > 0 )
   469 	const TInt arrayCount( hpiArray.Count() );
       
   470 	if( arrayCount > 0 )
   470 		{
   471 		{
   471 		RArray<TItemId> placeholders;
   472 		RArray<TItemId> placeholders;
   472 		
   473 		
   473 		TUint32 mediaId(0);
   474 		TUint32 mediaId( 0 );
   474 		TInt err(0);
   475 		TInt err( KErrNone );
   475 		
   476 		
   476 		for( TInt i = hpiArray.Count(); --i >= 0; )
   477 		for( TInt i = arrayCount; --i >= 0; )
   477 			{
   478 			{
   478 			CHarvesterPluginInfo* hpi = hpiArray[i];
   479 			CHarvesterPluginInfo* hpi = hpiArray[i];
   479 			for( TInt j = hpi->iQueue.Count(); --j >= 0; )
   480 			for( TInt j = hpi->iQueue.Count(); --j >= 0; )
   480 				{
   481 				{
   481 				CHarvesterData* hd = hpi->iQueue[j];
   482 				CHarvesterData* hd = hpi->iQueue[j];
   527     
   528     
   528     RImplInfoPtrArray infoArray;
   529     RImplInfoPtrArray infoArray;
   529     TCleanupItem cleanupItem( MdsUtils::CleanupEComArray, &infoArray );
   530     TCleanupItem cleanupItem( MdsUtils::CleanupEComArray, &infoArray );
   530     CleanupStack::PushL( cleanupItem );
   531     CleanupStack::PushL( cleanupItem );
   531     CComposerPlugin::ListImplementationsL( infoArray );
   532     CComposerPlugin::ListImplementationsL( infoArray );
   532     TInt count( 0 );
   533     const TInt count( infoArray.Count() );
   533     count = infoArray.Count();
       
   534 
   534 
   535     for ( TInt i=0; i < count; i++ )
   535     for ( TInt i=0; i < count; i++ )
   536         {
   536         {
   537         TUid uid = infoArray[i]->ImplementationUid();
   537         TUid uid = infoArray[i]->ImplementationUid();
   538         CComposerPlugin* plugin = NULL;
   538         CComposerPlugin* plugin = NULL;
   558 //
   558 //
   559 void CHarvesterAO::StopComposers()
   559 void CHarvesterAO::StopComposers()
   560     {
   560     {
   561     WRITELOG( "CHarvesterAO::StopComposers()" );
   561     WRITELOG( "CHarvesterAO::StopComposers()" );
   562     
   562     
   563     for ( TInt i = iComposerPluginArray.Count(); --i >= 0; )
   563     const TInt count( iComposerPluginArray.Count() );
       
   564     for ( TInt i = count; --i >= 0; )
   564         {
   565         {
   565         iComposerPluginArray[i]->RemoveSession();
   566         iComposerPluginArray[i]->RemoveSession();
   566         }
   567         }
   567 
   568 
   568     WRITELOG( "CHarvesterAO::StopComposers() - end" );
   569     WRITELOG( "CHarvesterAO::StopComposers() - end" );
   587 //
   588 //
   588 TBool CHarvesterAO::IsComposingReady()
   589 TBool CHarvesterAO::IsComposingReady()
   589     {
   590     {
   590     WRITELOG( "CHarvesterAO::IsComposingReady()" );
   591     WRITELOG( "CHarvesterAO::IsComposingReady()" );
   591     
   592     
   592     for ( TInt i = iComposerPluginArray.Count(); --i >= 0; )
   593     const TInt count( iComposerPluginArray.Count() );
       
   594     for ( TInt i = count; --i >= 0; )
   593         {
   595         {
   594         if ( iComposerPluginArray[i]->IsComposingComplete() == EFalse )
   596         if ( iComposerPluginArray[i]->IsComposingComplete() == EFalse )
   595             {
   597             {
   596             return EFalse;
   598             return EFalse;
   597             }
   599             }
   704 		    phData = CPlaceholderData::NewL();
   706 		    phData = CPlaceholderData::NewL();
   705 		    CleanupStack::PushL( phData );
   707 		    CleanupStack::PushL( phData );
   706 		    TEntry* entry = new (ELeave) TEntry();
   708 		    TEntry* entry = new (ELeave) TEntry();
   707 		    CleanupStack::PushL( entry );
   709 		    CleanupStack::PushL( entry );
   708 		    const TDesC& uri = hd->Uri();
   710 		    const TDesC& uri = hd->Uri();
   709 		    TInt err = iFs.Entry( uri, *entry );
   711 		    const TInt err = iFs.Entry( uri, *entry );
   710 		    if ( err != KErrNone )
   712 		    if ( err != KErrNone )
   711 		    	{
   713 		    	{
   712 		    	WRITELOG( "CHarvesterAO::HandlePlaceholdersL() - cannot create placeholder data object for camera. file does not exists" );
   714 		    	WRITELOG( "CHarvesterAO::HandlePlaceholdersL() - cannot create placeholder data object for camera. file does not exists" );
   713 	    		// notify observer
   715 	    		// notify observer
   714 	    	    HarvestCompleted( hd->ClientId(), hd->Uri(), err );
   716 	    	    HarvestCompleted( hd->ClientId(), hd->Uri(), err );
   769     	mdeObject->AddTimePropertyL( *iPropDefs->iLastModifiedDatePropertyDef, phData->Modified() );
   771     	mdeObject->AddTimePropertyL( *iPropDefs->iLastModifiedDatePropertyDef, phData->Modified() );
   770 	    
   772 	    
   771     	// set origin
   773     	// set origin
   772 		mdeObject->AddUint8PropertyL( *iPropDefs->iOriginPropertyDef, hd->Origin() );
   774 		mdeObject->AddUint8PropertyL( *iPropDefs->iOriginPropertyDef, hd->Origin() );
   773     	
   775     	
   774     	CPlaceholderData* ph = static_cast<CPlaceholderData*>( hd->ClientData() );
   776     	CPlaceholderData* ph = NULL;
   775 	    TInt isPreinstalled = ph->Preinstalled();
   777     	if( hd->TakeSnapshot() )
       
   778     	    {
       
   779     	    ph = static_cast<CPlaceholderData*>( hd->ClientData() );
       
   780     	    }
       
   781     	else
       
   782     	    {
       
   783     	    ph = phData;
       
   784     	    }
       
   785     	
       
   786 	    const TInt isPreinstalled = ph->Preinstalled();
   776 	    if( isPreinstalled == MdeConstants::MediaObject::EPreinstalled )
   787 	    if( isPreinstalled == MdeConstants::MediaObject::EPreinstalled )
   777 	    	{
   788 	    	{
   778 	    	WRITELOG("CHarvesterAO::HandlePlaceholdersL() - preinstalled");
   789 	    	WRITELOG("CHarvesterAO::HandlePlaceholdersL() - preinstalled");
   779 	    	mdeObject->AddInt32PropertyL( *iPropDefs->iPreinstalledPropertyDef, isPreinstalled );
   790 	    	mdeObject->AddInt32PropertyL( *iPropDefs->iPreinstalledPropertyDef, isPreinstalled );
   780 	    	}	    
   791 	    	}
   781 		
   792 		
   782 	    hd->SetEventType( EHarvesterEdit );
   793 	    hd->SetEventType( EHarvesterEdit );
   783 	    
   794 		
   784 		// skip 
   795 		// skip 
   785 		if( hd->TakeSnapshot() )
   796 		if( hd->TakeSnapshot() )
   786 			{
   797 			{
   787 			fastHarvestPlaceholderCount++;
   798 			fastHarvestPlaceholderCount++;
   788 			hd->SetObjectType( EFastHarvest );
   799 			hd->SetObjectType( EFastHarvest );
   801 		
   812 		
   802 		iReadyPHArray.Append( hd );
   813 		iReadyPHArray.Append( hd );
   803 		iPHArray.Remove( i );
   814 		iPHArray.Remove( i );
   804 		}
   815 		}
   805 	
   816 	
   806 	TInt objectCount = mdeObjectArray.Count();  
   817 	const TInt objectCount = mdeObjectArray.Count();  
   807 	
   818 	
   808     if( objectCount > 0 )
   819     if( objectCount > 0 )
   809 		{
   820 		{
   810 		// add object to mde
   821 		// add object to mde
   811 		iMdEHarvesterSession->AutoLockL( mdeObjectArray );
   822 		iMdEHarvesterSession->AutoLockL( mdeObjectArray );
   825 			iHarvesterEventManager->SendEventL( EHEObserverTypePlaceholder, EHEStateStarted, 
   836 			iHarvesterEventManager->SendEventL( EHEObserverTypePlaceholder, EHEStateStarted, 
   826 					iHarvesterEventManager->ItemCount( EHEObserverTypePlaceholder ) );
   837 					iHarvesterEventManager->ItemCount( EHEObserverTypePlaceholder ) );
   827 			}
   838 			}
   828 		
   839 		
   829 #ifdef _DEBUG
   840 #ifdef _DEBUG
   830 		for (TInt i = 0; i < mdeObjectArray.Count(); ++i)
   841 		for (TInt i = 0; i < objectCount; ++i)
   831 			{
   842 			{
   832 			CMdEObject* mdeObject = mdeObjectArray[i];
   843 			CMdEObject* mdeObject = mdeObjectArray[i];
   833 			if(mdeObject->Id() == 0)
   844 			if(mdeObject->Id() == 0)
   834 				{
   845 				{
   835 				WRITELOG1( "CHarvesterAO::HandlePlaceholdersL() - failed to add: %S", &mdeObject->Uri() );
   846 				WRITELOG1( "CHarvesterAO::HandlePlaceholdersL() - failed to add: %S", &mdeObject->Uri() );
  1024 	        	if( locData )
  1035 	        	if( locData )
  1025 	        		{
  1036 	        		{
  1026 	        		WRITELOG( "CHarvesterAO::HarvestingCompleted() - Creating location object. " );
  1037 	        		WRITELOG( "CHarvesterAO::HarvestingCompleted() - Creating location object. " );
  1027 	        		RLocationObjectManipulator lo;
  1038 	        		RLocationObjectManipulator lo;
  1028 	        		
  1039 	        		
  1029 	        		TInt loError = KErrNone;     		
  1040 	        		const TInt loError = lo.Connect();     		
  1030 	        		loError = lo.Connect();
       
  1031 	        		
  1041 	        		
  1032 	        		if (loError == KErrNone)
  1042 	        		if (loError == KErrNone)
  1033 	        			{
  1043 	        			{
  1034 	        			TInt err = lo.CreateLocationObject( *locData, aHD->MdeObject().Id() );
  1044 	        			TInt err = lo.CreateLocationObject( *locData, aHD->MdeObject().Id() );
  1035 	        			if( err != KErrNone )
  1045 	        			if( err != KErrNone )
  1079 			return;
  1089 			return;
  1080             }
  1090             }
  1081         else
  1091         else
  1082             {
  1092             {
  1083             WRITELOG1( "CHarvesterAO::HarvestingCompleted() - unknown error: %d", errorCode );
  1093             WRITELOG1( "CHarvesterAO::HarvestingCompleted() - unknown error: %d", errorCode );
       
  1094             delete aHD;
       
  1095             aHD = NULL;
  1084             }
  1096             }
  1085         
  1097         
  1086         WRITELOG( "==============================ERROR done =========================" );
  1098         WRITELOG( "==============================ERROR done =========================" );
  1087         }
  1099         }
  1088            
  1100            
  1113             }
  1125             }
  1114         else
  1126         else
  1115         	{
  1127         	{
  1116             WRITELOG( "CHarvesterAO::HandleSessionOpened() - error creating mde harvester session" );
  1128             WRITELOG( "CHarvesterAO::HandleSessionOpened() - error creating mde harvester session" );
  1117         	}
  1129         	}
       
  1130         
       
  1131         TRAPD( ohTrap, iMdeObjectHandler = CMdeObjectHandler::NewL( *iMdESession ) );
       
  1132         if ( ohTrap != KErrNone )
       
  1133                 {
       
  1134                 WRITELOG( "CHarvesterAO::HandleSessionOpened() - ObjectHandler creation failed" );
       
  1135                 }
       
  1136         
  1118 #ifdef _DEBUG
  1137 #ifdef _DEBUG
  1119         TRAP( errorTrap, PreallocateNamespaceL( aSession.GetDefaultNamespaceDefL() ) );
  1138         TRAP( errorTrap, PreallocateNamespaceL( aSession.GetDefaultNamespaceDefL() ) );
  1120         if ( errorTrap != KErrNone )
  1139         if ( errorTrap != KErrNone )
  1121             {
  1140             {
  1122             WRITELOG( "CHarvesterAO::HandleSessionOpened() - error loading default schema" );
  1141             WRITELOG( "CHarvesterAO::HandleSessionOpened() - error loading default schema" );
  1163         	}
  1182         	}
  1164         else
  1183         else
  1165         	{
  1184         	{
  1166         	WRITELOG( "CHarvesterAO::HandleSessionOpened() - couldn't create on demand observer" );
  1185         	WRITELOG( "CHarvesterAO::HandleSessionOpened() - couldn't create on demand observer" );
  1167         	}
  1186         	}
  1168 
       
  1169     	TRAPD( ohTrap, iMdeObjectHandler = CMdeObjectHandler::NewL( *iMdESession ) );
       
  1170     	if ( ohTrap != KErrNone )
       
  1171 				{
       
  1172 				WRITELOG( "CHarvesterAO::HandleSessionOpened() - ObjectHandler creation failed" );
       
  1173 				}
       
  1174     	
  1187     	
  1175         // Initializing pause indicator
  1188         // Initializing pause indicator
  1176         iServerPaused = EFalse;
  1189         iServerPaused = EFalse;
  1177 #ifdef _DEBUG
  1190 #ifdef _DEBUG
  1178         WRITELOG( "HarvesterThread::HandleSessionOpened() - Succeeded!" );
  1191         WRITELOG( "HarvesterThread::HandleSessionOpened() - Succeeded!" );
  1295         {
  1308         {
  1296         // no more items in queue
  1309         // no more items in queue
  1297         case ERequestIdle:
  1310         case ERequestIdle:
  1298             {
  1311             {
  1299             WRITELOG( "CHarvesterAO::RunL - ERequestIdle" );
  1312             WRITELOG( "CHarvesterAO::RunL - ERequestIdle" );
       
  1313             iReadyPHArray.Compress();
       
  1314             iContainerPHArray.Compress();
       
  1315             iPHArray.Compress();
  1300             }
  1316             }
  1301         break;
  1317         break;
  1302 
  1318 
  1303         // data added to harvester queue
  1319         // data added to harvester queue
  1304         case ERequestHarvest:
  1320         case ERequestHarvest:
  1306             WRITELOG( "CHarvesterAO::RunL - ERequestHarvest" );
  1322             WRITELOG( "CHarvesterAO::RunL - ERequestHarvest" );
  1307             
  1323             
  1308             // harvest new items first...
  1324             // harvest new items first...
  1309             if ( iQueue->ItemsInQueue() > 0 )
  1325             if ( iQueue->ItemsInQueue() > 0 )
  1310                 {
  1326                 {
  1311                 if ( !iHarvesting )
       
  1312                 	{
       
  1313                 	iHarvesting = ETrue;
       
  1314                 	iHarvesterEventManager->SendEventL( EHEObserverTypeOverall, EHEStateStarted );
       
  1315                 	// This next line is for caching the harvester started event for observers registering
       
  1316                 	// after harvesting has already started
       
  1317                 	iHarvesterEventManager->IncreaseItemCount( EHEObserverTypeOverall, KCacheItemCountForEventCaching );
       
  1318                 	}
       
  1319                 
       
  1320                 ReadItemFromQueueL();
  1327                 ReadItemFromQueueL();
  1321 				SetNextRequest( ERequestHarvest );
  1328 				SetNextRequest( ERequestHarvest );
  1322                 }
  1329                 }
  1323 
  1330 
  1324             // no more items to harvest
  1331             // no more items to harvest
  1335 				if(iReadyPHArray.Count() > 0)
  1342 				if(iReadyPHArray.Count() > 0)
  1336             		{
  1343             		{
  1337 #ifdef _DEBUG
  1344 #ifdef _DEBUG
  1338             		WRITELOG1("CHarvesterAO::RunL - items in ready pharray: %d", iReadyPHArray.Count() );
  1345             		WRITELOG1("CHarvesterAO::RunL - items in ready pharray: %d", iReadyPHArray.Count() );
  1339 #endif   		
  1346 #endif   		
  1340             		for ( TInt i = iReadyPHArray.Count(); --i >= 0; )
  1347             		const TInt beginIndex( iReadyPHArray.Count() );
       
  1348             		TInt endIndex( beginIndex - KPlaceholderQueueSize );
       
  1349             		if( endIndex < 0 )
       
  1350             		    {
       
  1351             		    endIndex = 0;
       
  1352             		    }
       
  1353             		for ( TInt i = beginIndex; --i >= endIndex; )
  1341             			{
  1354             			{
  1342                 		CheckFileExtensionAndHarvestL( iReadyPHArray[i] );
  1355                 		CheckFileExtensionAndHarvestL( iReadyPHArray[i] );
  1343                 		iReadyPHArray.Remove( i );
  1356                 		iReadyPHArray.Remove( i );
  1344             			}
  1357             			}
       
  1358             		if( iReadyPHArray.Count() )
       
  1359             		    {
       
  1360             		    SetNextRequest( ERequestHarvest );
       
  1361             		    break;
       
  1362             		    }
  1345             		iReadyPHArray.Reset();
  1363             		iReadyPHArray.Reset();
  1346             		}
  1364             		}
  1347 				
       
  1348 				if ( iHarvesting && !UnharvestedItemsLeftInPlugins() && 
       
  1349 					 !iReHarvester->ItemsInQueue() )
       
  1350 					{
       
  1351 					iHarvesting = EFalse;						
       
  1352 					iHarvesterEventManager->SendEventL( EHEObserverTypeOverall, EHEStateFinished );
       
  1353 					iHarvesterEventManager->DecreaseItemCountL( EHEObserverTypeOverall, KCacheItemCountForEventCaching );
       
  1354 				    iReadyPHArray.Compress();
       
  1355 				    iContainerPHArray.Compress();
       
  1356 				    iPHArray.Compress();
       
  1357 					}
       
  1358 
  1365 
  1359                 SetNextRequest( ERequestIdle );
  1366                 SetNextRequest( ERequestIdle );
  1360                 }
  1367                 }
  1361             }
  1368             }
  1362         break;
  1369         break;
  1795                 aMessage.Complete( err );
  1802                 aMessage.Complete( err );
  1796                 }
  1803                 }
  1797             return;
  1804             return;
  1798             }
  1805             }
  1799 
  1806 
  1800         #ifdef _DEBUG
  1807 #ifdef _DEBUG
  1801         const TInt count = albumIds.Count();
  1808         const TInt count = albumIds.Count();
  1802         for (TInt i = 0; i < count; ++i)
  1809         for (TInt i = 0; i < count; ++i)
  1803             {
  1810             {
  1804             WRITELOG2( "RHarvesterClient::HarvestFileWithUID - album id[%d]: %d", i, albumIds[i] );
  1811             WRITELOG2( "RHarvesterClient::HarvestFileWithUID - album id[%d]: %d", i, albumIds[i] );
  1805             }
  1812             }
  1806         #endif
  1813 #endif
  1807         
  1814         
  1808         delete albumIdBuf;
  1815         delete albumIdBuf;
  1809         albumIdBuf = NULL;
  1816         albumIdBuf = NULL;
  1810 		
  1817 		
  1811 #ifdef _DEBUG        
  1818 #ifdef _DEBUG        
  2409 	}
  2416 	}
  2410 
  2417 
  2411 TBool CHarvesterAO::UnharvestedItemsLeftInPlugins()
  2418 TBool CHarvesterAO::UnharvestedItemsLeftInPlugins()
  2412 	{
  2419 	{
  2413 	RPointerArray<CHarvesterPluginInfo>& infos = iHarvesterPluginFactory->GetPluginInfos();
  2420 	RPointerArray<CHarvesterPluginInfo>& infos = iHarvesterPluginFactory->GetPluginInfos();
  2414 	TInt count = infos.Count();
  2421 	const TInt count = infos.Count();
  2415 	for ( TInt i = count; --i >= 0; )
  2422 	for ( TInt i = count; --i >= 0; )
  2416 		{
  2423 		{
  2417 		if ( infos[i]->iQueue.Count() > 0 )
  2424 		if ( infos[i]->iQueue.Count() > 0 )
  2418 			{
  2425 			{
  2419 			return ETrue;
  2426 			return ETrue;