×
Namespaces

Variants
Actions

Monitoring call status with CTelephony

From Nokia Developer Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

The article is believed to be still valid for the original topic scope.

Article Metadata
Code ExampleArticle
Created: symbianyucca (27 Mar 2007)
Last edited: lpvalente (05 Apr 2014)



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 5 April 2014, at 21:27.
100 page views in the last 30 days.
×