Hello,
I'm hoping one of the veterans can help me out. I'm developing an application where I need to access the log engine. I'm trying to access some of the asynchronous functions such as SetRecentListL of the CLogViewRecent class. This obviously needs to be implemented as an active object but I'm running into problems. What's happening is that I access my request function HandleLog which makes the asynchronous request and so on. This happens when the appropiate selection is made from a menu. So the first time I access the menu nothing happens. It's the second time around when the event triggers and my popup displays. I don't know if this makes sense but below is my header and source code:
////////////////////////// header //////////////////////////
class CTest : public CActive
{
public:
static CTest* NewL();
void ConstructL();
virtual ~CTest();
void HandleLog();
private:
virtual void RunL();
virtual void DoCancel();
private:
CTest();
RTimer iTimer;
CLogClient* clc;
CLogViewRecent* clv;
RFs file;
TBool success;
};
////////////////////////// source //////////////////////////
#include "Test.h"
///////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CTest* CTest::NewL()
{
CTest* self = new(ELeave) CTest;
CleanupStack::PushL(self);
self->ConstructL();
CleanupStack::Pop();
return self;
}
CTest::CTest():CActive(0)
{
}
void CTest::ConstructL()
{
CActiveScheduler::Add(this); // add to scheduler
}
CTest::~CTest()
{
Cancel();
}
void CTest::HandleLog()
{
__ASSERT_ALWAYS(!IsActive(), User::Panic(_L("CTest"😉, 1));
file.Connect();
clc = CLogClient::NewL(file);
clv = CLogViewRecent::NewL(*clc);
file.Close();
success = clv->SetRecentListL(KLogNullRecentList, iStatus);
SetActive();
}
void CTest::RunL()
{
if(success)
{
globalNote->ShowNoteL(EAknGlobalInformationNote, _L("success"😉);
} else {
globalNote->ShowNoteL(EAknGlobalInformationNote, _L("failure"😉);
}
CleanupStack::PopAndDestroy();
}
void CTest:😃oCancel()
{
}
Everything runs fine in the emulator and on the target device is just that the first time that HandleLog is called nothing happens. Then the next time I click on the menu my popups display. I know I'm missing something with the active object but I'm just not sure what. I would greatly appreciate any insight you may have.
Best regards,
Dennis