harvester/harvesterplugins/ImagePlugin/src/harvesterimageplugin.cpp
changeset 21 50bf9db68373
parent 20 6dfc5f825351
child 23 33ae025ac1e8
--- a/harvester/harvesterplugins/ImagePlugin/src/harvesterimageplugin.cpp	Fri Mar 19 09:38:01 2010 +0200
+++ b/harvester/harvesterplugins/ImagePlugin/src/harvesterimageplugin.cpp	Fri Apr 16 15:23:55 2010 +0300
@@ -255,6 +255,7 @@
     
     User::LeaveIfError( iMimeTypeMappings.InsertInOrder( TMimeTypeMapping<TImageMetadataHandling>(
             KExtOtb(), KOtbMime(), EOtherHandling ), cmp ) );
+    
 	}
 
 void CHarvesterImagePlugin::HarvestL( CHarvesterData* aHD )
@@ -449,15 +450,59 @@
         TPtr8 imageDataPtr = aFileData.iImageData->Des();
         TRAP( err, iDecoder->OpenL(imageDataPtr, aFileData.iMime8,
                 CImageDecoder::TOptions( CImageDecoder::EPreferFastDecode | CImageDecoder::EOptionIgnoreExifMetaData ) ) );
-        WRITELOG( "CHarvesterImagePlugin::GatherData() - Image decoder has opened the file." );
 
         if ( err != KErrNone )
             {
             WRITELOG1( "CHarvesterImagePlugin::GatherData() - ERROR: Decoder could not open image data! Code %d", err );
+#ifdef _DEBUG
+            if( err == KErrInUse || err == KErrLocked )
+                {
+                TPtrC fileName( uri.Mid(2) );
+                WRITELOG1( "CHarvesterImagePlugin :: Checking open file handles to %S", &fileName );
+
+                CFileList* fileList = 0;
+                TOpenFileScan fileScan( iFs );
+
+                fileScan.NextL( fileList );   
+  
+                while ( fileList )   
+                    {
+                    const TInt count( fileList->Count() );
+                    for (TInt i = 0; i < count; i++ )   
+                        {   
+                        if ( (*fileList)[i].iName == uri.Mid(2) )
+                            {
+                            TFullName processName;
+                            TFindThread find(_L("*"));
+                            while( find.Next( processName ) == KErrNone )
+                                {
+                                RThread thread;
+                                TInt err = thread.Open( processName );
+     
+                                if ( err == KErrNone )
+                                    {
+                                    if ( thread.Id().Id() ==  fileScan.ThreadId() )
+                                        {
+                                        processName = thread.Name();
+                                        thread.Close();
+                                        WRITELOG1( "CHarvesterImagePlugin:: %S has a file handle open", &processName );
+                                        break;
+                                        }
+                                    thread.Close();
+                                    }
+                                }
+                            }
+                        }
+                    fileScan.NextL( fileList );   
+                    } 
+                }
+#endif
             iDecoder->Reset();
             return KErrCompletion; // metadata item still can be created, thus KErrCompletion
             }
 
+        WRITELOG( "CHarvesterImagePlugin::GatherData() - Image decoder has opened the file." );
+        
         if ( !iDecoder->ValidDecoder() )
         	{
         	// read all remaining data from file