harvester/common/src/harvesterpluginfactory.cpp
branchRCL_3
changeset 63 e538444823de
parent 53 29d87345eaeb
--- a/harvester/common/src/harvesterpluginfactory.cpp	Wed Sep 15 12:40:59 2010 +0300
+++ b/harvester/common/src/harvesterpluginfactory.cpp	Wed Oct 13 15:02:02 2010 +0300
@@ -68,12 +68,6 @@
 	{
 	WRITELOG( "CHarvesterPluginFactory::~CHarvesterPluginFactory()" );
 	
-	delete iLastConfirmedContainerExt;
-	iLastConfirmedContainerExt = NULL;
-	
-	delete iLastConfirmedSupportedExt;
-	iLastConfirmedSupportedExt = NULL;
-	
     if (iHarvesterEventManager)
         {
         iHarvesterEventManager->ReleaseInstance();
@@ -99,9 +93,50 @@
 // GetObjectDef
 // ---------------------------------------------------------------------------
 //
-EXPORT_C void CHarvesterPluginFactory::GetObjectDefL( CHarvesterData& /*aHD*/, TDes& aObjectDef )
+EXPORT_C void CHarvesterPluginFactory::GetObjectDefL( CHarvesterData& aHD, TDes& aObjectDef )
 	{
-	aObjectDef.Zero();
+	TPtrC extPtr;
+	if( MdsUtils::GetExt( aHD.Uri(), extPtr ) )
+		{
+		RPointerArray<CHarvesterPluginInfo> supportedPlugins;
+		CleanupClosePushL( supportedPlugins );
+		GetSupportedPluginsL( supportedPlugins, extPtr );
+		
+		const TInt sCount = supportedPlugins.Count();
+		if( sCount == 1 )
+			{
+			CHarvesterPluginInfo* info = supportedPlugins[0];
+			if( info->iObjectTypes.Count() == 1 )
+				{
+				aObjectDef.Copy( *(info->iObjectTypes[0]) );
+				aHD.SetHarvesterPluginInfo( info );
+				CleanupStack::PopAndDestroy( &supportedPlugins );
+				return;
+				}
+			}
+		for( TInt i = sCount - 1; i >=0; i-- )
+			{
+			CHarvesterPluginInfo* info = supportedPlugins[i];
+			if ( !(info->iPlugin) )
+				{
+				info->iPlugin = CHarvesterPlugin::NewL( info->iPluginUid );
+				info->iPlugin->SetQueue( info->iQueue );
+				info->iPlugin->SetHarvesterPluginFactory( *this );  
+				info->iPlugin->SetBlacklist( *iBlacklist );
+				}
+			info->iPlugin->GetObjectType( aHD.Uri(), aObjectDef );
+			if( aObjectDef.Length() > 0 )
+				{
+				aHD.SetHarvesterPluginInfo( info );
+				break;
+				}
+			}
+		CleanupStack::PopAndDestroy( &supportedPlugins );
+		}
+	else
+		{
+		aObjectDef.Zero();
+		}
 	}
 	
 // ---------------------------------------------------------------------------
@@ -174,8 +209,7 @@
 			
 		if( aHD->ObjectType() == EFastHarvest || aHD->Origin() == MdeConstants::Object::ECamera )
 		   	{
-		   	hpi->iQueue.InsertL( aHD, 0 );
-		   	
+		   	hpi->iQueue.Insert( aHD, 0 );
 		   	if( !hpi->iPlugin->IsActive() )
 		   	    {
 	            hpi->iPlugin->SetPriority( KHarvesterPriorityHarvestingPlugin + 1 );
@@ -294,9 +328,11 @@
     
     pluginInfo->iPluginUid = aPluginUid;
     
+#ifdef MDS_HARVESTERPLUGINS_ON_BOOT
     pluginInfo->iPlugin = CHarvesterPlugin::NewL( pluginInfo->iPluginUid );
     pluginInfo->iPlugin->SetQueue( pluginInfo->iQueue );
     pluginInfo->iPlugin->SetHarvesterPluginFactory( *this );
+#endif
     
     iHarvesterPluginInfoArray.AppendL( pluginInfo );
     CleanupStack::Pop( pluginInfo );
@@ -336,13 +372,6 @@
 	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; )
@@ -356,9 +385,6 @@
 				TInt result = MdsUtils::Compare( *ext, extPtr );
 				if ( result == 0 )
 					{
-                    delete iLastConfirmedSupportedExt;
-                    iLastConfirmedSupportedExt = NULL;
-                    iLastConfirmedSupportedExt = extPtr.Alloc();				    
 					return ETrue;
 					}
 				}
@@ -374,14 +400,6 @@
 	
 	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 );
@@ -391,9 +409,6 @@
 			if( info->iObjectTypes.Count() >  1 )
 				{
 				isContainerFile = ETrue;
-				delete iLastConfirmedContainerExt;
-				iLastConfirmedContainerExt = NULL;
-				iLastConfirmedContainerExt = extPtr.Alloc();
 				break;
 				}
 			}
