harvester/server/src/harvesterao.cpp
changeset 23 33ae025ac1e8
parent 21 50bf9db68373
child 25 8e4539ab1889
child 41 2290317b9ec5
equal deleted inserted replaced
21:50bf9db68373 23:33ae025ac1e8
   230     WRITELOG( "CHarvesterAO::ConstructL() - begin" );
   230     WRITELOG( "CHarvesterAO::ConstructL() - begin" );
   231     
   231     
   232     CActiveScheduler::Add( this );
   232     CActiveScheduler::Add( this );
   233 
   233 
   234 	User::LeaveIfError( iFs.Connect() );
   234 	User::LeaveIfError( iFs.Connect() );
   235 
   235 	
   236     // Setting up MdE Session
   236     // Setting up MdE Session
   237 	iMdESession = CMdESession::NewL( *this );
   237 	iMdESession = CMdESession::NewL( *this );
   238  	
       
   239     // Setting up context Engine (initialization is ready when ContextInitializationStatus -callback is called)
       
   240     iCtxEngine = CContextEngine::GetInstanceL( this ); // Create the context engine
       
   241 
   238 
   242     iBackupSubscriber = CBackupSubscriber::NewL( *this );
   239     iBackupSubscriber = CBackupSubscriber::NewL( *this );
   243 	
   240 	
   244 	iUnmountHandlerAO = CUnmountHandlerAO::NewL( *this );
   241 	iUnmountHandlerAO = CUnmountHandlerAO::NewL( *this );
   245 	iUnmountHandlerAO->WaitForUnmountL();
   242 	iUnmountHandlerAO->WaitForUnmountL();
   262     iReHarvester = CReHarvesterAO::NewL();
   259     iReHarvester = CReHarvesterAO::NewL();
   263     iReHarvester->SetHarvesterQueue( iQueue );
   260     iReHarvester->SetHarvesterQueue( iQueue );
   264     
   261     
   265     iHarvesterPluginFactory = CHarvesterPluginFactory::NewL();
   262     iHarvesterPluginFactory = CHarvesterPluginFactory::NewL();
   266     iHarvesterPluginFactory->SetBlacklist( *iBlacklist );
   263     iHarvesterPluginFactory->SetBlacklist( *iBlacklist );
       
   264     
       
   265     // Reset harvesting status for clients in case blacklisted file was handled
       
   266     iHarvesterPluginFactory->SendHarvestingStatusEventL( EFalse );
   267     
   267     
   268     iCameraExtensionArray = new ( ELeave ) CDesCArraySeg( 6 );
   268     iCameraExtensionArray = new ( ELeave ) CDesCArraySeg( 6 );
   269     iCameraExtensionArray->InsertIsqL( KExtensionMp4 );
   269     iCameraExtensionArray->InsertIsqL( KExtensionMp4 );
   270     iCameraExtensionArray->InsertIsqL( KExtensionMpg4 );
   270     iCameraExtensionArray->InsertIsqL( KExtensionMpg4 );
   271     iCameraExtensionArray->InsertIsqL( KExtensionMpeg4 );
   271     iCameraExtensionArray->InsertIsqL( KExtensionMpeg4 );
   523 	    removed = iQueue->RemoveItems( aMediaId );
   523 	    removed = iQueue->RemoveItems( aMediaId );
   524 	    WRITELOG1( "CHarvesterAO::HandleUnmount() removed iQueue = %d", removed );
   524 	    WRITELOG1( "CHarvesterAO::HandleUnmount() removed iQueue = %d", removed );
   525 	    TRAP_IGNORE( iHarvesterEventManager->DecreaseItemCountL( EHEObserverTypePlaceholder, removed ) );
   525 	    TRAP_IGNORE( iHarvesterEventManager->DecreaseItemCountL( EHEObserverTypePlaceholder, removed ) );
   526         TRAP_IGNORE( iHarvesterEventManager->DecreaseItemCountL( EHEObserverTypeMMC, removed ) );
   526         TRAP_IGNORE( iHarvesterEventManager->DecreaseItemCountL( EHEObserverTypeMMC, removed ) );
   527 	    }
   527 	    }
   528 	
       
   529 	iMediaIdUtil->RemoveMediaId( aMediaId );
       
   530 	
   528 	
   531 	removed = 0;
   529 	removed = 0;
   532 	
   530 	
   533 	RPointerArray<CHarvesterPluginInfo>& hpiArray = iHarvesterPluginFactory->GetPluginInfos();
   531 	RPointerArray<CHarvesterPluginInfo>& hpiArray = iHarvesterPluginFactory->GetPluginInfos();
   534 	const TInt hpiArrayCount( hpiArray.Count() );
   532 	const TInt hpiArrayCount( hpiArray.Count() );
   570             WRITELOG1( "CHarvesterAO::HandleUnmount() remove from plugins = %d", removed);
   568             WRITELOG1( "CHarvesterAO::HandleUnmount() remove from plugins = %d", removed);
   571             TRAP_IGNORE( iHarvesterEventManager->DecreaseItemCountL( EHEObserverTypePlaceholder, removed ) );
   569             TRAP_IGNORE( iHarvesterEventManager->DecreaseItemCountL( EHEObserverTypePlaceholder, removed ) );
   572             TRAP_IGNORE( iHarvesterEventManager->DecreaseItemCountL( EHEObserverTypeMMC, removed ) );
   570             TRAP_IGNORE( iHarvesterEventManager->DecreaseItemCountL( EHEObserverTypeMMC, removed ) );
   573 		    }
   571 		    }
   574 		}
   572 		}
       
   573 	
       
   574     iMediaIdUtil->RemoveMediaId( aMediaId );
   575 	
   575 	
   576 	// resume harvesting from last state
   576 	// resume harvesting from last state
   577     if( !iRamFull && !iDiskFull )
   577     if( !iRamFull && !iDiskFull )
   578         {
   578         {
   579         // resume monitoring
   579         // resume monitoring
   819 
   819 
   820 		CMdENamespaceDef& defNS = iMdESession->GetDefaultNamespaceDefL();
   820 		CMdENamespaceDef& defNS = iMdESession->GetDefaultNamespaceDefL();
   821 		CMdEObjectDef& mdeObjectDef = defNS.GetObjectDefL( objDefStr );
   821 		CMdEObjectDef& mdeObjectDef = defNS.GetObjectDefL( objDefStr );
   822 
   822 
   823 		CMdEObject* mdeObject = iMdESession->NewObjectL( mdeObjectDef, hd->Uri() );
   823 		CMdEObject* mdeObject = iMdESession->NewObjectL( mdeObjectDef, hd->Uri() );
       
   824 		CleanupStack::PushL( mdeObject );
   824 		
   825 		
   825 		CPlaceholderData* phData = NULL;
   826 		CPlaceholderData* phData = NULL;
   826 
   827 
   827 		if( hd->TakeSnapshot() )
   828 		if( hd->TakeSnapshot() )
   828 			{
   829 			{
   954 			hd->SetObjectType( ENormal );
   955 			hd->SetObjectType( ENormal );
   955 			}
   956 			}
   956 		
   957 		
   957 		hd->SetMdeObject( mdeObject );
   958 		hd->SetMdeObject( mdeObject );
   958 		
   959 		
   959 		mdeObjectArray.Append( mdeObject );
   960 		// Ownership of mdeObject transferred to the array
       
   961 		mdeObjectArray.AppendL( mdeObject );
   960 		
   962 		
   961 	    CleanupStack::PopAndDestroy( phData );
   963 	    CleanupStack::PopAndDestroy( phData );
       
   964 	    
       
   965 	    CleanupStack::Pop( mdeObject );
   962 		
   966 		
   963 		iReadyPHArray.Append( hd );
   967 		iReadyPHArray.Append( hd );
   964 		iPHArray.Remove( i );
   968 		iPHArray.Remove( i );
   965         i--;
   969         i--;
   966         endindex--;
   970         endindex--;
  1257 // ---------------------------------------------------------------------------
  1261 // ---------------------------------------------------------------------------
  1258 //
  1262 //
  1259 void CHarvesterAO::HandleSessionOpened( CMdESession& aSession, TInt aError )
  1263 void CHarvesterAO::HandleSessionOpened( CMdESession& aSession, TInt aError )
  1260     {
  1264     {
  1261     WRITELOG( "HarvesterThread::HandleSessionOpened()" );
  1265     WRITELOG( "HarvesterThread::HandleSessionOpened()" );
       
  1266     
  1262     if ( KErrNone == aError )
  1267     if ( KErrNone == aError )
  1263         {
  1268         {
  1264         TBool isTNMDaemonEnabled( EFalse );
  1269         TBool isTNMDaemonEnabled( EFalse );
  1265         TRAP_IGNORE( CHarvesterCenRepUtil::IsThumbnailDaemonEnabledL( isTNMDaemonEnabled ) );
  1270         TRAP_IGNORE( CHarvesterCenRepUtil::IsThumbnailDaemonEnabledL( isTNMDaemonEnabled ) );
  1266 
  1271 
  1277         else
  1282         else
  1278         	{
  1283         	{
  1279             WRITELOG( "CHarvesterAO::HandleSessionOpened() - error creating mde harvester session" );
  1284             WRITELOG( "CHarvesterAO::HandleSessionOpened() - error creating mde harvester session" );
  1280         	}
  1285         	}
  1281 
  1286 
       
  1287         // Setting up context Engine (initialization is ready when ContextInitializationStatus -callback is called)
       
  1288         TRAP( errorTrap, iCtxEngine = CContextEngine::GetInstanceL( this ) ); // Create the context engine 
       
  1289         if ( errorTrap != KErrNone )
       
  1290                 {
       
  1291                 WRITELOG( "CHarvesterAO::HandleSessionOpened() - Context Engine creation failed" );
       
  1292                 }
       
  1293         
  1282 #ifdef _DEBUG        
  1294 #ifdef _DEBUG        
  1283         TRAP( errorTrap, iMdeObjectHandler = CMdeObjectHandler::NewL( *iMdESession ) );
  1295         TRAP( errorTrap, iMdeObjectHandler = CMdeObjectHandler::NewL( *iMdESession ) );
  1284         if ( errorTrap != KErrNone )
  1296         if ( errorTrap != KErrNone )
  1285                 {
  1297                 {
  1286                 WRITELOG( "CHarvesterAO::HandleSessionOpened() - ObjectHandler creation failed" );
  1298                 WRITELOG( "CHarvesterAO::HandleSessionOpened() - ObjectHandler creation failed" );
  1311         TRAP_IGNORE( iMdeObjectHandler = CMdeObjectHandler::NewL( *iMdESession ) );
  1323         TRAP_IGNORE( iMdeObjectHandler = CMdeObjectHandler::NewL( *iMdESession ) );
  1312         TRAP_IGNORE( PreallocateNamespaceL( aSession.GetDefaultNamespaceDefL() ) );
  1324         TRAP_IGNORE( PreallocateNamespaceL( aSession.GetDefaultNamespaceDefL() ) );
  1313         TRAP_IGNORE( LoadMonitorPluginsL() );
  1325         TRAP_IGNORE( LoadMonitorPluginsL() );
  1314         TRAP_IGNORE( StartComposersL() );        
  1326         TRAP_IGNORE( StartComposersL() );        
  1315 #endif
  1327 #endif
  1316 
       
  1317         if ( iContextEngineInitialized )
       
  1318             {
       
  1319             iCtxEngine->SetMdeSession( iMdESession );
       
  1320             }
       
  1321 
  1328 
  1322             // Starting monitor plugins
  1329             // Starting monitor plugins
  1323         StartMonitoring();
  1330         StartMonitoring();
  1324 
  1331 
  1325         TRAP( errorTrap, iDiskFullNotifier = CMdSHarvesterDiskspaceObserverAO::NewL( *this, KDiskFullThreshold, KMdsSqlDbDefaultName ) );
  1332         TRAP( errorTrap, iDiskFullNotifier = CMdSHarvesterDiskspaceObserverAO::NewL( *this, KDiskFullThreshold, KMdsSqlDbDefaultName ) );
  1411 // ---------------------------------------------------------------------------
  1418 // ---------------------------------------------------------------------------
  1412 // HandleSessionError
  1419 // HandleSessionError
  1413 // ---------------------------------------------------------------------------
  1420 // ---------------------------------------------------------------------------
  1414 //
  1421 //
  1415 void CHarvesterAO::HandleSessionError( CMdESession& /*aSession*/, TInt aError )
  1422 void CHarvesterAO::HandleSessionError( CMdESession& /*aSession*/, TInt aError )
  1416     {    
  1423     {       
  1417     if ( KErrNone != aError )
  1424     if ( KErrNone != aError )
  1418         {
  1425         {
  1419         WRITELOG1( "HarvesterThread::HandleSessionError() - Error: %d!", aError );        
  1426         WRITELOG1( "HarvesterThread::HandleSessionError() - Error: %d!", aError );        
  1420         }
  1427         }
  1421     }
  1428     }
  2821             }
  2828             }
  2822         }
  2829         }
  2823     return EFalse;
  2830     return EFalse;
  2824     }
  2831     }
  2825 
  2832 
       
  2833 void CHarvesterAO::RemoveBlacklistedFile( CHarvesterData* aItem )
       
  2834     {
       
  2835     if( iMdeSessionInitialized )
       
  2836         {
       
  2837         TRAP_IGNORE( iMdESession->RemoveObjectL( aItem->Uri() ) );
       
  2838         }
       
  2839     }
       
  2840