Join Now
Quality Rating:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)
Expertise Level:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)

This page was last modified 04:23, 22 November 2007.

Monitoring call status with CTelephony

From Forum Nokia Wiki


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.

CallsMonitor.cpp

CCallMonitor::CCallMonitor(MCallCallBack& aCallBack)
:CActive(0),iCallBack(aCallBack),iCurrentStatusPckg(iCurrentStatus)
{
}
 
CCallMonitor::~CCallMonitor()
{
	Cancel();
 
	delete iTelephony;
}
 
void CCallMonitor::ConstructL(void)
{
	CActiveScheduler::Add(this);
 
	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

class MCallCallBack
{
public:
	virtual void CallStatusChangedL(CTelephony::TCallStatus& aStatus, TInt aError)=0;
};
 
class CCallMonitor : public CActive
		{
	public:
		~CCallMonitor();
		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;
		};
 
Powered by MediaWiki
     
     RDF Facets:
     
     
     qfnZtypeQUqfnTypeZCommunityContentQ
     qfnZtypeQUqfnTypeZWebpageQ
     qfnZtypeQUqfnTypeZWikiContentQ
     qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX