Make call with CTelephony - Forum Nokia Wiki
Make call with CTelephony
From Forum Nokia Wiki
CCallDialer example illustrates how to dial a new call using CTelephony. Note that this example is intended to be used only with S60 3rd Edition devices, and does not work with pre-3rd Edition devices.
To use this example first implement the callback interface function in the implementing class and then construct an instance of the CCallDialer. The call dialing starts automatically after the construction. In case the process is successful and the callee answers the call, RunL() will be called with KErrNone; otherwise the aError argument variable will indicate the error.
To instantiate the CCallDialer, from the observing class, use something like this:
iCallDialer = new (ELeave)CCallDialer(*this);
iCallDialer->ConstructL(phoneNumber);
Then, in the notifier method of the instantiating class, you may remove the dialer and optionally check status:
void CBoopCtlContainer::CallDialedL(TInt aError)
{
delete iCallDialer;
iCallDialer = NULL;
}You may subsequently dial another number by going tru the same sequence:
iCallDialer = new (ELeave)CCallDialer(*this);
iCallDialer->ConstructL(phoneNumber2);
[edit] MakeCall.cpp
CCallDialer::~CCallDialer()
{
Cancel();
delete iTelephony;
}
void CCallDialer::ConstructL(const TDesC& aNumber)
{
iTelephony = CTelephony::NewL();
CTelephony::TTelNumber telNumber(aNumber);
CTelephony::TCallParamsV1 callParams;
callParams.iIdRestrict = CTelephony::ESendMyId;
CTelephony::TCallParamsV1Pckg callParamsPckg(callParams);
iTelephony->DialNewCall(iStatus, callParamsPckg, telNumber, iCallId);
SetActive();
}
CCallDialer::CCallDialer(MDialObserver& aObserver)
: CActive(EPriorityNormal),iObserver(aObserver)
{
CActiveScheduler::Add(this);
}
void CCallDialer::RunL()
{
iObserver.CallDialedL(iStatus.Int());
}
void CCallDialer::DoCancel()
{
iTelephony->CancelAsync(CTelephony::EDialNewCallCancel);
}
[edit] MakeCall.h
#include
// link to etel3rdparty.lib
class MDialObserver
{
public:
virtual void CallDialedL(TInt aError) = 0;
};
class CCallDialer : public CActive
{
public:
CCallDialer(MDialObserver& aObserver);
void ConstructL(const TDesC& aNumber);
~CCallDialer();
private:
void RunL();
void DoCancel();
private:
MDialObserver& iObserver;
CTelephony* iTelephony;
CTelephony::TCallId iCallId;
};
From Forum Nokia Wiki
CCallDialer example illustrates how to dial a new call using CTelephony. Note that this example is intended to be used only with S60 3rd Edition devices, and does not work with pre-3rd Edition devices.
To use this example first implement the callback interface function in the implementing class and then construct an instance of the CCallDialer. The call dialing starts automatically after the construction. In case the process is successful and the callee answers the call, RunL() will be called with KErrNone; otherwise the aError argument variable will indicate the error.
To instantiate the CCallDialer, from the observing class, use something like this:
iCallDialer = new (ELeave)CCallDialer(*this);
iCallDialer->ConstructL(phoneNumber);
Then, in the notifier method of the instantiating class, you may remove the dialer and optionally check status:
void CBoopCtlContainer::CallDialedL(TInt aError)
{
delete iCallDialer;
iCallDialer = NULL;
}You may subsequently dial another number by going tru the same sequence:
iCallDialer = new (ELeave)CCallDialer(*this);
iCallDialer->ConstructL(phoneNumber2);
[edit] MakeCall.cpp
CCallDialer::~CCallDialer()
{
Cancel();
delete iTelephony;
}
void CCallDialer::ConstructL(const TDesC& aNumber)
{
iTelephony = CTelephony::NewL();
CTelephony::TTelNumber telNumber(aNumber);
CTelephony::TCallParamsV1 callParams;
callParams.iIdRestrict = CTelephony::ESendMyId;
CTelephony::TCallParamsV1Pckg callParamsPckg(callParams);
iTelephony->DialNewCall(iStatus, callParamsPckg, telNumber, iCallId);
SetActive();
}
CCallDialer::CCallDialer(MDialObserver& aObserver)
: CActive(EPriorityNormal),iObserver(aObserver)
{
CActiveScheduler::Add(this);
}
void CCallDialer::RunL()
{
iObserver.CallDialedL(iStatus.Int());
}
void CCallDialer::DoCancel()
{
iTelephony->CancelAsync(CTelephony::EDialNewCallCancel);
}
[edit] MakeCall.h
#include
// link to etel3rdparty.lib
class MDialObserver
{
public:
virtual void CallDialedL(TInt aError) = 0;
};
class CCallDialer : public CActive
{
public:
CCallDialer(MDialObserver& aObserver);
void ConstructL(const TDesC& aNumber);
~CCallDialer();
private:
void RunL();
void DoCancel();
private:
MDialObserver& iObserver;
CTelephony* iTelephony;
CTelephony::TCallId iCallId;
};

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home