harvester/server/src/harvesterao.cpp
changeset 40 910a23996aa0
parent 36 aa5a574040a4
child 43 c5e73110f733
equal deleted inserted replaced
38:5210ffae7137 40:910a23996aa0
   184     
   184     
   185     StopComposers();
   185     StopComposers();
   186     DeleteComposers();
   186     DeleteComposers();
   187 
   187 
   188     delete iDiskFullNotifier;
   188     delete iDiskFullNotifier;
       
   189     iDiskFullNotifier = NULL;
   189 	delete iBackupSubscriber;
   190 	delete iBackupSubscriber;
       
   191 	iBackupSubscriber = NULL;
   190     
   192     
   191     if (iBlacklist)
   193     if (iBlacklist)
   192 		{
   194 		{
   193 		iBlacklist->CloseDatabase();
   195 		iBlacklist->CloseDatabase();
   194 		delete iBlacklist;
   196 		delete iBlacklist;
       
   197 		iBlacklist = NULL;
   195 		}
   198 		}
   196 	delete iReHarvester;
   199 	delete iReHarvester;
       
   200 	iReHarvester = NULL;
   197 
   201 
   198     if ( iHarvestFileMessages.Count() > 0 )
   202     if ( iHarvestFileMessages.Count() > 0 )
   199         {
   203         {
   200         for ( TInt i = iHarvestFileMessages.Count()-1; i >= 0; --i )
   204         for ( TInt i = iHarvestFileMessages.Count()-1; i >= 0; --i )
   201             {
   205             {
   220     
   224     
   221     iTempReadyPHArray.ResetAndDestroy();
   225     iTempReadyPHArray.ResetAndDestroy();
   222     iTempReadyPHArray.Close();
   226     iTempReadyPHArray.Close();
   223     
   227     
   224 	delete iHarvesterOomAO;
   228 	delete iHarvesterOomAO;
       
   229 	iHarvesterOomAO = NULL;
   225     delete iRestoreWatcher;
   230     delete iRestoreWatcher;
       
   231     iRestoreWatcher = NULL;
   226 	delete iOnDemandAO;
   232 	delete iOnDemandAO;
       
   233 	iOnDemandAO = NULL;
   227 	delete iMdEHarvesterSession;
   234 	delete iMdEHarvesterSession;
       
   235 	iMdEHarvesterSession = NULL;
   228 	delete iMdESession;
   236 	delete iMdESession;
       
   237 	iMdESession = NULL;
   229 	delete iQueue;
   238 	delete iQueue;
       
   239 	iQueue = NULL;
   230 	delete iHarvesterPluginFactory;
   240 	delete iHarvesterPluginFactory;
       
   241 	iHarvesterPluginFactory = NULL;
   231 	delete iMdeObjectHandler;
   242 	delete iMdeObjectHandler;
       
   243 	iMdeObjectHandler = NULL;
   232 	delete iUnmountHandlerAO;
   244 	delete iUnmountHandlerAO;
       
   245 	iUnmountHandlerAO = NULL;
   233 	
   246 	
   234 	delete iPropDefs;
   247 	delete iPropDefs;
       
   248 	iPropDefs = NULL;
   235 	delete iCameraExtensionArray;
   249 	delete iCameraExtensionArray;
       
   250 	iCameraExtensionArray = NULL;
   236 	
   251 	
   237     delete iPhoneImagesPath;
   252     delete iPhoneImagesPath;
       
   253     iPhoneImagesPath = NULL;
   238     delete iMmcImagesPath;
   254     delete iMmcImagesPath;
       
   255     iMmcImagesPath = NULL;
   239     
   256     
   240     delete iPhoneVideosPath;
   257     delete iPhoneVideosPath;
       
   258     iPhoneVideosPath = NULL;
   241     delete iMmcVideosPath;
   259     delete iMmcVideosPath;
       
   260     iMmcVideosPath = NULL;
   242     
   261     
   243     delete iPhoneSoundsPath;
   262     delete iPhoneSoundsPath;
       
   263     iPhoneSoundsPath = NULL;
   244     delete iMmcSoundsPath;
   264     delete iMmcSoundsPath;
       
   265     iMmcSoundsPath = NULL;
   245 	
   266 	
   246 	RMediaIdUtil::ReleaseInstance();
   267 	RMediaIdUtil::ReleaseInstance();
   247     
   268     
   248     REComSession::FinalClose();
   269     REComSession::FinalClose();
   249     }
   270     }
   823             }
   844             }
   824     	while( hd != NULL &&
   845     	while( hd != NULL &&
   825 				iPHArray.Count() < KPlaceholderQueueSize &&
   846 				iPHArray.Count() < KPlaceholderQueueSize &&
   826 				hd->ObjectType() == EPlaceholder )
   847 				hd->ObjectType() == EPlaceholder )
   827     		{
   848     		{
   828         	iPHArray.Append( hd );
   849         	if(iPHArray.Append( hd ) != KErrNone)
   829         	if( hd->Origin() == MdeConstants::Object::ECamera || 
       
   830         	    hd->ObjectType() == EFastHarvest  )
       
   831         	    {
   850         	    {
   832         	    if( !iFastHarvestNeeded )
   851                 delete hd;
   833         	        {
   852                 hd = NULL;
   834                     iFastHarvestNeeded = ETrue;
       
   835                     // Fast harvest event must be handled even if MMC handling would be ongoing
       
   836                     SetPriority( KHarvesterPriorityMonitorPlugin );
       
   837         	        }
       
   838         	    break;
       
   839         	    }
   853         	    }
   840         	else if( iFastHarvestNeeded )
   854         	else
   841         	    {
   855         	    {
   842         	    iFastHarvestNeeded = EFalse;
   856                 if( hd->Origin() == MdeConstants::Object::ECamera || 
   843         	    SetPriority( KHarvesterCustomImportantPriority );
   857                     hd->ObjectType() == EFastHarvest  )
       
   858                     {
       
   859                     if( !iFastHarvestNeeded )
       
   860                         {
       
   861                         iFastHarvestNeeded = ETrue;
       
   862                         // Fast harvest event must be handled even if MMC handling would be ongoing
       
   863                         SetPriority( KHarvesterPriorityMonitorPlugin );
       
   864                         }
       
   865                     break;
       
   866                     }
       
   867                 else if( iFastHarvestNeeded )
       
   868                     {
       
   869                     iFastHarvestNeeded = EFalse;
       
   870                     SetPriority( KHarvesterCustomImportantPriority );
       
   871         	    	}
   844         	    }
   872         	    }
   845         	hd = iQueue->GetNextItem();
   873         	hd = iQueue->GetNextItem();
   846     		}
   874     		}
   847     	
   875     	
   848     	if( iFastHarvestNeeded && iPHArray.Count() > 0 )
   876     	if( iFastHarvestNeeded && iPHArray.Count() > 0 )
   875     	
   903     	
   876 		if( hd )
   904 		if( hd )
   877     		{
   905     		{
   878 	    	if( hd->ObjectType() == EPlaceholder )
   906 	    	if( hd->ObjectType() == EPlaceholder )
   879 	    		{
   907 	    		{
   880 	        	iPHArray.Append( hd );
   908 	        	if( iPHArray.Append( hd ) != KErrNone )
       
   909 	        	    {
       
   910                     delete hd;
       
   911                     hd = NULL;
       
   912 	        	    }
   881 	    		}
   913 	    		}
   882 	    	else
   914 	    	else
   883 	    		{
   915 	    		{
   884 	    		CheckFileExtensionAndHarvestL( hd );
   916 	    		CheckFileExtensionAndHarvestL( hd );
   885 	    		if( iUnmountDetected )
   917 	    		if( iUnmountDetected )
   937 		{
   969 		{
   938 		CHarvesterData* hd = iPHArray[i];
   970 		CHarvesterData* hd = iPHArray[i];
   939 		
   971 		
   940 		if( aCheck && iHarvesterPluginFactory->IsContainerFileL( hd->Uri() ) )
   972 		if( aCheck && iHarvesterPluginFactory->IsContainerFileL( hd->Uri() ) )
   941 			{
   973 			{
   942 			iContainerPHArray.Append( hd );
   974 			if( iContainerPHArray.Append( hd ) != KErrNone )
       
   975 			    {
       
   976                 delete hd;
       
   977                 hd = NULL;
       
   978 			    }
       
   979 
   943 			iPHArray.Remove( i );
   980 			iPHArray.Remove( i );
   944             i--;
   981 			i--;
   945             endindex--;
   982 			endindex--;
   946 			continue;
   983 			continue;
   947 			}
   984 			}
       
   985 		
   948 		TBuf<KObjectDefStrSize> objDefStr;
   986 		TBuf<KObjectDefStrSize> objDefStr;
   949 		
   987 		
   950 		if( !CheckForCameraItem( hd, objDefStr ) )
   988 		if( !CheckForCameraItem( hd, objDefStr ) )
   951 		    {
   989 		    {
   952 		    iHarvesterPluginFactory->GetObjectDefL( *hd, objDefStr );
   990 		    iHarvesterPluginFactory->GetObjectDefL( *hd, objDefStr );
   959 		    {
   997 		    {
   960 		    WRITELOG( "CHarvesterAO::HandlePlaceholdersL() - Unmount detected during execution!" );
   998 		    WRITELOG( "CHarvesterAO::HandlePlaceholdersL() - Unmount detected during execution!" );
   961 		    for( TInt y( iTempReadyPHArray.Count() -1 ); y >=0; y-- )
   999 		    for( TInt y( iTempReadyPHArray.Count() -1 ); y >=0; y-- )
   962 		        {
  1000 		        {
   963 		        CHarvesterData* hd = iTempReadyPHArray[y];
  1001 		        CHarvesterData* hd = iTempReadyPHArray[y];
   964 		        iPHArray.Insert( hd, 0 );
  1002 				
       
  1003 		        if(iPHArray.Insert( hd, 0 ) != KErrNone)
       
  1004 		            {
       
  1005                     delete hd;
       
  1006                     hd = NULL;
       
  1007 		            }
   965 		        }
  1008 		        }
   966 		    iTempReadyPHArray.Reset();
  1009 		    iTempReadyPHArray.Reset();
   967 		    CleanupStack::PopAndDestroy( &mdeObjectArray );
  1010 		    CleanupStack::PopAndDestroy( &mdeObjectArray );
   968 		    return;
  1011 		    return;
   969 		    }
  1012 		    }
   978                 {
  1021                 {
   979                 CHarvesterData* hd = iTempReadyPHArray[y];
  1022                 CHarvesterData* hd = iTempReadyPHArray[y];
   980                 if( currentPHArrayCount )
  1023                 if( currentPHArrayCount )
   981                     {
  1024                     {
   982                     // Leave the first item in the array as it is the priority item
  1025                     // Leave the first item in the array as it is the priority item
   983                     iPHArray.Insert( hd, 1 );
  1026                     if(iPHArray.Insert( hd, 1 ) != KErrNone)
       
  1027                         {
       
  1028                         delete hd;
       
  1029                         hd = NULL;
       
  1030                         }
   984                     }
  1031                     }
   985                 else
  1032                 else
   986                     {
  1033                     {
   987                     iPHArray.Insert( hd, 0 );
  1034                     if(iPHArray.Insert( hd, 0 ) != KErrNone)
       
  1035                         {
       
  1036                         delete hd;
       
  1037                         hd = NULL;
       
  1038                         }
   988                     }
  1039                     }
   989                 }
  1040                 }
   990             iTempReadyPHArray.Reset();
  1041             iTempReadyPHArray.Reset();
   991             CleanupStack::PopAndDestroy( &mdeObjectArray );
  1042             CleanupStack::PopAndDestroy( &mdeObjectArray );
   992             return;		
  1043             return;		
  1170 		
  1221 		
  1171 	    CleanupStack::PopAndDestroy( phData );
  1222 	    CleanupStack::PopAndDestroy( phData );
  1172 	    
  1223 	    
  1173 	    CleanupStack::Pop( mdeObject );
  1224 	    CleanupStack::Pop( mdeObject );
  1174 		
  1225 		
  1175 	    iTempReadyPHArray.Append( hd );
  1226 	    if(iTempReadyPHArray.Append( hd ) != KErrNone)
       
  1227 	        {
       
  1228             delete hd;
       
  1229             hd = NULL;
       
  1230 	        }
  1176 		iPHArray.Remove( i );
  1231 		iPHArray.Remove( i );
  1177         i--;
  1232         i--;
  1178         endindex--;
  1233         endindex--;
  1179 		}
  1234 		}
  1180 	
  1235 	
  1350     	iMdESession->RemoveObjectL( aHD->Uri() );
  1405     	iMdESession->RemoveObjectL( aHD->Uri() );
  1351     	}
  1406     	}
  1352 	
  1407 	
  1353 	TInt pluginErr = KErrNone;
  1408 	TInt pluginErr = KErrNone;
  1354     TRAPD( err, pluginErr = iHarvesterPluginFactory->HarvestL( aHD ));
  1409     TRAPD( err, pluginErr = iHarvesterPluginFactory->HarvestL( aHD ));
       
  1410     
  1355     if ( err != KErrNone )
  1411     if ( err != KErrNone )
  1356     	{
  1412     	{
  1357     	WRITELOG1( "CHarvesterAO::CheckFileExtensionAndHarvestL() - plugin error: %d", err );
  1413     	WRITELOG1( "CHarvesterAO::CheckFileExtensionAndHarvestL() - plugin error: %d", err );
  1358     	OstTrace1( TRACE_NORMAL, DUP6_CHARVESTERAO_CHECKFILEEXTENSIONANDHARVESTL, "CHarvesterAO::CheckFileExtensionAndHarvestL - plugin error: %d", err );
  1414     	OstTrace1( TRACE_NORMAL, DUP6_CHARVESTERAO_CHECKFILEEXTENSIONANDHARVESTL, "CHarvesterAO::CheckFileExtensionAndHarvestL - plugin error: %d", err );
  1359     	
  1415     	
  3039 					if( !IsDescInArray( path, aIgnorePaths ) )
  3095 					if( !IsDescInArray( path, aIgnorePaths ) )
  3040 						{
  3096 						{
  3041 						WRITELOG("CHarvesterAO::BootScanL() - scanFolders.AppendL");
  3097 						WRITELOG("CHarvesterAO::BootScanL() - scanFolders.AppendL");
  3042 						OstTrace0( TRACE_NORMAL, DUP2_CHARVESTERAO_BOOTSCANL, "CHarvesterAO::BootScanL - scanFolders.AppendL" );
  3098 						OstTrace0( TRACE_NORMAL, DUP2_CHARVESTERAO_BOOTSCANL, "CHarvesterAO::BootScanL - scanFolders.AppendL" );
  3043 						TScanItem* item = new (ELeave) TScanItem();
  3099 						TScanItem* item = new (ELeave) TScanItem();
       
  3100 						CleanupStack::PushL( item );
  3044 						item->iPath = name->AllocL();
  3101 						item->iPath = name->AllocL();
  3045 						item->iPreinstalled = MdeConstants::MediaObject::ENotPreinstalled;
  3102 						item->iPreinstalled = MdeConstants::MediaObject::ENotPreinstalled;
  3046 						aScanItems.AppendL( item );
  3103 						CleanupStack::Pop( item );
       
  3104 						aScanItems.AppendL( item ); // ownership is transferred
  3047 						}
  3105 						}
  3048 					}
  3106 					}
  3049 				else
  3107 				else
  3050 					{
  3108 					{
  3051 					TPtrC filename = *name;
  3109 					TPtrC filename = *name;
  3101 	                        hd->SetObjectType( EPlaceholder );
  3159 	                        hd->SetObjectType( EPlaceholder );
  3102 	                        hd->SetOrigin( MdeConstants::Object::EOther );
  3160 	                        hd->SetOrigin( MdeConstants::Object::EOther );
  3103 	                        hd->SetClientData( phData );
  3161 	                        hd->SetClientData( phData );
  3104 
  3162 
  3105 	                        CleanupStack::Pop( phData );
  3163 	                        CleanupStack::Pop( phData );
  3106 	                        hdArray.Append( hd );
  3164 							
       
  3165 	                        if(hdArray.Append( hd ) != KErrNone )
       
  3166 	                            {
       
  3167                                 delete hd;
       
  3168                                 hd = NULL;
       
  3169 	                            }
  3107 						    }
  3170 						    }
  3108 						CleanupStack::PopAndDestroy( &results );
  3171 						CleanupStack::PopAndDestroy( &results );
  3109 						CleanupStack::PopAndDestroy( &fileInfos );
  3172 						CleanupStack::PopAndDestroy( &fileInfos );
  3110 						CleanupStack::PopAndDestroy( &uris );
  3173 						CleanupStack::PopAndDestroy( &uris );
  3111 						}
  3174 						}