Namespaces
Variants
Actions

Monitoring call status with CTelephony

Jump to: navigation, search
Article Metadata

Code Example
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):

HelloWorld(CallStatus).zip

This page was last modified on 12 January 2012, at 06:04.
239 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved