os/persistentdata/loggingservices/eventlogger/LogServ/src/LogServRecentListManager.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/persistentdata/loggingservices/eventlogger/LogServ/src/LogServRecentListManager.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,72 @@
     1.4 +// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#include "LogServRecentListManager.h"
    1.20 +#include "LogServResourceInterpreter.h"
    1.21 +#include "LogServRecentList.h"
    1.22 +#include "logservpanic.h"
    1.23 +
    1.24 +/////////////////////////////////////////////////////////////////////////////////////////
    1.25 +// -----> CLogServRecentListManager (source)
    1.26 +/////////////////////////////////////////////////////////////////////////////////////////
    1.27 +
    1.28 +CLogServRecentListManager::~CLogServRecentListManager()
    1.29 +	{
    1.30 +	iLists.ResetAndDestroy();
    1.31 +	iLists.Close();
    1.32 +	}
    1.33 +
    1.34 +void CLogServRecentListManager::ConstructL(CLogServResourceInterpreter& aResourceInterpreter, TInt aResourceId)
    1.35 +	{
    1.36 +	TResourceReader reader;
    1.37 +	aResourceInterpreter.CreateResourceReaderLC(reader, aResourceId);
    1.38 +	const TInt count = reader.ReadInt16();
    1.39 +	iLists.ReserveL(count);
    1.40 +	for(TInt i=0; i<count; i++)
    1.41 +		{
    1.42 +		CLogServRecentList* list = CLogServRecentList::NewL(reader);
    1.43 +		TInt err = iLists.Append(list);
    1.44 +        __ASSERT_ALWAYS(err == KErrNone, Panic(ELogArrayReserved));
    1.45 +		}
    1.46 +	CleanupStack::PopAndDestroy(); // reader
    1.47 +#ifdef SYSLIBS_TEST
    1.48 +	//Creates a test recent list used by the unit tests. Helps covering most of the production code branches,
    1.49 +	//related to the recent lists functionality.
    1.50 +	CLogServRecentList* list = CLogServRecentList::TestNewL();
    1.51 +	iLists.AppendL(list);
    1.52 +#endif
    1.53 +	}
    1.54 +
    1.55 +CLogServRecentListManager* CLogServRecentListManager::NewL(CLogServResourceInterpreter& aResourceInterpreter, TInt aResourceId)
    1.56 +	{
    1.57 +	CLogServRecentListManager* self = new(ELeave) CLogServRecentListManager;
    1.58 +	CleanupStack::PushL(self);
    1.59 +	self->ConstructL(aResourceInterpreter, aResourceId);
    1.60 +	CleanupStack::Pop();
    1.61 +	return self;
    1.62 +	}
    1.63 +
    1.64 +const CLogServRecentList* CLogServRecentListManager::GetRecentList(const CLogEvent& aEvent) const
    1.65 +	{
    1.66 +	TInt count = iLists.Count();
    1.67 +	while(count--)
    1.68 +		{
    1.69 +		const CLogServRecentList* list = iLists[count];
    1.70 +		if (list->IsRecent(aEvent))
    1.71 +			return list;
    1.72 +		}
    1.73 +	return NULL;
    1.74 +	}
    1.75 +