You Are Here:

Community: Wiki

This page was last modified on 26 May 2009, at 16:06.

How to handle call events using CTelephony 3rd Edition

From Forum Nokia Wiki

This article intends to explain how to handle most of the events on a call using CTelephony in 3rd Edition

Events handled here are:

  1. Call Ringing
  2. Call Answered
  3. Call connecting
  4. Call connected
  5. Call disconnected
  6. Dial call


The implementation is so simple. The idea is simply active object listening to change in voice line

Contents

Headers Required

#include <Etel3rdParty.h>

Libraries Required

LIBRARY   etel3rdparty.lib

Capability Required

Capability  NetworkServices

Code

The following code assumes that you have a class for log text (CMyLog).

Define observer interface to be implemented by class you want it to be notified with events (if you like)


MPhoneReceiverObserver

#ifndef MPHONERECEIVEROBSERVER_H
#define MPHONERECEIVEROBSERVER_H
 
class MPhoneReceiverObserver
{
public:
virtual void CallRinging() {}
 
virtual void CallAnswered() {}
 
virtual void DialingCall() {}
 
virtual void CallConnecting() {}
 
virtual void CallConnected() {}
 
virtual void CallDisConnected() {}
 
};
 
#endif // MPHONERECEIVEROBSERVER_H


Define the active object that will listen to any change in voice line status


CPhoneReceiver Declaration

#include <e32base.h>	// For CActive, link against: euser.lib
#include "Etel3rdParty.h" //For CTelephony, link against etel3rdparty.lib
 
#include "MPhoneReceiverObserver.h"
#include "MyLog.h"
 
class CPhoneReceiver : public CActive
{
public:
// C++ constructor
CPhoneReceiver(MPhoneReceiverObserver& aPhoneReceiverObserver);
 
// Second-phase constructor
void ConstructL();
 
// Cancel and destroy
~CPhoneReceiver();
 
public: // New functions
// Function for making the initial request
void StartL();
 
private: // From CActive
// Handle completion
void RunL();
 
// How to cancel me
void DoCancel();
 
private:
//Define object to CTelephone to manage calls
CTelephony* iTelephony;
 
CTelephony::TCallInfoV1 iCurrentCallInfo;
CTelephony::TCallInfoV1Pckg iCurrentStatusPckg;
 
CTelephony::TCallId iCallID;
 
MPhoneReceiverObserver& iPhoneReceiverObserver;
 
 
};
 
#endif


CPhoneReceiver Implementation

#include "PhoneReceiver.h"
 
CPhoneReceiver::CPhoneReceiver(MPhoneReceiverObserver& aPhoneReceiverObserver)
: CActive(EPriorityStandard),
iCurrentStatusPckg(iCurrentCallInfo),
iPhoneReceiverObserver(aPhoneReceiverObserver)
{
}
 
void CPhoneReceiver::ConstructL()
{
//Create new object to telephony
iTelephony = CTelephony::NewL();
CActiveScheduler::Add(this); // Add to scheduler
}
 
CPhoneReceiver::~CPhoneReceiver()
{
Cancel(); // Cancel any request, if outstanding
 
delete iTelephony;
}
 
void CPhoneReceiver::DoCancel()
{
iTelephony->CancelAsync( CTelephony::EVoiceLineStatusChangeCancel );
}
 
void CPhoneReceiver::StartL()
{
Cancel(); // Cancel any request, just to be sure
 
//Notify of change in telephone line
iTelephony->NotifyChange( iStatus, CTelephony::EVoiceLineStatusChange,
iCurrentStatusPckg );
 
SetActive(); // Tell scheduler a request is active
}
 
void CPhoneReceiver::RunL()
{
if(iStatus.Int() == KErrNone)
{
//Get call status
CTelephony::TCallStatus callStatus = iCurrentStatusPckg().iStatus;
 
switch(callStatus)
{
case CTelephony::EStatusRinging:
iPhoneReceiverObserver.CallRinging();
break;
 
case CTelephony::EStatusAnswering:
iPhoneReceiverObserver.CallAnswered();
break;
 
case CTelephony::EStatusDialling:
iPhoneReceiverObserver.DialingCall();
break;
 
case CTelephony::EStatusConnecting:
iPhoneReceiverObserver.CallConnecting();
break;
 
case CTelephony::EStatusConnected:
iPhoneReceiverObserver.CallConnected();
break;
 
case CTelephony::EStatusDisconnecting:
iPhoneReceiverObserver.CallDisConnected();
break;
 
default:
#ifdef __USE_PHONE_RECEIVER_LOG__
TBuf<50> num;
num.Copy(_L("Default: "));
num.AppendNum(callStatus);
CMyLog::OpenAndWriteToFile(num);
#endif
break;
}
}
else
{
#ifdef __USE_PHONE_RECEIVER_LOG__
TBuf<50> num;
num.AppendNum(iStatus.Int());
num.Append(_L(" -- "));
CTelephony::TCallStatus callStatus = iCurrentStatusPckg().iStatus;
num.AppendNum(callStatus);
CMyLog::OpenAndWriteToFile(num);
#endif
}
 
//Notify every time before activate object
iTelephony->NotifyChange( iStatus, CTelephony::EVoiceLineStatusChange,
iCurrentStatusPckg );
 
if(!IsActive())
SetActive();
 
}

