You Are Here:

Community: Wiki


CS000849 - Obtaining recent calls

From Forum Nokia Wiki



ID CS000849 Creation date March 7, 2008
Platform S60 3rd Edition, MR
S60 3rd Edition, FP1
S60 3rd Edition, FP2 Beta
Tested on devices Nokia E61i
Nokia E90 Communicator
Nokia N95 8GB
Nokia 6220 Classic
Category Symbian C++ Subcategory Telephony


Keywords (APIs, classes, methods, functions): CActive, CLogClient, CLogViewRecent, CLogEvent, RFs, CLogViewRecent::SetRecentListL(), CLogViewRecent::Event(), CLogViewRecent::NextL()

Overview

This code example demonstrates how to obtain recent calls by using the S60 active object framework. In the example, recent calls are displayed on the screen one at a time.

MMP file

The following libraries are required:

LIBRARY  logcli.lib

Header file

#ifndef __LOGHANDLER_H_
#define __LOGHANDLER_H_
 
#include <e32base.h>
#include <logcli.h> // CLogClient
#include <logview.h> // CLogViewRecent
 
enum TTask
{
EGetRecent,
ESleep
};
 
class CLogHandler : public CActive
{
public:
/**
* Symbian OS default constructor
*/

CLogHandler();
 
/**
* 2nd phase constructor.
*/

static CLogHandler* NewL();
 
/**
* 2nd phase constructor.
*/

static CLogHandler* NewLC();
 
/**
* Destructor
*/

~CLogHandler();
 
/**
* Reads recent events from the main event database
*/

void ReadRecentEventsL();
 
private:
/**
* Symbian 2-phase constructor
*/

void ConstructL();
 
/**
* From CActive
*/

void RunL();
 
/**
* From CActive
*/

TInt RunError(TInt anError);
 
/**
* From CActive
*/

void DoCancel();
 
/**
* Handles a single recent event.
*/

void HandleRecentEventL(const CLogEvent& anEvent);
 
private: // Data
RFs iFs;
 
CLogClient* iLogClient;
CLogViewRecent* iLogViewRecent;
 
TTask iTask; // Task for RunL
};
 
#endif /*__LOGHANDLER_H_*/

Source file

#include <aknnotewrappers.h>
#include <e32base.h>
#include <logcli.h> // CLogClient
#include <logview.h> // CLogViewRecent
#include <logwrap.h> // CLogEvent
 
#include "LogHandler.h"
 
/**
* Constructor. Defines the priority for this active object.
*/

CLogHandler::CLogHandler() : CActive(EPriorityStandard)
{
}
 
/**
* 2nd phase constructor.
*/

CLogHandler* CLogHandler::NewL()
{
CLogHandler* self = CLogHandler::NewLC();
CleanupStack::Pop(self);
return self;
}
 
/**
* 2nd phase constructor.
*/

CLogHandler* CLogHandler::NewLC()
{
CLogHandler* self = new (ELeave) CLogHandler();
CleanupStack::PushL(self);
self->ConstructL();
return self;
}
 
/**
* 2nd phase constructor.
*/

void CLogHandler::ConstructL()
{
User::LeaveIfError(iFs.Connect());
 
// Establish connection to log engine
iLogClient = CLogClient::NewL(iFs);
iLogViewRecent = CLogViewRecent::NewL(*iLogClient);
 
iTask = ESleep; // Default task for RunL
 
CActiveScheduler::Add(this);
}
 
/**
* Destructor.
*/

CLogHandler::~CLogHandler()
{
Cancel();
 
delete iLogViewRecent;
delete iLogClient;
 
iFs.Close();
}
 
/**
* From CActive.
*/

void CLogHandler::RunL()
{
switch (iTask)
{
case EGetRecent:
{
// Retrieve the event and handle it
HandleRecentEventL(iLogViewRecent->Event());
 
// If there are more events in the log engine database...
if (iLogViewRecent->NextL(iStatus))
{
if (iStatus == KErrNone)
{
// ... set active to get the next one
SetActive();
}
}
else
{
// No more events. Go to sleep.
iTask = ESleep;
}
break;
}
 
case ESleep:
default:
{
break;
}
}
}
 
/**
* From CActive.
*/

TInt CLogHandler::RunError(TInt anError)
{
return anError;
}
 
/**
* From CActive.
*/

void CLogHandler::DoCancel()
{
// Cancel the appropriate task
switch (iTask)
{
case EGetRecent:
{
iLogViewRecent->Cancel();
}
 
case ESleep:
default:
{
break;
}
}
}
 
/**
* Reads recent events from the main event database
*/

void CLogHandler::ReadRecentEventsL()
{
if (iLogViewRecent->SetRecentListL(KLogNullRecentList, iStatus))
{
if (iStatus == KErrNone)
{
// If there are events in the log view, set this active object active
// to get the events from the main event database. See RunL().
iTask = EGetRecent;
SetActive();
}
}
else
{
_LIT(KTxt, "No recent calls.");
CAknInformationNote* note = new (ELeave)CAknInformationNote(ETrue);
note->ExecuteLD(KTxt);
}
}
 
/**
* Displays a recent event in an information note.
*/

void CLogHandler::HandleRecentEventL(const CLogEvent& anEvent)
{
TBuf<255> buffer;
_LIT(KTxt, "Description: %S\nNumber: %S");
buffer.Format(KTxt, &(anEvent.Description()), &(anEvent.Number()));
CAknInformationNote* note = new (ELeave)CAknInformationNote(ETrue);
note->ExecuteLD(buffer);
}

Postconditions

Recent calls are displayed on the screen one at a time.

Related Wiki Articles

No related wiki articles found

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fwikiE2eforumE2enokiaE2ecomE2findeE78E2ephpE2fFileE3aMicrokernelE5fArchitectureE2eGIFX qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqfntypeZWikiContentQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZtypeQUqfntypeZWikiContentQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqfntypeZWikiContentQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