Terminate a Call Tutorial

This tutorial describes how to terminate a call with the telephony API for applications.

Context

The procedure for terminating incoming calls is the same whether there is a second call in progress or not. When you have two calls in progress, one will always be active while the other will always be on hold. You can either:
  • terminate an on-hold call and then you will be left with an active call

  • terminate an active call and then you will be left with a call on hold; the on-hold call does not become active. You can make it active with CTelephony::Resume()

Steps

  1. create a new instance of CTelephony
  2. use CTelephony::Hangup() terminates a call. Pass it the ID of the call to terminate. The ID is the CTelephony::TCallId returned when you dialled or answered the call
  3. pass the enumeration CTelephony::EHangupCancel to cancel it Use CTelephony::Hangup() to terminate either call when you have two call in progress. Pass it the ID of the call you wish to terminate. To terminate them both, call the method twice with the two IDs.

Call termination example

#include <e32base.h>
#include <Etel3rdParty.h>

class CClientApp : public CActive
    { 

private:
    CTelephony* iTelephony;
    CTelephony::TCallId iCallId;

public:
    CClientApp(CTelephony* aTelephony, CTelephony::TCallId aCallId);
    void SomeFunction();

private:
    /*
       These are the pure virtual methods from CActive that  
       MUST be implemented by all active objects
       */
    void RunL();
    void DoCancel();
   };

CClientApp::CClientApp(CTelephony* aTelephony, CTelephony::TCallId aCallId)
    : CActive(EPriorityStandard),
      iTelephony(aTelephony),
      iCallId(aCallId)
    {
    //default constructor
    }

void CClientApp::SomeFunction()
    {
    iTelephony->Hangup(iStatus, iCallId);
    SetActive();
    }

void CClientApp::RunL()
    {
    if(iStatus==KErrNone)
       {} // The call has been terminted successfully;
    }

void CClientApp::DoCancel()
    {
    iTelephony->CancelAsync(CTelephony::EHangupCancel);
    }

Related tasks