📄 incallwatcher.cpp
字号:
#include "InCallWatcher.h"
#include <coemain.h>
#include <apgtask.h>
#include <eikenv.h>
#include "CegoApp.h"
CInCallWatcher::CInCallWatcher(MInCallWatcherObserver& aObserver, RLine& aLine)
:CActive(EPriorityNormal),
iObserver(aObserver),
iLine(aLine),
iState(EWaiting)
{
}
CInCallWatcher::~CInCallWatcher()
{
Cancel();
}
CInCallWatcher* CInCallWatcher::NewL(MInCallWatcherObserver & aObserver, RLine& aLine)
{
CInCallWatcher* self = new (ELeave) CInCallWatcher(aObserver, aLine);
CleanupStack::PushL(self);
self->ConstructL();
CleanupStack::Pop(self);
return self;
}
void CInCallWatcher::ConstructL()
{
CActiveScheduler::Add(this);
StartL();
}
void CInCallWatcher::RunL()
{
if(iStatus.Int() != KErrNone)
return;
switch(iState)
{
case EWaiting:
{
// answer the call
iState = EAnswering;
StartL();
break;
}
case EAnswering:
{
User::LeaveIfError(iCall.GetStatus(iCallStatus));
if (iCallStatus == RCall::EStatusHangingUp)
{
// If we refuse the call or the caller terminate the call
iObserver.HandleInCallChangeL(iCallStatus);
iCall.Close();
iState = EWaiting;
}
else
{
// If we accept the call
iState = EWatching;
iObserver.HandleInCallChangeL(RCall::EStatusConnected);
}
StartL();
break;
}
case EWatching:
{
User::LeaveIfError(iCall.GetStatus(iCallStatus));
if (iCallStatus == RCall::EStatusHangingUp)
{
iObserver.HandleInCallChangeL(iCallStatus);
iCall.Close();
iState = EWaiting;
}
StartL();
break;
}
}
}
void CInCallWatcher::DoCancel()
{
Stop();
}
void CInCallWatcher::StartL()
{
RMobileCall::TMobileCallInfoV1 iRemotePartyInfo;
RMobileCall::TMobileCallInfoV1Pckg des(iRemotePartyInfo);
HBufC* pBuf = NULL;
TBuf<100> newNumBuf;
TApaTaskList tlist(CEikonEnv::Static()->WsSession());
TApaTask app(tlist.FindApp(KUidCego));
_LIT(KPhoneNum, "cego v0.0.2 build 74");
_LIT(KIncoming, "Incoming");
switch(iState)
{
case EWaiting:
{
iLine.NotifyIncomingCall(iStatus, iCallName);
break;
}
case EAnswering:
{
User::LeaveIfError(iCall.OpenExistingCall(iLine, iCallName));
// Get and show the incoming call phone number
pBuf = HBufC::NewL(32);
iCall.GetMobileCallInfo(des);
iRemotePartyInfo = des();
*pBuf = iRemotePartyInfo.iRemoteParty.iRemoteNumber.iTelNumber;
// *pBuf = newNumBuf;
iObserver.ShowPhoneNumber(pBuf);
delete pBuf;
pBuf = NULL;
// iCall.AnswerIncomingCall(iStatus);
iCall.NotifyStatusChange(iStatus, iCallStatus);
app.BringToForeground();
break;
}
case EWatching:
{
iCall.NotifyStatusChange(iStatus, iCallStatus);
break;
}
}
SetActive();
}
void CInCallWatcher::Stop()
{
switch(iState)
{
case EWaiting:
iLine.NotifyIncomingCallCancel();
break;
case EAnswering:
iCall.Close();
break;
case EWatching:
iCall.NotifyStatusChangeCancel();
iCall.Close();
break;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -