📄 celliddetector.cpp
字号:
/*
============================================================================
Name : CellidDetector.cpp
Author : Hatma Suryotrisongko
Version :
Copyright : www.hatma.info
Description : CCellidDetector implementation
============================================================================
*/
#include "CellidDetector.h"
CCellidDetector::CCellidDetector() : CActive( EPriorityStandard ) // Standard priority
{
}
CCellidDetector* CCellidDetector::NewLC()
{
CCellidDetector* self = new ( ELeave ) CCellidDetector();
CleanupStack::PushL( self );
self->ConstructL();
return self;
}
CCellidDetector* CCellidDetector::NewL()
{
CCellidDetector* self = CCellidDetector::NewLC();
CleanupStack::Pop(); // self;
return self;
}
void CCellidDetector::ConstructL()
{
iTelephony = CTelephony::NewL(); // Constructs a CTelephony object.
CActiveScheduler::Add( this ); // Add to scheduler
}
CCellidDetector::~CCellidDetector()
{
Cancel(); // Cancel any request, if outstanding
// Delete instance variables if any
delete iTelephony;
}
void CCellidDetector::DoCancel()
{
// Cancels an outstanding asynchronous request. (Cancel a pending GetCurrentNetworkInfo request.)
iTelephony->CancelAsync(CTelephony::EGetCurrentNetworkInfoCancel);
}
void CCellidDetector::StartL()
{
Cancel(); // Cancel any request, just to be sure
iState = EGetPhoneInfo;
CTelephony::TNetworkInfoV1Pckg networkInfoPckg( iNetworkInfo ); //A typedef'd packaged CTelephony::TNetworkInfoV1 for passing through a generic API method.
iTelephony->GetCurrentNetworkInfo(iStatus, networkInfoPckg); //Retrieve over-the-air network information about the currently registered mobile network.
SetActive(); // Tell scheduler a request is active
iActiveSchedulerWait.Start(); //Starts a new wait loop under the control of the current active scheduler.
}
void CCellidDetector::RunL()
{
iState = EDone;
if ( iActiveSchedulerWait.IsStarted() ) // Reports whether this CActiveSchedulerWait object is currently started.
{
iActiveSchedulerWait.AsyncStop(); // Stops the scheduling loop owned by this object.
if(iStatus == KErrNone)
{
iCellId = iNetworkInfo.iCellId;
}
else
{
// ***********Handle Error here ************
}
}
}
TInt CCellidDetector::RunError( TInt aError )
{
return aError;
}
// Method untuk mengambil informasi cellid saat ini
TUint CCellidDetector::GetNetworkCellId(TUint& aCellId)
{
StartL();
aCellId = iCellId;
return aCellId;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -