Thursday, January 22, 2015

HOW TO MAKE A CALL USING CTELEPHONY?

Description:
This label explains about how to make call using CTelephony.
APIs Information:
class CTelephony - By using this you can find information about phone and dial call, answer and control voice calls.
CTelephony::DialNewCall(TRequestStatus &aStatus, TDes8 &aCallParams, const TTelNumber &aTelNumber, TCallId &aCallId, const TPhoneLine aLine=EVoiceLine) const;

Usage:


CCallMaker* iCallmaker = new (ELeave)CCallMaker(*this); 
iCallmaker->ConstructL("Telephone number to be called");

//The class activate the call manager should derive from class MCallObserver and 
// shound implement the pure virtual function CallDialedL.

CallDialedL(TInt aError) 
{
 RDebug::Printf("CallDialedL = %d",aError);
 delete iCallmaker;
 iCallmaker = NULL;
}

//Observer class for call back.
class MCallObserver 
{ 
 public: 
 virtual void CallDialedL(TInt aError) = 0; 
};
//Implementst the call handling.
class CCallMaker : public CActive 
{
 public: 
 //Initialize the callback pointer 
 CCallMaker(MCallObserver& aObserver);
 //Initialize the call and make the active object to Active 
 void ConstructL(const TDesC& aNumber);
 ~CCallMaker();
 //From CActive Class
 private: 
 void RunL(); 
 void DoCancel();
 private: //Data
 MCallObserver& iObserver; 
 CTelephony* iTelephony; 
 CTelephony::TCallId iCallId; 
 CTelephony::TCallParamsV1 iCallParams; 
 CTelephony::TCallParamsV1Pckg iCallParamsPckg; 
};

//Definition
CCallMaker::~CCallMaker() 
{ 
 Cancel(); 
 delete iTelephony;
}

void CCallMaker::ConstructL(const TDesC& aNumber) 
{
 iTelephony = CTelephony::NewL(); 
 CTelephony::TTelNumber telNumber;
 telNumber.Copy(aNumber); 
 iCallId = CTelephony::EISVMaxNumOfCalls; 
 iCallParams.iIdRestrict = CTelephony::ESendMyId; 
 iTelephony->DialNewCall(iStatus, iCallParamsPckg, telNumber, iCallId); SetActive();
 iStatus = KRequestPending;
}

CCallMaker::CCallMaker(MCallObserver& aObserver): CActive(EPriorityNormal),iObserver(aObserver), iCallParamsPckg(iCallParams)
{ 
 CActiveScheduler::Add(this);
}
void CCallMaker::RunL() 
{ 
 iObserver.CallDialedL(iStatus.Int());
}

void CCallMaker::DoCancel() 
{ 
 iTelephony->CancelAsync(CTelephony::EDialNewCallCancel);
}

0 comments:

Post a Comment