-
Don't read callog.
I am use Ex: [url]http://www.developer.nokia.com/Community/Wiki/Logs_Example[/url] read callog.
File header:
[QUOTE]
#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,
Esleep
};
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);
public:
void ReadEvent();
private: // data
TCallLogReaderState iEngineState;
CLogClient* iLogClient;
CLogViewEvent* iLogView;
CLogViewRecent* iLogRecent;
CLogFilter* iLogFilter;
MLogCallBack* iCallBack;
RFs iFsSession;
};
[/QUOTE]
File .Cpp
[QUOTE]
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)
{
User::LeaveIfError(iFsSession.Connect());
iLogClient = CLogClient::NewL(iFsSession);
iLogView = CLogViewEvent::NewL(*iLogClient);
iLogRecent = CLogViewRecent::NewL(*iLogClient);
iLogFilter = CLogFilter::NewL();
iEngineState = Esleep;
CActiveScheduler::Add(this);
}
void CCallLogReader::DoCancel()
{
if(iLogView)
iLogView->Cancel();
if(iLogClient)
iLogClient->Cancel();
}
void CCallLogReader::RunL()
{
switch (iEngineState)
{
case Esleep:
break;
case EReadingEntries:
{
if(iLogView)
{
if (iCallBack)
{
iCallBack->HandleLogEventL(iLogView->Event());
}
else
{
iEngineState = Esleep;
DoneReadingL(KErrNone);
break;
}
if (iLogView->NextL(iStatus))
{
SetActive();
}
else
{
DoneReadingL(KErrNone);
}
}
break;
}
default:
break;
}
}
void CCallLogReader::ReadEvent()
{
if(iLogView->SetFilterL(*iLogFilter, iStatus))
{
iEngineState = EReadingEntries;
SetActive();
}
else
{
DoneReadingL(KErrNone);
}
}
void CCallLogReader::DoneReadingL(TInt aError)
{
iCallBack->LogProcessed(aError);
}
[/QUOTE]
in My Class , i am call:
[QUOTE]
iCallLog = CCallLogReader::NewL(this);
iCallLog->ReadEvent();
[/QUOTE]
[QUOTE]
void MuClassView::HandleLogEventL(const CLogEvent& event)
{
TBuf<20> Number, Direction, Name;
TLogDuration Duration;
TTime aTime;
Number.Copy(event.Number());
Name.Copy(event.Description());
Direction.Copy(event.Direction());
Duration = event.Duration();
aTime = event.Time();
RFile file;
TBuf8<100> buf;
/* Open a file if it exists, otherwise create new one*/
if (KErrNone != file.Open(CCoeEnv::Static()->FsSession(), _L("E:\\CallLog.txt"), EFileWrite))
{
file.Replace(CCoeEnv::Static()->FsSession(), _L("E:\\CallLog.txt"), EFileWrite);
}
TInt pos = 0;
file.Seek(ESeekEnd, pos);
file.Write(_L8("\n\nName : "));
buf.Copy(Name);
file.Write(buf);
file.Write(_L8("\nNumber : "));
buf.Copy(Number);
file.Write(buf);
file.Write(_L8("\nDirection : "));
buf.Copy(Direction);
file.Write(buf);
file.Write(_L8("\nTime : "));
TBuf<50> dateString;
_LIT(KDateString3,"%D%M%Y%/0%1%/1%2%/2%3%/3");
aTime.FormatL(dateString,KDateString3);
buf.Copy(dateString);
buf.Append(_L(" - "));
_LIT(KDateString5,"%-B%:0%J%:1%T%:2%S%:3%+B");
aTime.FormatL(dateString,KDateString5);
buf.Append(dateString);
file.Write(buf);
file.Write(_L8("\nDuration : "));
buf.Num(Duration);
file.Write(buf);
file.Close();
}
[/QUOTE]
but I only get results by WLAN connection.
Can anyone help me! Thanks!
-
Re: Don't read callog.
What excatly is happening when you try the code, and what do you expect to happen instead ?
Also if you use example without modifications, then do not paste the code here, just refer to teh example. And if you did modify the code, you could first check whether the modification did make the difference in operations.