1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/loggingservices/eventlogger/LogServ/src/LogServCacheConfig.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,105 @@
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 "LogServCacheConfig.h"
1.20 +#include "LOGQUERY.H"
1.21 +#include "logservpanic.h"
1.22 +#include "LogServDatabaseTransactionInterface.h"
1.23 +
1.24 +/////////////////////////////////////////////////////////////////////////////////////////
1.25 +// -----> CLogServCacheConfig (source)
1.26 +/////////////////////////////////////////////////////////////////////////////////////////
1.27 +
1.28 +CLogServCacheConfig::CLogServCacheConfig(MLogServDatabaseTransactionInterface& aDatabase)
1.29 +: iDatabase(aDatabase)
1.30 + {
1.31 + }
1.32 +
1.33 +CLogServCacheConfig::~CLogServCacheConfig()
1.34 + {
1.35 + }
1.36 +
1.37 +void CLogServCacheConfig::ConstructL()
1.38 + {
1.39 + ReadL();
1.40 + }
1.41 +
1.42 +CLogServCacheConfig* CLogServCacheConfig::NewL(MLogServDatabaseTransactionInterface& aDatabase)
1.43 + {
1.44 + CLogServCacheConfig* self = new(ELeave) CLogServCacheConfig(aDatabase);
1.45 + CleanupStack::PushL(self);
1.46 + self->ConstructL();
1.47 + CleanupStack::Pop(self);
1.48 + return self;
1.49 + }
1.50 +
1.51 +/**
1.52 +Get the current configuration
1.53 +*/
1.54 +const TLogConfig& CLogServCacheConfig::Config() const
1.55 + {
1.56 + return iConfig;
1.57 + }
1.58 +
1.59 +/**
1.60 +Update the config table
1.61 +*/
1.62 +void CLogServCacheConfig::UpdateL(const TLogConfig& aConfig)
1.63 + {
1.64 + RLogConfigDbTable tbl;
1.65 + tbl.OpenLC(iDatabase.DTIDatabase());
1.66 + if(!tbl.FirstL())
1.67 + {
1.68 + User::Leave(KErrNotFound);
1.69 + }
1.70 + tbl.UpdateL();
1.71 + tbl.SetColL(RLogConfigDbTable::iAgeColNo, aConfig.iMaxEventAge);
1.72 + tbl.SetColL(RLogConfigDbTable::iSizeColNo, aConfig.iMaxLogSize);
1.73 + tbl.SetColL(RLogConfigDbTable::iRecentColNo, aConfig.iMaxRecentLogSize);
1.74 + tbl.PutL();
1.75 + CleanupStack::PopAndDestroy(&tbl);
1.76 + iRequestedConfiguration = aConfig;
1.77 + iInTransaction = ETrue;
1.78 + }
1.79 +
1.80 +/**
1.81 +Commit the requested configuration
1.82 +*/
1.83 +void CLogServCacheConfig::Commit()
1.84 + {
1.85 + __ASSERT_ALWAYS(iInTransaction, Panic(ELogCacheConfigNotInTransaction));
1.86 + iConfig = iRequestedConfiguration;
1.87 + iInTransaction = EFalse;
1.88 + }
1.89 +
1.90 +/////////////////////////////////////////////////////////////////////////////////////////
1.91 +/////////////////////////////////////////////////////////////////////////////////////////
1.92 +/////////////////////////////////////////////////////////////////////////////////////////
1.93 +
1.94 +void CLogServCacheConfig::ReadL()
1.95 + {
1.96 + RLogConfigDbTable tbl;
1.97 + tbl.OpenLC(iDatabase.DTIDatabase(), RDbRowSet::EReadOnly);
1.98 + if(!tbl.FirstL())
1.99 + {
1.100 + User::Leave(KErrNotFound);
1.101 + }
1.102 + __ASSERT_ALWAYS(tbl.CountL() == 1, Panic(ELogTooManyRows4));
1.103 + tbl.GetL();
1.104 + iConfig.iMaxEventAge = tbl.ColUint32(RLogConfigDbTable::iAgeColNo);
1.105 + iConfig.iMaxLogSize = tbl.ColUint16(RLogConfigDbTable::iSizeColNo);
1.106 + iConfig.iMaxRecentLogSize = tbl.ColUint8(RLogConfigDbTable::iRecentColNo);
1.107 + CleanupStack::PopAndDestroy(&tbl);
1.108 + }