loggingservices/eventlogger/test/src/t_logutil3.cpp
author hgs
Mon, 27 Sep 2010 11:59:56 +0100
changeset 51 7d4490026038
permissions -rw-r--r--
201037_06
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
51
7d4490026038 201037_06
hgs
parents:
diff changeset
     1
// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
7d4490026038 201037_06
hgs
parents:
diff changeset
     2
// All rights reserved.
7d4490026038 201037_06
hgs
parents:
diff changeset
     3
// This component and the accompanying materials are made available
7d4490026038 201037_06
hgs
parents:
diff changeset
     4
// under the terms of "Eclipse Public License v1.0"
7d4490026038 201037_06
hgs
parents:
diff changeset
     5
// which accompanies this distribution, and is available
7d4490026038 201037_06
hgs
parents:
diff changeset
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
7d4490026038 201037_06
hgs
parents:
diff changeset
     7
//
7d4490026038 201037_06
hgs
parents:
diff changeset
     8
// Initial Contributors:
7d4490026038 201037_06
hgs
parents:
diff changeset
     9
// Nokia Corporation - initial contribution.
7d4490026038 201037_06
hgs
parents:
diff changeset
    10
//
7d4490026038 201037_06
hgs
parents:
diff changeset
    11
// Contributors:
7d4490026038 201037_06
hgs
parents:
diff changeset
    12
//
7d4490026038 201037_06
hgs
parents:
diff changeset
    13
// Description:
7d4490026038 201037_06
hgs
parents:
diff changeset
    14
//
7d4490026038 201037_06
hgs
parents:
diff changeset
    15
#include "t_logutil3.h"
7d4490026038 201037_06
hgs
parents:
diff changeset
    16
#include <centralrepository.h>
7d4490026038 201037_06
hgs
parents:
diff changeset
    17
#include "LOGREPDEFS.H"
7d4490026038 201037_06
hgs
parents:
diff changeset
    18
7d4490026038 201037_06
hgs
parents:
diff changeset
    19
//This function reads logeng repository file and returns the integer value of the given key. 
7d4490026038 201037_06
hgs
parents:
diff changeset
    20
static TInt LogGetRepositoryValueL(CRepository& aRepository, TInt aKey)
7d4490026038 201037_06
hgs
parents:
diff changeset
    21
	{		
7d4490026038 201037_06
hgs
parents:
diff changeset
    22
	TInt val = -1;		
7d4490026038 201037_06
hgs
parents:
diff changeset
    23
	User::LeaveIfError(aRepository.Get(aKey, val));
7d4490026038 201037_06
hgs
parents:
diff changeset
    24
	return val;
7d4490026038 201037_06
hgs
parents:
diff changeset
    25
	}
7d4490026038 201037_06
hgs
parents:
diff changeset
    26
7d4490026038 201037_06
hgs
parents:
diff changeset
    27
void LogGetContactmatchCountAndNameFormatL(TInt& aContactMatchCount, TLogContactNameFormat& aContactNameFormat)
7d4490026038 201037_06
hgs
parents:
diff changeset
    28
	{
7d4490026038 201037_06
hgs
parents:
diff changeset
    29
	CRepository* repository = NULL;
7d4490026038 201037_06
hgs
parents:
diff changeset
    30
	TRAPD(err, repository = CRepository::NewL(KUidLogengRepository));		
7d4490026038 201037_06
hgs
parents:
diff changeset
    31
	if(err == KErrNone)
7d4490026038 201037_06
hgs
parents:
diff changeset
    32
		{
7d4490026038 201037_06
hgs
parents:
diff changeset
    33
		CleanupStack::PushL(repository);
7d4490026038 201037_06
hgs
parents:
diff changeset
    34
		aContactMatchCount = LogGetRepositoryValueL(*repository, KContactMatchCountRepKey);
7d4490026038 201037_06
hgs
parents:
diff changeset
    35
		aContactNameFormat = static_cast <TLogContactNameFormat> (LogGetRepositoryValueL(*repository, KContactNameFormatRepKey));
7d4490026038 201037_06
hgs
parents:
diff changeset
    36
		CleanupStack::PopAndDestroy(repository);
7d4490026038 201037_06
hgs
parents:
diff changeset
    37
		}
7d4490026038 201037_06
hgs
parents:
diff changeset
    38
	else if(err == KErrCorrupt)
7d4490026038 201037_06
hgs
parents:
diff changeset
    39
		{
7d4490026038 201037_06
hgs
parents:
diff changeset
    40
		__ASSERT_DEBUG(!repository, User::Invariant());
7d4490026038 201037_06
hgs
parents:
diff changeset
    41
		User::Leave(err);
7d4490026038 201037_06
hgs
parents:
diff changeset
    42
		}
7d4490026038 201037_06
hgs
parents:
diff changeset
    43
	else
7d4490026038 201037_06
hgs
parents:
diff changeset
    44
		{
7d4490026038 201037_06
hgs
parents:
diff changeset
    45
		__ASSERT_DEBUG(!repository, User::Invariant());
7d4490026038 201037_06
hgs
parents:
diff changeset
    46
		aContactMatchCount = KLogContactMatchCount;
7d4490026038 201037_06
hgs
parents:
diff changeset
    47
		aContactNameFormat = KLogContactNameFormat;
7d4490026038 201037_06
hgs
parents:
diff changeset
    48
		}
7d4490026038 201037_06
hgs
parents:
diff changeset
    49
	}
7d4490026038 201037_06
hgs
parents:
diff changeset
    50