featuremgmt/featuremgr/src/serverexe/featmgrserver.h
changeset 0 08ec8eefde2f
child 6 5ffdb8f2067f
equal deleted inserted replaced
-1:000000000000 0:08ec8eefde2f
       
     1 /*
       
     2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #ifndef FEATMGRSERVER_H
       
    22 #define FEATMGRSERVER_H
       
    23 
       
    24 //  INCLUDES
       
    25 #include <e32svr.h>
       
    26 #include <featmgr/featurecmn.h>
       
    27 #include <babackup.h>
       
    28 #include "featmgrclientserver.h"
       
    29 #include <featmgr/featureinfoplugin.h>
       
    30 #include "featmgrtimer.h"
       
    31 #include "featmgrfeatureregistry.h"
       
    32 #include "burstate.h"
       
    33 
       
    34 // FORWARD DECLARATIONS
       
    35 class CFeatMgrPluginHandler;
       
    36 class CFeatMgrFeatureRegistry;
       
    37 
       
    38 enum TFeatureSupport
       
    39     {
       
    40     EFeatureSupportDisable = EFalse,
       
    41     EFeatureSupportEnable = ETrue,
       
    42     EFeatureSupportUntouch = 2
       
    43     };
       
    44 
       
    45 // CLASS DECLARATIONS
       
    46 
       
    47 #ifdef EXTENDED_FEATURE_MANAGER_TEST
       
    48 /**
       
    49  Auto shutdown class (standard pattern) for testing purposes 
       
    50 
       
    51 */
       
    52 class CShutdown : public CTimer
       
    53 	{
       
    54 	enum TMemScanShutdown
       
    55 	    {
       
    56 	    EMemScanServShutdownDelay=0x200000
       
    57 	    };
       
    58 public:
       
    59 	inline CShutdown();
       
    60 	inline void ConstructL();
       
    61 	inline void Start();
       
    62 private:
       
    63 	void RunL();
       
    64 	};
       
    65 #endif // EXTENDED_FEATURE_MANAGER_TEST
       
    66 
       
    67 /**
       
    68   Feature Manager server implementation 
       
    69 
       
    70 */
       
    71 NONSHARABLE_CLASS(CFeatMgrServer) : 
       
    72     public CPolicyServer,
       
    73     public MFeatMgrTimerCallback,
       
    74     public MFeatMgrRegistryObserver,
       
    75     private MBackupOperationObserver, 
       
    76     private MBackupObserver    
       
    77     {
       
    78     public:  // Constructors and destructor
       
    79         
       
    80         /**
       
    81          Creates a new server. Newly created instance is left in the cleanup stack.
       
    82          @param aPriority Priority of the server.
       
    83          @return A pointer to the created object.
       
    84         */
       
    85         static CFeatMgrServer* NewLC( const TInt aPriority );
       
    86 
       
    87         /**
       
    88          Destructor.
       
    89         */
       
    90         virtual ~CFeatMgrServer();
       
    91 
       
    92     public: // New functions      
       
    93            
       
    94         /**
       
    95          Called by plugin handler to inform feature info to server.
       
    96         */ 
       
    97         void FeatureInfoL( RArray<FeatureInfoCommand::TFeature>& aFeatureList, 
       
    98                            CFeatMgrPluginHandler* aPluginHandler );
       
    99 
       
   100         /**
       
   101          Called by plugin handler to inform feature info to server.
       
   102         */ 
       
   103         void FeatureInfoL( RFeatureArray& aFeatureList, CFeatMgrPluginHandler* aPluginHandler );
       
   104 
       
   105         /**
       
   106          Returns ETrue if all plugins are ready and 
       
   107          Feature info received. 
       
   108          Else returns EFalse.
       
   109         
       
   110          @return feature support status
       
   111         */
       
   112         TBool PluginsReady() const;
       
   113 
       
   114 #ifdef EXTENDED_FEATURE_MANAGER_TEST
       
   115         /**
       
   116          Called by session to indicate addition of session.
       
   117         */ 
       
   118         void AddSession();
       
   119         
       
   120         /**
       
   121          Called by session to indicate end of session.
       
   122         */ 
       
   123         void DropSession();
       
   124 #endif // EXTENDED_FEATURE_MANAGER_TEST
       
   125 
       
   126     public: // Functions from base classes
       
   127         
       
   128     	// From MFeatMgrTimerCallback    	
       
   129     	virtual void TimerFired();
       
   130 
       
   131         // From MFeatMgrRegistryObserver    	
       
   132     	virtual void HandleFeatureChange( TFeatureServerEntry& aFeature, TFeatureChangeType aType );
       
   133         
       
   134        	/**
       
   135 		Function from MBackupOperationObserver in response to a change in the state of the backup and
       
   136 		restore operation(s). This function is called to notify the Feature Manager that a backup and 
       
   137 		restore operation is in progress. However, this is not the whole story, and notification using 
       
   138 		the callback ChangeLockFileL() is also used.
       
   139 		@param			aBackupOperationAttributes The current state of the backup operation. Made up of 
       
   140 		                MBackupObserver::TFileLockFlags and TOperationType types.
       
   141 		@see			MBackupObserver::TFileLockFlags 
       
   142 		@see			TOperationType.
       
   143 	    */
       
   144         void HandleBackupOperationEventL(const TBackupOperationAttributes& aBackupOperationAttributes);
       
   145 
       
   146        	/**
       
   147 		 * Function from MBackupObserver in response to a change in the state of the file to be subject to
       
   148 		 * the BUR operation. This function is called to notify the Feature Manager that a filelock has 
       
   149 		 * changed.
       
   150 		 * @param aFileName name of the file whose status has changed.
       
   151 		 * @param	aFlags the lock status information for the file. 
       
   152 	     */
       
   153         void ChangeFileLockL( const TDesC& aFileName, TFileLockFlags aFlags );
       
   154         
       
   155     public:
       
   156 
       
   157     /**
       
   158      * Feature manager state machine function.
       
   159      * This returns the feature manager back to a normal state.
       
   160      * @param BURStatus current state
       
   161      * @return BURStatus the next state
       
   162      */ 
       
   163     BURStatus Goto_NormalState( BURStatus aCurrent );
       
   164     /**
       
   165      * Feature manager state machine function.
       
   166      * This will put the Feature Manager into the "start backup" state. Where the Feature Manager
       
   167      * is expecting the BUR backup to start.
       
   168      * @param BURStatus current state
       
   169      * @return BURStatus the next state
       
   170      */ 
       
   171     BURStatus Goto_StartBackupState( BURStatus aCurrent );
       
   172     /**
       
   173      * Feature manager state machine function.
       
   174      * This will put the Feature Manager into the "end backup" state. Where the Feature Manager
       
   175      * is expecting the BUR backup has just ended, and it is required to return itself to a 
       
   176      * normal operating mode.
       
   177      * @param BURStatus current state
       
   178      * @return BURStatus the next state
       
   179      */ 
       
   180     BURStatus Goto_EndBackupState( BURStatus aCurrent );
       
   181     /**
       
   182      * Feature manager state machine function.
       
   183      * This will put the Feature Manager into the "start restore" state. Where the Feature Manager
       
   184      * is expecting the BUR restore operation to start.
       
   185      * @param BURStatus current state
       
   186      * @return BURStatus the next state
       
   187      */ 
       
   188     BURStatus Goto_StartRestoreState( BURStatus aCurrent );
       
   189     /**
       
   190      * Feature manager state machine function.
       
   191      * This will put the Feature Manager into the "end restore" state. Where the Feature Manager
       
   192      * is expecting the BUR restore operation has just ended, and it is required to return itself 
       
   193      * to a normal operating mode.
       
   194      * @param BURStatus current state
       
   195      * @return BURStatus the next state
       
   196      */ 
       
   197     BURStatus Goto_EndRestoreState( BURStatus aCurrent );
       
   198     /**
       
   199      * Feature manager state machine function.
       
   200      * This will return the Feature Manager from its current state, and into a "safe" state whereby
       
   201      * a normal operating mode is possible again. This is an error recovery function.
       
   202      * @param BURStatus current state
       
   203      * @return BURStatus the next state
       
   204      */ 
       
   205     BURStatus Goto_ErrorState( BURStatus aCurrent );
       
   206     
       
   207     private:
       
   208 
       
   209     /* Clears the feature array ready to re-populate it during a restore operation */
       
   210     void ClearFeatures( void );
       
   211     /* Reloads the feature array and merges features during a restore operation */
       
   212     void LoadFeaturesL( void );
       
   213     /* Handles any outstanding notifications after a restore operation */
       
   214     void HandleRestoredNotificationsL( void );
       
   215     
       
   216     private:
       
   217 
       
   218         /**
       
   219          C++ constructor.
       
   220         */
       
   221         CFeatMgrServer( const TInt aPriority, 
       
   222                         const TServerType aType = EUnsharableSessions );
       
   223         /**
       
   224          By default Symbian 2nd phase constructor is private.
       
   225         */
       
   226         void ConstructL();
       
   227         
       
   228         /**
       
   229          Creates a new session when client connects.
       
   230          @param aVersion Version
       
   231          @param aMessage 'connect' message from the client
       
   232          @return Pointer to created session or leaves with codes
       
   233                  KErrNotSupported if versions does not match
       
   234                  KErrNoMemory if creation of new session fails.
       
   235         */
       
   236         CSession2* NewSessionL( const TVersion& aVersion,
       
   237                                 const RMessage2& aMessage ) const;
       
   238         /**
       
   239          Panics the server thread
       
   240          @param aCategory Panicer's id 
       
   241          @param aPanic    Reason of panic 
       
   242          @return void
       
   243         */
       
   244         void Panic( const TDesC& aCategory, const TInt aReason );
       
   245         
       
   246         /**
       
   247          Lists and loads Feature Manager plugins.
       
   248         */
       
   249         TBool LoadPluginsL();
       
   250         
       
   251         /**
       
   252          Deletes plugin handler if feature info is ready.
       
   253         */
       
   254         void DeletePlugins();
       
   255         
       
   256         /**
       
   257          Check whether plugins have finished processing.
       
   258         */
       
   259         void CheckPluginsReadyL();
       
   260         
       
   261         /**
       
   262          Calls ServicePendingRequestsL of sessions  
       
   263         */
       
   264         void ServicePendingRequests();
       
   265         
       
   266     private:    // Data
       
   267         
       
   268         // Timer pointer.
       
   269         CFeatMgrTimer* iTimer;     
       
   270 
       
   271         CBurState iBurState;
       
   272         // ETrue when feature info received from all plugins
       
   273         TBool iPluginsReady;
       
   274                 
       
   275         // Struct to contain information of found Feature Manager plugins
       
   276         struct SFeatMgrPluginInfo
       
   277             {
       
   278             // Plugin handler of the plugin
       
   279             CFeatMgrPluginHandler*  iPluginHandler;
       
   280             // ETrue if feature info received from plugin handler
       
   281             TBool iPluginReady;
       
   282             };
       
   283 	    
       
   284 	    // Array of found Feature Manager plugins
       
   285 	    RArray<SFeatMgrPluginInfo>  iPluginList;
       
   286 	    	    
       
   287         // ETrue if all plugin handlers are deleted
       
   288         TBool  iPluginsDeleted;
       
   289         
       
   290         // ETrue if ServicePendingRequest not called yet.
       
   291         TBool iPendingRequests;
       
   292         
       
   293         // File server session
       
   294         RFs iFs;         
       
   295 
       
   296         // ETrue when iPluginsReady is ETrue and all feature files have been read. 
       
   297         TBool iFeaturesReady;
       
   298 
       
   299         CFeatMgrFeatureRegistry* iRegistry;
       
   300 
       
   301         // Backup Notification
       
   302         TUint32                   iBackupFlag;
       
   303         CBaBackupSessionWrapper * iBackupNotification;
       
   304 
       
   305 #ifdef EXTENDED_FEATURE_MANAGER_TEST
       
   306         TInt iSessionCount;
       
   307         CShutdown iShutdown;
       
   308 #endif
       
   309     };
       
   310 
       
   311 #endif      // FEATMGRSERVER_H 
       
   312             
       
   313 // End of File