featuremgmt/featuremgr/src/serverexe/featmgrserver.cpp
changeset 14 15018f1726c7
parent 0 08ec8eefde2f
child 15 3eacc0623088
equal deleted inserted replaced
1:c084286672be 14:15018f1726c7
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    33 _LIT( KPanicCategory, "EnhancedFeatMgrServer" );
    33 _LIT( KPanicCategory, "EnhancedFeatMgrServer" );
    34 #else
    34 #else
    35 _LIT( KPanicCategory, "FeatMgrServer" );
    35 _LIT( KPanicCategory, "FeatMgrServer" );
    36 #endif // EXTENDED_FEATURE_MANAGER_TEST
    36 #endif // EXTENDED_FEATURE_MANAGER_TEST
    37 
    37 
    38 // LOCAL FUNCTION PROTOTYPES
       
    39 TInt E32Main(); // Process entry point
       
    40 
       
    41 // ============================ MEMBER FUNCTIONS ===============================
    38 // ============================ MEMBER FUNCTIONS ===============================
    42 
    39 
    43 // -----------------------------------------------------------------------------
    40 // -----------------------------------------------------------------------------
    44 // CFeatMgrServer::CFeatMgrServer
    41 // CFeatMgrServer::CFeatMgrServer
    45 // C++ default constructor can NOT contain any code, that
    42 // C++ default constructor can NOT contain any code, that
    47 // -----------------------------------------------------------------------------
    44 // -----------------------------------------------------------------------------
    48 //
    45 //
    49 CFeatMgrServer::CFeatMgrServer( const TInt aPriority, const TServerType aType  )
    46 CFeatMgrServer::CFeatMgrServer( const TInt aPriority, const TServerType aType  )
    50     :
    47     :
    51     CPolicyServer( aPriority, KFeatMgrPlatSecPolicy, aType ), iBurState(this),
    48     CPolicyServer( aPriority, KFeatMgrPlatSecPolicy, aType ), iBurState(this),
       
    49     iBURInProgress(EFalse),
    52     iPluginsReady(EFalse), 
    50     iPluginsReady(EFalse), 
    53     iPluginsDeleted( EFalse ),
    51     iPluginsDeleted( EFalse ),
    54     iPendingRequests( ETrue ),
    52     iPendingRequests( ETrue ),
    55     iFeaturesReady(EFalse)
    53     iFeaturesReady(EFalse)
    56     
    54     
   437 TBool CFeatMgrServer::PluginsReady() const
   435 TBool CFeatMgrServer::PluginsReady() const
   438     {
   436     {
   439     FUNC_LOG
   437     FUNC_LOG
   440     return(iPluginsReady);
   438     return(iPluginsReady);
   441    	}
   439    	}
       
   440 
       
   441 // -----------------------------------------------------------------------------
       
   442 // CFeatMgrServer::BackupIsInProgress()
       
   443 // -----------------------------------------------------------------------------
       
   444 TBool CFeatMgrServer::BURIsInProgress() const
       
   445     {
       
   446     FUNC_LOG
       
   447     return(iBURInProgress);
       
   448     }
   442    	
   449    	
   443 // -----------------------------------------------------------------------------
   450 // -----------------------------------------------------------------------------
   444 // CFeatMgrServer::ServicePendingRequests()
   451 // CFeatMgrServer::ServicePendingRequests()
   445 // -----------------------------------------------------------------------------
   452 // -----------------------------------------------------------------------------
   446 
   453 
   669 	TInt err( KErrNone );
   676 	TInt err( KErrNone );
   670 	
   677 	
   671 	switch( aCurrent )
   678 	switch( aCurrent )
   672 		{
   679 		{
   673 		case( EFeatMgrBURState_BackupStarted ) :
   680 		case( EFeatMgrBURState_BackupStarted ) :
   674 			iPluginsReady = ETrue;
   681 			iBURInProgress = EFalse;
   675 			ServicePendingRequests();
   682 			ServicePendingRequests();
   676 			break;
   683 			break;
   677 		case( EFeatMgrBURState_RestoreStarted ) :
   684 		case( EFeatMgrBURState_RestoreStarted ) :
   678 		    iPluginsReady    = EFalse;
   685 		    iPluginsReady    = EFalse;
   679 		    iPluginsDeleted  = EFalse;
   686 		    iPluginsDeleted  = EFalse;
   699 	}
   706 	}
   700 
   707 
   701 BURStatus CFeatMgrServer::Goto_StartBackupState( BURStatus /* aCurrent */ )
   708 BURStatus CFeatMgrServer::Goto_StartBackupState( BURStatus /* aCurrent */ )
   702 	{
   709 	{
   703 	BURStatus aNewState = EFeatMgrBURState_BackupStarted;  // state++
   710 	BURStatus aNewState = EFeatMgrBURState_BackupStarted;  // state++
   704 	iPluginsReady = EFalse;
   711 	iBURInProgress = ETrue;
   705 	return aNewState;
   712 	return aNewState;
   706 	}
   713 	}
   707 
   714 
   708 BURStatus CFeatMgrServer::Goto_EndBackupState( BURStatus /* aCurrent */  )
   715 BURStatus CFeatMgrServer::Goto_EndBackupState( BURStatus /* aCurrent */  )
   709 	{
   716 	{
   710 	BURStatus aNewState = EFeatMgrBURState_BackupEnded;   // state++
   717 	BURStatus aNewState = EFeatMgrBURState_BackupEnded;   // state++
   711 	
   718 	
   712 	iPluginsReady = ETrue;
   719 	iBURInProgress = EFalse;
   713 	ServicePendingRequests();
   720 	ServicePendingRequests();
   714 	// no error from ServicePendingRequests() is possible
   721 	// no error from ServicePendingRequests() is possible
   715 	
   722 	
   716 	return aNewState;
   723 	return aNewState;
   717 	}
   724 	}
   718 
   725 
   719 BURStatus CFeatMgrServer::Goto_StartRestoreState( BURStatus /* aCurrent */  )
   726 BURStatus CFeatMgrServer::Goto_StartRestoreState( BURStatus /* aCurrent */  )
   720 	{
   727 	{
   721 	// remarkably like Goto_StartBackupState
   728 	// remarkably like Goto_StartBackupState
   722 	BURStatus aNewState = EFeatMgrBURState_RestoreStarted;  // state++
   729 	BURStatus aNewState = EFeatMgrBURState_RestoreStarted;  // state++
   723 	iPluginsReady = EFalse;
   730 	iBURInProgress = ETrue;
   724 	return aNewState;
   731 	return aNewState;
   725 	}
   732 	}
   726 
   733 
   727 BURStatus CFeatMgrServer::Goto_EndRestoreState( BURStatus /* aCurrent */  )
   734 BURStatus CFeatMgrServer::Goto_EndRestoreState( BURStatus /* aCurrent */  )
   728 	{
   735 	{
   729 	BURStatus aNewState = EFeatMgrBURState_Error;   // fail safe
   736 	BURStatus aNewState = EFeatMgrBURState_Error;   // fail safe
   730 	TInt err( KErrNone );
   737 	TInt err( KErrNone );
   731 	
   738 	iBURInProgress = EFalse;
   732     iPluginsReady    = EFalse;
   739 	iPluginsReady    = EFalse;
   733     iPluginsDeleted  = EFalse;
   740     iPluginsDeleted  = EFalse;
   734     iPendingRequests = ETrue;
   741     iPendingRequests = ETrue;
   735     iFeaturesReady   = EFalse;
   742     iFeaturesReady   = EFalse;
   736 
   743 
   737 	// re-read the new features
   744 	// re-read the new features
   847         }
   854         }
   848 
   855 
   849     return;
   856     return;
   850 }
   857 }
   851 
   858 
   852 
       
   853 // ============================= LOCAL FUNCTIONS ===============================
       
   854 
       
   855 // -----------------------------------------------------------------------------
       
   856 // Function that starts the FeatMgrServer.
       
   857 // -----------------------------------------------------------------------------
       
   858 //
       
   859 static void RunServerL()
       
   860     {
       
   861     FUNC_LOG
       
   862 
       
   863     // Naming the server thread after the startup helps to debug panics
       
   864     User::LeaveIfError( User::RenameProcess( KServerProcessName ) );
       
   865     
       
   866     User::LeaveIfError( User::RenameThread( KServerProcessName ) );
       
   867      
       
   868     // Create and install the active scheduler we need
       
   869     CActiveScheduler* scheduler = new(ELeave) CActiveScheduler;
       
   870     CleanupStack::PushL( scheduler );
       
   871     
       
   872     CActiveScheduler::Install( scheduler );
       
   873     
       
   874     // Now we are ready to instantiate the actual CServer2 instance
       
   875     CFeatMgrServer* server = CFeatMgrServer::NewLC( KServerCActivePriority );
       
   876 
       
   877 	// Initialisation complete, now signal the client
       
   878 	RProcess::Rendezvous(KErrNone);
       
   879 
       
   880     INFO_LOG( "RunServerL() - Starting scheduler..." );
       
   881 
       
   882 	// Ready to run
       
   883 	CActiveScheduler::Start();
       
   884 
       
   885     INFO_LOG( "RunServerL() - Scheduler stopped" );
       
   886 
       
   887 	// Cleanup the server and scheduler
       
   888 	CleanupStack::PopAndDestroy( server );
       
   889 	CleanupStack::PopAndDestroy( scheduler );
       
   890     }
       
   891 
       
   892 // -----------------------------------------------------------------------------
       
   893 // Main function
       
   894 // -----------------------------------------------------------------------------
       
   895 //
       
   896 TInt E32Main()
       
   897     {
       
   898     FUNC_LOG
       
   899 
       
   900 	__UHEAP_MARK;
       
   901 
       
   902 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
   903 	TInt ret = KErrNoMemory;
       
   904 
       
   905 	if ( cleanup )
       
   906 		{
       
   907 		TRAP( ret, RunServerL() );
       
   908 		delete cleanup;
       
   909 		}
       
   910 
       
   911 	__UHEAP_MARKEND;
       
   912 
       
   913 	return ret;
       
   914     }
       
   915 
       
   916 //  End of File  
   859 //  End of File