Output

The following is a sample for the log file written above

Log:25-4-2009-15-18-53
////////////////////
Call Ringing
////////////////////
Call Answered
////////////////////
Call connected
////////////////////
Call disconnected
////////////////////
Default: 1 //Line Idle
////////////////////

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZdescriptionQSxEa0E20WikiE20javaE20symbianE5fosE20s60E20maemoE20cE2bE2bE20WikiE20HomeE20WikiE20HelpE20OverviewE20GlossaryE20CreateE20PageE20ProposeE20anE20ArticleE20SpotlightE20TopicE20E2dE20WE52TE20WidgetsE20ProgrammingE20E4canguageE20E2dE20SymbianE20CE2bE2bE20E2dE20OpenE20CE2fCE2bE2bE20E2dE20JavaE20E2dE20FlashE20E4citeE20E2dE20PythonE20WebE20TechnologiesE20E2dE20WE52TE20WidgetsE20E2dE20WidSetsE20ToolsE20andE20SE44KE20CodeE20E45E78amplesE20KnowledgeE20BaseE20TechnologyE20AreasE20SoftwareE20PlatformsE20E44evelopmentE20ProcessE20E3fE3fWikiE20ChineseE20E3fE3fE3fWikiE20JapaneseE20PortugueseE2fBrazilianE20E52ussianE20WhatE20linksE20hereE20UploadE20fileE20SpecialE20pagesE20PrintableE20versionE44ownloadE20asE20PE44FE20GoE20ToE20E2eE2eE2eX qdcZidentifierQSxhttpE3aE2fE2fwikiE2eforumE2enokiaE2ecomE2findeE78E2ephpE2fJ2ME45E5fE52SSE5fParserE5fwithE5fKE58mlX qdcZpublisherQUxhttpE3aE2fE2fswE2enokiaE2ecomE2fidE2fc764fd1cE2d8b06E2d499aE2d9a6aE2d17c3903d5a65E2fforumE5fnokiaE5fcrawlerE5fagentX qdcZtitleQSxJ2ME45E20E52SSE20ParserE20withE20KE58mlE20E2dE20ForumE20NokiaE20WikiX qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qrssZdescriptionQSxEa0E20WikiE20javaE20symbianE5fosE20s60E20maemoE20cE2bE2bE20WikiE20HomeE20WikiE20HelpE20OverviewE20GlossaryE20CreateE20PageE20ProposeE20anE20ArticleE20SpotlightE20TopicE20E2dE20WE52TE20WidgetsE20ProgrammingE20E4canguageE20E2dE20SymbianE20CE2bE2bE20E2dE20OpenE20CE2fCE2bE2bE20E2dE20JavaE20E2dE20FlashE20E4citeE20E2dE20PythonE20WebE20TechnologiesE20E2dE20WE52TE20WidgetsE20E2dE20WidSetsE20ToolsE20andE20SE44KE20CodeE20E45E78amplesE20KnowledgeE20BaseE20TechnologyE20AreasE20SoftwareE20PlatformsE20E44evelopmentE20ProcessE20E3fE3fWikiE20ChineseE20E3fE3fE3fWikiE20JapaneseE20PortugueseE2fBrazilianE20E52ussianE20WhatE20linksE20hereE20UploadE20fileE20SpecialE20pagesE20PrintableE20versionE44ownloadE20asE20PE44FE20GoE20ToE20E2eE2eE2eX qfnZdistributionQUxhttpE3aE2fE2fwikiE2eforumE2enokiaE2ecomE2fX qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZupdatedQDx2008E2d10E2d02X qmarsZdescriptionQSxEa0E20WikiE20javaE20symbianE5fosE20s60E20maemoE20cE2bE2bE20WikiE20HomeE20WikiE20HelpE20OverviewE20GlossaryE20CreateE20PageE20ProposeE20anE20ArticleE20SpotlightE20TopicE20E2dE20WE52TE20WidgetsE20ProgrammingE20E4canguageE20E2dE20SymbianE20CE2bE2bE20E2dE20OpenE20CE2fCE2bE2bE20E2dE20JavaE20E2dE20FlashE20E4citeE20E2dE20PythonE20WebE20TechnologiesE20E2dE20WE52TE20WidgetsE20E2dE20WidSetsE20ToolsE20andE20SE44KE20CodeE20E45E78amplesE20KnowledgeE20BaseE20TechnologyE20AreasE20SoftwareE20PlatformsE20E44evelopmentE20ProcessE20E3fE3fWikiE20ChineseE20E3fE3fE3fWikiE20JapaneseE20PortugueseE2fBrazilianE20E52ussianE20WhatE20linksE20hereE20UploadE20fileE20SpecialE20pagesE20PrintableE20versionE44ownloadE20asE20PE44FE20GoE20ToE20E2eE2eE2eX qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ
User Rating: qfnZuserE5FratingQNx2E2E0000X