×
Namespaces

Variants
Actions

How to answer/close call in CTelephony using a single Active Object

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Code Example
Source file: Media:CallTest.zip
Tested with
SDK: S60 3rd FP1
Devices(s): N82
Platform Security
Signing Required: Self-Signed
Capabilities: NetworkServices
Article
Keywords: CTelephony
Created: vineet.jain (03 Feb 2012)
Last edited: hamishwillee (06 Mar 2012)

This article shows how to answer or hangup the call using CTelephony with same active object on Symbian C++.

Contents

Introduction

This article shows how to answer or hangup the call using CTelephony with same active object on Symbian C++. Sometimes developers face issues with answer or hangup the calls in the same active object using CTelephony class. This article can help you to solve this issue.

So By this article you can get to know how to handle both of these operations(answering & hanging) in same active object.

Library Required

etel3rdparty.lib

Header Required

Etel3rdParty.h

Header

#include <Etel3rdParty.h>
// link to etel3rdparty.lib
 
#ifndef __CALLTEST_H__
#define __CALLTEST_H__
 
class CCallTest : public CActive
{
public:
static CCallTest* NewL();
static CCallTest* NewLC();
~CCallTest();
 
protected:
CCallTest();
void ConstructL();
 
private:
void RunL();
void DoCancel();
 
private:
CTelephony* iTelephony;
CTelephony::TCallId iCallId;
CTelephony::TCallStatusV1Pckg iCallStatusPckg;
CTelephony::TCallStatusV1 iLineStatus;
public:
void StartL();
void AnswerCall();
void HangupCall();
};
#endif // __CALLTEST_H__

Source

#include "TestCall.h"
 
CCallTest* CCallTest::NewL()
{
CCallTest* self = CCallTest::NewLC();
CleanupStack::Pop(self);
return self;
}
 
CCallTest* CCallTest::NewLC()
{
CCallTest* self = new (ELeave) CCallTest();
CleanupStack::PushL(self);
self->ConstructL();
return self;
}
 
 
CCallTest::~CCallTest()
{
Cancel();
delete iTelephony;
}
 
void CCallTest::ConstructL()
{
iTelephony = CTelephony::NewL();
}
 
CCallTest::CCallTest()
: CActive(EPriorityStandard), iCallStatusPckg(iLineStatus)
{
CActiveScheduler::Add(this);
}
 
void CCallTest::StartL()
{
Cancel(); // Cancel any request, just to be sure
iTelephony->NotifyChange(iStatus,CTelephony::EVoiceLineStatusChange,iCallStatusPckg);
SetActive(); // Tell scheduler a request is active
}
 
void CCallTest::RunL()
{
if(iStatus == KErrNone)
{
iTelephony->GetLineStatus(CTelephony::EVoiceLine,iCallStatusPckg); // Get line status instead of getting call status'
switch(iCallStatusPckg().iStatus)
{
case CTelephony::EStatusDialling:
StartL();
break;
case CTelephony::EStatusConnecting:
StartL();
break;
case CTelephony::EStatusAnswering:
StartL();
break;
case CTelephony::EStatusConnected:
HangupCall(); // Hangup the call as soon as call is connected or it can also be called from somewhere else(like some menu command)
break;
case CTelephony::EStatusRinging:
{
AnswerCall(); // Answer the call when its in ringing state
}break;
case CTelephony::EStatusUnknown:
StartL();
break;
case CTelephony::EStatusIdle: // Control goes here after call is hang up
StartL(); // Again start listening for any incoming call
break;
case CTelephony::EStatusDisconnecting:
StartL();
break;
default:
break;
}
}
 
}
 
// Cancel Any pending request, just to be sure
void CCallTest::DoCancel()
{
iTelephony->CancelAsync(CTelephony::EVoiceLineStatusChangeCancel);
iTelephony->CancelAsync(CTelephony::EAnswerIncomingCallCancel);
iTelephony->CancelAsync(CTelephony::EHangupCancel);
 
}
 
void CCallTest::AnswerCall()
{
Cancel();
iTelephony->AnswerIncomingCall(iStatus, iCallId);
SetActive();
}
 
void CCallTest::HangupCall()
{
Cancel();
iTelephony->Hangup(iStatus, iCallId);
SetActive();
}

How to use

iCallTest = CCallTest::NewL();
iCallTest->StartL(); // Start listening for Incoming call

NOTE : This code is tested on Nokia N82 device (an FP1 device) but code should work on all other Symbian versions till Symbian^3.

This page was last modified on 6 March 2012, at 02:15.
50 page views in the last 30 days.
×