CTelephony
represents the voice line's status with a
CTelephony::TCallStatus
. Possible status values include
Idle, Ringing, On-Hold etc. When the voice line's status is
Ringing (CTelephony::EStatusRinging
) then there is an
incoming voice call to be answered.
Use CTelephony::NotifyChange()
to detect
changes in the voice line's status. NotifyChange()
can be used to
detect a variety of changes, but in this case you are only interested in the
status of the voice line. Pass the method a notification event, in
this case CTelephony::EVoiceLineStatusChange
. Also pass it
an empty CTelephony::TCallStatusV1Pckg
.
The method starts an asynchonous operation that completes when the
voice line's status changes. At this point, the line's status (a
TCallStatus
) is written into the TCallStatusV1
. If
this status is Ringing
(CTelephony::EStatusRinging
) then there is an incoming
call.
Notification is described more in How to get notification when information changes. It includes an example active object that detects incoming calls.
The procedure for detecting incoming calls is the same whether
there is a second call in progress or not; the line's status changes to
CTelephony::EStatusRinging
from whatver state it used to
be.
Answer a call with
CTelephony::AnswerIncomingCall()
. You can only answer a
call when the voice line's status is Ringing
(CTelephony::EStatusRinging
); see
Detect an incoming call.
AnswerIncomingCall()
returns a
CTelephony::TCallId
that identifies the call. This will be
either CTelephony::EISVCall1
or
CTelephony::EISVCall2
. You need this ID to perform
operations such as putting the call on hold and hanging up: it tells
CTelephony
's methods which call to operate on. It also tells the
methods that you answered the call, and hence you are allowed to control the
call.
AnswerIncomingCall()
is asynchronous; Use
CTelephony::EAnswerIncomingCallCancel
to cancel the
operation.
For example:
#include <e32base.h>
#include <Etel3rdParty.h>
class CClientApp : public CActive
{
private:
CTelephony* iTelephony;
CTelephony::TCallId iCallId;
public:
CClientApp(CTelephony* aTelephony);
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)
: CActive(EPriorityStandard),
iTelephony(aTelephony)
{
//default constructor
}
void CClientApp::SomeFunction()
{
iTelephony->AnswerIncomingCall(iStatus, iCallId);
SetActive();
}
void CClientApp::RunL()
{
if(iStatus==KErrNone)
{} // The call has been answered successfully;
// iCallId contains the call's ID, needed when controlling the call.
}
void CClientApp::DoCancel()
{
iTelephony->CancelAsync(CTelephony::EAnswerIncomingCallCancel);
}
Remember to link to the Etel3rdParty.lib
and
euser.lib
libraries.
This describes how to answer a second call while another is in progress.
Put the first call on hold
This is the same as holding a call in Hold a call.
If the other call was not dialled or answered by you then you
cannot control it, and so you cannot put it on hold. If it is not on hold
already (i.e. the Voice line status is not CTelephony::EStatusHold
) then
you cannot answer the call.
Answer the second call
This is the same as answering a call in
Answer an incoming call.
AnswerIncomingCall()
will return a different call ID from the
first call.
Remember that answering a call is an asynchronous operation: you do not know whether you have successfully answered the call until the asynchronous operation has completed. If the operation fails, remember to resume the original call; see Resume a call.
As a result, the first call is on-hold and the second call is active; the phone user is talking to the second caller.