sl@0
|
1 |
// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
#include "LogServCacheConfig.h"
|
sl@0
|
17 |
#include "LOGQUERY.H"
|
sl@0
|
18 |
#include "logservpanic.h"
|
sl@0
|
19 |
#include "LogServDatabaseTransactionInterface.h"
|
sl@0
|
20 |
|
sl@0
|
21 |
/////////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
22 |
// -----> CLogServCacheConfig (source)
|
sl@0
|
23 |
/////////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
24 |
|
sl@0
|
25 |
CLogServCacheConfig::CLogServCacheConfig(MLogServDatabaseTransactionInterface& aDatabase)
|
sl@0
|
26 |
: iDatabase(aDatabase)
|
sl@0
|
27 |
{
|
sl@0
|
28 |
}
|
sl@0
|
29 |
|
sl@0
|
30 |
CLogServCacheConfig::~CLogServCacheConfig()
|
sl@0
|
31 |
{
|
sl@0
|
32 |
}
|
sl@0
|
33 |
|
sl@0
|
34 |
void CLogServCacheConfig::ConstructL()
|
sl@0
|
35 |
{
|
sl@0
|
36 |
ReadL();
|
sl@0
|
37 |
}
|
sl@0
|
38 |
|
sl@0
|
39 |
CLogServCacheConfig* CLogServCacheConfig::NewL(MLogServDatabaseTransactionInterface& aDatabase)
|
sl@0
|
40 |
{
|
sl@0
|
41 |
CLogServCacheConfig* self = new(ELeave) CLogServCacheConfig(aDatabase);
|
sl@0
|
42 |
CleanupStack::PushL(self);
|
sl@0
|
43 |
self->ConstructL();
|
sl@0
|
44 |
CleanupStack::Pop(self);
|
sl@0
|
45 |
return self;
|
sl@0
|
46 |
}
|
sl@0
|
47 |
|
sl@0
|
48 |
/**
|
sl@0
|
49 |
Get the current configuration
|
sl@0
|
50 |
*/
|
sl@0
|
51 |
const TLogConfig& CLogServCacheConfig::Config() const
|
sl@0
|
52 |
{
|
sl@0
|
53 |
return iConfig;
|
sl@0
|
54 |
}
|
sl@0
|
55 |
|
sl@0
|
56 |
/**
|
sl@0
|
57 |
Update the config table
|
sl@0
|
58 |
*/
|
sl@0
|
59 |
void CLogServCacheConfig::UpdateL(const TLogConfig& aConfig)
|
sl@0
|
60 |
{
|
sl@0
|
61 |
RLogConfigDbTable tbl;
|
sl@0
|
62 |
tbl.OpenLC(iDatabase.DTIDatabase());
|
sl@0
|
63 |
if(!tbl.FirstL())
|
sl@0
|
64 |
{
|
sl@0
|
65 |
User::Leave(KErrNotFound);
|
sl@0
|
66 |
}
|
sl@0
|
67 |
tbl.UpdateL();
|
sl@0
|
68 |
tbl.SetColL(RLogConfigDbTable::iAgeColNo, aConfig.iMaxEventAge);
|
sl@0
|
69 |
tbl.SetColL(RLogConfigDbTable::iSizeColNo, aConfig.iMaxLogSize);
|
sl@0
|
70 |
tbl.SetColL(RLogConfigDbTable::iRecentColNo, aConfig.iMaxRecentLogSize);
|
sl@0
|
71 |
tbl.PutL();
|
sl@0
|
72 |
CleanupStack::PopAndDestroy(&tbl);
|
sl@0
|
73 |
iRequestedConfiguration = aConfig;
|
sl@0
|
74 |
iInTransaction = ETrue;
|
sl@0
|
75 |
}
|
sl@0
|
76 |
|
sl@0
|
77 |
/**
|
sl@0
|
78 |
Commit the requested configuration
|
sl@0
|
79 |
*/
|
sl@0
|
80 |
void CLogServCacheConfig::Commit()
|
sl@0
|
81 |
{
|
sl@0
|
82 |
__ASSERT_ALWAYS(iInTransaction, Panic(ELogCacheConfigNotInTransaction));
|
sl@0
|
83 |
iConfig = iRequestedConfiguration;
|
sl@0
|
84 |
iInTransaction = EFalse;
|
sl@0
|
85 |
}
|
sl@0
|
86 |
|
sl@0
|
87 |
/////////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
88 |
/////////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
89 |
/////////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
90 |
|
sl@0
|
91 |
void CLogServCacheConfig::ReadL()
|
sl@0
|
92 |
{
|
sl@0
|
93 |
RLogConfigDbTable tbl;
|
sl@0
|
94 |
tbl.OpenLC(iDatabase.DTIDatabase(), RDbRowSet::EReadOnly);
|
sl@0
|
95 |
if(!tbl.FirstL())
|
sl@0
|
96 |
{
|
sl@0
|
97 |
User::Leave(KErrNotFound);
|
sl@0
|
98 |
}
|
sl@0
|
99 |
__ASSERT_ALWAYS(tbl.CountL() == 1, Panic(ELogTooManyRows4));
|
sl@0
|
100 |
tbl.GetL();
|
sl@0
|
101 |
iConfig.iMaxEventAge = tbl.ColUint32(RLogConfigDbTable::iAgeColNo);
|
sl@0
|
102 |
iConfig.iMaxLogSize = tbl.ColUint16(RLogConfigDbTable::iSizeColNo);
|
sl@0
|
103 |
iConfig.iMaxRecentLogSize = tbl.ColUint8(RLogConfigDbTable::iRecentColNo);
|
sl@0
|
104 |
CleanupStack::PopAndDestroy(&tbl);
|
sl@0
|
105 |
}
|