sl@0: // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #include "LogChangeDefinition.h" sl@0: sl@0: // User includes sl@0: #include "logclipanic.h" sl@0: sl@0: sl@0: ///////////////////////////////////////////////////////////////////////////////////////// sl@0: // -----> CLogChangeDefinition (source) sl@0: ///////////////////////////////////////////////////////////////////////////////////////// sl@0: sl@0: CLogChangeDefinition::CLogChangeDefinition(TInt aGranularity) sl@0: : iChanges(aGranularity) sl@0: { sl@0: } sl@0: sl@0: EXPORT_C CLogChangeDefinition::~CLogChangeDefinition() sl@0: { sl@0: iChanges.Close(); sl@0: } sl@0: sl@0: void CLogChangeDefinition::ConstructL(const CLogChangeDefinition& aCopy) sl@0: { sl@0: const TInt count = aCopy.Count(); sl@0: for(TInt i=0; iConstructL(aCopy); sl@0: CleanupStack::Pop(self); sl@0: return self; sl@0: } sl@0: sl@0: EXPORT_C CLogChangeDefinition* CLogChangeDefinition::NewL(RReadStream& aStream) sl@0: { sl@0: CLogChangeDefinition* self = new(ELeave) CLogChangeDefinition(KLogChangeDefinitionDefaultGranularity); sl@0: CleanupStack::PushL(self); sl@0: aStream >> *self; sl@0: CleanupStack::Pop(self); sl@0: return self; sl@0: } sl@0: sl@0: ///////////////////////////////////////////////////////////////////////////////////////// sl@0: ///////////////////////////////////////////////////////////////////////////////////////// sl@0: ///////////////////////////////////////////////////////////////////////////////////////// sl@0: sl@0: EXPORT_C TInt CLogChangeDefinition::Count() const sl@0: { sl@0: return iChanges.Count(); sl@0: } sl@0: sl@0: EXPORT_C TLogDatabaseChangeType CLogChangeDefinition::At(TInt aIndex) const sl@0: { sl@0: const TLogShdChangeDetails& entry = iChanges[aIndex]; sl@0: return entry.iType; sl@0: } sl@0: sl@0: EXPORT_C TLogDatabaseChangeType CLogChangeDefinition::At(TInt aIndex, TLogId& aId) const sl@0: { sl@0: const TLogShdChangeDetails& entry = iChanges[aIndex]; sl@0: aId = entry.iId; sl@0: return entry.iType; sl@0: } sl@0: sl@0: EXPORT_C TLogDatabaseChangeType CLogChangeDefinition::At(TInt aIndex, TLogId& aId, TInt& aViewIndex) const sl@0: { sl@0: const TLogShdChangeDetails& entry = iChanges[aIndex]; sl@0: aId = entry.iId; sl@0: aViewIndex = entry.iViewIndex; sl@0: return entry.iType; sl@0: } sl@0: sl@0: EXPORT_C TInt CLogChangeDefinition::Find(TLogId aId) const sl@0: { sl@0: // Linear search sl@0: const TLogShdChangeDetails entryToFind(aId); sl@0: TIdentityRelation relation(CompareEntryIds); sl@0: const TInt position = iChanges.Find(entryToFind, relation); sl@0: return position; sl@0: } sl@0: sl@0: EXPORT_C TInt CLogChangeDefinition::Find(TLogId aId, TLogDatabaseChangeType aType) const sl@0: { sl@0: // First try and find any log id regardless of change type sl@0: TInt position = Find(aId); sl@0: if (position >= 0) sl@0: { sl@0: const TInt count = iChanges.Count(); sl@0: sl@0: // Keep iterating through the changes until we sl@0: // sl@0: // a) Reach the end of the changes OR sl@0: // b) Reach a change corresponding to a different log id OR sl@0: // c) Find the change we're interested in sl@0: TInt i = position; sl@0: position = KErrNotFound; sl@0: // sl@0: for(; i relation(CompareViewIndicies); sl@0: const TInt position = iChanges.Find(entryToFind, relation); sl@0: return position; sl@0: } sl@0: sl@0: EXPORT_C void CLogChangeDefinition::AddL(TLogId aId, TLogDatabaseChangeType aType, TInt aViewIndex) sl@0: { sl@0: switch(aType) sl@0: { sl@0: case ELogChangeTypeEventChanged: sl@0: case ELogChangeTypeEventChangedHidden: sl@0: case ELogChangeTypeEventAdded: sl@0: case ELogChangeTypeEventDeleted: sl@0: case ELogChangeTypeLogCleared: sl@0: AddToContainerL(aId, aType, aViewIndex); sl@0: break; sl@0: // sl@0: default: sl@0: case ELogChangeTypeUndefined: sl@0: __ASSERT_ALWAYS(0, Panic(ELogUndefinedChangeType)); sl@0: break; sl@0: } sl@0: } sl@0: sl@0: EXPORT_C void CLogChangeDefinition::Reset() sl@0: { sl@0: iChanges.Reset(); sl@0: iChanges.GranularCompress(); sl@0: } sl@0: sl@0: ///////////////////////////////////////////////////////////////////////////////////////// sl@0: ///////////////////////////////////////////////////////////////////////////////////////// sl@0: ///////////////////////////////////////////////////////////////////////////////////////// sl@0: sl@0: EXPORT_C void CLogChangeDefinition::InternalizeL(RReadStream& aStream) sl@0: { sl@0: TLogShdChangeDetails entry; sl@0: // sl@0: TCardinality count; sl@0: aStream >> count; sl@0: // sl@0: for(TInt i=0; i(aStream.ReadInt32L()); sl@0: entry.iType = static_cast(aStream.ReadUint8L()); sl@0: entry.iViewIndex = static_cast(aStream.ReadInt32L()); sl@0: // sl@0: User::LeaveIfError(iChanges.Append(entry)); sl@0: } sl@0: } sl@0: sl@0: EXPORT_C void CLogChangeDefinition::ExternalizeL(RWriteStream& aStream) const sl@0: { sl@0: TCardinality count = Count(); sl@0: aStream << count; sl@0: // sl@0: for(TInt i=0; i