loggingservices/eventlogger/LogServ/src/LogServRecentListManager.cpp
changeset 0 08ec8eefde2f
equal deleted inserted replaced
-1:000000000000 0:08ec8eefde2f
       
     1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include "LogServRecentListManager.h"
       
    17 #include "LogServResourceInterpreter.h"
       
    18 #include "LogServRecentList.h"
       
    19 #include "logservpanic.h"
       
    20 
       
    21 /////////////////////////////////////////////////////////////////////////////////////////
       
    22 // -----> CLogServRecentListManager (source)
       
    23 /////////////////////////////////////////////////////////////////////////////////////////
       
    24 
       
    25 CLogServRecentListManager::~CLogServRecentListManager()
       
    26 	{
       
    27 	iLists.ResetAndDestroy();
       
    28 	iLists.Close();
       
    29 	}
       
    30 
       
    31 void CLogServRecentListManager::ConstructL(CLogServResourceInterpreter& aResourceInterpreter, TInt aResourceId)
       
    32 	{
       
    33 	TResourceReader reader;
       
    34 	aResourceInterpreter.CreateResourceReaderLC(reader, aResourceId, CLogServResourceInterpreter::ELogWrap);
       
    35 	const TInt count = reader.ReadInt16();
       
    36 	iLists.ReserveL(count);
       
    37 	for(TInt i=0; i<count; i++)
       
    38 		{
       
    39 		CLogServRecentList* list = CLogServRecentList::NewL(reader);
       
    40 		TInt err = iLists.Append(list);
       
    41         __ASSERT_ALWAYS(err == KErrNone, Panic(ELogArrayReserved));
       
    42 		}
       
    43 	CleanupStack::PopAndDestroy(); // reader
       
    44 #ifdef SYSLIBS_TEST
       
    45 	//Creates a test recent list used by the unit tests. Helps covering most of the production code branches,
       
    46 	//related to the recent lists functionality.
       
    47 	CLogServRecentList* list = CLogServRecentList::TestNewL();
       
    48 	iLists.AppendL(list);
       
    49 #endif
       
    50 	}
       
    51 
       
    52 CLogServRecentListManager* CLogServRecentListManager::NewL(CLogServResourceInterpreter& aResourceInterpreter, TInt aResourceId)
       
    53 	{
       
    54 	CLogServRecentListManager* self = new(ELeave) CLogServRecentListManager;
       
    55 	CleanupStack::PushL(self);
       
    56 	self->ConstructL(aResourceInterpreter, aResourceId);
       
    57 	CleanupStack::Pop();
       
    58 	return self;
       
    59 	}
       
    60 
       
    61 const CLogServRecentList* CLogServRecentListManager::GetRecentList(const CLogEvent& aEvent) const
       
    62 	{
       
    63 	TInt count = iLists.Count();
       
    64 	while(count--)
       
    65 		{
       
    66 		const CLogServRecentList* list = iLists[count];
       
    67 		if (list->IsRecent(aEvent))
       
    68 			return list;
       
    69 		}
       
    70 	return NULL;
       
    71 	}
       
    72