CHWRMLight Class Reference

API published in: S60 3rd Ed

Link against: hwrmlightclient.lib

Capability Information

Required Capabilities

None


#include <hwrmlight.h>

Detailed Description

The class used to control the device lights.

The HW Resource Manager Light API is a library API providing the ability to control the various light targets of the device. The API provides also methods to retrieve the current light status and the supported light targets of the device. The API is meant for all applications which need to control lights of the device.

Type of the HW Resource Manager Light API is a synchronous method call meaning the method call will block the client application. Every new call of the light API method stops all ongoing light control orders. Light state after duration based orders expire is the state specified by the last non-duration based order.

The API consist of the classes CHWRMLight and MHWRMLightObserver. If the client requires up-to-date status information, it should also provide callback pointer of the MHWRMLightObserver implementing class for the NewL-method.

Usage:

 #include <HWRMLight.h>  // link against HWRMLightClient.lib

 // A CHWRMLight instance can be created by using NewL() or NewLC() methods. 
 // Up-to-date status information not required, no callbacks.
 CHWRMLight* light = CHWRMLight::NewL();

 // After this, lights can be directly controlled via the provided class methods. 
 light-> LightOnL (EPrimaryDisplay, 5000); // Turn display lights on for five seconds.
 light->LightOffL(EPrimaryDisplay); // Turn display lights off indefinitely.

 // To clean up, delete the created object:
 delete light;

Public Types

enum   TLightStatus { ELightStatusUnknown = 0, ELightOn, ELightOff, ELightBlink }
  Possible light states that can be get for the different light targets. More...
enum   TLightTarget {
  ENoTarget = 0x0, EPrimaryDisplay = 0x1, EPrimaryKeyboard = 0x2, EPrimaryDisplayAndKeyboard = 0x3,
  ESecondaryDisplay = 0x4, ESecondaryKeyboard = 0x8, ESecondaryDisplayAndKeyboard = 0xC, ECustomTarget1 = 0x10,
  ECustomTarget2 = 0x20, ECustomTarget3 = 0x40, ECustomTarget4 = 0x80, ESystemTarget = 0x80000000
}
  Possible light targets. More...

Public Member Functions

virtual void  ReserveLightL (TInt aTarget)=0
  Reserves light target exclusively for this client.
virtual void  ReserveLightL (TInt aTarget, TBool aRestoreState, TBool aForceNoCCoeEnv)=0
  Reserves light target exclusively for this client.
virtual void  ReleaseLight (TInt aTarget)=0
  Releases light target if it was previously reserved for this client.
virtual void  LightOnL (TInt aTarget)=0
  The LightOnL method switches the specified target light on for infinite duration using default intensity.
virtual void  LightOnL (TInt aTarget, TInt aDuration)=0
  The LightOnL method switches the specified target light on for the specified duration using default intensity.
virtual void  LightOnL (TInt aTarget, TInt aDuration, TInt aIntensity, TBool aFadeIn)=0
  The LightOnL method switches the specified target light on for the specified duration using specified intensity.
virtual void  LightBlinkL (TInt aTarget)=0
  The LightBlinkL method blinks the target light(s) of the device for infinite duration using default intensity.
virtual void  LightBlinkL (TInt aTarget, TInt aDuration)=0
  The LightBlinkL method blinks the target light(s) of the device for specified duration using default intensity.
virtual void  LightBlinkL (TInt aTarget, TInt aDuration, TInt aOnDuration, TInt aOffDuration, TInt aIntensity)=0
  The LightBlinkL method blinks the target light(s) of the device for specified duration using specified intensity.
virtual void  LightOffL (TInt aTarget)=0
  The LightOffL method switches the device light off for the specified target for infinite duration.
virtual void  LightOffL (TInt aTarget, TInt aDuration)=0
  The LightOffL method switches the device light off for the specified target for the specified duration time.
virtual void  LightOffL (TInt aTarget, TInt aDuration, TBool aFadeOut)=0
  The LightOffL method switches the device light off for the specified target for the specified duration time.
virtual TLightStatus  LightStatus (TInt aTarget) const =0
  This method retrieves the current light status.
