66 // |
66 // |
67 CHarvesterPluginFactory::~CHarvesterPluginFactory() |
67 CHarvesterPluginFactory::~CHarvesterPluginFactory() |
68 { |
68 { |
69 WRITELOG( "CHarvesterPluginFactory::~CHarvesterPluginFactory()" ); |
69 WRITELOG( "CHarvesterPluginFactory::~CHarvesterPluginFactory()" ); |
70 |
70 |
71 delete iLastConfirmedContainerExt; |
|
72 iLastConfirmedContainerExt = NULL; |
|
73 |
|
74 delete iLastConfirmedSupportedExt; |
|
75 iLastConfirmedSupportedExt = NULL; |
|
76 |
|
77 if (iHarvesterEventManager) |
71 if (iHarvesterEventManager) |
78 { |
72 { |
79 iHarvesterEventManager->ReleaseInstance(); |
73 iHarvesterEventManager->ReleaseInstance(); |
80 } |
74 } |
81 |
75 |
97 |
91 |
98 // --------------------------------------------------------------------------- |
92 // --------------------------------------------------------------------------- |
99 // GetObjectDef |
93 // GetObjectDef |
100 // --------------------------------------------------------------------------- |
94 // --------------------------------------------------------------------------- |
101 // |
95 // |
102 EXPORT_C void CHarvesterPluginFactory::GetObjectDefL( CHarvesterData& /*aHD*/, TDes& aObjectDef ) |
96 EXPORT_C void CHarvesterPluginFactory::GetObjectDefL( CHarvesterData& aHD, TDes& aObjectDef ) |
103 { |
97 { |
104 aObjectDef.Zero(); |
98 TPtrC extPtr; |
|
99 if( MdsUtils::GetExt( aHD.Uri(), extPtr ) ) |
|
100 { |
|
101 RPointerArray<CHarvesterPluginInfo> supportedPlugins; |
|
102 CleanupClosePushL( supportedPlugins ); |
|
103 GetSupportedPluginsL( supportedPlugins, extPtr ); |
|
104 |
|
105 const TInt sCount = supportedPlugins.Count(); |
|
106 if( sCount == 1 ) |
|
107 { |
|
108 CHarvesterPluginInfo* info = supportedPlugins[0]; |
|
109 if( info->iObjectTypes.Count() == 1 ) |
|
110 { |
|
111 aObjectDef.Copy( *(info->iObjectTypes[0]) ); |
|
112 aHD.SetHarvesterPluginInfo( info ); |
|
113 CleanupStack::PopAndDestroy( &supportedPlugins ); |
|
114 return; |
|
115 } |
|
116 } |
|
117 for( TInt i = sCount - 1; i >=0; i-- ) |
|
118 { |
|
119 CHarvesterPluginInfo* info = supportedPlugins[i]; |
|
120 if ( !(info->iPlugin) ) |
|
121 { |
|
122 info->iPlugin = CHarvesterPlugin::NewL( info->iPluginUid ); |
|
123 info->iPlugin->SetQueue( info->iQueue ); |
|
124 info->iPlugin->SetHarvesterPluginFactory( *this ); |
|
125 info->iPlugin->SetBlacklist( *iBlacklist ); |
|
126 } |
|
127 info->iPlugin->GetObjectType( aHD.Uri(), aObjectDef ); |
|
128 if( aObjectDef.Length() > 0 ) |
|
129 { |
|
130 aHD.SetHarvesterPluginInfo( info ); |
|
131 break; |
|
132 } |
|
133 } |
|
134 CleanupStack::PopAndDestroy( &supportedPlugins ); |
|
135 } |
|
136 else |
|
137 { |
|
138 aObjectDef.Zero(); |
|
139 } |
105 } |
140 } |
106 |
141 |
107 // --------------------------------------------------------------------------- |
142 // --------------------------------------------------------------------------- |
108 // GetMimeType |
143 // GetMimeType |
109 // --------------------------------------------------------------------------- |
144 // --------------------------------------------------------------------------- |
172 hpi->iPlugin->SetBlacklist( *iBlacklist ); |
207 hpi->iPlugin->SetBlacklist( *iBlacklist ); |
173 } |
208 } |
174 |
209 |
175 if( aHD->ObjectType() == EFastHarvest || aHD->Origin() == MdeConstants::Object::ECamera ) |
210 if( aHD->ObjectType() == EFastHarvest || aHD->Origin() == MdeConstants::Object::ECamera ) |
176 { |
211 { |
177 hpi->iQueue.InsertL( aHD, 0 ); |
212 hpi->iQueue.Insert( aHD, 0 ); |
178 |
|
179 if( !hpi->iPlugin->IsActive() ) |
213 if( !hpi->iPlugin->IsActive() ) |
180 { |
214 { |
181 hpi->iPlugin->SetPriority( KHarvesterPriorityHarvestingPlugin + 1 ); |
215 hpi->iPlugin->SetPriority( KHarvesterPriorityHarvestingPlugin + 1 ); |
182 } |
216 } |
183 } |
217 } |
292 CleanupStack::Pop( str ); |
326 CleanupStack::Pop( str ); |
293 } |
327 } |
294 |
328 |
295 pluginInfo->iPluginUid = aPluginUid; |
329 pluginInfo->iPluginUid = aPluginUid; |
296 |
330 |
|
331 #ifdef MDS_HARVESTERPLUGINS_ON_BOOT |
297 pluginInfo->iPlugin = CHarvesterPlugin::NewL( pluginInfo->iPluginUid ); |
332 pluginInfo->iPlugin = CHarvesterPlugin::NewL( pluginInfo->iPluginUid ); |
298 pluginInfo->iPlugin->SetQueue( pluginInfo->iQueue ); |
333 pluginInfo->iPlugin->SetQueue( pluginInfo->iQueue ); |
299 pluginInfo->iPlugin->SetHarvesterPluginFactory( *this ); |
334 pluginInfo->iPlugin->SetHarvesterPluginFactory( *this ); |
|
335 #endif |
300 |
336 |
301 iHarvesterPluginInfoArray.AppendL( pluginInfo ); |
337 iHarvesterPluginInfoArray.AppendL( pluginInfo ); |
302 CleanupStack::Pop( pluginInfo ); |
338 CleanupStack::Pop( pluginInfo ); |
303 } |
339 } |
304 |
340 |
334 EXPORT_C TBool CHarvesterPluginFactory::IsSupportedFileExtension( const TDesC& aFileName ) |
370 EXPORT_C TBool CHarvesterPluginFactory::IsSupportedFileExtension( const TDesC& aFileName ) |
335 { |
371 { |
336 TPtrC extPtr; |
372 TPtrC extPtr; |
337 if( MdsUtils::GetExt( aFileName, extPtr ) ) |
373 if( MdsUtils::GetExt( aFileName, extPtr ) ) |
338 { |
374 { |
339 if( iLastConfirmedSupportedExt && |
|
340 extPtr.CompareF( iLastConfirmedSupportedExt->Des() ) == 0 ) |
|
341 { |
|
342 // Extension has previously been confirmed to be |
|
343 // supported file extension, no need to ask from plugins |
|
344 return ETrue; |
|
345 } |
|
346 TInt pluginInfoCount = iHarvesterPluginInfoArray.Count(); |
375 TInt pluginInfoCount = iHarvesterPluginInfoArray.Count(); |
347 TInt extCount = 0; |
376 TInt extCount = 0; |
348 for ( TInt i = pluginInfoCount; --i >= 0; ) |
377 for ( TInt i = pluginInfoCount; --i >= 0; ) |
349 { |
378 { |
350 CHarvesterPluginInfo* info = iHarvesterPluginInfoArray[i]; |
379 CHarvesterPluginInfo* info = iHarvesterPluginInfoArray[i]; |
354 TDesC* ext = info->iExtensions[k]; |
383 TDesC* ext = info->iExtensions[k]; |
355 // checking against supported plugin file extensions |
384 // checking against supported plugin file extensions |
356 TInt result = MdsUtils::Compare( *ext, extPtr ); |
385 TInt result = MdsUtils::Compare( *ext, extPtr ); |
357 if ( result == 0 ) |
386 if ( result == 0 ) |
358 { |
387 { |
359 delete iLastConfirmedSupportedExt; |
|
360 iLastConfirmedSupportedExt = NULL; |
|
361 iLastConfirmedSupportedExt = extPtr.Alloc(); |
|
362 return ETrue; |
388 return ETrue; |
363 } |
389 } |
364 } |
390 } |
365 } |
391 } |
366 } |
392 } |
372 TBool isContainerFile = EFalse; |
398 TBool isContainerFile = EFalse; |
373 TPtrC extPtr; |
399 TPtrC extPtr; |
374 |
400 |
375 if( MdsUtils::GetExt( aURI, extPtr ) ) |
401 if( MdsUtils::GetExt( aURI, extPtr ) ) |
376 { |
402 { |
377 if( iLastConfirmedContainerExt && |
|
378 extPtr.CompareF( iLastConfirmedContainerExt->Des() ) == 0 ) |
|
379 { |
|
380 // Extension has previously been confirmed to be |
|
381 // container file extension, no need to ask from plugins |
|
382 return ETrue; |
|
383 } |
|
384 |
|
385 RPointerArray<CHarvesterPluginInfo> supportedPlugins; |
403 RPointerArray<CHarvesterPluginInfo> supportedPlugins; |
386 CleanupClosePushL( supportedPlugins ); |
404 CleanupClosePushL( supportedPlugins ); |
387 GetSupportedPluginsL( supportedPlugins, extPtr ); |
405 GetSupportedPluginsL( supportedPlugins, extPtr ); |
388 for( TInt i = supportedPlugins.Count() - 1; i >=0; i-- ) |
406 for( TInt i = supportedPlugins.Count() - 1; i >=0; i-- ) |
389 { |
407 { |
390 CHarvesterPluginInfo* info = supportedPlugins[i]; |
408 CHarvesterPluginInfo* info = supportedPlugins[i]; |
391 if( info->iObjectTypes.Count() > 1 ) |
409 if( info->iObjectTypes.Count() > 1 ) |
392 { |
410 { |
393 isContainerFile = ETrue; |
411 isContainerFile = ETrue; |
394 delete iLastConfirmedContainerExt; |
|
395 iLastConfirmedContainerExt = NULL; |
|
396 iLastConfirmedContainerExt = extPtr.Alloc(); |
|
397 break; |
412 break; |
398 } |
413 } |
399 } |
414 } |
400 CleanupStack::PopAndDestroy( &supportedPlugins ); |
415 CleanupStack::PopAndDestroy( &supportedPlugins ); |
401 } |
416 } |
420 } |
435 } |
421 } |
436 } |
422 |
437 |
423 EXPORT_C void CHarvesterPluginFactory::SendHarvestingStatusEventL( TBool aStarted ) |
438 EXPORT_C void CHarvesterPluginFactory::SendHarvestingStatusEventL( TBool aStarted ) |
424 { |
439 { |
425 WRITELOG( "CHarvesterPluginFactory::SendHarvestingStatusEventL" ); |
|
426 const TInt pluginInfoCount = iHarvesterPluginInfoArray.Count(); |
440 const TInt pluginInfoCount = iHarvesterPluginInfoArray.Count(); |
427 TBool itemsLeft( EFalse ); |
441 TBool itemsLeft( EFalse ); |
428 TBool allPluginsOnIdle( ETrue ); |
442 TBool allPluginsOnIdle( ETrue ); |
429 for ( TInt i = pluginInfoCount; --i >= 0; ) |
443 for ( TInt i = pluginInfoCount; --i >= 0; ) |
430 { |
444 { |
444 } |
458 } |
445 } |
459 } |
446 |
460 |
447 if( !iHarvesting && itemsLeft && aStarted ) |
461 if( !iHarvesting && itemsLeft && aStarted ) |
448 { |
462 { |
449 WRITELOG( "CHarvesterPluginFactory::SendHarvestingStatusEventL - overall started" ); |
|
450 iHarvesting = ETrue; |
463 iHarvesting = ETrue; |
451 iHarvesterEventManager->SendEventL( EHEObserverTypeOverall, EHEStateStarted ); |
464 iHarvesterEventManager->SendEventL( EHEObserverTypeOverall, EHEStateStarted ); |
452 // This next line is for caching the harvester started event for observers registering |
465 // This next line is for caching the harvester started event for observers registering |
453 // after harvesting has already started |
466 // after harvesting has already started |
454 iHarvesterEventManager->IncreaseItemCount( EHEObserverTypeOverall, KCacheItemCountForEventCaching ); |
467 iHarvesterEventManager->IncreaseItemCount( EHEObserverTypeOverall, KCacheItemCountForEventCaching ); |
455 return; |
468 return; |
456 } |
469 } |
457 else if( iHarvesting && (!itemsLeft || allPluginsOnIdle) && !aStarted ) |
470 else if( iHarvesting && (!itemsLeft || allPluginsOnIdle) && !aStarted ) |
458 { |
471 { |
459 WRITELOG( "CHarvesterPluginFactory::SendHarvestingStatusEventL - overall finished" ); |
|
460 iHarvesting = EFalse; |
472 iHarvesting = EFalse; |
461 iHarvesterEventManager->SendEventL( EHEObserverTypeOverall, EHEStateFinished ); |
473 iHarvesterEventManager->SendEventL( EHEObserverTypeOverall, EHEStateFinished ); |
462 iHarvesterEventManager->DecreaseItemCountL( EHEObserverTypeOverall, KCacheItemCountForEventCaching ); |
474 iHarvesterEventManager->DecreaseItemCountL( EHEObserverTypeOverall, KCacheItemCountForEventCaching ); |
463 } |
475 } |
464 } |
476 } |
468 const TInt count = iHarvesterPluginInfoArray.Count(); |
480 const TInt count = iHarvesterPluginInfoArray.Count(); |
469 for ( TInt i = count; --i >= 0; ) |
481 for ( TInt i = count; --i >= 0; ) |
470 { |
482 { |
471 if( iHarvesterPluginInfoArray[i]->iPlugin && aPaused ) |
483 if( iHarvesterPluginInfoArray[i]->iPlugin && aPaused ) |
472 { |
484 { |
473 iHarvesterPluginInfoArray[i]->iPlugin->StopHarvest(); |
485 iHarvesterPluginInfoArray[i]->iPlugin->Cancel(); |
474 } |
486 } |
475 else if( iHarvesterPluginInfoArray[i]->iPlugin ) |
487 else if( iHarvesterPluginInfoArray[i]->iPlugin ) |
476 { |
488 { |
477 iHarvesterPluginInfoArray[i]->iPlugin->StartHarvest(); |
489 iHarvesterPluginInfoArray[i]->iPlugin->StartHarvest(); |
478 } |
490 } |
479 } |
491 } |
480 } |
492 } |
481 |
493 |
482 EXPORT_C void CHarvesterPluginFactory::GetObjectDefL( CHarvesterData* aHD, TDes& aObjectDef ) |
|
483 { |
|
484 TPtrC extPtr; |
|
485 if( MdsUtils::GetExt( aHD->Uri(), extPtr ) ) |
|
486 { |
|
487 RPointerArray<CHarvesterPluginInfo> supportedPlugins; |
|
488 CleanupClosePushL( supportedPlugins ); |
|
489 GetSupportedPluginsL( supportedPlugins, extPtr ); |
|
490 |
|
491 const TInt sCount = supportedPlugins.Count(); |
|
492 if( sCount == 1 ) |
|
493 { |
|
494 CHarvesterPluginInfo* info = supportedPlugins[0]; |
|
495 if( info->iObjectTypes.Count() == 1 ) |
|
496 { |
|
497 aObjectDef.Copy( *(info->iObjectTypes[0]) ); |
|
498 aHD->SetHarvesterPluginInfo( info ); |
|
499 CleanupStack::PopAndDestroy( &supportedPlugins ); |
|
500 return; |
|
501 } |
|
502 } |
|
503 for( TInt i = sCount - 1; i >=0; i-- ) |
|
504 { |
|
505 CHarvesterPluginInfo* info = supportedPlugins[i]; |
|
506 if ( !(info->iPlugin) ) |
|
507 { |
|
508 info->iPlugin = CHarvesterPlugin::NewL( info->iPluginUid ); |
|
509 info->iPlugin->SetQueue( info->iQueue ); |
|
510 info->iPlugin->SetHarvesterPluginFactory( *this ); |
|
511 info->iPlugin->SetBlacklist( *iBlacklist ); |
|
512 } |
|
513 info->iPlugin->GetObjectType( aHD->Uri(), aObjectDef ); |
|
514 // It is possible for unmount to occure while we are waiting |
|
515 // for GetObjectType to return, thus check aHD for validity |
|
516 if( aHD && aObjectDef.Length() > 0 ) |
|
517 { |
|
518 aHD->SetHarvesterPluginInfo( info ); |
|
519 break; |
|
520 } |
|
521 else if( !aHD ) |
|
522 { |
|
523 break; |
|
524 } |
|
525 } |
|
526 CleanupStack::PopAndDestroy( &supportedPlugins ); |
|
527 } |
|
528 else |
|
529 { |
|
530 aObjectDef.Zero(); |
|
531 } |
|
532 } |
|
533 |
|
534 |
|