×
Namespaces

Variants
Actions

How to List Delivery Reports on Symbian

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Tested with
Devices(s): Tested on Nokia E66, Nokia N96
Compatibility
Platform(s): S60 3rd Edition
S60 3rd Edition FP1
S60 3rd Edition FP2
S60 5th Edition
S60 3rd Edition FP2
S60 3rd Edition FP1
Article
Keywords: CLogFilter, CLogFilterList, CLogViewEvent,
Created: User:Kbwiki (10 Nov 2009)
Last edited: hamishwillee (14 Jun 2013)

Contents

Overview

This article describes how to list delivery reports for short messages.

Description

Delivery reports can be listed by filtering logs as follows:

  • Event type: SMS
  • Direction: Out
  • Status: Pending, Delivered or Failed

Solution

Derive a class from CActive and use classes provided by the log engine to filter out log events corresponding to SMS delivery reports.

Header file

  #include <e32base.h>
#include <f32file.h> // RFs
#include <logcli.h> // CLogClient
#include <logview.h> // CLogViewEvent
 
class CDeliveryReportEngine : public CActive
{
public:
// NewL constructor
static CDeliveryReportEngine* NewL();
 
// destructor
~CDeliveryReportEngine();
 
public:
void ReadDeliveryReportsL();
 
protected: // from CActive
void RunL();
void DoCancel();
 
private:
// Private constructors
CDeliveryReportEngine();
void ConstructL();
 
void AppendFilterL( const TDesC &aDirection,
const TDesC &aStatus,
TLogFlags aFlags,
TUint32 aNullFields,
TUid aType );
 
private:
 
// Data
CLogClient* iLogClient;
CLogViewEvent* iLogViewEvent;
CLogFilterList* iFilterList;
RFs iFs;
};


Filtering the logs for Delivery Reports

The CLogViewEvent and CLogFilterList classes provide methods for reading log entries one by one from the database and filtering them based on event type, direction, and status. The delivery status is represented by a string. Standard strings are available in the log wrapper resource file and can be accessed through predefined resource IDs.

  CDeliveryReportEngine::CDeliveryReportEngine()
: CActive( CActive::EPriorityStandard )
{
CActiveScheduler::Add( this );
}
 
 
CDeliveryReportEngine* CDeliveryReportEngine::NewL()
{
CDeliveryReportEngine* self = new (ELeave) CDeliveryReportEngine;
CleanupStack::PushL( self );
self->ConstructL();
CleanupStack::Pop(); // self
return self;
}
 
 
void CDeliveryReportEngine::ConstructL()
{
User::LeaveIfError( iFs.Connect() );
iLogClient = CLogClient::NewL( iFs );
}
 
 
CDeliveryReportEngine::~CDeliveryReportEngine()
{
Cancel();
 
if( iFilterList )
{
// Deletes all filters in the list
iFilterList->ResetAndDestroy();
}
 
delete iFilterList;
delete iLogViewEvent;
delete iLogClient;
iFs.Close();
}
 
 
void CDeliveryReportEngine::ReadDeliveryReportsL()
{
Cancel();
 
if( !iLogViewEvent )
{
iLogViewEvent = CLogViewEvent::NewL( *iLogClient );
}
 
if( !iFilterList )
{
TLogString logString;
 
// Create a set of event view filters
iFilterList = new ( ELeave ) CLogFilterList();
 
// Append filter for Direction: OUT
iLogClient->GetString( logString, R_LOG_DIR_OUT );
AppendFilterL( logString, KNullDesC, KLogEventRead, ELogFlagsField, TUid() );
 
// Append filter for event type: SMS
AppendFilterL( KNullDesC, KNullDesC, 0, 0, KLogShortMessageEventTypeUid );
 
// Append filter for Status: Pending
iLogClient->GetString( logString, R_LOG_DEL_PENDING );
AppendFilterL( KNullDesC, logString, 0, 0, TUid() );
 
// Append filter for Status: Delivered
iLogClient->GetString( logString, R_LOG_DEL_DONE );
AppendFilterL( KNullDesC, logString, 0, 0, TUid() );
 
// Append filter for Status: Failed
iLogClient->GetString( logString, R_LOG_DEL_FAILED );
AppendFilterL( KNullDesC, logString, 0, 0, TUid() );
}
 
if ( iLogViewEvent->SetFilterL( *iFilterList, iStatus ) )
{
SetActive();
}
else
{
// No events in the view
}
}
 
 
void CDeliveryReportEngine::AppendFilterL( const TDesC &aDirection,
const TDesC &aStatus,
TLogFlags aFlags,
TUint32 aNullFields,
TUid aType )
{
CLogFilter* logFilter = CLogFilter::NewL();
CleanupStack::PushL( logFilter );
logFilter->SetDirection( aDirection );
logFilter->SetStatus( aStatus );
logFilter->SetFlags( aFlags );
logFilter->SetNullFields( aNullFields );
logFilter->SetEventType( aType );
iFilterList->AppendL( logFilter );
CleanupStack::Pop( logFilter );
}

After reading each filtered log entry, the RunL() function of the active object will be called. CLogViewEvent::Event() will return the current log event that matches the set filters.

  void CDeliveryReportEngine::RunL()
{
if( iStatus == KErrNone && iLogViewEvent )
{
// Use the following functions to access delivery report details:
 
// iLogViewEvent->Event().Description();
// iLogViewEvent->Event().Status();
// iLogViewEvent->Event().Number();
 
// Try retrieving the next event
if ( iLogViewEvent->NextL( iStatus ) )
{
SetActive();
}
else
{
// No more events
}
}
}
 
 
void CDeliveryReportEngine::DoCancel()
{
delete iLogViewEvent;
iLogViewEvent = 0;
}


Required capabilities
ReadUserData

Related article

S60 Platform Log example

This page was last modified on 14 June 2013, at 10:06.
52 page views in the last 30 days.
×