Symbian
Symbian OS Library

SYMBIAN OS V9.3

[Index] [Spacer] [Previous] [Next]



How to terminate calls


Terminate a call

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.

CTelephony::Hangup() is asynchronous; use 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.

If you terminate an active call while another is on hold, then

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 terminate either:

For 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);
    }

Remember to link to the Etel3rdParty.lib and euser.lib libraries.

[Top]


Detect remote party terminating a call

CTelephony represents the status of your calls with a CTelephony::TCallStatus. Possible status values include Idle, Ringing, On-Hold etc:

Use CTelephony::NotifyChange() to detect changes in the voice line's status. CTelephony::NotifyChange() can be used to detect a variety of changes, but in this case you are only interested in the status of your voice calls. Pass the method a notification event: pass it CTelephony::EOwnedCall1StatusChange to detect a change in call 1's status, and pass it CTelephony::EOwnedCall2StatusChange for call 2. Also pass it an empty CTelephony::TCallStatusV1Pckg.

The method starts an asynchonous operation that completes when the calls's status changes. At this point, the call's new status is written into the CTelephony::TCallStatusV1Pckg.

Notification is described more in How to Get Notification when Information Changes. It includes an example active object.

The procedure for detecting a terminated call is the same whether there is a second call in progress or not.

For example:

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

class CClientApp : public CActive
    { 

private:
    CTelephony* iTelephony;
    CTelephony::TCallId iCallId;
                CTelephony::TCallStatusV1 iCallStatusV1;
                CTelephony::TCallStatusV1Pckg iCallStatusV1Pckg;
    CTelephony::TNotificationEvent iEvent;

public:
    CClientApp(CTelephony* aTelephony, CTelephony::TCallId aCallId);
    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),
      iCallId(aCallId),
      iCallStatusV1Pckg(iCallStatusV1)
    {
    //default constructor
    }

TInt CClientApp::SomeFunction()
    {
    switch(iCallId)
       {
       case CTelephony::EISVCall1:
          iEvent = CTelephony::EOwnedCall1StatusChange;
          break;

       case CTelephony::EISVCall2:
          iEvent = CTelephony::EOwnedCall2StatusChange;
          break;

       default:
          // We have not been given a valid call ID, so return an error
          return KErrArgument;
       }

    iTelephony->NotifyChange(iStatus, iEvent, iCallStatusV1Pckg);
    SetActive();
    return KErrNone;
    }

void CClientApp::RunL()
    {
    if(iStatus==KErrNone)
       {
       // The status of the call has changed.
       if(iCallStatusV1.iStatus == CTelephony::EStatusIdle)
          {
          // The call has been terminated.
          }
       else
          {
          // The call has not yet been terminated, so request notification again
          iTelephony->NotifyChange(iStatus, iEvent, iCallStatusV1Pckg);
          SetActive();
          }
       }
    }

void CClientApp::DoCancel()
    {
    CTelephony::TCancellationRequest cancelRequest;
    if(iCallId == CTelephony::EISVCall1)
       {
       cancelRequest = CTelephony::EOwnedCall1StatusChangeCancel;
       }
    else // iCallId == CTelephony::EISVCall2
       {
       cancelRequest = CTelephony::EOwnedCall2StatusChangeCancel;
       }
    iTelephony->CancelAsync(cancelRequest);
    }

Remember to link to the Etel3rdParty.lib and euser.lib libraries.