⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 callengine.cpp

📁 symbian 2rd下可以获取并显示来电号码
💻 CPP
字号:
#include "CallEngine.h"
#include "InCallView.h"
#include "OutCallView.h"

#include <bautils.h>    // BaflUtils
#include <aknutils.h>    // BaflUtils

#include <coemain.h>
#include <apgtask.h>
#include <eikenv.h>
#include "CegoApp.h"

_LIT(KTSY, "phonetsy");

CCallEngine::CCallEngine() 
    {
    }

CCallEngine::~CCallEngine()
    {
    delete iInCallWatcher;
    iInCallWatcher = NULL;
    delete iOutCallWatcher;
    iOutCallWatcher = NULL;
    TelephonyCleanup();
    }

CCallEngine* CCallEngine::NewL()
    {
    CCallEngine* self = new (ELeave) CCallEngine();
    CleanupStack::PushL(self);
    self->ConstructL();
    CleanupStack::Pop(self);
    return self;
    }

void CCallEngine::ConstructL()
    {
    }

void CCallEngine::HandleInCallChangeL(const RCall::TStatus& aStatus)
    {
    switch(aStatus)
        {
        case RCall::EStatusConnected:
            {
            iObserver->HandleCallChangeL(aStatus);
            break;
            }
        case RCall::EStatusHangingUp:
            {
            iObserver->HandleCallChangeL(aStatus);
            break;
            }
        default:
            break;
        }
    }

void CCallEngine::StartEngineL()
    {
    TelStartL();
    iInCallWatcher = CInCallWatcher::NewL(*this, iLine); 
    iOutCallWatcher = COutCallWatcher::NewL(*this, iLine);
    }

void CCallEngine::StopEngine()
    {
    TelephonyCleanup();
    }

void CCallEngine::TelStartL()
    {
    if(iInCallWatcher)
        return;
    if (iOutCallWatcher)
        return ;

    User::LeaveIfError(iTelServer.Connect());
    User::LeaveIfError(iTelServer.LoadPhoneModule(KTSY));
    // Get the line info
    TInt numberPhones = 0;
    User::LeaveIfError(iTelServer.EnumeratePhones(numberPhones));
    if(!numberPhones)
        User::Leave(KErrNotFound);
    RTelServer::TPhoneInfo phoneInfo;
    User::LeaveIfError(iTelServer.GetPhoneInfo(0, phoneInfo));
    User::LeaveIfError(iPhone.Open(iTelServer, phoneInfo.iName));
    //
    TInt numberLines = 0;
    User::LeaveIfError(iPhone.EnumerateLines(numberLines));
    RPhone::TLineInfo lineInfo;
    TBool foundLine = EFalse;
    for(TInt a = 0; a < numberLines; a++)
        {
        User::LeaveIfError(iPhone.GetLineInfo(a, lineInfo));
        if(lineInfo.iLineCapsFlags & RLine::KCapsVoice)
            {
            foundLine = ETrue;
            break;
            }
        }

        if(!foundLine)
            User::Leave(KErrNotFound);

        User::LeaveIfError(iLine.Open(iPhone, lineInfo.iName));
    }

    void CCallEngine::TelephonyCleanup()
        {
        iPhone.Close();
        iLine.Close();
        iTelServer.Close();
        }

    void CCallEngine::ShowPhoneNumber(HBufC * aPhoneNumber)
        {
        iObserver->ShowPhoneNumber(aPhoneNumber);
        }

void CCallEngine::HandleOutCallHungUpL()
    {
    // Bring this application to foreground
    TApaTaskList tlist(CEikonEnv::Static()->WsSession());
    TApaTask app(tlist.FindApp(KUidCego)); 
    app.BringToForeground();
    iOutCallView->ShowCalleePage();
    }

void CCallEngine::MakeCallL(const TDesC& aNumber)
    {
     iOutCallWatcher->MakeCallL(aNumber);
    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -