Update contrib.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #include "LogServCacheConfig.h"
18 #include "logservpanic.h"
19 #include "LogServDatabaseTransactionInterface.h"
21 /////////////////////////////////////////////////////////////////////////////////////////
22 // -----> CLogServCacheConfig (source)
23 /////////////////////////////////////////////////////////////////////////////////////////
25 CLogServCacheConfig::CLogServCacheConfig(MLogServDatabaseTransactionInterface& aDatabase)
26 : iDatabase(aDatabase)
30 CLogServCacheConfig::~CLogServCacheConfig()
34 void CLogServCacheConfig::ConstructL()
39 CLogServCacheConfig* CLogServCacheConfig::NewL(MLogServDatabaseTransactionInterface& aDatabase)
41 CLogServCacheConfig* self = new(ELeave) CLogServCacheConfig(aDatabase);
42 CleanupStack::PushL(self);
44 CleanupStack::Pop(self);
49 Get the current configuration
51 const TLogConfig& CLogServCacheConfig::Config() const
57 Update the config table
59 void CLogServCacheConfig::UpdateL(const TLogConfig& aConfig)
61 RLogConfigDbTable tbl;
62 tbl.OpenLC(iDatabase.DTIDatabase());
65 User::Leave(KErrNotFound);
68 tbl.SetColL(RLogConfigDbTable::iAgeColNo, aConfig.iMaxEventAge);
69 tbl.SetColL(RLogConfigDbTable::iSizeColNo, aConfig.iMaxLogSize);
70 tbl.SetColL(RLogConfigDbTable::iRecentColNo, aConfig.iMaxRecentLogSize);
72 CleanupStack::PopAndDestroy(&tbl);
73 iRequestedConfiguration = aConfig;
74 iInTransaction = ETrue;
78 Commit the requested configuration
80 void CLogServCacheConfig::Commit()
82 __ASSERT_ALWAYS(iInTransaction, Panic(ELogCacheConfigNotInTransaction));
83 iConfig = iRequestedConfiguration;
84 iInTransaction = EFalse;
87 /////////////////////////////////////////////////////////////////////////////////////////
88 /////////////////////////////////////////////////////////////////////////////////////////
89 /////////////////////////////////////////////////////////////////////////////////////////
91 void CLogServCacheConfig::ReadL()
93 RLogConfigDbTable tbl;
94 tbl.OpenLC(iDatabase.DTIDatabase(), RDbRowSet::EReadOnly);
97 User::Leave(KErrNotFound);
99 __ASSERT_ALWAYS(tbl.CountL() == 1, Panic(ELogTooManyRows4));
101 iConfig.iMaxEventAge = tbl.ColUint32(RLogConfigDbTable::iAgeColNo);
102 iConfig.iMaxLogSize = tbl.ColUint16(RLogConfigDbTable::iSizeColNo);
103 iConfig.iMaxRecentLogSize = tbl.ColUint8(RLogConfigDbTable::iRecentColNo);
104 CleanupStack::PopAndDestroy(&tbl);