loggingservices/eventlogger/LogServ/src/LOGADD.CPP
changeset 51 7d4490026038
parent 14 15018f1726c7
child 55 44f437012c90
equal deleted inserted replaced
40:b8bdbc8f59c7 51:7d4490026038
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    23 #include "LogServRecentList.h"
    23 #include "LogServRecentList.h"
    24 #include "LogServDatabaseTransactionInterface.h"
    24 #include "LogServDatabaseTransactionInterface.h"
    25 #include "LogServResourceInterpreter.h"
    25 #include "LogServResourceInterpreter.h"
    26 #include "LogServCacheConfig.h"
    26 #include "LogServCacheConfig.h"
    27 #include "LogServDatabaseChangeInterface.h"
    27 #include "LogServDatabaseChangeInterface.h"
    28 #include <logserv.rsg>
       
    29 #include <centralrepository.h>
    28 #include <centralrepository.h>
    30 #include "LogServCacheStrings.h"
    29 #include "LogServCacheStrings.h"
    31 #include "LogServCacheTypes.h"
    30 #include "LogServCacheTypes.h"
    32 #include "LOGREPDEFS.H"
    31 #include "LOGREPDEFS.H"
    33 
    32 
    86 	TInt val = -1;		
    85 	TInt val = -1;		
    87 	User::LeaveIfError(aRepository.Get(aKey, val));
    86 	User::LeaveIfError(aRepository.Get(aKey, val));
    88 	return val;
    87 	return val;
    89 	}
    88 	}
    90 
    89 
    91 //This function reads logeng resource file and returns the integer value of the given resource id. 
    90 static void LogGetContactmatchCountAndNameFormatL(TInt& aContactMatchCount, TLogContactNameFormat& aContactNameFormat)
    92 static TInt LogGetResourceValueL(CLogServResourceInterpreter& aResourceInterpreter, TInt aResourceId)
       
    93 	{		
       
    94 	TResourceReader reader;
       
    95 	aResourceInterpreter.CreateResourceReaderLC(reader, aResourceId, CLogServResourceInterpreter::ELogServer);
       
    96 	TInt val = reader.ReadInt16();
       
    97 	CleanupStack::PopAndDestroy();
       
    98 	return val;
       
    99 	}
       
   100 
       
   101 static void LogGetContactmatchCountAndNameFormatL(CLogServResourceInterpreter& aResourceInterpreter, TInt& aContactMatchCount, TLogContactNameFormat& aContactNameFormat)
       
   102 	{
    91 	{
   103 	CRepository* repository = NULL;
    92 	CRepository* repository = NULL;
   104 	TRAPD(err, repository = CRepository::NewL(KUidLogengRepository));		
    93 	TRAPD(err, repository = CRepository::NewL(KUidLogengRepository));		
   105 	if(err == KErrCorrupt)
    94 	if(err == KErrNone)
   106 		{
       
   107 		__ASSERT_DEBUG(!repository, User::Invariant());
       
   108 		User::Leave(err);
       
   109 		}
       
   110 	else if(err == KErrNone)
       
   111 		{
    95 		{
   112 		CleanupStack::PushL(repository);
    96 		CleanupStack::PushL(repository);
   113 		aContactMatchCount = LogGetRepositoryValueL(*repository, KContactMatchCountRepKey);
    97 		aContactMatchCount = LogGetRepositoryValueL(*repository, KContactMatchCountRepKey);
   114 		aContactNameFormat = static_cast <TLogContactNameFormat> (LogGetRepositoryValueL(*repository, KContactNameFormatRepKey));
    98 		aContactNameFormat = static_cast <TLogContactNameFormat> (LogGetRepositoryValueL(*repository, KContactNameFormatRepKey));
   115 		CleanupStack::PopAndDestroy(repository);
    99 		CleanupStack::PopAndDestroy(repository);
   116 		}
   100 		}
       
   101 	else if(err == KErrCorrupt)
       
   102 		{
       
   103 		__ASSERT_DEBUG(!repository, User::Invariant());
       
   104 		User::Leave(err);
       
   105 		}
   117 	else
   106 	else
   118 		{
   107 		{
   119 		__ASSERT_DEBUG(!repository, User::Invariant());
   108 		__ASSERT_DEBUG(!repository, User::Invariant());
   120 		aContactMatchCount = LogGetResourceValueL(aResourceInterpreter, R_LOG_CONTACT_MATCH_COUNT);
   109 		aContactMatchCount = KLogContactMatchCount;
   121 		aContactNameFormat = static_cast <TLogContactNameFormat> (LogGetResourceValueL(aResourceInterpreter, R_LOG_CONTACT_NAME_FORMAT));
   110 		aContactNameFormat = KLogContactNameFormat;
   122 		}
   111 		}
   123 	#ifdef SYSLIBS_TEST
   112 	#ifdef SYSLIBS_TEST
   124 	LogStoreContactMatchCountAndNameFormatL(aContactMatchCount, aContactNameFormat);
   113 	LogStoreContactMatchCountAndNameFormatL(aContactMatchCount, aContactNameFormat);
   125 	#endif	
   114 	#endif	
   126 	}
   115 	}
   155 
   144 
   156 void CLogAddEvent::ConstructL()
   145 void CLogAddEvent::ConstructL()
   157 	{
   146 	{
   158 	iDuplicate = CLogDuplicate::NewL(iDatabase, Priority());
   147 	iDuplicate = CLogDuplicate::NewL(iDatabase, Priority());
   159 	iDuplicateFilter = CLogFilter::NewL();
   148 	iDuplicateFilter = CLogFilter::NewL();
   160 	::LogGetContactmatchCountAndNameFormatL(iDatabase.DTIResourceInterface(), iContactMatchCount, iContactNameFormat);
   149 	::LogGetContactmatchCountAndNameFormatL(iContactMatchCount, iContactNameFormat);
   161 	}
   150 	}
   162 
   151 
   163 //This method will open contacts database (if not opened yet), only if the value of 
   152 //This method will open contacts database (if not opened yet), only if the value of 
   164 //r_log_contact_match_count resource in logserv.rsg resource file is not 0.
   153 //iContactMatchCount is not 0.
   165 //Se how iContactMatchCount data member is initialised.
   154 //Se how iContactMatchCount data member is initialised.
   166 TBool CLogAddEvent::PerformContactMatchL()
   155 TBool CLogAddEvent::PerformContactMatchL()
   167 	{
   156 	{
   168 	if (iContactMatchCount <= 0 || iEvent->Contact() != KLogNullContactId)
   157 	if (iContactMatchCount <= 0 || iEvent->Contact() != KLogNullContactId)
   169 		return EFalse;
   158 		return EFalse;