harvester/harvesterplugins/ImagePlugin/src/harvesterimageplugin.cpp
branchRCL_3
changeset 7 3cebc1a84278
parent 6 646a02f170b9
child 9 82c0024438c8
equal deleted inserted replaced
6:646a02f170b9 7:3cebc1a84278
    23 
    23 
    24 #include "harvesterlog.h"
    24 #include "harvesterlog.h"
    25 #include "mdsutils.h"
    25 #include "mdsutils.h"
    26 #include "harvesterexifutil.h"
    26 #include "harvesterexifutil.h"
    27 #include "harvesterimageplugin.h"
    27 #include "harvesterimageplugin.h"
    28 #include "harvestercommon.h"
       
    29 #include "mdeobjectwrapper.h"
    28 #include "mdeobjectwrapper.h"
    30 
    29 
    31 using namespace MdeConstants;
    30 using namespace MdeConstants;
    32 
    31 
    33 // image mime types
    32 // image mime types
   255     		KExtWmf(), KWmfMime(), EOtherHandling ), cmp ) );
   254     		KExtWmf(), KWmfMime(), EOtherHandling ), cmp ) );
   256     
   255     
   257     User::LeaveIfError( iMimeTypeMappings.InsertInOrder( TMimeTypeMapping<TImageMetadataHandling>(
   256     User::LeaveIfError( iMimeTypeMappings.InsertInOrder( TMimeTypeMapping<TImageMetadataHandling>(
   258             KExtOtb(), KOtbMime(), EOtherHandling ), cmp ) );
   257             KExtOtb(), KOtbMime(), EOtherHandling ), cmp ) );
   259     
   258     
   260     SetPriority( KHarvesterPriorityHarvestingPlugin + 1 );
       
   261 	}
   259 	}
   262 
   260 
   263 void CHarvesterImagePlugin::HarvestL( CHarvesterData* aHD )
   261 void CHarvesterImagePlugin::HarvestL( CHarvesterData* aHD )
   264 	{
   262 	{
   265 	WRITELOG( "CHarvesterImagePlugin::HarvestL()" );
   263 	WRITELOG( "CHarvesterImagePlugin::HarvestL()" );
   450         WRITELOG( "CHarvesterImagePlugin::GatherData() - Exif could not be read. Using ICL." );
   448         WRITELOG( "CHarvesterImagePlugin::GatherData() - Exif could not be read. Using ICL." );
   451 
   449 
   452         TPtr8 imageDataPtr = aFileData.iImageData->Des();
   450         TPtr8 imageDataPtr = aFileData.iImageData->Des();
   453         TRAP( err, iDecoder->OpenL(imageDataPtr, aFileData.iMime8,
   451         TRAP( err, iDecoder->OpenL(imageDataPtr, aFileData.iMime8,
   454                 CImageDecoder::TOptions( CImageDecoder::EPreferFastDecode | CImageDecoder::EOptionIgnoreExifMetaData ) ) );
   452                 CImageDecoder::TOptions( CImageDecoder::EPreferFastDecode | CImageDecoder::EOptionIgnoreExifMetaData ) ) );
   455         WRITELOG( "CHarvesterImagePlugin::GatherData() - Image decoder has opened the file." );
       
   456 
   453 
   457         if ( err != KErrNone )
   454         if ( err != KErrNone )
   458             {
   455             {
   459             WRITELOG1( "CHarvesterImagePlugin::GatherData() - ERROR: Decoder could not open image data! Code %d", err );
   456             WRITELOG1( "CHarvesterImagePlugin::GatherData() - ERROR: Decoder could not open image data! Code %d", err );
       
   457 #ifdef _DEBUG
       
   458             if( err == KErrInUse || err == KErrLocked )
       
   459                 {
       
   460                 TPtrC fileName( uri.Mid(2) );
       
   461                 WRITELOG1( "CHarvesterImagePlugin :: Checking open file handles to %S", &fileName );
       
   462 
       
   463                 CFileList* fileList = 0;
       
   464                 TOpenFileScan fileScan( iFs );
       
   465 
       
   466                 fileScan.NextL( fileList );   
       
   467   
       
   468                 while ( fileList )   
       
   469                     {
       
   470                     const TInt count( fileList->Count() );
       
   471                     for (TInt i = 0; i < count; i++ )   
       
   472                         {   
       
   473                         if ( (*fileList)[i].iName == uri.Mid(2) )
       
   474                             {
       
   475                             TFullName processName;
       
   476                             TFindThread find(_L("*"));
       
   477                             while( find.Next( processName ) == KErrNone )
       
   478                                 {
       
   479                                 RThread thread;
       
   480                                 TInt err = thread.Open( processName );
       
   481      
       
   482                                 if ( err == KErrNone )
       
   483                                     {
       
   484                                     if ( thread.Id().Id() ==  fileScan.ThreadId() )
       
   485                                         {
       
   486                                         processName = thread.Name();
       
   487                                         thread.Close();
       
   488                                         WRITELOG1( "CHarvesterImagePlugin:: %S has a file handle open", &processName );
       
   489                                         break;
       
   490                                         }
       
   491                                     thread.Close();
       
   492                                     }
       
   493                                 }
       
   494                             }
       
   495                         }
       
   496                     fileScan.NextL( fileList );   
       
   497                     } 
       
   498                 }
       
   499 #endif
   460             iDecoder->Reset();
   500             iDecoder->Reset();
   461             return KErrCompletion; // metadata item still can be created, thus KErrCompletion
   501             return KErrCompletion; // metadata item still can be created, thus KErrCompletion
   462             }
   502             }
   463 
   503 
       
   504         WRITELOG( "CHarvesterImagePlugin::GatherData() - Image decoder has opened the file." );
       
   505         
   464         if ( !iDecoder->ValidDecoder() )
   506         if ( !iDecoder->ValidDecoder() )
   465         	{
   507         	{
   466         	// read all remaining data from file
   508         	// read all remaining data from file
   467         	TInt64 additionalDataSize = aFileData.iFileSize - aFileData.iImageDataSize;
   509         	TInt64 additionalDataSize = aFileData.iFileSize - aFileData.iImageDataSize;
   468         	if( additionalDataSize < 0 )
   510         	if( additionalDataSize < 0 )