lowlevellibsandfws/pluginfw/Framework/frame/Registrar.h
changeset 0 e4d67989cc36
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Contains the definition of the CRegistrar class.
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @internalComponent
       
    20  @file 
       
    21 */
       
    22 
       
    23 #ifndef __REGISTRAR_H__
       
    24 #define __REGISTRAR_H__
       
    25 
       
    26 #include <f32file.h>
       
    27 #include <barsread2.h> // RResourceReader
       
    28 #include "DiscovererObserver.h"
       
    29 #include "BackupNotifierObserver.h"
       
    30 #include "RegistryData.h"
       
    31 #include "StartupStateObserver.h"
       
    32 #include "callback.h"
       
    33 class CDiscoverer;
       
    34 class CBackupNotifier;
       
    35 class MRegistrarObserver;
       
    36 class CEComCachedDriveInfo;
       
    37 
       
    38 /**
       
    39 	@internalComponent
       
    40 	@since 7.0
       
    41 	Responsible for managing Interface Implementaion Collection registration
       
    42 	(adding and removing entries).
       
    43  */
       
    44 
       
    45 class CRegistrar : public CBase, public MStartupStateObserver, private MDiscovererObserver, private MBackupNotifierObserver
       
    46 {
       
    47 public:
       
    48 
       
    49 /** State declaration for CRegistrar */	
       
    50 	enum TRegistrarState
       
    51 	{
       
    52 	/** Undefined state*/
       
    53 	EReg_Undefined,
       
    54 	/** Internalization/Externalization and Discovery in progress */
       
    55 	EReg_StartupInProgess,
       
    56 	/** Internalization/Externalization and Discovery complete */
       
    57 	EReg_StartupComplete
       
    58 	};
       
    59 	
       
    60 /**
       
    61 	@fn				static CRegistrar* NewL(CRegistryData& aRegistry, MRegistrarObserver& aRegistrarObserver, RFs& aFs)
       
    62 	Intended Usage	: Standardised safe construction which leaves nothing 
       
    63 					on the cleanup stack.
       
    64 	Error Condition	: Cannot fully construct because of memory limitations.	
       
    65 	@leave			KErrNoMemory
       
    66 	@since			7.0
       
    67 	@param			aRegistry A reference to the registry data management class.
       
    68 	@param			aRegistrarObserver A reference to the registrar observer class.
       
    69 	@param			aFs A reference to an connected file server session.
       
    70 	@return			CRegistrar* A pointer to the new class
       
    71 	@pre 			None
       
    72 	@post			CRegistrar is fully constructed, 
       
    73 					and initialised.
       
    74  */
       
    75 	
       
    76 	static CRegistrar* NewL(CRegistryData& aRegistry, MRegistrarObserver& aRegistrarObserver, RFs& aFs);
       
    77 
       
    78 /**
       
    79 	@fn				~CRegistrar()
       
    80 	Intended Usage	: Standard default d'tor
       
    81 	Error Condition	: None
       
    82 	@since			7.0
       
    83 	@pre 			None
       
    84 	@post			CRegistrar is totally destroyed
       
    85  */
       
    86 	
       
    87 	~CRegistrar();
       
    88 
       
    89 /**
       
    90 	@fn				Enable(TUid aImplementationUid)
       
    91 	Intended Usage	:Allow the specified Interface Implementation to be used.
       
    92 	Error Condition	: KErrEnableFailed The enable call failed.
       
    93 	@since			7.0	:
       
    94 	@param			aImplementationUid The Interface Implementation to enable.
       
    95 	@return			KErrNone on success, KErrEnableFailed otherwise.
       
    96 	@pre 			CRegistrar is fully constructed
       
    97 	@post			The interface implementation identified by 
       
    98 					the UID	is made available for use.
       
    99  */
       
   100 	
       
   101 	TInt Enable(TUid aImplementationUid);
       
   102 
       
   103 /**
       
   104 	@fn				Disable(TUid aImplementationUid)
       
   105 	Intended Usage	:Stop the specified interface implementation 
       
   106 					from being used.
       
   107 	Error Condition	: KErrDisableFailed The disable call failed.
       
   108 	@since			7.0	:
       
   109 	@param			aImplementationUid The Interface Implementation to disable.
       
   110 	@return			KErrNone on success, KErrDisableFailed otherwise.
       
   111 	@pre 			CRegistrar is fully constructed
       
   112 	@post			The interface implementation identified by 
       
   113 					the UID	is no longer available for use.
       
   114  */	
       
   115 	
       
   116 	TInt Disable(TUid aImplementationUid);
       
   117 
       
   118 /**
       
   119 	@fn				Resume()
       
   120 	Intended Usage	: Overload of the MBackupNotifierObserver method.
       
   121 					Allow registration of new Interface Implementation Collections
       
   122 					to begin again.
       
   123 	Error Condition	: KErrResumeFailed The registration resume failed.
       
   124 	@since			7.0	:
       
   125 	@return			KErrNone on success, KErrResumeFailed otherwise.
       
   126 	@pre 			CRegistrar is fully constructed
       
   127 	@post			Registration suspension is cancelled.
       
   128  */	
       
   129 	
       
   130 	TInt Resume();
       
   131 
       
   132 /**
       
   133 	@fn				Suspend()
       
   134 	Intended Usage	: Overload of the MBackupNotifierObserver method.
       
   135 					Suspend registration of new Interface Implementation Collections.
       
   136 	Error Condition	: KErrSuspendFailed The registration suspension failed.
       
   137 	@since			7.0	:
       
   138 	@return			KErrNone on success, KErrSuspendFailed otherwise.
       
   139 	@pre 			CRegistrar is fully constructed
       
   140 	@post			Registration is suspended.
       
   141  */	
       
   142 	
       
   143 	TInt Suspend();
       
   144 	
       
   145 /** 
       
   146 	@fn				ProcessSSAEventL()
       
   147 	Intended Usage	:Overload of MStartupStateObserver method.
       
   148 					Used by CServerStratupMgr to notify the objects 
       
   149 					of the start-up state changes.
       
   150 	@param 			aKnownState the startup state passing into the CRegistar.
       
   151 	@pre 			CRegistrar is fully constructed.
       
   152 	@post 			CRegistrar is notified of the start-up state changes.
       
   153 */
       
   154 	void ProcessSSAEventL(TStartupStateIdentifier aKnownState);
       
   155 
       
   156 /** Install a callback function to receive notification of SWI status
       
   157 changes. Note that the callback is passed along to CDsicoverer which
       
   158 does the SWI monitoring.
       
   159 @param aCallBack the callback function to install.
       
   160 */
       
   161 	void InstallSwiEventCallBack(const TCallBackWithArg& aCallBack);
       
   162 
       
   163 /** Install a callback function to receive notification of BUR status
       
   164 changes. Note that the callback is passed along to CDsicoverer which
       
   165 does the BUR monitoring.
       
   166 @param aCallBack the callback function to install.
       
   167 */
       
   168 	void InstallBurEventCallBack(const TCallBackWithArg& aCallBack);
       
   169 
       
   170 private:
       
   171 // MDiscovererObserver method implementations
       
   172 /**
       
   173 	@fn				DiscoveriesBegin()
       
   174 	Intended Usage	:Overload of the MDiscovererObserver callback method.
       
   175 					The cue that a registry update is about to occur.
       
   176 	Error Condition	: None.
       
   177 	@since			7.0	:
       
   178 	@pre 			CRegistrar is fully constructed
       
   179 	@post			The Registry data manager has been informed that its internal
       
   180 					data is out of date.
       
   181  */
       
   182 	
       
   183 	void DiscoveriesBegin();
       
   184 
       
   185 /**
       
   186 	@fn				RegisterDiscoveryL(const TDriveName& aDrive,CPluginBase*& aDirEntry,TBool aAnyDllDiscovered)
       
   187 	Intended Usage	:Overload of the MDiscovererObserver callback method.
       
   188 					Adds the specified Interface Implementation Collection to the 
       
   189 					registry.
       
   190 	Error Condition	: Leaves with an error code.
       
   191 	@leave  		KErrNoMemory, KErrRegistrationFailed.
       
   192 	@since			9.1	:
       
   193 	@param			aDrive, the drive containing this entry
       
   194 	@param			aDirEntry The directory entry to register.
       
   195 	@param			aAnyDllDiscovered A flag to tell if any DLL is discovered in the drive.
       
   196 	@pre 			CRegistrar is fully constructed
       
   197 	@post			The Interface Implementation Collection identified by the directory entry 
       
   198 					is registered.
       
   199  */
       
   200 	
       
   201 	void RegisterDiscoveryL(const TDriveName& aDrive,CPluginBase*& aDirEntry, TBool aAnyDllDiscovered);
       
   202 
       
   203 /**
       
   204 	@fn				UpdateRegistryL(TDriveUnit& driveUnit, TUid aDllUid, const TTime& aModified, TInt& aRegistryDriveIndex)
       
   205 	Intended Usage	:Checks if the Registry must be updated or not.
       
   206 	Error Condition	: Leaves with an error code.
       
   207 	@leave			KErrNoMemory, KErrRegistrationFailed.
       
   208 	@since			9.0	:
       
   209 	@param			aDrive The drive the registry data has been found on
       
   210 	@param			aDllUid The interface implementation collection data to add. 
       
   211 					CRegistryData takes ownership of this object
       
   212 					so it should not be on the CleanupStack.
       
   213 	@param			aModified The date of the last modification of the Interface 
       
   214 					Implementation Collection. 
       
   215 	@param			aRegistryDriveIndex An output providing index within the registry data 
       
   216 					for the branch that the registry entry was found within. 
       
   217 	@return			ETrue if the Interface Implementation Collection already has a registry entry and
       
   218 					must be updated.
       
   219 					EFalse otherwise.
       
   220 	@pre 			CRegistrar is fully constructed
       
   221 	@post			No change to object..
       
   222  */
       
   223 	TBool UpdateRegistryL(TDriveUnit& driveUnit, TUid aDllUid, const TTime& aModified, TInt& aRegistryDriveIndex);
       
   224 
       
   225 /**
       
   226 	@fn				DiscoveriesComplete(TBool aSuccessful,TPluginProcessingTypeIdentifier aProcessingType)
       
   227 	Intended Usage	:Overload of the MDiscovererObserver callback method.
       
   228 	Error Condition	: None.
       
   229 	@since			7.0	:
       
   230 	@param			aSuccessful ETrue indicates the scan completed successfully,
       
   231 					EFalse, that the scan was only partial.
       
   232 	@param			aProcessingType indicates the type of processing for plugins
       
   233 					for ensuring that plugins are not processed multiple times
       
   234 					during start-up phase
       
   235 	@pre 			CRegistrar is fully constructed
       
   236 	@post			The current registry data and the 
       
   237 					internal access indexes have been rebuilt.
       
   238  */
       
   239 	
       
   240 	void DiscoveriesComplete(TBool aSuccessful, TPluginProcessingTypeIdentifier aProcessingType);
       
   241 /**
       
   242 	@fn 			SetDiscoveryFlagL(const TDriveUnit aDrive)
       
   243 	Intended Usage	:Overload of the MDiscovererObserver callback method
       
   244 					to notify the observer to find the drive has changed.
       
   245 	Error Condition	: None.
       
   246 	@param 			aDrive The identifier of the drive changed.
       
   247 	@pre 			The MDiscovererObserver must be fully constructed
       
   248 	@post			The flag is set.				 
       
   249 */	
       
   250 	void SetDiscoveryFlagL(const TDriveUnit& aDriveUnit);
       
   251 /**
       
   252 	@fn				DriveRemovedL(TDriveUnit aDrive)
       
   253 	Intended Usage	:Overload of the MDiscovererObserver callback method.
       
   254 					The cue to signal the registry that 
       
   255 					the registered Interface Implementation Collections
       
   256 					stored upon the specified drive should no 
       
   257 					longer available for use.
       
   258 	Error Condition	: Leaves with an error code.
       
   259 	@leave  		KErrNoMemory
       
   260 	@since			7.0	:
       
   261 	@param			aDrive	The drive identifier.
       
   262 	@pre 			CRegistrar is fully constructed.
       
   263 	@post			The registered Interface Implementation Collections
       
   264 					stored upon the specified drive are no 
       
   265 					longer available for use.
       
   266  */
       
   267 	
       
   268 	void DriveRemovedL(TDriveUnit aDrive);
       
   269 
       
   270 /**
       
   271 	@fn				DriveReinstatedL(TDriveUnit aDrive)
       
   272 	Intended Usage	:Overload of the MDiscovererObserver callback method.
       
   273 					The cue to signal the registry that 
       
   274 					the registered Interface Implementation Collections
       
   275 					stored upon the specified drive are again
       
   276 					available for use.
       
   277 	Error Condition	: Leaves with an error code.
       
   278 	@leave  		KErrNoMemory, KErrRegistrationFailed.
       
   279 	@since			7.0	:
       
   280 	@param			aDrive	The drive identifier.
       
   281 	@pre 			CRegistrar is fully constructed.
       
   282 	@post			The registered Interface Implementation Collections
       
   283 					stored upon the specified drive are again 
       
   284 					made available for use.
       
   285  */
       
   286 	
       
   287 	void DriveReinstatedL(TDriveUnit aDrive);
       
   288 
       
   289 /**
       
   290 	@fn				NotifiedWithErrorCode(TInt aError)
       
   291 	Intended Usage	:Overload of the MDiscovererObserver callback method.
       
   292 					The notification that the notifier has been activated
       
   293 					with an error status code. The observer should instruct
       
   294 					the notification object how to proceed.
       
   295 	Error Condition	: None.	
       
   296 	@since			7.0	:
       
   297 	@param			aError	The error value recieved by the notifier.
       
   298 	@return			ETrue for ignore error, EFalse otherwise. 
       
   299 	@pre 			CRegistrar is fully constructed.
       
   300 	@post			The status code should be used by the observer to instruct 
       
   301 					the notifier to cease recieving notifications or not.
       
   302  */
       
   303 	
       
   304 	TBool NotifiedWithErrorCode(TInt aError);
       
   305 	
       
   306 /*	
       
   307 	@fn				LanguageChangedL(TBool& aLanguageChanged)
       
   308 	Intended Usage	:Overload of the MDiscovererObserver callback method.
       
   309 					It is used to notify the observer that the language switch notifier has been activated.
       
   310 					The observer should instruct the notification object how to proceed.
       
   311 	Error Condition	: Leaves with an error code.
       
   312 	@leave  		KErrNoMemory
       
   313 	@since			9.3	:
       
   314 	@param			aLanguageChanged the flag returned to indicate whether language downgrade path is changed.
       
   315 	@pre 			The MDiscovererObserver must be fully constructed, and
       
   316 					capable of accepting discoveries for registration.
       
   317 	@post			The CRegistryData will have its iLanguageChanged 
       
   318 					flag set to True when language switch happens.
       
   319 
       
   320 */
       
   321 	void LanguageChangedL(TBool& aLanguageChanged);
       
   322 
       
   323 // Internal methods
       
   324 /**
       
   325 	@internalComponent
       
   326 	@fn				CRegistrar(CRegistryData& aRegistry, MRegistrarObserver& aRegistrarObserver, RFs& aFs)
       
   327 	Intended Usage	: Standardised default c'tor
       
   328 	Error Condition	: None
       
   329 	@since			7.0
       
   330 	@param			aRegistry A reference to the registry data management class.
       
   331 	@param			aRegistrarObserver A reference to the registrar observer class.
       
   332 	@param			aFs A reference to an connected file server session.
       
   333 	@pre 			None
       
   334 	@post			CRegistrar is fully constructed
       
   335  */
       
   336 	
       
   337 	CRegistrar(CRegistryData& aRegistry, MRegistrarObserver& aRegistrarObserver, RFs& aFs);
       
   338 
       
   339 /**
       
   340 	@fn				void ConstructL()
       
   341 	Intended Usage	: Standardised 2nd, (Initialisation) phase of two phase construction.
       
   342 	Error Condition	: None
       
   343 	@leave			None
       
   344 	@since			7.0
       
   345 	@pre 			CRegistrar is fully constructed.
       
   346 	@post			CRegistrar is fully initialised.
       
   347  */
       
   348 	
       
   349 	void ConstructL();
       
   350 
       
   351 /**
       
   352 	@fn				ParseRegistrationDataL(CPluginBase*& aEntry, 
       
   353 										   const TDriveUnit& aDrive, 
       
   354 										   TBool aUpdate, 
       
   355 										   TInt aRegistryDriveIndex)
       
   356 	Intended Usage	: To determine if the directory entry for an Interface Implementation 
       
   357 					Collection entry requires registration.
       
   358 					Parsing the associated resource file information where necessary.
       
   359 	Error Condition	: Parsing fails due to a lack of memory, or a parsing error.
       
   360 	@leave  		KErrNoMemory
       
   361 	@since			9.1
       
   362 	@param			aEntry The directory entry data for the Interface Impplementation Collection.
       
   363 	@param			aDrive The drive the registry data has been found on 
       
   364 	@param			aUpdate A flag indicating if this is an update, or new entry.
       
   365 	@param			aRegistryDriveIndex The index within the registry data 
       
   366 					for the branch that the registry entry was found within. 
       
   367 	@param			aDriveData Output value, which delivers the CDriveData object, needed for the
       
   368 					CDllData object construction.
       
   369 	@pre 			CRegistrar is fully constructed.
       
   370 	@post			The Interface Implementation Collection entry has been processed appropriately.
       
   371 */
       
   372 	
       
   373 	void ParseRegistrationDataL(CPluginBase*& aEntry,
       
   374 								const TDriveUnit& aDrive, 
       
   375 								TBool aUpdate, 
       
   376 								TInt aRegistryDriveIndex, 
       
   377 								CRegistryData::CDriveData* aDriveData);
       
   378 
       
   379 /**
       
   380 	@fn				ParseL(CPluginBase*& aEntry, CRegistryData::CDllData& aDll)
       
   381 	Intended Usage	: Parsing the resource file information associated with an
       
   382 					Interface Implementation Collection for entry into the registry
       
   383 					information.	
       
   384 	Error Condition	: Parsing fails due to a lack of memory, or a parsing error.
       
   385 	@leave  		KErrNoMemory
       
   386 	@since			9.1
       
   387 	@param			aEntry The directory entry data for the Interface Impplementation Collection.
       
   388 	@param			aDll The CDllData information to fill
       
   389 	@pre 			CRegistrar is fully constructed.
       
   390 	@post			The resource file has been parsed and the data added to 'aDll'.
       
   391  */
       
   392 	
       
   393 	void ParseL(CPluginBase*& aEntry,CRegistryData::CDllData& aDll);
       
   394 /**
       
   395 	Intended Usage	: Get resource format version from the resource file
       
   396 	@param			aReader The resource file reader.
       
   397 	@param			aResourceFormatVersion The resource file format version 
       
   398 	@pre 			CRegistrar is fully constructed.
       
   399  */
       
   400 	void GetResourceFormatVersionL(RResourceReader& aReader, TInt& aResourceFormatVersion);
       
   401 /**
       
   402 	@fn 			State()
       
   403 	Intended Usage	:Retrieve the object's current state.
       
   404 	@return 		TCRegistarState the CRegistrar's current state.
       
   405 	@pre			CRegistrar is fully constructed.
       
   406 	@post 			the CRegistrar's current state has been returned.
       
   407 */
       
   408 	TRegistrarState State() const;
       
   409 	
       
   410 /**
       
   411 	@fn 			InitialiseEvent()
       
   412 	Intended Usage	: change the state during the CRegistrar's construction.
       
   413 	@post			: state is changed to EReg_StartupInProgess.
       
   414 */
       
   415 	void InitialiseEvent();
       
   416 	
       
   417 /** 
       
   418 	@fn				IsAnyDllRegisteredWithDriveL(const TDriveUnit aDrive)
       
   419 	Intended Usage	Find if any Dll is registered in the drive unit.
       
   420 	@param 			aDrive the identifier of the drive to find if any Dll is registered.
       
   421 	@return			ETrue if any Dll is registered in the drive, otherwise EFalse.
       
   422 	@pre			CRegistrar is fully constructed.
       
   423 	@post			If any Dll registered in the drive is returned.
       
   424 */
       
   425 	TBool IsAnyDllRegisteredWithDriveL(const TDriveUnit aDrive) const;
       
   426 	
       
   427 
       
   428 	
       
   429 //Attributes
       
   430 private:
       
   431 
       
   432 	/** The reference to the registry data manager class */
       
   433 	
       
   434 	CRegistryData&		iRegistry;
       
   435 	/** The owned discovery notification handling class */
       
   436 	
       
   437 	CDiscoverer*		iDiscoverer;
       
   438 	/** The owned backup/restore notification handling class */
       
   439 	
       
   440 	CBackupNotifier*	iBackupNotifier;
       
   441 	/** 
       
   442 		The reference to the observer of the 
       
   443 		Registrar for change notification. 
       
   444 	*/
       
   445 	
       
   446 	MRegistrarObserver& iRegistrarObserver;
       
   447 	/** A reference to a conncted file session */
       
   448 	
       
   449 	RFs&			iFs;
       
   450 	
       
   451 	/** The current state of this object */
       
   452 	TRegistrarState iState;
       
   453 
       
   454 	/** cached info on drivelist */
       
   455 	CEComCachedDriveInfo*  iCachedDriveInfo;
       
   456 
       
   457 	// Declare the test accessor as a friend
       
   458 	friend class TRegistrar_StateAccessor;
       
   459 };
       
   460 
       
   461 #endif /* __REGISTRAR_H__ */
       
   462