×
Namespaces

Variants
Actions

How to delete last dialed number from call logs

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Tested with
Devices(s): Emulator
Compatibility
Platform(s): Symbian
Article
Keywords: CLogClient, CLogViewEvent, CLogFilter, Call Log
Created: skumar_rao (24 Jul 2010)
Last edited: hamishwillee (30 May 2013)

Overview

  • Following article presents code on how to delete last dialed number from call logs from S60 Device.


Header ( DeleteLastCallLogEntry.h )

/*
============================================================================
Name : DeleteLastCallLogEntry.h
Author  : skumar.mobiledev@gmail.com
Version  : 1.0
Copyright  : Your copyright notice
Description : CDeleteLastCallLogEntry declaration
============================================================================
*/

 
#ifndef DELETELASTCALLLOGENTRY_H
#define DELETELASTCALLLOGENTRY_H
 
// INCLUDES
#include <F32FILE.H>
#include <LOGVIEW.H>
#include <logcli.h>
 
class CDeleteLastCallLogEntry : public CActive
{
public:
~CDeleteLastCallLogEntry();
static CDeleteLastCallLogEntry* NewL();
static CDeleteLastCallLogEntry* NewLC();
 
private:
CDeleteLastCallLogEntry();
void ConstructL();
 
private: // from CActive
void DoCancel();
void RunL();
 
public:
void DeleteLastDialledEntryL();
 
private:
enum TCallLogReaderState
{
ECreatingView,
EReadingEntries,
EReadingLast,
EDeleteEntry
};
TCallLogReaderState iEngineState;
CLogClient* iLogClient;
CLogViewEvent* iLogView;
CLogFilter* iLogFilter;
//MLogCallBack* iCallBack;
RFs iFsSession;
};
 
#endif // DELETELASTCALLLOGENTRY_H

Source ( DeleteLastCallLogEntry.cpp )

{{{
/*
============================================================================
Name : DeleteLastCallLogEntry.cpp
Author  : skumar.mobiledev@gmail.com
Version  : 1.0
Copyright  : Your copyright notice
Description : CDeleteLastCallLogEntry implementation
============================================================================
*/

 
#include "DeleteLastCallLogEntry.h"
 
 
CDeleteLastCallLogEntry::CDeleteLastCallLogEntry()
:CActive(CActive::EPriorityStandard)
{
// No implementation required
}
 
CDeleteLastCallLogEntry::~CDeleteLastCallLogEntry()
{
Cancel();
delete iLogView, iLogView = NULL;
delete iLogFilter, iLogFilter = NULL;
delete iLogClient, iLogClient = NULL;
iFsSession.Close();
}
 
CDeleteLastCallLogEntry* CDeleteLastCallLogEntry::NewLC()
{
CDeleteLastCallLogEntry* self = new (ELeave) CDeleteLastCallLogEntry();
CleanupStack::PushL(self);
self->ConstructL();
return self;
}
 
CDeleteLastCallLogEntry* CDeleteLastCallLogEntry::NewL()
{
CDeleteLastCallLogEntry* self = CDeleteLastCallLogEntry::NewLC();
CleanupStack::Pop(); // self;
return self;
}
 
void CDeleteLastCallLogEntry::ConstructL()
{
CActiveScheduler::Add(this);
 
User::LeaveIfError(iFsSession.Connect());
 
}
 
void CDeleteLastCallLogEntry::DeleteLastDialledEntryL()
{
Cancel();
if(iLogClient)
{
delete iLogClient;
iLogClient = NULL;
}
if(iLogView)
{
delete iLogView;
iLogView = NULL;
}
if(iLogFilter)
{
delete iLogFilter;
iLogFilter = NULL;
}
iLogClient = CLogClient::NewL(iFsSession);
iLogView = CLogViewEvent::NewL(*iLogClient);
iLogFilter = CLogFilter::NewL();
 
iLogFilter->SetEventType(KLogCallEventTypeUid);
 
TBuf<KLogMaxDirectionLength> direction;
iLogClient->GetString(direction, R_LOG_DIR_OUT);
iLogFilter->SetDirection(direction);
 
if(iLogView->SetFilterL(*iLogFilter, iStatus))
{
iEngineState = ECreatingView;
SetActive();
}
}
 
void CDeleteLastCallLogEntry::RunL()
{
if(iStatus == KErrNone)
{
switch (iEngineState)
{
case ECreatingView:
{
if(iLogView)
{
// The filtered view has been successfully created
// so issue a request to start processing logs backwards
if(iLogView->FirstL(iStatus))
{
iEngineState = EReadingEntries;
SetActive();
}
}
}
break;
case EReadingLast:
{
if(iLogView)
{
iLogView->FirstL(iStatus);
iEngineState = EReadingEntries;
SetActive();
}
}
break;
 
case EReadingEntries:
{
if(iLogView)
{
// since we are working from last-to-first
// you could also delete entries at this point if necessary
//iCallBack->HandleLogEventL(iLogView->Event());
 
//iEngineState = EReadingEntries;
//if(iLogView->PreviousL(iStatus))
/// SetActive();
const CLogEvent& event = iLogView->Event();
 
iEngineState = EDeleteEntry;
iLogClient->DeleteEvent(event.Id(), iStatus);
SetActive();
}
}
break;
 
default:
break;
}
}
}
 
void CDeleteLastCallLogEntry::DoCancel()
{
if(iLogView)
iLogView->Cancel();
 
if(iLogClient)
iLogClient->Cancel();
}

--skumar_rao 04:55, 24 July 2010 (UTC)

This page was last modified on 30 May 2013, at 04:38.
42 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×