--- a/harvester/common/src/harvesterpluginfactory.cpp Tue Jul 06 14:44:37 2010 +0300
+++ b/harvester/common/src/harvesterpluginfactory.cpp Fri Sep 17 16:54:49 2010 +0300
@@ -68,6 +68,12 @@
{
WRITELOG( "CHarvesterPluginFactory::~CHarvesterPluginFactory()" );
+ delete iLastConfirmedContainerExt;
+ iLastConfirmedContainerExt = NULL;
+
+ delete iLastConfirmedSupportedExt;
+ iLastConfirmedSupportedExt = NULL;
+
if (iHarvesterEventManager)
{
iHarvesterEventManager->ReleaseInstance();
@@ -93,50 +99,9 @@
// GetObjectDef
// ---------------------------------------------------------------------------
//
-EXPORT_C void CHarvesterPluginFactory::GetObjectDefL( CHarvesterData& aHD, TDes& aObjectDef )
+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 );
- if( aObjectDef.Length() > 0 )
- {
- aHD.SetHarvesterPluginInfo( info );
- break;
- }
- }
- CleanupStack::PopAndDestroy( &supportedPlugins );
- }
- else
- {
- aObjectDef.Zero();
- }
+ aObjectDef.Zero();
}
// ---------------------------------------------------------------------------
@@ -209,7 +174,8 @@
if( aHD->ObjectType() == EFastHarvest || aHD->Origin() == MdeConstants::Object::ECamera )
{
- hpi->iQueue.Insert( aHD, 0 );
+ hpi->iQueue.InsertL( aHD, 0 );
+
if( !hpi->iPlugin->IsActive() )
{
hpi->iPlugin->SetPriority( KHarvesterPriorityHarvestingPlugin + 1 );
@@ -328,11 +294,9 @@
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 );
@@ -372,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; )
@@ -385,6 +356,9 @@
TInt result = MdsUtils::Compare( *ext, extPtr );
if ( result == 0 )
{
+ delete iLastConfirmedSupportedExt;
+ iLastConfirmedSupportedExt = NULL;
+ iLastConfirmedSupportedExt = extPtr.Alloc();
return ETrue;
}
}
@@ -400,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 );
@@ -409,6 +391,9 @@
if( info->iObjectTypes.Count() > 1 )
{
isContainerFile = ETrue;
+ delete iLastConfirmedContainerExt;
+ iLastConfirmedContainerExt = NULL;
+ iLastConfirmedContainerExt = extPtr.Alloc();
break;
}
}
@@ -437,6 +422,7 @@
EXPORT_C void CHarvesterPluginFactory::SendHarvestingStatusEventL( TBool aStarted )
{
+ WRITELOG( "CHarvesterPluginFactory::SendHarvestingStatusEventL" );
const TInt pluginInfoCount = iHarvesterPluginInfoArray.Count();
TBool itemsLeft( EFalse );
TBool allPluginsOnIdle( ETrue );
@@ -460,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
@@ -469,6 +456,7 @@
}
else if( iHarvesting && (!itemsLeft || allPluginsOnIdle) && !aStarted )
{
+ WRITELOG( "CHarvesterPluginFactory::SendHarvestingStatusEventL - overall finished" );
iHarvesting = EFalse;
iHarvesterEventManager->SendEventL( EHEObserverTypeOverall, EHEStateFinished );
iHarvesterEventManager->DecreaseItemCountL( EHEObserverTypeOverall, KCacheItemCountForEventCaching );
@@ -482,7 +470,7 @@
{
if( iHarvesterPluginInfoArray[i]->iPlugin && aPaused )
{
- iHarvesterPluginInfoArray[i]->iPlugin->Cancel();
+ iHarvesterPluginInfoArray[i]->iPlugin->StopHarvest();
}
else if( iHarvesterPluginInfoArray[i]->iPlugin )
{
@@ -491,3 +479,56 @@
}
}
+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();
+ }
+ }
+
+