Hello everyone,
I'm trying (and keep trying) to retrieve the caller number from incoming call. But I still can't do it. When incoming call arrive, it show blank information note then the application crash. I'm going crazy now. Could you help me please.... Here is my code, please guide me and show me where I'm doing wrong:

///////////////////////////////////////
// ActiveIncomingCallObserver.cpp //
///////////////////////////////////////

#ifndef __ACTIVEINCOMINGCALLOBSERVER__
#define __ACTIVEINCOMINGCALLOBSERVER__

#include <etel.h>
#include <EIKENV.H>

#include "IncomingCallObserverInterface.h"
#include "IncomingCallObserver.h"

#include <e32base.h>

//tel num
#include <logcli.h>
#include <logview.h>
#include <f32file.h>
#include <logwrap.h>
#include <e32svr.h>
#include <aknnotewrappers.h>



class CActiveIncomingCallObserver : public CActive
{
public:
CActiveIncomingCallObserver(MIncomingCallObserverInterface* aObserver);
~CActiveIncomingCallObserver();
void ConstructL();
void StartObserver();

public:
CLogViewRecent* iRecentLogView;
RFs iFs;
CLogClient* iLogClient;
//void GetLatest();

private:
virtual void DoCancel();
virtual void RunL();

private:
TInt InitializePhone();
void ReleasePhone();

private:
MIncomingCallObserverInterface* iObserver;

RCall::TStatus iCallStatus;
TName iName;

TBool iLineInited;
TBuf <40> iTsyName;
RTelServer iTelServer;
RPhone iPhone;
RLine iLine;

TBool iCallActive;
RCall iCall;

};
#endif


////////////////////////////////////
// ActiveIncomingCallObserver.cpp //
////////////////////////////////////

#include "ActiveIncomingCallObserver.h"
#include <apgtask.h>
#include <aknnotewrappers.h>

CActiveIncomingCallObserver::CActiveIncomingCallObserver(MIncomingCallObserverInterface* aObserver)
: CActive(0)
{
iObserver = aObserver;
iLineInited = EFalse;
iCallActive = EFalse;
}

CActiveIncomingCallObserver::~CActiveIncomingCallObserver()
{
// Cancel any request, if outstanding
if (IsActive())
{
Cancel();
}
else
{
ReleasePhone();
}
}

void CActiveIncomingCallObserver::ConstructL()
{
CActiveScheduler::Add(this);
}

void CActiveIncomingCallObserver:oCancel()
{
ReleasePhone();
//iRecentLogView->Cancel();
}

void CActiveIncomingCallObserver::RunL()
{
if (iStatus == KErrNone)
{
if (iCallActive)
{
// We are polling for the RCall status
if (iCallStatus == RCall::EStatusHangingUp || iCallStatus == RCall::EStatusIdle || iCallStatus == RCall::EStatusUnknown)
{
iCallActive = EFalse;
iCall.Close();
iLine.NotifyIncomingCall(iStatus, iName);
if (iObserver)
{
iObserver->IncomingCallObserverInterface_HandleItL();
}
}
else
{

iCallActive = EFalse;
iCall.NotifyStatusChange(iStatus, iCallStatus);
User::WaitForRequest(iStatus);
}
//GetLatest();
}
else
{
// There's an incoming call!
iCallActive = ETrue;
iCall.OpenExistingCall(iLine, iName);

// I add my function here to answer then hanging up
iCall.AnswerIncomingCall (iStatus);
User::WaitForRequest(iStatus);

iCall.NotifyStatusChange(iStatus, iCallStatus);
User::WaitForRequest(iStatus);
iCall.HangUp(iStatus);
User::WaitForRequest(iStatus);

// Here I add codes for retrieving caller number
iFs.Connect();
iLogClient = CLogClient::NewL(iFs);
iRecentLogView = CLogViewRecent::NewL(*iLogClient);
iRecentLogView->SetRecentListL(KLogNullRecentList,iStatus);
User::WaitForRequest(iStatus);
TBuf<20> iTelNumber;
const CLogEvent& event = iRecentLogView->Event();
iTelNumber.Copy(event.Number());
CAknInformationNote *notify=new (ELeave) CAknInformationNote;
notify->ExecuteLD(iTelNumber);

iCall.NotifyStatusChange(iStatus, iCallStatus);
}
// And we re-enable the polling
SetActive();
}
}

void CActiveIncomingCallObserver::StartObserver()
{
// Just in case - but we should not need it!
Cancel();
if (InitializePhone() == KErrNone)
{
// Tells scheduler a request is active
SetActive();
}
}

TInt CActiveIncomingCallObserver::InitializePhone()
{
TInt theError;
if (iLineInited)
{
return KErrNone;
}
theError = iTelServer.Connect();
if (theError)
{
return theError;
}
// Find the number of phones available from the tel server
TInt numberPhones;
theError = iTelServer.EnumeratePhones(numberPhones);
if (theError)
{
iTelServer.Close();
return theError;
}
// Check there are available phones
if (numberPhones < 1)
{
iTelServer.Close();
return KErrNotFound;
}
// Read the TSY module name
theError = iTelServer.GetTsyName(0, iTsyName);
if (theError != KErrNone)
{
iTelServer.Close();
return theError;
}
// Load in the phone device driver
theError = iTelServer.LoadPhoneModule(iTsyName);
if (theError)
{
iTelServer.Close();
return theError;
}
// Get info about the first available phone
RTelServer::TPhoneInfo info;
theError = iTelServer.GetPhoneInfo(0, info);
if (theError)
{
iTelServer.UnloadPhoneModule(iTsyName);
iTelServer.Close();
return theError;
}
// Use this info to open a connection to the phone, the phone is identified by its name
theError = iPhone.Open(iTelServer, info.iName);
if (theError)
{
iTelServer.UnloadPhoneModule(iTsyName);
iTelServer.Close();
return theError;
}
// Get info about the first line from the phone
RPhone::TLineInfo lineInfo;
theError = iPhone.GetLineInfo(0, lineInfo);
if (theError)
{
iPhone.Close();
iTelServer.UnloadPhoneModule(iTsyName);
iTelServer.Close();
return theError;
}
// Use this to open a line
theError = iLine.Open(iPhone, lineInfo.iName);
if (theError)
{
iPhone.Close();
iTelServer.UnloadPhoneModule(iTsyName);
iTelServer.Close();
return theError;
}
iLine.NotifyIncomingCall(iStatus, iName);
iLineInited = ETrue;

return KErrNone;
}

void CActiveIncomingCallObserver::ReleasePhone()
{
if (iLineInited)
{
if (iCallActive)
{
iCall.NotifyStatusChangeCancel();
iCall.Close();
}
else
{
iLine.NotifyIncomingCallCancel();
}
iLine.Close();
iPhone.Close();
iTelServer.UnloadPhoneModule(iTsyName);
iTelServer.Close();
iLineInited = EFalse;
}
}


Thank you very much...


Eric