@@ -422,7 +437,6 @@
 
 EXPORT_C void CHarvesterPluginFactory::SendHarvestingStatusEventL( TBool aStarted )
     {
-    WRITELOG( "CHarvesterPluginFactory::SendHarvestingStatusEventL" );
     const TInt pluginInfoCount = iHarvesterPluginInfoArray.Count();
     TBool itemsLeft( EFalse );
     TBool allPluginsOnIdle( ETrue );
@@ -446,7 +460,6 @@
     
     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
@@ -456,7 +469,6 @@
         }
     else if( iHarvesting && (!itemsLeft || allPluginsOnIdle) && !aStarted )
         {
-        WRITELOG( "CHarvesterPluginFactory::SendHarvestingStatusEventL - overall finished" );
         iHarvesting = EFalse;                       
         iHarvesterEventManager->SendEventL( EHEObserverTypeOverall, EHEStateFinished );
         iHarvesterEventManager->DecreaseItemCountL( EHEObserverTypeOverall, KCacheItemCountForEventCaching );
@@ -470,7 +482,7 @@
         {
         if( iHarvesterPluginInfoArray[i]->iPlugin && aPaused )
             {
-            iHarvesterPluginInfoArray[i]->iPlugin->StopHarvest();
+            iHarvesterPluginInfoArray[i]->iPlugin->Cancel();
             }
         else if( iHarvesterPluginInfoArray[i]->iPlugin )
             {
@@ -479,56 +491,3 @@
         }
     }
 
-EXPORT_C void CHarvesterPluginFactory::GetObjectDefL( CHarvesterData* aHD, TDes& aObjectDef )
-    {
-    TPtrC extPtr;
-    if( MdsUtils::GetExt( aHD->Uri(), extPtr ) )
-        {
-        RPointerArray<CHarvesterPluginInfo> supportedPlugins;
-        CleanupClosePushL( supportedPlugins );
-        GetSupportedPluginsL( supportedPlugins, extPtr );
-        
-        const TInt sCount = supportedPlugins.Count();
-        if( sCount == 1 )
-            {
-            CHarvesterPluginInfo* info = supportedPlugins[0];
-            if( info->iObjectTypes.Count() == 1 )
-                {
-                aObjectDef.Copy( *(info->iObjectTypes[0]) );
-                aHD->SetHarvesterPluginInfo( info );
-                CleanupStack::PopAndDestroy( &supportedPlugins );
-                return;
-                }
-            }
-        for( TInt i = sCount - 1; i >=0; i-- )
-            {
-            CHarvesterPluginInfo* info = supportedPlugins[i];
-            if ( !(info->iPlugin) )
-                {
-                info->iPlugin = CHarvesterPlugin::NewL( info->iPluginUid );
-                info->iPlugin->SetQueue( info->iQueue );
-                info->iPlugin->SetHarvesterPluginFactory( *this );  
-                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 );
-                break;
-                }
-            else if( !aHD )
-                {
-                break;
-                }
-            }
-        CleanupStack::PopAndDestroy( &supportedPlugins );
-        }
-    else
-        {
-        aObjectDef.Zero();
-        }
-    }
-
-