virtual TInt  SupportedTargets () const =0
  This method retrieves the supported light targets of the device.

Static Public Member Functions

static IMPORT_C CHWRMLight NewL ()
  Two-phased constructor.
static IMPORT_C CHWRMLight NewLC ()
  Two-phased constructor.
static IMPORT_C CHWRMLight NewL (MHWRMLightObserver *aCallback)
  Two-phased constructor.
static IMPORT_C CHWRMLight NewLC (MHWRMLightObserver *aCallback)
  Two-phased constructor.

Member Enumeration Documentation

enum CHWRMLight::TLightStatus
 

Possible light states that can be get for the different light targets.

Enumerator:
ELightStatusUnknown  For debugging/development and signaling an error conditions.
ELightOn  Light state switch to light on.
ELightOff  Light state switch to light off.
ELightBlink  Light state switch to light blinking.
enum CHWRMLight::TLightTarget
 

Possible light targets.

Targets can be used as bitmask. Some common masks are provided as enum.

Note that all targets are not supported by all devices. Attempting to use unsupported target will result in KErrNotSupported.

At least one target must be defined.

Enumerator:
ENoTarget  No target.

Not a valid target value, used only for error checking.

EPrimaryDisplay  Primary display of the device.
EPrimaryKeyboard  Primary keyboard of the device.
EPrimaryDisplayAndKeyboard  Both primary display and the primary keyboard of the device.
ESecondaryDisplay  Secondary display of the device.
ESecondaryKeyboard  Secondary keyboard of the device.
ESecondaryDisplayAndKeyboard  Both secondary display and the secondary keyboard of the device.
ECustomTarget1  Device specific custom target 1.
ECustomTarget2  Device specific custom target 2.
ECustomTarget3  Device specific custom target 3.
ECustomTarget4  Device specific custom target 4.
ESystemTarget  Special target used to control all currently available system lights.

System lights normally include all displays and keyboards, but not custom lights. This is however device dependent.

A target mask including this target is always changed to a device state specific target mask. Note that the system target with any other target is not supported.

This target is always supported but it is never included in supported targets mask.

See also:
CHWRMLight::SupportedTargets()

Member Function Documentation

virtual void CHWRMLight::LightBlinkL TInt  aTarget,
TInt  aDuration,
TInt  aOnDuration,
TInt  aOffDuration,
TInt  aIntensity
[pure virtual]
 

The LightBlinkL method blinks the target light(s) of the device for specified duration using specified intensity.

On- and Off-cycle times of the blinking can also be controlled.

Parameters:
aTarget  Defines which light should be controlled. Multiple lights can be specified with using bitwise-or.
aDuration  Duration of the time the light is set to blink measured in milliseconds. After the duration expires, the light state for target will be changed to whatever state was caused by the last infinite time duration call, or default state determined by inactivity timer, in case there has not been a previous infinite time duration call in this session. If the aTotalDuration time is KHWRMInfiniteDuration then it means an infinite value that has to be stopped by calling of any of the other light control methods. Duration can have maximum value of KHWRMLightMaxDuration.
aOnDuration  Duration time, measured in milliseconds, of how long the Light is switched on in every Blink cycle. Duration can have maximum value of KHWRMLightMaxDuration. For device default cycle duration, use value KHWRMDefaultCycleTime. If either of aOnDuration or aOffDuration is KHWRMDefaultCycleTime, both must be KHWRMDefaultCycleTime. Some devices might not support variable blink cycle times, in which case default value will be substituted.
aOffDuration  Duration time, measured in milliseconds, of how long the Light is switched off in every Blink cycle. Duration can have maximum value of KHWRMLightMaxDuration. For device default cycle duration, use value KHWRMDefaultCycleTime. If either of aOnDuration or aOffDuration is KHWRMDefaultCycleTime, both must be KHWRMDefaultCycleTime. Some devices might not support variable blink cycle times, in which case default value will be substituted.
aIntensity  Intensity of the light. If aIntensity is KHWRMDefaultIntensity, device default intensity will be used. Note: All devices might not support user defined intensity, in which case device will behave in its default fashion.
Leave:
KErrArgument One of the parameters is out of range or otherwise invalid.
Leave:
KErrNotSupported One or more of specified targets are not supported.
Leave:
KErrBadHandle Light session has been invalidated.
Leave:
KErrTimedOut Timeout occurred in controlling light.
Leave:
KErrInUse One or more of specified targets are not reserved for this client but are reserved for others.
Leave:
KErrNoMemory There is a memory allocation failure.
Leave:
KErrGeneral There is a hardware error.
See also:
TLightTarget
virtual void CHWRMLight::LightBlinkL TInt  aTarget,
TInt  aDuration
[pure virtual]
 

