Monitoring alarms using Symbian C++
Article Metadata
Tested with
Devices(s): Nokia N95
Compatibility
Platform(s): S60 3rd Edition
Platform Security
Signing Required: DevCert
Capabilities: ReadUserData WriteUserData ReadDeviceData WriteDeviceData
Article
Keywords: RASCliSession
Created: User:Technical writer 1
(02 Oct 2008)
Last edited: hamishwillee
(14 Jun 2012)
Contents |
Overview
RASCliSession offers an easy and effective way for monitoring alarm server events, including actual alarm events as well as any modifications done for alarms. The handled alarms include both clock & calendar alarms.
MMP file
The following capabilities and libraries are required:
CAPABILITY ReadUserData WriteUserData ReadDeviceData WriteDeviceData
LIBRARY alarmclient.lib
LIBRARY alarmshared.lib
Header file
#include <e32base.h>
#include <ASCliSession.h>
class CCalAlarmObserver : public CActive
{
public:
void ConstructL();
CCalAlarmObserver();
~CCalAlarmObserver();
protected:
void DoCancel();
void RunL();
private:
void StartMonitoring();
private:
MMyLogCallBack& iCallBack;
RASCliSession iASCliSession;
TAlarmId iAlarmId;
};
Source file
#include <ASShdDefs.h>
#include <ASShdAlarm.h>
CCalAlarmObserver::CCalAlarmObserver():CActive(EPriorityStandard)
{}
CCalAlarmObserver::~CCalAlarmObserver()
{
Cancel();
iASCliSession.Close();
}
void CCalAlarmObserver::ConstructL()
{
CActiveScheduler::Add(this);
iASCliSession.Connect();
StartMonitoring();
}
void CCalAlarmObserver::StartMonitoring()
{
iASCliSession.NotifyChange(iStatus, iAlarmId);
SetActive();
}
void CCalAlarmObserver::RunL()
{
switch(iStatus.Int())
{
case EAlarmChangeEventState:
break;
case EAlarmChangeEventStatus:
break;
case EAlarmChangeEventCharacteristics:
break;
case EAlarmChangeEventAlarmDeletion:
break;
case EAlarmChangeEventAlarmAddition:
break;
case EAlarmChangeEventTimerExpired:
break;
//.... Check other states is needed
default:
break;
};
TASShdAlarm allarm;
if(iASCliSession.GetAlarmDetails(iAlarmId,allarm) == KErrNone)
{
// allarm.Status()
// allarm.State()
// allarm.NextDueTime()
// ...
}
StartMonitoring();
}
void CCalAlarmObserver::DoCancel()
{
iASCliSession.NotifyChangeCancel();
}
Postconditions
After you start the monitoring, each event notification will call the RunL function and the possible error code is stored in iStatus. In case iStatus is non-negative, it actually contains the event status.
The Alarms ID is stored in the Alarm id variable given to the alarm session when NotifyChange is called, and the alarm details can be retrieved by using this ID as shown in the above code snippet.

