Monitoring call status with CTelephony
Article Metadata
Code Example
Source file: Media:HelloWorld(CallStatus).zip
Article
Created: symbianyucca
(27 Mar 2007)
Last edited: hamishwillee
(12 Jan 2012)
The CCallMonitor illustrates how to monitor call status with CTelephony. This example is intended to be used only with S60 3rd Edition devices, and does not work with pre-3rd Edition devices.
For in and outgoing calls you could use this code for retrieving the caller's phone number.
Enum CTelephony::TCallStatus contains possible statuses:
enum TCallStatus
{
/**
Indicates that the status is unknown.
*/
EStatusUnknown,
/**
Idle line status (no active calls).
*/
EStatusIdle,
/**
Call dialling status .
*/
EStatusDialling,
/**
Call ringing status.
*/
EStatusRinging,
/**
Call answering status.
*/
EStatusAnswering,
/**
Call connecting status.
*/
EStatusConnecting,
/**
Call connected status.
*/
EStatusConnected,
/**
Call is undergoing temporary channel loss and it may or may not be reconnected.
*/
EStatusReconnectPending,
/**
Call disconnecting status.
*/
EStatusDisconnecting,
/**
Call on hold.
*/
EStatusHold,
/**
Call is transferring.
*/
EStatusTransferring,
/**
Call in transfer is alerting the remote party.
*/
EStatusTransferAlerting
};
Capability:
Capability NetworkServices
Link against:
LIBRARY etel3rdparty.lib
CallsMonitor.cpp
#include "CallsMonitor.h"
CCallMonitor* CCallMonitor::NewLC(MCallCallBack& aObserver)
{
CCallMonitor* self = new (ELeave) CCallMonitor(aObserver);
CleanupStack::PushL(self);
self->ConstructL();
return self;
}
CCallMonitor* CCallMonitor::NewL(MCallCallBack& aObserver)
{
CCallMonitor* self = CCallMonitor::NewLC(aObserver);
CleanupStack::Pop(); // self;
return self;
}
CCallMonitor::CCallMonitor(MCallCallBack& aCallBack)
:CActive(EPriorityStandard),iCallBack(aCallBack),iCurrentStatusPckg(iCurrentStatus)
{
CActiveScheduler::Add(this);
}
CCallMonitor::~CCallMonitor()
{
Cancel();
delete iTelephony;
}
void CCallMonitor::ConstructL(void)
{
iTelephony = CTelephony::NewL();
StartListening();
}
void CCallMonitor::CancelOperation(void)
{
Cancel();
}
void CCallMonitor::DoCancel()
{
iTelephony->CancelAsync(CTelephony::EVoiceLineStatusChangeCancel);
}
void CCallMonitor::RunL()
{
iCallBack.CallStatusChangedL(iCurrentStatus.iStatus,iStatus.Int());
if(iStatus != KErrCancel)
StartListening();
}
void CCallMonitor::StartListening()
{
Cancel();
iCurrentStatus.iStatus = CTelephony::EStatusUnknown;
iTelephony->NotifyChange(iStatus,CTelephony::EVoiceLineStatusChange,iCurrentStatusPckg);
SetActive();
}
CallsMonitor.h
#include <Etel3rdParty.h>
class MCallCallBack
{
public:
virtual void CallStatusChangedL(CTelephony::TCallStatus& aStatus, TInt aError)=0;
};
class CCallMonitor : public CActive
{
public:
~CCallMonitor();
static CCallMonitor* NewLC(MCallCallBack& aObserver);
static CCallMonitor* NewL(MCallCallBack& aObserver);
private:
CCallMonitor(MCallCallBack& aCallBack);
void ConstructL();
protected:
void DoCancel();
void RunL();
private:
void CancelOperation(void);
void StartListening();
private:
MCallCallBack& iCallBack;
TInt iState;
CTelephony::TCallStatusV1 iCurrentStatus;
CTelephony::TCallStatusV1Pckg iCurrentStatusPckg;
CTelephony* iTelephony;
};
Full example (verified on a S60 5th Edition device):


09 Sep
2009
One more useful article about CTelephony. This article demonstrates how to use the main feature of CTelephony - how to obtain call status. You could use class CCallMonitor in you own application (the source code is fully self-sufficient, you could just copy it in your project). Common approach for implementing such functionality is realization of server application without GUI. Such application could work as a logger of phone activity.
05 Sep
2009
The code snippet provided in this article shows how to monitor the call status using the CTelephony API. It registers interest for receiving a notification for Voice Line Status changes. The code snippet provided can also register interest for receiving a notification for owned Call 1 and Call 2 Status changes in a similar way.
10 Sep
2009
This article have a nice code snippet that can directly be used in any GUI / Non-UI applications by just copying to .h and .cpp files and adding to project. Only thing it lacks is it does not show how to handle more then one call handling for that developers should be referring to SDK Documents. This article need to be re-formatted with headers. But that does not reduce the importance or usability of this article.
26 Sep
2009
Useful article to get notification on change in Voice Line Status like get notification on incoming call, get notification on outgoing call, get notification on disconnecting call. Both GUI application as well as exe can use this class CCallMonitor easily. But do not forgot to create and add active scheduler in exe before using CCallMonitor (which is an active object).
What purpose does the member iState have? In my opinion it can be removed.
BR, Rene
I am sorry to say this, but this code snippet does work for me on Nokia 5800 - firmware v50.0.005. If I make a call using the standard phone app the change of the voice line status is not reported (I do not end up in RunL).