harvester/server/src/harvesterao.cpp
changeset 23 33ae025ac1e8
parent 21 50bf9db68373
child 25 8e4539ab1889
child 41 2290317b9ec5
--- a/harvester/server/src/harvesterao.cpp	Fri Apr 16 15:23:55 2010 +0300
+++ b/harvester/server/src/harvesterao.cpp	Mon May 03 12:55:01 2010 +0300
@@ -232,12 +232,9 @@
     CActiveScheduler::Add( this );
 
 	User::LeaveIfError( iFs.Connect() );
-
+	
     // Setting up MdE Session
 	iMdESession = CMdESession::NewL( *this );
- 	
-    // Setting up context Engine (initialization is ready when ContextInitializationStatus -callback is called)
-    iCtxEngine = CContextEngine::GetInstanceL( this ); // Create the context engine
 
     iBackupSubscriber = CBackupSubscriber::NewL( *this );
 	
@@ -265,6 +262,9 @@
     iHarvesterPluginFactory = CHarvesterPluginFactory::NewL();
     iHarvesterPluginFactory->SetBlacklist( *iBlacklist );
     
+    // Reset harvesting status for clients in case blacklisted file was handled
+    iHarvesterPluginFactory->SendHarvestingStatusEventL( EFalse );
+    
     iCameraExtensionArray = new ( ELeave ) CDesCArraySeg( 6 );
     iCameraExtensionArray->InsertIsqL( KExtensionMp4 );
     iCameraExtensionArray->InsertIsqL( KExtensionMpg4 );
@@ -526,8 +526,6 @@
         TRAP_IGNORE( iHarvesterEventManager->DecreaseItemCountL( EHEObserverTypeMMC, removed ) );
 	    }
 	
-	iMediaIdUtil->RemoveMediaId( aMediaId );
-	
 	removed = 0;
 	
 	RPointerArray<CHarvesterPluginInfo>& hpiArray = iHarvesterPluginFactory->GetPluginInfos();
@@ -573,6 +571,8 @@
 		    }
 		}
 	
+    iMediaIdUtil->RemoveMediaId( aMediaId );
+	
 	// resume harvesting from last state
     if( !iRamFull && !iDiskFull )
         {
@@ -821,6 +821,7 @@
 		CMdEObjectDef& mdeObjectDef = defNS.GetObjectDefL( objDefStr );
 
 		CMdEObject* mdeObject = iMdESession->NewObjectL( mdeObjectDef, hd->Uri() );
+		CleanupStack::PushL( mdeObject );
 		
 		CPlaceholderData* phData = NULL;
 
@@ -956,9 +957,12 @@
 		
 		hd->SetMdeObject( mdeObject );
 		
-		mdeObjectArray.Append( mdeObject );
+		// Ownership of mdeObject transferred to the array
+		mdeObjectArray.AppendL( mdeObject );
 		
 	    CleanupStack::PopAndDestroy( phData );
+	    
+	    CleanupStack::Pop( mdeObject );
 		
 		iReadyPHArray.Append( hd );
 		iPHArray.Remove( i );
@@ -1259,6 +1263,7 @@
 void CHarvesterAO::HandleSessionOpened( CMdESession& aSession, TInt aError )
     {
     WRITELOG( "HarvesterThread::HandleSessionOpened()" );
+    
     if ( KErrNone == aError )
         {
         TBool isTNMDaemonEnabled( EFalse );
@@ -1279,6 +1284,13 @@
             WRITELOG( "CHarvesterAO::HandleSessionOpened() - error creating mde harvester session" );
         	}
 
+        // Setting up context Engine (initialization is ready when ContextInitializationStatus -callback is called)
+        TRAP( errorTrap, iCtxEngine = CContextEngine::GetInstanceL( this ) ); // Create the context engine 
+        if ( errorTrap != KErrNone )
+                {
+                WRITELOG( "CHarvesterAO::HandleSessionOpened() - Context Engine creation failed" );
+                }
+        
 #ifdef _DEBUG        
         TRAP( errorTrap, iMdeObjectHandler = CMdeObjectHandler::NewL( *iMdESession ) );
         if ( errorTrap != KErrNone )
@@ -1314,11 +1326,6 @@
         TRAP_IGNORE( StartComposersL() );        
 #endif
 
-        if ( iContextEngineInitialized )
-            {
-            iCtxEngine->SetMdeSession( iMdESession );
-            }
-
             // Starting monitor plugins
         StartMonitoring();
 
@@ -1413,7 +1420,7 @@
 // ---------------------------------------------------------------------------
 //
 void CHarvesterAO::HandleSessionError( CMdESession& /*aSession*/, TInt aError )
-    {    
+    {       
     if ( KErrNone != aError )
         {
         WRITELOG1( "HarvesterThread::HandleSessionError() - Error: %d!", aError );        
@@ -2823,3 +2830,11 @@
     return EFalse;
     }
 
+void CHarvesterAO::RemoveBlacklistedFile( CHarvesterData* aItem )
+    {
+    if( iMdeSessionInitialized )
+        {
+        TRAP_IGNORE( iMdESession->RemoveObjectL( aItem->Uri() ) );
+        }
+    }
+