×
Namespaces

Variants
Actions

Disconnecting a voice call with CTelephony

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Tested with
Devices(s): Nokia 5800 XpressMusic
Compatibility
Platform(s): S60 3rd Edition
S60 5th Edition
Article
Keywords: CTelephony, TCallId
Created: tepaa (29 Apr 2009)
Last edited: hamishwillee (05 Jul 2012)

Contents

Overview

This snippet demonstrates how to make a voice call with CTelephony::DialNewCall() and then disconnect the call using CTelephony::Hangup() from etel3rdparty.lib. Note that you can only disconnect calls that have been initiated by your application using the Telephony ISV API (CTelephony).


MMP file

The following libraries and capabilities are required:

CAPABILITY NetworkServices
LIBRARY etel3rdparty.lib // Telephony ISV API


Header

#include <Etel3rdParty.h> // Telephony ISV API
 
class CYourCall : public CActive
{
public:
CYourCall();
virtual ~CYourCall();
void ConstructL();
void HangUpL();
void Dial(const TDesC& aNumber);
 
protected:
void DoCancel();
void RunL();
 
private:
// Telephony ISV API
CTelephony* iTelephony;
CTelephony::TCallId iCallId;
TBool iHangedUp;
};


Source

CYourCall::CYourCall()
:CActive(CActive::EPriorityStandard)
{
}
 
CYourCall::~CYourCall()
{
Cancel();
 
delete iTelephony;
}
 
void CYourCall::ConstructL(void)
{
CActiveScheduler::Add(this);
iTelephony = CTelephony::NewL();
}
 
void CYourCall::DoCancel()
{
iTelephony->CancelAsync(CTelephony::EDialNewCallCancel);
}
 
 
void CYourCall::RunL()
{
if (iStatus.Int()==KErrNone && !iHangedUp)
HangUpL();
}
 
void CYourCall::Dial(const TDesC& aNumber)
{
// Dial new call with given number
CTelephony::TTelNumber telNumber(aNumber);
 
CTelephony::TCallParamsV1 callParams;
callParams.iIdRestrict = CTelephony::ESendMyId;
CTelephony::TCallParamsV1Pckg callParamsPckg(callParams);
 
iTelephony->DialNewCall(iStatus, callParamsPckg, telNumber, iCallId);
SetActive();
}
 
void CYourCall::HangUpL()
{
if (IsActive())
return;
 
// Hang up call right after CTelephony::DialNewCall() is completed
iHangedUp = ETrue;
iTelephony->Hangup(iStatus,iCallId);
SetActive();
}


How to use

iCallMonitor = new (ELeave) CYourCall();
CleanupStack::PushL(iCallMonitor);
iCallMonitor->ConstructL();
CleanupStack::Pop();
 
iCallMonitor->Dial(_L("05012345678"));


Postconditions

The call is connected and then disconnected.


See also

This page was last modified on 5 July 2012, at 11:04.
57 page views in the last 30 days.