⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 calllogengine.cpp

📁 Symbian s60 2rd 通话摘要例题
💻 CPP
字号:
/**
* 
* @brief Definition of CCallLogEngine
*
* Copyright (c) EMCC Software Ltd 2003
* @version 1.0
*/

// INCLUDES

//  Class include
#include "CallLogEngine.h"

// System includes
#include <eikenv.h>			// CCoeEnv
#include <logview.h>		// CLogViewEvent
 
// User includes
#include "CallArray.h"		// CCallArray
#include "EngineObserver.h"	// MCallLogEngineObserver

#if defined(_DEBUG)
#include "debugentries.h"	// CAddEntries
#endif // (_DEBUG)

// ================= MEMBER FUNCTIONS =======================

/**
* C++ Constructor
* @param aObserver log engine observer
* @param aCallArray the array to be filled with information from the log engine
*/
CCallLogEngine::CCallLogEngine(MCallLogEngineObserver& aObserver, CCallArray& aCallArray)
	:CActive(CActive::EPriorityStandard), iObserver(aObserver), iCallArray(aCallArray)
	{
	}

/** 
* Destructor.  Frees up memory 
*/
CCallLogEngine::~CCallLogEngine()
	{
	Cancel();
	delete iLogView;
	delete iLogClient;
	delete iLogFilter;

#if defined(_DEBUG)
	delete iEntryAdd;
#endif // (_DEBUG)
	}

/**
* Symbian OS 2 phase constructor.
* Constructs the CCallLogEngine using the NewLC method, popping
* the constructed object from the CleanupStack before returning it.
* 
* @param aObserver log engine observer
* @param aCallArray the array to be filled with information from the log engine
* @param aDirectionId what type of calls to filter from log i.e incoming
* @return The newly constructed CCallLogEngine
*/
CCallLogEngine* CCallLogEngine::NewL(MCallLogEngineObserver& aObserver, CCallArray& aCallArray, TInt aDirection)
	{
	CCallLogEngine* self = CCallLogEngine::NewLC(aObserver, aCallArray, aDirection);
	CleanupStack::Pop(self);
	return self;
	}

/**
* Symbian OS 2 phase constructor.
* Constructs the CCallLogEngine using the constructor and ConstructL 
* method, leaving the constructed object on the CleanupStack before returning it.
* 
* @param aObserver log engine observer
* @param aCallArray the array to be filled with information from the log engine
* @param aDirectionId what type of calls to filter from log i.e incoming
* @return The newly constructed CCallLogEngine
*/
CCallLogEngine* CCallLogEngine::NewLC(MCallLogEngineObserver& aObserver, CCallArray& aCallArray, TInt aDirection)
	{
	CCallLogEngine* self = new (ELeave) CCallLogEngine(aObserver, aCallArray);
	CleanupStack::PushL(self);
	self->ConstructL(aDirection);
	return self;
	}

/**
* Symbian OS 2nd phase constructor.  
* @param aDirectionId what type of calls to filter from log i.e incoming
*/ 
void CCallLogEngine::ConstructL(TInt aDirection)
	{
	// Get the file server session owned by control environment
	RFs& fsSession = CCoeEnv::Static()->FsSession();

	// create the log engine, a view of the logengine, a filter
	iLogClient = CLogClient::NewL(fsSession);
	iLogView = CLogViewEvent::NewL(*iLogClient);
	iLogFilter = CLogFilter::NewL();

	// Find from the log engine, the string for the given direction resource
	TBuf<64> direction;
	iLogClient->GetString(direction, aDirection);

	// Set the direction to be filtered 
	iLogFilter->SetDirection(direction);
	iLogFilter->SetEventType(KLogCallEventTypeUid);

	// Add to the active scheduler
	CActiveScheduler::Add(this);

	// Add the log events to the array of call information
	// ** Note that this is only performed when the engine is created, so any 
	// ** changes to the call log while the application is running will be ignored.
	PopulateCallArrayL();
	}

/** 
* Makes an asynchronous request to set the a filter on
* the current log view. If there are no events in the filtered
* view, calls the observer's  CallArrayEmpty() function. 
* In a debug build, the new entries are asynchronously added to the event log
*/ 
void CCallLogEngine::PopulateCallArrayL()
	{
	// Filter the view by the requrements in iFilter, if there
	// are no events in the view, eventsInView is EFalse, and the 
	// asynchronous request is not issued.
	TBool eventsInView = iLogView->SetFilterL(*iLogFilter, iStatus);
	iEngineState = ECreatingView;

	if (eventsInView)
		{
		// if there are events in the filtered view
		// issue the asynchronous request
		SetActive();
		}
	else
		{
#if defined(_DEBUG)
		// if there are no events in the view
		// add some dummy events to the log engine
		// if this is a debug build

		// **** Note that the dummy events will only be added the first time this runs as the events
		// **** are saved permanently in the event log. To delete the event log, remove the file
		// **** C:\system\data\logdbu.dat or use the Log application to clear it on target.

		iEngineState = EDebugCreatingEventLog;
		iEntryAdd = CAddEntries::NewL(*iLogClient, iStatus);
		SetActive();
#else
		// In a non-debug build, inform the observer 
		// that there no events in the view
		iObserver.CallArrayEmptyL();
#endif // (_DEBUG)
		}
	}


/**
* Called from CActive::Cancel(), allowing this object 
* to provide specific cleanup activity.
*
*/
void CCallLogEngine::DoCancel()
	{
	}

/**
* Called when the an asynchronous request completes. If there has been
* error the observer's CallLogErrorL is called. If the request completes
* successfully a state pattern is used to determine whether an oberver 
* function is called or an asynchronous request made.
* 
*/
void CCallLogEngine::RunL()
	{
	if (iStatus != KErrNone)
		{
		// if there has been a problem inform the observer.
		iObserver.CallLogErrorL();
		return;
		}

	switch (iEngineState)
		{
		case ECreatingView:
			{
			// The filtered view has been successfully created
			// so issue a request to go to the first event
			iLogView->FirstL(iStatus);
			iEngineState = EAddingEntry;
			SetActive();
			break;
			}
		case EAddingEntry:
			{
			// Add the current event to the array of events
			const CLogEvent& event = iLogView->Event();
			iCallArray.AddEntryL(event);

			// Are there any more entries
			if (iLogView->NextL(iStatus))
				{
				// if there is another entry, issue the request
				// to move to the next entry.
				SetActive();
				}
			else
				{
				// if there aren't any more entries, inform the observer
				// that the array has been created.
				iObserver.CallArrayCreatedL();
				}
			break;
			}
#if defined(_DEBUG)
		case EDebugCreatingEventLog:
			{
			// If under a debug build, events have been added to 
			// the event log, create a filtered view of the added
			// events.
			iLogView->SetFilterL(*iLogFilter, iStatus);
			iEngineState = ECreatingView;
			SetActive();
			}
#endif // _DEBUG
		default:
			break;
		}
	}

/**
* Called if RunL leaves
* 
* @param the error that RunL leaves with. 
* @return error code
*/	
TInt CCallLogEngine::RunError(TInt /*aError*/)
	{
	return KErrNone;
	}

// End of File

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -