diff -r 000000000000 -r 89d6a7a84779 Symbian3/SDK/Source/GUID-B4218FA6-5BE0-4000-BC85-3078892EDADA.dita --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Symbian3/SDK/Source/GUID-B4218FA6-5BE0-4000-BC85-3078892EDADA.dita Thu Jan 21 18:18:20 2010 +0000 @@ -0,0 +1,96 @@ + + + + + +Environment +changes +

The Environment Change Notifier informs an application about changes +in the system environment. The class that implements the API is CEnvironmentChangeNotifier, which is an +active object. The following changes are notified:

+ +

In order to receive environment change events, a TCallBack object must be created. The constructor of the callback object takes two +parameters: The first is a pointer to a function to be called when an event +occurs and the second is a pointer to the object that implements the function.

+TCallBack( TInt ( *aFunction )( TAny* aPtr ) ) +

The CEnvironmentChangeNotifier object takes +two parameters. The first one is a priority of the active object and the second +one is a reference to the callback object.

+static CEnvironmentChangeNotifier* NewL(TInt aPriority, const TCallBack& aCallBack) +

The Start() function is called in order to start +observation.

+void Start() +

When an environment change event occurs, the function whose pointer +was given to the callback object is called. Details about an event that occurred +can be queried using the Change() function.

+TInt Change() const +

The function returns a bit pattern, where each bit value corresponds +to one of the enumerations defined in TChanges (e32const.h).

+enum TChanges + { + EChangesLocale = 0x01, + EChangesMidnightCrossover = 0x02, + EChangesThreadDeath = 0x04, + EChangesPowerStatus = 0x08, + EChangesSystemTime = 0x10, + EChangesFreeMemory = 0x20, + EChangesOutOfMemory = 0x40, + }; + +

Code example:

+void CExampleEnvChangeNotifier::ConstructL() + { + iCallBack = new( ELeave )TCallBack( CallBackFunction, this ); + iChangeNotifier = + CEnvironmentChangeNotifier::NewL( 0, *iCallBack ); + iChangeNotifier->Start(); + } +CExampleEnvChangeNotifier::~CMyEnvChangeNotifier() + { + iChangeNotifier->Cancel(); + delete iChangeNotifier; + delete iCallBack; + } +TInt CExampleEnvChangeNotifier::CallBackFunction( TAny* aFunction ) + { + return( (CEventsEnvChangeNotifier* )aFunction )->ChangeL(); + } +TInt CExampleEnvChangeNotifier::ChangeL() + { + TInt change = iChangeNotifier->Change(); + if( change & EChangesLocale ) + { + // Locale change, do something + } + if( change & EChangesMidnightCrossover ) + { + // Midnight crossover, do something + } + if( change & EChangesThreadDeath ) + { + // Thread death, do something + } + if( change & EChangesPowerStatus ) + { + // Power status change, do something + } + if(change & EChangesSystemTime ) + { + // System status change, do something + } + return 1; + } + +
\ No newline at end of file