The LightBlinkL method blinks the target light(s) of the device for specified duration using default intensity.

Calling this method is equal to calling LightBlinkL(aTarget, aDuration, KHWRMDefaultCycleTime, KHWRMDefaultCycleTime, KHWRMDefaultIntensity).

Parameters:
aTarget  Defines which light should be controlled. Multiple lights can be specified with using bitwise-or.
aDuration  Duration of the time the light is set to blink measured in milliseconds. After the duration expires, the light state for target will be changed to whatever state was caused by the last infinite time duration call, or default state determined by inactivity timer, in case there has not been a previous infinite time duration call in this session. If the aTotalDuration time is KHWRMInfiniteDuration then it means an infinite value that has to be stopped by calling of any of the other light control methods. Duration can have maximum value of KHWRMLightMaxDuration.
Leave:
KErrArgument Parameter aDuration is out of range.
Leave:
KErrNotSupported One or more of specified targets are not supported.
Leave:
KErrBadHandle Light session has been invalidated.
Leave:
KErrTimedOut Timeout occurred in controlling light.
Leave:
KErrInUse One or more of specified targets are not reserved for this client but are reserved for others.
Leave:
KErrNoMemory There is a memory allocation failure.
Leave:
KErrGeneral There is a hardware error.
See also:
TLightTarget
virtual void CHWRMLight::LightBlinkL TInt  aTarget  )  [pure virtual]
 

The LightBlinkL method blinks the target light(s) of the device for infinite duration using default intensity.

Calling this method is equal to call LightBlinkL(aTarget, KHWRMInfiniteDuration, KHWRMDefaultCycleTime, KHWRMDefaultCycleTime, KHWRMDefaultIntensity).

Parameters:
aTarget  Defines which light should be controlled. Multiple lights can be specified with using bitwise-or.
Leave:
KErrNotSupported One or more of specified targets are not supported.
Leave:
KErrBadHandle Light session has been invalidated.
Leave:
KErrTimedOut Timeout occurred in controlling light.
Leave:
KErrInUse One or more of specified targets are not reserved for this client but are reserved for others.
Leave:
KErrNoMemory There is a memory allocation failure.
Leave:
KErrGeneral There is a hardware error.
See also:
TLightTarget
virtual void CHWRMLight::LightOffL TInt  aTarget,
TInt  aDuration,
TBool  aFadeOut
[pure virtual]
 

The LightOffL method switches the device light off for the specified target for the specified duration time.

Lights fade-out can also be controlled.

Parameters:
aTarget  Defines which light should be controlled. Multiple lights can be specified with using bitwise-or.
aDuration  Duration of the time the light is switched off measured in milliseconds. After the duration expires, the light state for target will be changed to whatever state was caused by the last infinite time duration call, or default state determined by inactivity timer, in case there has not been a previous infinite time duration call in this session. If the aDuration time is KHWRMInfiniteDuration then it means an infinite value that has to be stopped by calling of any of the other light control methods. Duration can have maximum value of KHWRMLightMaxDuration.
aFadeOut  If ETrue, lights will not turn off instantly but instead smoothly fade-out Note: All devices will not support fade-out, in which case device will behave in its default fashion.
Leave:
KErrArgument aDuration is out of range.
Leave:
KErrNotSupported One or more of specified targets are not supported.
Leave:
KErrBadHandle Light session has been invalidated.
Leave:
KErrTimedOut Timeout occurred in controlling light.
Leave:
KErrInUse One or more of specified targets are not reserved for this client but are reserved for others.
Leave:
KErrNoMemory There is a memory allocation failure.
Leave:
KErrGeneral There is a hardware error.
See also:
TLightTarget
virtual void CHWRMLight::LightOffL TInt  aTarget,
TInt  aDuration
[pure virtual]
 

The LightOffL method switches the device light off for the specified target for the specified duration time.

Lights will be switched off with fade-out.

Calling this method is equal to call LightOffL(aTarget, aDuration, ETrue).

Parameters:
aTarget  Defines which light should be controlled. Multiple lights can be specified with using bitwise-or.
aDuration  Duration of the time the light is switched off measured in milliseconds. After the duration expires, the light state for target will be changed to whatever state was caused by the last infinite time duration call, or default state determined by inactivity timer, in case there has not been a previous infinite time duration call in this session. If the aDuration time is KHWRMInfiniteDuration then it means an infinite value that has to be stopped by calling of any of the other light control methods. Duration can have maximum value of KHWRMLightMaxDuration.
Leave:
KErrArgument Parameter aDuration is out of range.
Leave:
KErrNotSupported One or more of specified targets are not supported.
Leave:
KErrBadHandle Light session has been invalidated.
Leave:
KErrTimedOut Timeout occurred in controlling light.
Leave:
KErrInUse One or more of specified targets are not reserved for this client but are reserved for others.
Leave:
KErrNoMemory There is a memory allocation failure.
Leave:
KErrGeneral There is a hardware error.
See also:
TLightTarget
virtual void CHWRMLight::LightOffL TInt  aTarget  )  [pure virtual]
 

The LightOffL method switches the device light off for the specified target for infinite duration.

Lights will be switched off with fade-out.

Calling this method is equal to call LightOffL(aTarget, KHWRMInfiniteDuration, ETrue).

Parameters:
aTarget  Defines which light should be controlled. Multiple lights can be specified with using bitwise-or.
Leave:
KErrNotSupported One or more of specified targets are not supported.
Leave:
KErrBadHandle Light session has been invalidated.
Leave:
KErrTimedOut Timeout occurred in controlling light.
Leave:
KErrInUse One or more of specified targets are not reserved for this client but are reserved for others.
Leave:
KErrNoMemory There is a memory allocation failure.
Leave:
KErrGeneral There is a hardware error.
See also:
TLightTarget
virtual void CHWRMLight::LightOnL TInt  aTarget,
TInt  aDuration,
TInt  aIntensity,
TBool  aFadeIn
[pure virtual]
 

The LightOnL method switches the specified target light on for the specified duration using specified intensity.

Fade-in can also be controlled.

Parameters:
aTarget  Defines which light should be controlled. Multiple lights can be specified with using bitwise-or.
aDuration  Duration of the time the light is switched on measured in milliseconds. After the duration expires, the light state for target will be changed to whatever state was caused by the last infinite time duration call, or default state determined by inactivity timer, in case there has not been a previous infinite time duration call in this session. If the aDuration time is KHWRMInfiniteDuration then it means an infinite value that has to be stopped by calling of any of the other light control methods. Duration can have maximum value of KHWRMLightMaxDuration.
aIntensity  Intensity of the light. If aIntensity is KHWRMDefaultIntensity, device default intensity will be used. Note: All devices might not support user defined intensity, in which case device will behave in its default fashion.
aFadeIn  If ETrue, lights will not turn on instantly but instead smoothly fade-in. Note: All devices will not support fade-in, in which case device will behave in its default fashion.
Leave:
KErrArgument One of the parameters is out of range.
Leave:
KErrNotSupported One or more of specified targets are not supported.
Leave:
KErrBadHandle Light session has been invalidated.
Leave:
KErrTimedOut Timeout occurred in controlling light.
Leave:
KErrInUse One or more of specified targets are not reserved for this client but are reserved for others.
Leave:
KErrNoMemory There is a memory allocation failure.
Leave:
KErrGeneral There is a hardware error.
See also:
TLightTarget
virtual void CHWRMLight::LightOnL TInt  aTarget,
TInt  aDuration
[pure virtual]
 

