symbian 日志引擎 log engine CLogClient使用 通信日志读写
Symbian系统中电话呼叫等记录信息存储在一个数据库中,通过CLogClient可以操作这个数据,通过它可以找到自己需要的记录
以下将详细讲解如何读写 通信日志log engine的使用
Link against:
LIBRARY logcli.lib
Capabilities:
CAPABILITY ReadUserData
LogReader.cpp
#include "LogReader.h" CCallLogReader* CCallLogReader::NewL(MLogCallBack* aCallBack) { CCallLogReader* self = CCallLogReader::NewLC(aCallBack); CleanupStack::Pop(self); return self; } CCallLogReader* CCallLogReader::NewLC(MLogCallBack* aCallBack) { CCallLogReader* self = new (ELeave) CCallLogReader(aCallBack); CleanupStack::PushL(self); self->ConstructL(); return self; } CCallLogReader::CCallLogReader(MLogCallBack* aCallBack) :CActive(CActive::EPriorityStandard),iCallBack(aCallBack) { } CCallLogReader::~CCallLogReader() { Cancel(); delete iLogView, iLogView = NULL; delete iLogFilter, iLogFilter = NULL; delete iLogClient, iLogClient = NULL; iFsSession.Close(); } void CCallLogReader::ConstructL(void) { CActiveScheduler::Add(this); User::LeaveIfError(iFsSession.Connect()); iLogClient = CLogClient::NewL(iFsSession); iLogView = CLogViewEvent::NewL(*iLogClient); iLogFilter = CLogFilter::NewL(); if(iLogView->SetFilterL(*iLogFilter, iStatus)) { iEngineState = ECreatingView; SetActive(); } else DoneReadingL(KErrNone); } void CCallLogReader::DoCancel() { if(iLogView) iLogView->Cancel(); if(iLogClient) iLogClient->Cancel(); } void CCallLogReader::RunL() { if(iStatus != KErrNone) DoneReadingL(iStatus.Int()); else switch (iEngineState) { case ECreatingView: if(iLogView) { // The filtered view has been successfully created // so issue a request to start processing logs backwards if(iLogView->LastL(iStatus)) { iEngineState = EReadingEntries; SetActive(); } else DoneReadingL(KErrNone); } break; case EReadingLast: if(iLogView) { iLogView->FirstL(iStatus); iEngineState = EReadingEntries; SetActive(); } break; case EReadingEntries: if(iLogView) { // since we are working from last-to-first // you could also delete entries at this point if necessary iCallBack->HandleLogEventL(iLogView->Event()); iEngineState = EReadingEntries; if(iLogView->PreviousL(iStatus)) SetActive(); else DoneReadingL(KErrNone); } break; default: break; } } void CCallLogReader::DoneReadingL(TInt aError) { iCallBack->LogProcessed(aError); }
LogReader.h
#include <F32FILE.H> #include <LOGVIEW.H> #include <logcli.h> class MLogCallBack { public: virtual void HandleLogEventL(const CLogEvent& event) = 0; virtual void LogProcessed(TInt aError) = 0; }; class CCallLogReader: public CActive { enum TCallLogReaderState { ECreatingView, EReadingEntries, EReadingLast }; public: // constructors and destructor static CCallLogReader* NewL(MLogCallBack* aCallBack); static CCallLogReader* NewLC(MLogCallBack* aCallBack); ~CCallLogReader(); public: // from CActive void DoCancel(); void RunL(); private: // constructors CCallLogReader(MLogCallBack* aCallBack); void ConstructL(); void DoneReadingL(TInt aError); private: // data TCallLogReaderState iEngineState; CLogClient* iLogClient; CLogViewEvent* iLogView; CLogFilter* iLogFilter; MLogCallBack* iCallBack; RFs iFsSession; };
以上都是来自
我们在使用以上两个源代码之后
只需要让我们需要调用的类
比如Cs60_clog_sampleAppUi 让他继承MLogCallBack类
如下
class Cs60_clog_sampleAppUi : public CAknAppUi, public MLogCallBack
然后在函数HandleLogEventL中就可以查看我们的调用过程
void Cs60_clog_sampleAppUi::HandleLogEventL(const CLogEvent& event) { iEventCounter++; CLogEvent* aEvent = CLogEvent::NewL(); aEvent->CopyL(event); // = event; TBuf<256> aNum = aEvent->Subject(); delete aEvent; }
博客版权归
http://blog.youkuaiyun.com/Zengyangtech 博主所有,转载请注明,谢谢。