Symbian 打电话类

http://wiki.forum.nokia.com/index.php/Make_call_with_CTelephony



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.

Headers required:

#include <Etel3rdParty.h>

Library required:

LIBRARY etel3rdparty.lib

Capabilities required:

CAPABILITY NetworkServices


To instantiate the CCallDialer, from the observing class, use something like this:

iCallDialer = CCallDialer::NewL(*this, phoneNumber1);

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 try the same sequence:

iCallDialer = CCallDialer::NewL(*this, phoneNumber2);

MakeCall.cpp

#include "MakeCall.h"
 
CCallDialer* CCallDialer::NewL(MDialObserver& aCallBack, const TDesC& aNumber)
{
    CCallDialer* self = CCallDialer::NewLC(aCallBack, aNumber);
    CleanupStack::Pop(self);
    return self;
}
 
CCallDialer* CCallDialer::NewLC(MDialObserver& aCallBack, const TDesC& aNumber)
{
    CCallDialer* self = new (ELeave) CCallDialer(aCallBack);
    CleanupStack::PushL(self);
    self->ConstructL(aNumber);
    return self;
}
 
 
CCallDialer::~CCallDialer()
{
    Cancel();
    delete iTelephony;
}
 
void CCallDialer::ConstructL(const TDesC& aNumber)
{
    iTelephony = CTelephony::NewL();
    CTelephony::TTelNumber telNumber(aNumber);
 
    iCallParams.iIdRestrict = CTelephony::ESendMyId;
 
    iTelephony->DialNewCall(iStatus, iCallParamsPckg, telNumber, iCallId);
    SetActive();
}
 
CCallDialer::CCallDialer(MDialObserver& aObserver)
: CActive(EPriorityNormal),iObserver(aObserver), iCallParamsPckg(iCallParams)
{
    CActiveScheduler::Add(this);
}
 
void CCallDialer::RunL()
{
    iObserver.CallDialedL(iStatus.Int());
}
 
void CCallDialer::DoCancel()
{
    iTelephony->CancelAsync(CTelephony::EDialNewCallCancel);
}

MakeCall.h

#include <Etel3rdParty.h>
// link to etel3rdparty.lib
 
class MDialObserver
{
    public:
        virtual void CallDialedL(TInt aError) = 0;
};
 
class CCallDialer : public CActive
{
    public:
        static CCallDialer* NewL(MDialObserver& aCallBack, const TDesC& aNumber);
        static CCallDialer* NewLC(MDialObserver& aCallBack, const TDesC& aNumber);
        ~CCallDialer();
 
    protected:
        CCallDialer(MDialObserver& aObserver);
        void ConstructL(const TDesC& aNumber);
 
    private:
        void RunL();
        void DoCancel();
 
    private:
        MDialObserver&                iObserver;
        CTelephony*                   iTelephony;
        CTelephony::TCallId           iCallId;
        CTelephony::TCallParamsV1     iCallParams;
        CTelephony::TCallParamsV1Pckg iCallParamsPckg;
};

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值