Using the System Agent for getting notifications on Symbian (S60 2nd Edition)
The (deprecated) System Agent was used in S60 1st and 2nd Edition Devices to get system event and other notification.
The System Agent is a Symbian C++ server that provides a generic framework of notifications and system event state monitoring. It provides clients with access to the information through client-side handles.
- The two main classes involved are RSystemAgent and RSAVarChangeNotify.
- RSystemAgent is used to get data and also to register interest in a change to a value.
- RSAVarChangeNotify is used to tell System Agent that a state has changed. Once System Agent is notified of a change, it pushes this information out to all parties who have registered an interest in that state.
- All System Agent information is stored via a UID. The System Agent values that are supported by default are stored in sacls.h. The list includes KUidPhonePwr, KUidSIMStatus, KUidNetworkStatus, KUidNetworkStrength, KUidChargerStatus, KUidBatteryStrength, KUidCurrentCall, KUidDataPort, KUidInboxStatus, KUidOutboxStatus, KUidClock, KUidAlarm and KUidIrdaStatus.
The following example code shows how System Agent could be used inside an active object:
// aUid is the UID we want to monitor.
// We want notification of the item change ..
The example shows the connection to the System Agent server, and the call to NotifyOnEvent tells System Agent that you wish to be notified when the value of the item associated to aUid changes. The application will be notified through the completion of the request associated with the trequestStatus, which is set in the TSysAgentEvent. This will result in the RunL on the active object to be invoked.
More advanced monitoring of system data can be achieved through the use of TSysAgentCondition, which allows for notification when one of the conditions ESysAgentEquals, ESysAgentNotEquals, ESysAgentGreaterThan or ESysAgentLessThan is met. In this case, RSystemAgent::NotifyOnCondition() is used.