×
Namespaces

Variants
Actions

Using the System Agent for getting notifications on Symbian (S60 2nd Edition)

From Nokia Developer Wiki
Jump to: navigation, search

The (deprecated) System Agent was used in S60 1st and 2nd Edition Devices to get system event and other notification.

Warning.pngWarning: From S60 3rd Edition is replaced by the Publish & Subscribe framework

Article Metadata
Compatibility
Platform(s): S60 1st Edition, S60 2nd Edition
S60 1st Edition
Article
Keywords: RSystemAgent, RSAVarChangeNotify
Created: vasant21 (24 May 2007)
Updated: hamishwillee (18 Nov 2011)
Reviewed: hamishwillee (18 Nov 2011)
Last edited: hamishwillee (18 Nov 2011)

Overview

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.

Code example

The following example code shows how System Agent could be used inside an active object:

RSystemAgent sysAgent;
TSysAgentEvent sysAgentEvent;
sysAgent.Connect();
sysAgentEvent.SetRequestStatus(iStatus);
 
// aUid is the UID we want to monitor.
sysAgentEvent.SetUid(aUid);
 
// We want notification of the item change ..
sysAgent.NotifyOnEvent(sysAgentEvent);

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.

Advanced Monitoring

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.

This page was last modified on 18 November 2011, at 07:22.
46 page views in the last 30 days.
×