harvester/server/src/mdeobjecthandler.cpp
branchRCL_3
changeset 15 3cebc1a84278
parent 0 c53acadfccc6
child 19 82c0024438c8
equal deleted inserted replaced
14:646a02f170b9 15:3cebc1a84278
   125                 WRITELOG1( "CMdeObjectHandler::SetMetadataObjectL() - AlbumID: %d", albumId );
   125                 WRITELOG1( "CMdeObjectHandler::SetMetadataObjectL() - AlbumID: %d", albumId );
   126                 CMdERelation* relation =  
   126                 CMdERelation* relation =  
   127                		iMdeSession->NewRelationLC(
   127                		iMdeSession->NewRelationLC(
   128                 		albumRelationDef, albumId, objectId, 0 );
   128                 		albumRelationDef, albumId, objectId, 0 );
   129                 relationEventArray.Append( STATIC_CAST( CMdEInstanceItem*, relation ) );
   129                 relationEventArray.Append( STATIC_CAST( CMdEInstanceItem*, relation ) );
   130                 CleanupStack::Pop();
   130                 CleanupStack::Pop(); //relation
   131                 }
   131                 }
   132             }
   132             }
   133         }
   133         }
   134     
   134     
   135     if ( eventDef )
   135     if ( eventDef )
   139         if ( objectId != 0 )
   139         if ( objectId != 0 )
   140             {
   140             {
   141             CMdEEvent* event = iMdeSession->NewEventLC( 
   141             CMdEEvent* event = iMdeSession->NewEventLC( 
   142             		*eventDef, objectId, time );
   142             		*eventDef, objectId, time );
   143             relationEventArray.Append( STATIC_CAST( CMdEInstanceItem*, event ) );
   143             relationEventArray.Append( STATIC_CAST( CMdEInstanceItem*, event ) );
   144             CleanupStack::Pop();
   144             CleanupStack::Pop(); // event
   145             }
   145             }
   146         }
   146         }
   147 
   147 
   148     if ( relationEventArray.Count() > 0 )
   148     if ( relationEventArray.Count() > 0 )
   149         {
   149         {
   184         		// The file can be open, as long as it is not open for modification anywhere
   184         		// The file can be open, as long as it is not open for modification anywhere
   185                 RFile64 tempFile;
   185                 RFile64 tempFile;
   186                 error = tempFile.Open( iFs, aHD.Uri(), EFileRead | EFileShareReadersOnly );
   186                 error = tempFile.Open( iFs, aHD.Uri(), EFileRead | EFileShareReadersOnly );
   187                 if( error != KErrNone )
   187                 if( error != KErrNone )
   188                     {
   188                     {
       
   189 #ifdef _DEBUG
       
   190                     if( error == KErrInUse || error || KErrLocked )
       
   191                         {
       
   192                         TPtrC fileName( aHD.Uri().Mid(2) );
       
   193                         WRITELOG1( "CMdeObjectHandler :: Checking open file handles to %S", &fileName );
       
   194 
       
   195                         CFileList* fileList = 0;
       
   196                         TOpenFileScan fileScan( iFs );
       
   197 
       
   198                         fileScan.NextL( fileList );   
       
   199           
       
   200                         while ( fileList )   
       
   201                             {
       
   202                             const TInt count( fileList->Count() ); 
       
   203                             for (TInt i = 0; i < count; i++ )   
       
   204                                 {   
       
   205                                 if ( (*fileList)[i].iName == aHD.Uri().Mid(2) )
       
   206                                     {
       
   207                                     TFullName processName;
       
   208                                     TFindThread find(_L("*"));
       
   209                                     while( find.Next( processName ) == KErrNone )
       
   210                                         {
       
   211                                         RThread thread;
       
   212                                         TInt err = thread.Open( processName );
       
   213              
       
   214                                         if ( err == KErrNone )
       
   215                                             {
       
   216                                             if ( thread.Id().Id() ==  fileScan.ThreadId() )
       
   217                                                 {
       
   218                                                 processName = thread.Name();
       
   219                                                 thread.Close();
       
   220                                                 WRITELOG1( "CMdeObjectHandler:: %S has a file handle open", &processName );
       
   221                                                 break;
       
   222                                                 }
       
   223                                             thread.Close();
       
   224                                             }
       
   225                                         }
       
   226                                     }
       
   227                                 }
       
   228                             fileScan.NextL( fileList );   
       
   229                             } 
       
   230                         }
       
   231 #endif
   189                     WRITELOG( "CMdeObjectHandler::GetMetadataObjectL() - file handle is open! Returning." );
   232                     WRITELOG( "CMdeObjectHandler::GetMetadataObjectL() - file handle is open! Returning." );
   190                     return NULL;
   233                     return NULL;
   191                     }
   234                     }
   192                 tempFile.Close();
   235                 tempFile.Close();
   193         		}
   236         		}