代码共享:监控系统来电事件。可以来电时播放自己的铃声
2010-03-19 09:43
351 查看
监控系统, 铃声, 来电, 代码, 播放
#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
}
}
#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
}
}
相关文章推荐
- 零代码如何打造自己的实时监控预警系统
- 零代码如何打造自己的实时监控预警系统
- 零代码如何打造自己的实时监控预警系统
- android mp3 播放系统基本原理,可以播放音乐的哦
- Intel manual appendix a 说明intel可以监控到的事件
- iOS 播放系统自带铃声
- 如何安装整个linux系统中所需要的mp3播放库插件? 可以在安装rpmfusion仓库后直接通过dnf install进行按照就可以了
- 车辆管理系统之继续自己的任务(八)-----终于可以修改了!
- Snare for Windows 3.1.7 - 监控系统事件日志
- 开发自己的监控系统一、email篇
- 已知道 一个窗口的句柄, 如何扑捉该窗口的onresize 事件,并在onresize 事件中写入自己的代码?
- 深度分析:Android4.3下MMS发送到附件为音频文件(音频为系统内置音频)的彩信给自己,添加音频-发送彩信-接收彩信-下载音频附件-预览-播放(三,接收彩信<1,接收短信>)
- 深度分析:Android4.3下MMS发送到附件为音频文件(音频为系统内置音频)的彩信给自己,添加音频-发送彩信-接收彩信-下载音频附件-预览-播放(三,接收彩信<2,下载彩信>)
- 预览来电铃声,如何让背景音乐暂停播放
- grails不想用系统生成的字段id可以自己改
- 用bochs调试自己写的系统引导代码
- 开源一个自己做的在线高亮代码编辑器,适用于CMS等系统
- inotify之文件系统事件监控使用入门
- 如何移植mad-hacking到Debian系统,使net-snmp可以监控raid和disk