监控系统, 铃声, 来电, 代码, 播放
#include <aknnotewrappers.h>
#include <PathInfo.h>
#include <apgtask.h>
#include <eikenv.h>
#include <apmstd.h>
#include <apgcli.h>
#include "ImyAppUi.h"
CmyTelephoneWatcher* CmyTelephoneWatcher::NewL(CMyRingToneAppUi* aAppUi)
{
CmyTelephoneWatcher* self = new(ELeave)CmyTelephoneWatcher(aAppUi);
CleanupStack::PushL(self);
self->ConstructL();
CleanupStack::Pop();
return self;
}
CmyTelephoneWatcher::CmyTelephoneWatcher(CMyRingToneAppUi* aAppUi)
: CActive(EPriorityStandard),
iAppUi(aAppUi),
iIsAnswering(EFalse),
iLineStatusPckg( iLineStatus )// Standard priority
{
//default constructor
iLineStatus.iStatus = CTelephony::EStatusUnknown;
iLastInformedLineStatus = CTelephony::EStatusUnknown;
}
void CmyTelephoneWatcher::ConstructL()
{
iTelephony = CTelephony::NewL();
CActiveScheduler::Add(this); // Add to scheduler
}
CmyTelephoneWatcher::~CmyTelephoneWatcher()
{
Cancel(); // Cancel any request, if outstanding
delete iTelephony;
}
void CmyTelephoneWatcher::DoCancel()
{
iTelephony->CancelAsync( CTelephony::EVoiceLineStatusChangeCancel );
}
void CmyTelephoneWatcher::StartL(TTimeIntervalMicroSeconds32 aDelay)
{
/*
Panic if this object is already performing an asynchronous
operation
*/
_LIT( KNotifyExamplePanic, "CNotifyExample" );
__ASSERT_ALWAYS( !IsActive(), User::Panic( KNotifyExamplePanic, 1 ));
Cancel();
iTelephony->NotifyChange( iStatus,
CTelephony::EVoiceLineStatusChange,
iLineStatusPckg );
SetActive();
}
void CmyTelephoneWatcher::RunL()
{
if(iLineStatus.iStatus == CTelephony::EStatusRinging)
{
//handle Incomming call
GetNumber();
}
/* Request the next notification */
iTelephony->NotifyChange( iStatus,
CTelephony::EVoiceLineStatusChange,
iLineStatusPckg );
SetActive();
}
void CmyTelephoneWatcher::GetNumber()
{
CTelephony::TCallInfoV1 callInfoV1;
CTelephony::TCallInfoV1Pckg callInfoV1Pckg( callInfoV1 );
CTelephony::TCallSelectionV1 callSelectionV1;
CTelephony::TCallSelectionV1Pckg callSelectionV1Pckg( callSelectionV1 );
CTelephony::TRemotePartyInfoV1 remotePartyInfoV1;
CTelephony::TRemotePartyInfoV1Pckg remotePartyInfoV1Pckg( remotePartyInfoV1 );
callSelectionV1.iLine = CTelephony::EVoiceLine;
callSelectionV1.iSelect = CTelephony::EInProgressCall;
iTelephony->GetCallInfo( callSelectionV1Pckg, callInfoV1Pckg, remotePartyInfoV1Pckg );
TBuf<64> remoteNumber;
if(remotePartyInfoV1.iRemoteIdStatus==CTelephony::ERemoteIdentityAvailable)
{
// remotePartyInfoV1.iRemoteIdStatus==CTelephony::ERemoteIdentityAvailable .....never comes true and the
// execution never reaches here
remoteNumber.Copy(remotePartyInfoV1.iRemoteNumber.iTelNumber);
}
else
{
// We always come here and the length of remotePartyInfoV1.iRemoteNumber.iTelNumber is always 0
remoteNumber.Copy(remotePartyInfoV1.iRemoteNumber.iTelNumber);
}
if(remotePartyInfoV1.iRemoteNumber.iTelNumber.Length() > 0)
{
//Show the remote Number
}
}