Listening
for Property Changes
The sensor channel APIs enable the client applications to be notified
about the changes to properties associated with a sensor channel.
The client applications
can use the property listener to monitor the property changes made by other
clients.
- Create a property
listener implementation for the MSensrvPropertyListener interface.
class PropertyListener:public MSensrvPropertyListener
{
public:
void PropertyChanged(CSensrvChannel &aChannel, const TSensrvProperty &aChangedProperty)
{
...
//Implementation
}
void PropertyError(CSensrvChannel &aChannel, TSensrvErrorSeverity aError)
{
...
//Implementation
}
void SetPropertySuccessIndicationChanged(TSetPropertySuccessIndicator aIndication)
{
...
//Implementation
}
void GetPropertyListenerInterfaceL(TUid aInterfaceUid, TAny *&aInterface)
{
...
//Implementation
}
};
- Start property listening
by passing an instance of property listener implementation using CSensrvChannel::SetPropertyListenerL().
//Instance of the property listener implementation
PropertyListener propListener;
...
CSensrvChannel* channel;
...
channel->SetPropertyListenerL(&propListener);
...
When a property change occurs, a PropertyChanged() notification
is delivered through the MSensrvPropertyListener callback
interface to the clients that are listening for property changes.Note: The
client that set the property is not notified.
- Once you get the
required property changes associated with the sensor channel, you can stop
property listening by passing a NULL parameter to the CSensrvChannel::SetPropertyListenerL() function.
channel->SetPropertyListenerL();