author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 13 Oct 2010 14:24:28 +0300 | |
branch | RCL_3 |
changeset 44 | 5033d469f7c9 |
parent 37 | 870918037e16 |
permissions | -rw-r--r-- |
37 | 1 |
/* |
2 |
* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 |
* All rights reserved. |
|
4 |
* This component and the accompanying materials are made available |
|
5 |
* under the terms of "Eclipse Public License v1.0" |
|
6 |
* which accompanies this distribution, and is available |
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 |
* |
|
9 |
* Initial Contributors: |
|
10 |
* Nokia Corporation - initial contribution. |
|
11 |
* |
|
12 |
* Contributors: |
|
13 |
* |
|
14 |
* Description: Implementation of CBlidSettings class which provide access to Blid settings. Blid Setting can be read and modified using this class |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
// INCLUDE FILES |
|
19 |
#include <f32file.h> // RFs |
|
20 |
#include <centralrepository.h> |
|
44
5033d469f7c9
Revision: 201038
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
21 |
#include <Blid.rsg> |
37 | 22 |
#include <eikenv.h> |
23 |
||
24 |
#include "CBlidSettings.h" |
|
25 |
#include "MBlidEngObserver.h" |
|
26 |
#include "CBlidMeasurementSettingListener.h" |
|
27 |
#include "BlidSettingsCrkeys.h" |
|
28 |
#include "Blid.hrh" |
|
29 |
||
30 |
// CONSTANTS |
|
31 |
||
32 |
// ============================ MEMBER FUNCTIONS ============================== |
|
33 |
// ---------------------------------------------------------------------------- |
|
34 |
// CBlidSettings::CBlidSettings |
|
35 |
// C++ default constructor can NOT contain any code, that |
|
36 |
// might leave. |
|
37 |
// ---------------------------------------------------------------------------- |
|
38 |
// |
|
39 |
CBlidSettings::CBlidSettings() |
|
40 |
: iAltCalibration(0) |
|
41 |
,iBacklightOption(0) |
|
42 |
,iIsOdoReset( EFalse ) |
|
43 |
{ |
|
44 |
iArrivedDistance = -1; |
|
45 |
} |
|
46 |
||
47 |
// ---------------------------------------------------------------------------- |
|
48 |
// CBlidSettings::ConstructL |
|
49 |
// Symbian 2nd phase constructor can leave. |
|
50 |
// ---------------------------------------------------------------------------- |
|
51 |
// |
|
52 |
void CBlidSettings::ConstructL() |
|
53 |
{ |
|
54 |
iSysofMeasSettings = CBlidMeasurementSettingListener::NewL( * this ); |
|
55 |
iArrivedToneName = HBufC8::NewL( KMaxFileName ); |
|
56 |
HandleSysMeasureValueL(); |
|
57 |
iRepository = CRepository::NewL( KCRUidBlidOdometerSettings ); |
|
58 |
} |
|
59 |
||
60 |
// ---------------------------------------------------------------------------- |
|
61 |
// CBlidSettings::NewL |
|
62 |
// Two-phased constructor. |
|
63 |
// ---------------------------------------------------------------------------- |
|
64 |
// |
|
65 |
CBlidSettings* CBlidSettings::NewL() |
|
66 |
{ |
|
67 |
CBlidSettings* self = new( ELeave ) CBlidSettings; |
|
68 |
CleanupStack::PushL( self ); |
|
69 |
self->ConstructL(); |
|
70 |
CleanupStack::Pop( self ); |
|
71 |
return self; |
|
72 |
} |
|
73 |
||
74 |
// ---------------------------------------------------------------------------- |
|
75 |
// CBlidSettings::~CBlidSettings |
|
76 |
// ---------------------------------------------------------------------------- |
|
77 |
// |
|
78 |
CBlidSettings::~CBlidSettings() |
|
79 |
{ |
|
80 |
delete iSysofMeasSettings; |
|
81 |
delete iArrivedToneName; |
|
82 |
delete iRepository; |
|
83 |
} |
|
84 |
||
85 |
// ---------------------------------------------------------------------------- |
|
86 |
// CBlidSettings::SetAltCalibration |
|
87 |
// ---------------------------------------------------------------------------- |
|
88 |
// |
|
89 |
void CBlidSettings::SetAltCalibration( const TReal32 aAltCalibration ) |
|
90 |
{ |
|
91 |
TReal altCalibration = aAltCalibration; |
|
92 |
iRepository->Set( KBlidAltCalibrationValue, altCalibration ); |
|
93 |
} |
|
94 |
||
95 |
// ---------------------------------------------------------------------------- |
|
96 |
// CBlidSettings::AltCalibration |
|
97 |
// ---------------------------------------------------------------------------- |
|
98 |
// |
|
99 |
TReal32 CBlidSettings::AltCalibration() |
|
100 |
{ |
|
101 |
TReal altCalibration; |
|
102 |
TInt error = iRepository->Get( KBlidAltCalibrationValue, altCalibration ); |
|
103 |
if( error == KErrNone ) |
|
104 |
{ |
|
105 |
iAltCalibration = altCalibration; |
|
106 |
} |
|
107 |
return iAltCalibration; |
|
108 |
} |
|
109 |
||
110 |
// ---------------------------------------------------------------------------- |
|
111 |
// CBlidSettings::UnitOfMeasurement |
|
112 |
// ---------------------------------------------------------------------------- |
|
113 |
// |
|
114 |
TReal32 CBlidSettings::UnitOfMeasurement() |
|
115 |
{ |
|
116 |
return iMeasurementUnit; |
|
117 |
} |
|
118 |
||
119 |
// ---------------------------------------------------------------------------- |
|
120 |
// CBlidSettings::HandleSysMeasureVlueL |
|
121 |
// ---------------------------------------------------------------------------- |
|
122 |
// |
|
123 |
void CBlidSettings::HandleSysMeasureValueL() |
|
124 |
{ |
|
125 |
iMeasurementUnit = iSysofMeasSettings->SysofMeasurementL(); |
|
126 |
} |
|
127 |
||
128 |
// ---------------------------------------------------------------------------- |
|
129 |
// CBlidSettings::SetBacklightOption |
|
130 |
// ---------------------------------------------------------------------------- |
|
131 |
// |
|
132 |
void CBlidSettings::SetBacklightOption( const TReal32 aBacklightOption ) |
|
133 |
{ |
|
134 |
TReal backlightOption = aBacklightOption; |
|
135 |
iRepository->Set( KBlidBacklightOptionValue, backlightOption ); |
|
136 |
} |
|
137 |
||
138 |
// ---------------------------------------------------------------------------- |
|
139 |
// CBlidSettings::GetBacklightOption |
|
140 |
// ---------------------------------------------------------------------------- |
|
141 |
// |
|
142 |
TReal32 CBlidSettings::GetBacklightOption() |
|
143 |
{ |
|
144 |
TReal backlightOption; |
|
145 |
TInt error = iRepository->Get( KBlidBacklightOptionValue, backlightOption ); |
|
146 |
if( error == KErrNone ) |
|
147 |
{ |
|
148 |
iBacklightOption = backlightOption; |
|
149 |
} |
|
150 |
return iBacklightOption; |
|
151 |
} |
|
152 |
||
153 |
// ---------------------------------------------------------------------------- |
|
154 |
// CBlidSettings::SetArrivedToneName |
|
155 |
// ---------------------------------------------------------------------------- |
|
156 |
// |
|
157 |
void CBlidSettings::SetArrivedToneName( const TDesC8& aArrivedToneName ) |
|
158 |
{ |
|
159 |
iRepository->Set( KBlidArrivedToneNameString, aArrivedToneName ); |
|
160 |
} |
|
161 |
||
162 |
// ---------------------------------------------------------------------------- |
|
163 |
// CBlidSettings::GetArrivedToneName |
|
164 |
// ---------------------------------------------------------------------------- |
|
165 |
// |
|
166 |
TDesC8& CBlidSettings::GetArrivedToneName() |
|
167 |
{ |
|
168 |
TPtr8 des = iArrivedToneName->Des(); |
|
169 |
TInt error = iRepository->Get( KBlidArrivedToneNameString, des ); |
|
170 |
if( error != KErrNone ) |
|
171 |
{ |
|
172 |
if( iArrivedToneName->Length() <= 0 ) |
|
173 |
{ |
|
174 |
des.Copy( _L8( " Off " ) ); |
|
175 |
} |
|
176 |
} |
|
177 |
return ( *iArrivedToneName ); |
|
178 |
} |
|
179 |
||
180 |
// ---------------------------------------------------------------------------- |
|
181 |
// CBlidSettings::SetResetOdometerOption |
|
182 |
// ---------------------------------------------------------------------------- |
|
183 |
// |
|
184 |
void CBlidSettings::SetResetOdometerOption( const TReal32 aIsOdoReset ) |
|
185 |
{ |
|
186 |
TReal isOdoReset = aIsOdoReset; |
|
187 |
iRepository->Set( KBlidDoResetValue, isOdoReset ); |
|
188 |
} |
|
189 |
||
190 |
// ---------------------------------------------------------------------------- |
|
191 |
// CBlidSettings::GetResetOdometerOption |
|
192 |
// ---------------------------------------------------------------------------- |
|
193 |
// |
|
194 |
TReal32 CBlidSettings::GetResetOdometerOption() |
|
195 |
{ |
|
196 |
TReal isOdoReset; |
|
197 |
TInt error = iRepository->Get( KBlidDoResetValue, isOdoReset ); |
|
198 |
if( error != KErrNone ) |
|
199 |
{ |
|
200 |
iIsOdoReset = isOdoReset; |
|
201 |
} |
|
202 |
return iIsOdoReset; |
|
203 |
} |
|
204 |
||
205 |
// ---------------------------------------------------------------------------- |
|
206 |
// CBlidSettings::SetResetOdometerOption |
|
207 |
// ---------------------------------------------------------------------------- |
|
208 |
// |
|
209 |
void CBlidSettings::SetArrivedDistance( TReal32 aDistance ) |
|
210 |
{ |
|
211 |
TReal arrivedDistance = aDistance; |
|
212 |
iRepository->Set( KBlidOdometerSettingsValue, arrivedDistance ); |
|
213 |
} |
|
214 |
||
215 |
// ---------------------------------------------------------------------------- |
|
216 |
// CBlidSettings::GetResetOdometerOption |
|
217 |
// ---------------------------------------------------------------------------- |
|
218 |
// |
|
219 |
TReal32 CBlidSettings::GetArrivedDistance() |
|
220 |
{ |
|
221 |
TReal arrivedDistance; |
|
222 |
TInt error = iRepository->Get( KBlidOdometerSettingsValue, arrivedDistance ); |
|
223 |
if( error == KErrNone ) |
|
224 |
{ |
|
225 |
iArrivedDistance = arrivedDistance; |
|
226 |
} |
|
227 |
return iArrivedDistance; |
|
228 |
} |
|
229 |
||
230 |
// End of File |