Categories: Symbian C++ | Code Examples | Telephony | S60 3rd Edition | S60 3rd Edition, Feature Pack 1 | S60 3rd Edition, Feature Pack 2
This page was last modified 06:08, 7 March 2008.
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 |
| APIs | None | Classes | CActive CLogClient CLogViewRecent CLogEvent RFs |
| Methods | 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 Discussions | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Lost calls list | rambler82 | General Symbian C++ | 3 | 2006-11-14 10:36 |
| S40 support incoming calls | cguard | Mobile Java Tools & SDKs | 2 | 2006-07-13 06:59 |
| apis for call report details | saugatapaul | General Symbian C++ | 1 | 2008-03-04 10:46 |
| Handling Incoming calls in Series 60,2nd edition | krisdhingra | General Symbian C++ | 1 | 2007-02-15 14:37 |
| Draw on screen from background application | dancom | General Symbian C++ | 2 | 2003-05-26 12:37 |

