×
Namespaces

Variants
Actions
Revision as of 04:26, 14 June 2012 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Monitoring alarms using Symbian C++

From Nokia Developer Wiki
Jump to: navigation, search
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.

This page was last modified on 14 June 2012, at 04:26.
86 page views in the last 30 days.