harvester/common/src/harvesterpluginfactory.cpp
branchRCL_3
changeset 49 f23c07ec56e2
parent 47 b73252188534
child 50 85f623e1ef41
--- a/harvester/common/src/harvesterpluginfactory.cpp	Thu Aug 19 10:20:41 2010 +0300
+++ b/harvester/common/src/harvesterpluginfactory.cpp	Tue Aug 31 15:37:30 2010 +0300
@@ -68,6 +68,12 @@
 	{
 	WRITELOG( "CHarvesterPluginFactory::~CHarvesterPluginFactory()" );
 	
+	delete iLastConfirmedContainerExt;
+	iLastConfirmedContainerExt = NULL;
+	
+	delete iLastConfirmedSupportedExt;
+	iLastConfirmedSupportedExt = NULL;
+	
     if (iHarvesterEventManager)
         {
         iHarvesterEventManager->ReleaseInstance();
@@ -330,6 +336,13 @@
 	TPtrC extPtr;
 	if( MdsUtils::GetExt( aFileName, extPtr ) )
 		{
+        if( iLastConfirmedSupportedExt &&
+            extPtr.CompareF( iLastConfirmedSupportedExt->Des() ) == 0 )
+            {
+            // Extension has previously been confirmed to be 
+            // supported file extension, no need to ask from plugins
+            return ETrue;
+            }
 		TInt pluginInfoCount = iHarvesterPluginInfoArray.Count();
 		TInt extCount = 0;
 		for ( TInt i = pluginInfoCount; --i >= 0; )
@@ -343,6 +356,9 @@
 				TInt result = MdsUtils::Compare( *ext, extPtr );
 				if ( result == 0 )
 					{
+                    delete iLastConfirmedSupportedExt;
+                    iLastConfirmedSupportedExt = NULL;
+                    iLastConfirmedSupportedExt = extPtr.Alloc();				    
 					return ETrue;
 					}
 				}
@@ -358,6 +374,14 @@
 	
 	if( MdsUtils::GetExt( aURI, extPtr ) )
 		{
+	    if( iLastConfirmedContainerExt &&
+	        extPtr.CompareF( iLastConfirmedContainerExt->Des() ) == 0 )
+	        {
+	        // Extension has previously been confirmed to be 
+	        // container file extension, no need to ask from plugins
+	        return ETrue;
+	        }
+	
 		RPointerArray<CHarvesterPluginInfo> supportedPlugins;
 		CleanupClosePushL( supportedPlugins );
 		GetSupportedPluginsL( supportedPlugins, extPtr );
@@ -367,6 +391,9 @@
 			if( info->iObjectTypes.Count() >  1 )
 				{
 				isContainerFile = ETrue;
+				delete iLastConfirmedContainerExt;
+				iLastConfirmedContainerExt = NULL;
+				iLastConfirmedContainerExt = extPtr.Alloc();
 				break;
 				}
 			}
@@ -395,6 +422,7 @@
 
 EXPORT_C void CHarvesterPluginFactory::SendHarvestingStatusEventL( TBool aStarted )
     {
+    WRITELOG( "CHarvesterPluginFactory::SendHarvestingStatusEventL" );
     const TInt pluginInfoCount = iHarvesterPluginInfoArray.Count();
     TBool itemsLeft( EFalse );
     TBool allPluginsOnIdle( ETrue );
@@ -418,6 +446,7 @@
     
     if( !iHarvesting && itemsLeft && aStarted )
         {
+        WRITELOG( "CHarvesterPluginFactory::SendHarvestingStatusEventL - overall started" );
         iHarvesting = ETrue;
         iHarvesterEventManager->SendEventL( EHEObserverTypeOverall, EHEStateStarted );
         // This next line is for caching the harvester started event for observers registering
@@ -427,6 +456,7 @@
         }
     else if( iHarvesting && (!itemsLeft || allPluginsOnIdle) && !aStarted )
         {
+        WRITELOG( "CHarvesterPluginFactory::SendHarvestingStatusEventL - overall finished" );
         iHarvesting = EFalse;                       
         iHarvesterEventManager->SendEventL( EHEObserverTypeOverall, EHEStateFinished );
         iHarvesterEventManager->DecreaseItemCountL( EHEObserverTypeOverall, KCacheItemCountForEventCaching );
@@ -440,7 +470,7 @@
         {
         if( iHarvesterPluginInfoArray[i]->iPlugin && aPaused )
             {
-            iHarvesterPluginInfoArray[i]->iPlugin->Cancel();
+            iHarvesterPluginInfoArray[i]->iPlugin->StopHarvest();
             }
         else if( iHarvesterPluginInfoArray[i]->iPlugin )
             {
@@ -481,6 +511,8 @@
                 info->iPlugin->SetBlacklist( *iBlacklist );
                 }
             info->iPlugin->GetObjectType( aHD->Uri(), aObjectDef );
+            // It is possible for unmount to occure while we are waiting
+            // for GetObjectType to return, thus check aHD for validity
             if( aHD && aObjectDef.Length() > 0 )
                 {
                 aHD->SetHarvesterPluginInfo( info );