Call Swap Tutorial

This tutorial describes how to swap calls with the telephony API for applications.


  1. create a new instance of CTelephony

  2. use CTelephony::GetCallDynamicCaps() to check if the device supports swap function

  3. call CTelephony::Swap() when you have an active call and a call on hold The function makes the held call active and the puts the active call on hold. Pass the function the IDs of the two calls. The IDs are CTelephony::TCallId objects returned when you dialled or answered the calls.

  4. pass the enumeration CTelephony::ESwapCancel to cancel the asynchronous request

Call swap example

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

class CClientApp : public CActive
    { 

private:
    CTelephony* iTelephony;
    CTelephony::TCallId iCallIdA;
    CTelephony::TCallId iCallIdB;

public:
    CClientApp(CTelephony* aTelephony, CTelephony::TCallId aCallIdA, CTelephony::TCallId aCallIdB);
    TInt 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),
      iCallIdA(aCallIdA)
      iCallIdB(aCallIdB)
    {
    //default constructor
    }

TInt CClientApp::SomeFunction()
    {
    // Check that the phone supports Resuming calls.
    CTelephony::TCallCapsV1 callCapsV1;
    CTelephony::TCallCapsV1Pckg callCapsV1Pckg(callCapsV1);
    iTelephony->GetCallDynamicCaps(iCallId, callCapsV1Pckg);

    if( callCapsV1.iControlCaps & CTelephony::KCapsSwap )
       {
       // The call represented by 'iCallId' can be swapped
       iTelephony->Swap(iStatus, iCallIdA, iCallIdB);
       SetActive();
       return KErrNone;
       }
    else
       {
       // The call cannot be swapped; 
       // return an error indicate this.
       return KErrNotSupported;
       }
    }

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

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