The LightOnL method switches the specified target light on for the specified duration using default intensity.

Lights will use fade-in.

Calling this method is equal to call LightOnL(aTarget, aDuration, KHWRMDefaultIntensity, ETrue).

Parameters:
aTarget  Defines which light should be controlled. Multiple lights can be specified with using bitwise-or.
aDuration  Duration of the time the light is switched on measured in milliseconds. After the duration expires, the light state for target will be changed to whatever state was caused by the last infinite time duration call, or default state determined by inactivity timer, in case there has not been a previous infinite time duration call in this session. If the aDuration time is KHWRMInfiniteDuration then it means an infinite value that has to be stopped by calling of any of the other ' light control methods. Duration can have maximum value of KHWRMLightMaxDuration.
Leave:
KErrArgument Parameter aDuration is out of range.
Leave:
KErrNotSupported One or more of specified targets are not supported.
Leave:
KErrBadHandle Light session has been invalidated.
Leave:
KErrTimedOut Timeout occurred in controlling light.
Leave:
KErrInUse One or more of specified targets are not reserved for this client but are reserved for others.
Leave:
KErrNoMemory There is a memory allocation failure.
Leave:
KErrGeneral There is a hardware error.
See also:
TLightTarget
virtual void CHWRMLight::LightOnL TInt  aTarget  )  [pure virtual]
 

The LightOnL method switches the specified target light on for infinite duration using default intensity.

Lights will use fade-in.

Calling this method is equal to calling LightOnL(aTarget, KHWRMInfiniteDuration, KHWRMDefaultIntensity, ETrue).

Parameters:
aTarget  Defines which light should be controlled. Multiple lights can be specified with using bitwise-or.
Leave:
KErrNotSupported One or more of specified targets are not supported.
Leave:
KErrBadHandle Light session has been invalidated.
Leave:
KErrTimedOut Timeout occurred in controlling light.
Leave:
KErrInUse One or more of specified targets are not reserved for this client but are reserved for others.
Leave:
KErrNoMemory There is a memory allocation failure.
Leave:
KErrGeneral There is a hardware error.
See also:
TLightTarget
virtual TLightStatus CHWRMLight::LightStatus TInt  aTarget  )  const [pure virtual]
 

This method retrieves the current light status.

Parameters:
aTarget  Defines which light status is returned. This method only supports single target, as different targets might have different statuses.
Returns:
TLightStatus indicating the current light status. If there is a problem or multiple targets were specified, CHWRMLight::ELightStatusUnknown is returned.
See also:
MHWRMLightObserver

TLightTarget

static IMPORT_C CHWRMLight* CHWRMLight::NewL MHWRMLightObserver aCallback  )  [static]
 

Two-phased constructor.

Use this method for creating a Light client with callbacks.

Parameters:
aCallback  Pointer to the callback instance.
Returns:
A pointer to a new instance of the CHWRMLight class.
Leave:
KErrNotSupported Device doesn't support Light feature.
Leave:
KErrNoMemory There is a memory allocation failure.
static IMPORT_C CHWRMLight* CHWRMLight::NewL  )  [static]
 

Two-phased constructor.

Returns:
A pointer to a new instance of the CHWRMLight class.
Leave:
KErrNotSupported Device doesn't support Light feature.
Leave:
KErrNoMemory There is a memory allocation failure.
static IMPORT_C CHWRMLight* CHWRMLight::NewLC MHWRMLightObserver aCallback  )  [static]
 

Two-phased constructor.

Use this method for creating a Light client with callbacks. Leaves instance to cleanup stack.

Parameters:
aCallback  Pointer to the callback instance
Returns:
A pointer to a new instance of the CHWRMLight class.
Leave:
KErrNotSupported Device doesn't support Light feature.
Leave:
KErrNoMemory There is a memory allocation failure.
static IMPORT_C CHWRMLight* CHWRMLight::NewLC  )  [static]
 

Two-phased constructor.

Leaves instance to cleanup stack.

Returns:
A pointer to a new instance of the CHWRMLight class.
Leave:
KErrNotSupported Device doesn't support Light feature.
Leave:
KErrNoMemory There is a memory allocation failure.
virtual void CHWRMLight::ReleaseLight TInt  aTarget  )  [pure virtual]
 

Releases light target if it was previously reserved for this client.

If this client has not reserved any of the specified lights, this method does nothing. Any reserved light targets that are released and have no other suspended clients will be reset to default state, which is either lights on or lights off, depending on system inactivity time.

Parameters:
aTarget  Defines which light should be released. Multiple lights can be specified with using bitwise-or.
See also:
TLightTarget
virtual void CHWRMLight::ReserveLightL TInt  aTarget,
TBool  aRestoreState,
TBool  aForceNoCCoeEnv
[pure virtual]
 

Reserves light target exclusively for this client.

A higher priority client may cause lower priority client reservation to be temporarily suspended. Commands can still be issued in suspended state, but they will not be acted upon unless suspension is lifted within specified duration. The suspended client will not get any notification about suspension. If light target is already reserved by a higher or equal priority application, reserving will still succeeds, but reservation is immediately suspended.

Parameters:
aTarget  Defines which light should be reserved. Multiple lights can be specified with using bitwise-or.
aRestoreState  If ETrue, the state frozen on last release will be restored upon successful reservation. I.e. if light was blinking when it was released by this client the last time, it would start blinking again upon successful reservation. For the first reservation of each session this parameter is always considered EFalse regardless of what is supplied, as there is no previous frozen state to restore.
aForceNoCCoeEnv  If EFalse, then reservation requires that this client is on the foreground at the time of reservation and light target will be automatically released and re-reserved based on background/foreground status of the this client. This also implies that CCoeEnv::Static() != NULL is required. If ETrue, the client will not require CCoeEnv to be present nor does it automatically reserve/release light by depending on foreground/background status of the client. Only trusted clients are allowed to set this flag to ETrue. A client is considered trusted if it has nonstandard priority defined in the internal lights policy of the HW Resource Manager. A client can be defined trusted only by S60 or a product.
Leave:
KErrNotSupported One or more of specified targets are not supported.
Leave:
KErrAccessDenied Paramenter aForceNoCCoeEnv is ETrue and client is not trusted.
Leave:
KErrBadHandle Parameter ForceNoCCoeEnv is EFalse and no CCoeEnv present.
Leave:
KErrNotReady Trying to reserve while on background and parameter aForceNoCCoeEnv is EFalse.
Leave:
KErrNoMemory There is a memory allocation failure.
See also:
TLightTarget
virtual void CHWRMLight::ReserveLightL TInt  aTarget  )  [pure virtual]
 

Reserves light target exclusively for this client.

A higher priority client may cause lower priority client reservation to be temporarily suspended. Commands can still be issued in suspended state, but they will not be acted upon unless suspension is lifted within specified duration. The suspended client will not get any notification about suspension. If light target is already reserved by a higher or equal priority application, reserving will still succeeds, but reservation is immediately suspended.

Calling this method is equal to calling ReserveLightL( aTarget, EFalse, EFalse), i.e. any previously frozen state will not be restored and CCoeEnv background/foreground status is always used to control further reservations.

Parameters:
aTarget  Defines which light should be reserved. Multiple lights can be specified with using bitwise-or.
Leave:
KErrNotSupported One or more of specified targets are not supported.
Leave:
KErrAccessDenied No CCoeEnv present.
Leave:
KErrNotReady Trying to reserve while on background.
Leave:
KErrNoMemory There is a memory allocation failure.
See also:
TLightTarget
virtual TInt CHWRMLight::SupportedTargets  )  const [pure virtual]
 

This method retrieves the supported light targets of the device.

Any attempt to use or reserve unsupported targets will fail with KErrNotSupported.

Returns:
Bitmask containing supported light targets.
See also:
TLightTarget

The documentation for this class was generated from the following file:

Copyright © Nokia Corporation 2001-2008
Back to top